Latte: Support for SAMPLE_LB

This commit is contained in:
Exzap 2023-12-13 12:22:59 +01:00
parent df282ab230
commit 2167143c17
3 changed files with 12 additions and 2 deletions

View File

@ -666,6 +666,9 @@ void LatteDecompiler_ParseTEXClause(LatteDecompilerShader* shaderContext, LatteD
uint32 offsetY = (word2 >> 5) & 0x1F; uint32 offsetY = (word2 >> 5) & 0x1F;
uint32 offsetZ = (word2 >> 10) & 0x1F; uint32 offsetZ = (word2 >> 10) & 0x1F;
sint8 lodBias = (word2 >> 21) & 0x7F;
if ((lodBias&0x40) != 0)
lodBias |= 0x80;
// bufferID -> Texture index // bufferID -> Texture index
// samplerId -> Sampler index // samplerId -> Sampler index
sint32 textureIndex = bufferId - 0x00; sint32 textureIndex = bufferId - 0x00;
@ -693,6 +696,7 @@ void LatteDecompiler_ParseTEXClause(LatteDecompilerShader* shaderContext, LatteD
texInstruction.textureFetch.unnormalized[1] = coordTypeY == 0; texInstruction.textureFetch.unnormalized[1] = coordTypeY == 0;
texInstruction.textureFetch.unnormalized[2] = coordTypeZ == 0; texInstruction.textureFetch.unnormalized[2] = coordTypeZ == 0;
texInstruction.textureFetch.unnormalized[3] = coordTypeW == 0; texInstruction.textureFetch.unnormalized[3] = coordTypeW == 0;
texInstruction.textureFetch.lodBias = (sint8)lodBias;
cfInstruction->instructionsTEX.emplace_back(texInstruction); cfInstruction->instructionsTEX.emplace_back(texInstruction);
} }
else if( inst0_4 == GPU7_TEX_INST_SET_CUBEMAP_INDEX ) else if( inst0_4 == GPU7_TEX_INST_SET_CUBEMAP_INDEX )

View File

@ -2560,10 +2560,15 @@ void _emitTEXSampleTextureCode(LatteDecompilerShaderContext* shaderContext, Latt
} }
// 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) 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->addFmt("{}", (float)texInstruction->textureFetch.lodBias / 16.0f);
else
{ {
src->add(","); src->add(",");
_emitTEXSampleCoordInputComponent(shaderContext, texInstruction, 3, LATTE_DECOMPILER_DTYPE_FLOAT); _emitTEXSampleCoordInputComponent(shaderContext, texInstruction, 3, LATTE_DECOMPILER_DTYPE_FLOAT);
} }
}
else if( texOpcode == GPU7_TEX_INST_SAMPLE_LZ || texOpcode == GPU7_TEX_INST_SAMPLE_C_LZ ) else if( texOpcode == GPU7_TEX_INST_SAMPLE_LZ || texOpcode == GPU7_TEX_INST_SAMPLE_C_LZ )
{ {
src->add(",0.0"); src->add(",0.0");

View File

@ -57,6 +57,7 @@ struct LatteDecompilerTEXInstruction
sint8 offsetY{}; sint8 offsetY{};
sint8 offsetZ{}; sint8 offsetZ{};
bool unnormalized[4]{}; // set if texture coordinates are in [0,dim] range instead of [0,1] bool unnormalized[4]{}; // set if texture coordinates are in [0,dim] range instead of [0,1]
sint8 lodBias{}; // divide by 16 to get actual value
}textureFetch; }textureFetch;
// memRead // memRead
struct struct