Open Swyter opened 6 years ago
I have seen the same issue in my own personal shader. In my case, though, the value was a uint
not used by a loop but that was only used with increment:
uint j;
for (uint i = 0; i < 300; i++) {
if (some_condiition_met) {
j++;
}
}
uvec3 color = uvec3(j / 300);
This was for a Julia-set shader I was working on: my_bad_julia_shader.txt.
It took me 2 or 3 days to diagnose the issue as an uninitialized variable compiling with only glslangValidator
.
So this is related to this Mesa bug: https://bugs.freedesktop.org/show_bug.cgi?id=105755
Turns out that the Mesa compiler detects and throws warnings when variables are potentially uninitialized while the reference compiler does not. This is specially important to avoid undefined behavior and infinite loops that may completely lockup the system, specially because
glslangValidator
is used as the de facto linter for GLSL.Maybe this case should be handled better.
PS: Here is the test-case: uninitialized-for-loop-counter-variable-glsl-example.zip