Open gfxstrand opened 7 years ago
Hi, unfortunately I just lost two full days hunting down a similar case in my own shader. This 'uint' comparison pitfalls happens often when converting OpenCL code to GLSL/Vulkan, because things that work with 'int' in OpenCL often require 'uint' in GLSL/Vulkan, and then you overlook the comparison. Catching such simple bugs would really be important! Thanks, Elmar
Today, someone filed a bug against our Vulkan driver saying that it hangs when you try to run the following compute shader compiled, I believe, with glslang:
The problem with the shader was that they used an unsigned integer for
i
and a condition ofi >= 0
which always evaluates to true yielding an infinite loop. Since we do nothing in our Vulkan driver to guard against infinite loops (why would we?) they got a GPU hang.It would be really nice if glslang could emit some sort of a warning when someone tries to do an unsafe comparison in a similar way to what GCC does with -Wsign-compare. If it had such a warning, they probably would never have even submitted the bug.