Global const inlining breaks after a block scope using the same id
LeStahL opened this issue · comments
The shader
#version 450
out vec4 out_color;
const float s = 1.;
float a(float s) {
s = 2.;
return s;
}
void main() {
out_color = vec4(s, s, a(s), s);
}
gets minified to
#version 450
out vec4 m;
float s(float s) { return 2.; }
void main() { m = vec4(s, s, s(s), s); }
Which produces the following compiler error:
C:\Users\NR4>Downloads\glslang-master-windows-Release\bin\glslangValidator.exe minbug.min.frag
minbug.min.frag
ERROR: 0:2: 's' : undeclared identifier
ERROR: 0:2: '' : compilation terminated
ERROR: 2 compilation errors. No code generated.
I worked around this by avoiding globally defined ids in any and all block scopes.
The code defines two s
(one global, the other is a parameter). A workaround is to rename one of them.
The line s = 2.
seems to cause a bug in the inlining mechanism. This seems to happen only when s
is a function argument (not if it's a local variable).