Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

valid shader with implicit for and if scope marked as invalid by glslangValidator #3690

Open
LeStahL opened this issue Aug 8, 2024 · 1 comment

Comments

@LeStahL
Copy link

LeStahL commented Aug 8, 2024

Hi!

The shader

#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).

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 laurentlb/shader-minifier#435).

@arcady-lunarg
Copy link
Contributor

I think your reading of the spec here is correct and glslang is incorrectly producing an error here, as the inner v should have its scope start right after the first semicolon of the for loop and shadow the outer v.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants