Fix predicate implementations.

This commit is contained in:
Skyth 2024-10-16 17:36:49 +03:00
parent c0bafdb37f
commit 2c373f210c

View file

@ -124,6 +124,16 @@ void ShaderRecompiler::printDstSwizzle01(uint32_t dstRegister, uint32_t dstSwizz
void ShaderRecompiler::recompile(const VertexFetchInstruction& instr, uint32_t address) void ShaderRecompiler::recompile(const VertexFetchInstruction& instr, uint32_t address)
{ {
if (instr.isPredicated)
{
indent();
println("if ({}p0)", instr.predicateCondition ? "" : "!");
indent();
out += "{\n";
++indentation;
}
indent(); indent();
print("r{}.", instr.dstRegister); print("r{}.", instr.dstRegister);
printDstSwizzle(instr.dstSwizzle, false); printDstSwizzle(instr.dstSwizzle, false);
@ -167,6 +177,13 @@ void ShaderRecompiler::recompile(const VertexFetchInstruction& instr, uint32_t a
out += ";\n"; out += ";\n";
printDstSwizzle01(instr.dstRegister, instr.dstSwizzle); printDstSwizzle01(instr.dstRegister, instr.dstSwizzle);
if (instr.isPredicated)
{
--indentation;
indent();
out += "}\n";
}
} }
void ShaderRecompiler::recompile(const TextureFetchInstruction& instr) void ShaderRecompiler::recompile(const TextureFetchInstruction& instr)
@ -174,6 +191,16 @@ void ShaderRecompiler::recompile(const TextureFetchInstruction& instr)
if (instr.opcode != FetchOpcode::TextureFetch) if (instr.opcode != FetchOpcode::TextureFetch)
return; return;
if (instr.isPredicated)
{
indent();
println("if ({}p0)", instr.predCondition ? "" : "!");
indent();
out += "{\n";
++indentation;
}
indent(); indent();
print("r{}.", instr.dstRegister); print("r{}.", instr.dstRegister);
printDstSwizzle(instr.dstSwizzle, false); printDstSwizzle(instr.dstSwizzle, false);
@ -219,6 +246,13 @@ void ShaderRecompiler::recompile(const TextureFetchInstruction& instr)
out += ";\n"; out += ";\n";
printDstSwizzle01(instr.dstRegister, instr.dstSwizzle); printDstSwizzle01(instr.dstRegister, instr.dstSwizzle);
if (instr.isPredicated)
{
--indentation;
indent();
out += "}\n";
}
} }
void ShaderRecompiler::recompile(const AluInstruction& instr) void ShaderRecompiler::recompile(const AluInstruction& instr)
@ -226,7 +260,7 @@ void ShaderRecompiler::recompile(const AluInstruction& instr)
if (instr.isPredicated) if (instr.isPredicated)
{ {
indent(); indent();
println("if ({}p0)", instr.predicateCondition ? "!" : ""); println("if ({}p0)", instr.predicateCondition ? "" : "!");
indent(); indent();
out += "{\n"; out += "{\n";
@ -815,6 +849,18 @@ void ShaderRecompiler::recompile(const AluInstruction& instr)
out += ')'; out += ')';
out += ";\n"; out += ";\n";
switch (instr.scalarOpcode)
{
case AluScalarOpcode::MaxAs:
indent();
println("a0 = (int)clamp(floor({} + 0.5), -256.0, 255.0);", op(SCALAR_0));
break;
case AluScalarOpcode::MaxAsf:
indent();
println("a0 = (int)clamp(floor({}), -256.0, 255.0);", op(SCALAR_0));
break;
}
} }
uint32_t scalarWriteMask = instr.scalarWriteMask; uint32_t scalarWriteMask = instr.scalarWriteMask;
@ -1219,7 +1265,7 @@ void ShaderRecompiler::recompile(const uint8_t* shaderData)
{ {
if (cfInstr.condJmp.isPredicated) if (cfInstr.condJmp.isPredicated)
{ {
println("\t\t\tif ({}p0)", cfInstr.condJmp.condition ? "!" : ""); println("\t\t\tif ({}p0)", cfInstr.condJmp.condition ? "" : "!");
} }
else else
{ {