-
Notifications
You must be signed in to change notification settings - Fork 870
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
Index value issue in GLSL front nested loop #5246
Comments
I run into this as well, trying to build a minimal example to figure out what exactly is going wrong. One thing I noticed is that the index variable might be declared as an |
I built and illustrative example on Shadertoy porting this to wgpu via our wgpu-shadertoy implementation you get the following behaviour: working by declaring the inner index outside the loop: inner loop gets run 18 times: broken when declared inside the index, the inner loop runs 3 times. But only on the first loop of the outer loop. So my hypothesis seems to be: If you declare the inner index variable inside the inner loop: it only runs the inner on the first loop out the outer loop. hope this helps. |
I think the issue is here: wgpu/naga/src/front/glsl/parser/functions.rs Line 438 in 6f68d3d
the last arg should be Would you be open to start a PR for this? |
Thanks for the hint, PR submitted! |
Description
I'm successfully converting a shader from GLSL to WGSL, with no errors.
The shader contain a nested loop and I notice there is an issue with the index value.
Repro steps
Where:
Note: I'm exaggerating the kernel radius to make the results more obvious
The above code produce this results:
And by changing the order of the loops to
I get:
Expected vs observed behavior
I notice that I can solve the issue by creating the index values outside the scope of the loops and that solve the problem:
Extra materials
Here is a conversion of the above GLSL code to WGLS
and id.txt using
naga-cli
ir.txt
Platform
Information about your OS, version of
wgpu
, your tech stack, etc.The text was updated successfully, but these errors were encountered: