fix: missing lod parameter

This commit is contained in:
Samuliak 2024-08-22 18:20:26 +02:00
parent b332d638c7
commit 8e87b9676a

View File

@ -2429,27 +2429,29 @@ static void _emitTEXSampleTextureCode(LatteDecompilerShaderContext* shaderContex
src->addFmt("+ float2(1.0)/float2(tex{}.get_width(), tex{}.get_height())/512.0", texInstruction->textureFetch.textureIndex, texInstruction->textureFetch.textureIndex); src->addFmt("+ float2(1.0)/float2(tex{}.get_width(), tex{}.get_height())/512.0", texInstruction->textureFetch.textureIndex, texInstruction->textureFetch.textureIndex);
} }
// lod or lod bias parameter // lod or lod bias parameter
if( texOpcode == GPU7_TEX_INST_SAMPLE_L || texOpcode == GPU7_TEX_INST_SAMPLE_LB || texOpcode == GPU7_TEX_INST_SAMPLE_C_L) // 1D textures don't support lod
if (texDim != Latte::E_DIM::DIM_1D && texDim != Latte::E_DIM::DIM_1D_ARRAY)
{ {
src->add(","); if( texOpcode == GPU7_TEX_INST_SAMPLE_L || texOpcode == GPU7_TEX_INST_SAMPLE_LB || texOpcode == GPU7_TEX_INST_SAMPLE_C_L)
if (texOpcode == GPU7_TEX_INST_SAMPLE_LB) {
{ src->add(", ");
src->addFmt("bias({})", _FormatFloatAsConstant((float)texInstruction->textureFetch.lodBias / 16.0f)); if (texOpcode == GPU7_TEX_INST_SAMPLE_LB)
} {
else src->addFmt("bias({})", _FormatFloatAsConstant((float)texInstruction->textureFetch.lodBias / 16.0f));
{ }
// TODO: is this correct? else
src->add("level("); {
_emitTEXSampleCoordInputComponent(shaderContext, texInstruction, 3, LATTE_DECOMPILER_DTYPE_FLOAT); // TODO: is this correct?
src->add(")"); src->add("level(");
} _emitTEXSampleCoordInputComponent(shaderContext, texInstruction, 3, LATTE_DECOMPILER_DTYPE_FLOAT);
src->add(")");
}
}
else if( texOpcode == GPU7_TEX_INST_SAMPLE_LZ || texOpcode == GPU7_TEX_INST_SAMPLE_C_LZ )
{
src->add(", level(0.0)");
}
} }
// TODO: uncomment?
//else if( texOpcode == GPU7_TEX_INST_SAMPLE_LZ || texOpcode == GPU7_TEX_INST_SAMPLE_C_LZ )
//{
// // TODO: correct?
// src->add(", level(0.0)");
//}
} }
// gradient parameters // gradient parameters
if (texOpcode == GPU7_TEX_INST_SAMPLE_G) if (texOpcode == GPU7_TEX_INST_SAMPLE_G)