Implement svPos register.

This commit is contained in:
Skyth 2024-10-16 17:36:35 +03:00
parent a3e36719e7
commit c0bafdb37f
2 changed files with 12 additions and 2 deletions

View file

@ -31,7 +31,7 @@ struct Shader
be<uint32_t> physicalOffset;
be<uint32_t> size;
be<uint32_t> field8;
be<uint32_t> fieldC;
be<uint32_t> fieldC; // svPos register: (fieldC >> 8) & 0xFF
be<uint32_t> field10;
be<uint32_t> interpolatorInfo; // interpolator count: (interpolatorInfo >> 5) & 0x1F
};

View file

@ -1099,7 +1099,17 @@ void ShaderRecompiler::recompile(const uint8_t* shaderData)
for (size_t i = 0; i < 32; i++)
{
if (!printedRegisters[i])
println("\tfloat4 r{} = 0.0;", i);
{
print("\tfloat4 r{} = ", i);
if (isPixelShader && i == ((shader->fieldC >> 8) & 0xFF))
{
out += "float4((iPos.xy - 0.5) * float2(iFace ? 1.0 : -1.0, 1.0), 0.0, 0.0);\n";
}
else
{
out += "0.0;\n";
}
}
}
out += "\tint a0 = 0;\n";