Compare commits

...

4 commits

Author SHA1 Message Date
Isaac Marovitz
6c7c8fa87d
Initial vertex IO fixes
Signed-off-by: Isaac Marovitz <isaacryu@icloud.com>
2025-03-21 14:39:39 -04:00
Isaac Marovitz
790c8be91b
Fix UNROLL macro
Signed-off-by: Isaac Marovitz <isaacryu@icloud.com>
2025-03-21 14:33:22 -04:00
Isaac Marovitz
2d9e24c52f
Nvm fix mul properly
Signed-off-by: Isaac Marovitz <isaacryu@icloud.com>
2025-03-21 13:34:14 -04:00
Isaac Marovitz
9112665766
Fix MSL matrix mul
Signed-off-by: Isaac Marovitz <isaacryu@icloud.com>
2025-03-21 13:31:37 -04:00
2 changed files with 19 additions and 6 deletions

View file

@ -168,6 +168,12 @@ float rcp(T a)
{
return 1.0 / a;
}
template<typename T>
float4x4 mul(T a, T b)
{
a * b;
}
#endif
#ifdef __air__

View file

@ -1360,13 +1360,15 @@ void ShaderRecompiler::recompile(const uint8_t* shaderData, const std::string_vi
out += "#if __air__\n";
out += "struct StageIn\n";
out += "{\n";
if (isPixelShader) {
out += "struct StageIn\n";
out += "{\n";
for (auto& [usage, usageIndex] : INTERPOLATORS)
println("\tfloat4 i{}{};", USAGE_VARIABLES[uint32_t(usage)], usageIndex);
for (auto& [usage, usageIndex] : INTERPOLATORS)
println("\tfloat4 i{}{};", USAGE_VARIABLES[uint32_t(usage)], usageIndex);
out += "};\n";
out += "};\n";
}
if (isPixelShader)
out += "[[fragment]]\n";
@ -1479,8 +1481,13 @@ void ShaderRecompiler::recompile(const uint8_t* shaderData, const std::string_vi
#ifdef UNLEASHED_RECOMP
if (hasIndexCount)
{
out += "#ifdef __air__\n";
out += "\tuint iVertexId [[vertex_id]],\n";
out += "\tuint iInstanceId [[instance_id]],\n";
out += "#else\n";
out += "\tin uint iVertexId : SV_VertexID,\n";
out += "\tin uint iInstanceId : SV_InstanceID,\n";
out += "#endif\n";
}
#endif
@ -1503,7 +1510,7 @@ void ShaderRecompiler::recompile(const uint8_t* shaderData, const std::string_vi
out += "\tfloat4x4 mtxProjection = float4x4(g_MtxProjection(0), g_MtxProjection(1), g_MtxProjection(2), g_MtxProjection(3));\n";
out += "\tfloat4x4 mtxProjectionReverseZ = mul(mtxProjection, float4x4(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, -1, 0, 0, 0, 1, 1));\n";
out += "\t[unroll] for (int iterationIndex = 0; iterationIndex < 2; iterationIndex++)\n";
out += "\tUNROLL for (int iterationIndex = 0; iterationIndex < 2; iterationIndex++)\n";
out += "\t{\n";
}
#endif