Hi,
I have an issue with a hlsl shader im running in unity. The shader is relatively complex with 10 keywords. Now I was running some performance tests on another machine with a worse gpu and I noticed a performance drop when i deactivate one of those keywords.
in hlsl
#pragma multi_compile_local _ KEY1
#pragma multi_compile_local _ KEY2
#pragma multi_compile_local _ KEY3
#pragma multi_compile_local _ KEY4
#pragma multi_compile_local _ KEY5
#pragma multi_compile_local _ KEY6
#pragma multi_compile_local _ KEY7
#pragma multi_compile_local _ KEY8
#pragma multi_compile_local _ KEY9
#pragma multi_compile_local _ KEY10
half4 frag(v2f i) : SV_Target
{
#ifdef KEY2
// complex calculation
#endif
// other stuff
}
in c# (runtime)
GetMaterial().DisableKeyword(keyword);
the complex calculation does not interact with any of the other stuff it just modifies a variable that gets passed through
Now this leaves me confused because in my mind the gpu should switch to a lower cost computation and perform better after disabling this keyword but it almost seems that both computations (with and without KEY2) are done.
my unity version is 2022.3.6f1