fix: sample compare component count

This commit is contained in:
Samuliak 2025-01-18 19:40:22 +01:00
parent f0cf61461c
commit 86f364889a
No known key found for this signature in database

View file

@ -2295,6 +2295,10 @@ static void _emitTEXSampleTextureCode(LatteDecompilerShaderContext* shaderContex
}
else
{
// sample_compare returns a float, need to convert to float4
if (isCompare)
src->addFmt("float4(");
if (emulateCompare)
{
cemu_assert_debug(!isGather);
@ -2555,10 +2559,10 @@ static void _emitTEXSampleTextureCode(LatteDecompilerShaderContext* shaderContex
src->add(")");
}
// sample_compare doesn't return a float
if (!isCompare)
{
if( texOpcode == GPU7_TEX_INST_SAMPLE_C || texOpcode == GPU7_TEX_INST_SAMPLE_C_LZ )
if (isCompare)
src->add(")");
if (texOpcode == GPU7_TEX_INST_SAMPLE_C || texOpcode == GPU7_TEX_INST_SAMPLE_C_LZ)
{
src->add(".");
@ -2581,7 +2585,7 @@ static void _emitTEXSampleTextureCode(LatteDecompilerShaderContext* shaderContex
src->add(".");
for (sint32 f = 0; f < 4; f++)
{
if( texInstruction->dstSel[f] < 4 )
if (texInstruction->dstSel[f] < 4)
{
uint8 elemIndex = texInstruction->dstSel[f];
if (isGather)
@ -2601,9 +2605,8 @@ static void _emitTEXSampleTextureCode(LatteDecompilerShaderContext* shaderContex
elemIndex = fetchToGather[elemIndex];
}
src->add(resultElemTable[elemIndex]);
numWrittenElements++;
}
else if( texInstruction->dstSel[f] == 7 )
else if (texInstruction->dstSel[f] == 7)
{
// masked and not written
}
@ -2613,7 +2616,6 @@ static void _emitTEXSampleTextureCode(LatteDecompilerShaderContext* shaderContex
}
}
}
}
src->add(");");
// debug