Hey, so I’m working on a shader compiler that takes shader microcode from another language and converts it to SPIR-V.
I’ve noticed that when dealing with code that does a lot of branching (jump statements and such), NVIDIA’s shader compiler will eat up a lot of memory.
I’ve even had plenty of cases where it would consume so much that it would deadlock my entire computer, prompting a restart.
From the compiled shader code, I could see that NVIDIA’s compiler was taking the dumb route and duplicating a lot of code when taking branches. This can be fixed by including OpSelectionMerges, but unfortunately, there’s no metadata in the source shader code that describes high-level control flow constructs.
We could add a compiler that analyzes the code and adds in OpSelectionMerges, but my question is: Is NVIDIA going to address this behavior?