mirror of
https://github.com/hedge-dev/XenosRecomp.git
synced 2026-04-26 20:11:38 +00:00
Avoid dynamic branches when loading array constants.
This commit is contained in:
parent
11128441c6
commit
31513fbfbb
1 changed files with 8 additions and 3 deletions
|
|
@ -1130,8 +1130,10 @@ void ShaderRecompiler::recompile(const uint8_t* shaderData, const std::string_vi
|
||||||
|
|
||||||
if (constantInfo->registerCount > 1)
|
if (constantInfo->registerCount > 1)
|
||||||
{
|
{
|
||||||
println("#define {}(INDEX) ((INDEX) < {} ? vk::RawBufferLoad<float4>(g_PushConstants.{}ShaderConstants + ({} + (INDEX)) * 16, 0x10) : 0.0)",
|
uint32_t tailCount = (isPixelShader ? 224 : 256) - constantInfo->registerIndex;
|
||||||
constantName, constantInfo->registerCount.get(), shaderName, constantInfo->registerIndex.get());
|
|
||||||
|
println("#define {}(INDEX) select((INDEX) < {}, vk::RawBufferLoad<float4>(g_PushConstants.{}ShaderConstants + ({} + min(INDEX, {})) * 16, 0x10), 0.0)",
|
||||||
|
constantName, tailCount, shaderName, constantInfo->registerIndex.get(), tailCount - 1);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
@ -1185,7 +1187,10 @@ void ShaderRecompiler::recompile(const uint8_t* shaderData, const std::string_vi
|
||||||
println(" : packoffset(c{});", constantInfo->registerIndex.get());
|
println(" : packoffset(c{});", constantInfo->registerIndex.get());
|
||||||
|
|
||||||
if (constantInfo->registerCount > 1)
|
if (constantInfo->registerCount > 1)
|
||||||
println("#define {0}(INDEX) ((INDEX) < {1} ? {0}[INDEX] : 0.0)", constantName, constantInfo->registerCount.get());
|
{
|
||||||
|
uint32_t tailCount = (isPixelShader ? 224 : 256) - constantInfo->registerIndex;
|
||||||
|
println("#define {0}(INDEX) select((INDEX) < {1}, {0}[min(INDEX, {2})], 0.0)", constantName, tailCount, tailCount - 1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue