KhronosGroup / KhronosGroup/glslang
valid shader with implicit `for` and `if` scope marked as invalid by glslangValidator
- Dominant language
- C++
- Stars
- 3.6k
- Forks
- 989
- Avg merge
- 1d 2h
- Merged PRs (30d)
- 31
Description
Hi!
The shader
```glsl
#version 450
out vec3 v;
void main()
{
vec3 i;
for(int v=0;v<500;v++)
if(v>1)
i+=9;
v=abs(gl_FragCoord.y)<.3?
i*1.1:
i;
}
```
seems to get identified as invalid by `glslangValidator` although it is valid [(see specification)](https://registry.khronos.org/OpenGL/specs/gl/GLSLangSpec.4.50.pdf#%5B%7B%22num%22%3A139%2C%22gen%22%3A0%7D%2C%7B%22name%22%3A%22XYZ%22%7D%2C115.2%2C279.2%2C0%5D).
Output of `glslangValidator`:
```
ERROR: 0:10: 'assign' : cannot convert from ' temp 3-component vector of float' to ' temp int'
ERROR: 0:12: '' : compilation terminated
ERROR: 2 compilation errors. No code generated.
```
I use `Glslang Version: 11:14.3.0` to reproduce.
(Related to https://github.com/laurentlb/shader-minifier/issues/435).
Contributor guide
Research direction
Start by reproducing the report with glslangValidator 11:14.3.0 and the GLSL shader in the issue, then compare the implicit for/if scope handling with the GLSL 4.50 specification. Done means the valid shader is accepted without the reported vector-to-int conversion error, with regression coverage for this case.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100