Skip to content

Naga does not support our "SPIR-V conditional backedges" lifting for loops. #9

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

Closed
eddyb opened this issue Nov 17, 2022 · 0 comments · Fixed by gfx-rs/naga#2290
Closed
Labels
bug Something isn't working

Comments

@eddyb
Copy link
Contributor

eddyb commented Nov 17, 2022

Context: gfx-rs/naga#1977 (comment)

This is not unique to us: as demonstrated there, do-while loops compiled by glslang produce the same Naga error as any SPIR-T loops lifted to SPIR-V - after all, both use the same SPIR-V feature that allows the backedge branch to be a OpBranchConditional between:

  • going back to the loop header (i.e. the backedge itself)
  • leaving to the loop merge block (i.e. breaking out of the loop)

This is a bug on their end, and the WGSL break if feature appears to have been designed to encode such "conditional backedges", but currently there's no detection for them to produce the appropriate naga AST.

We could work around it by doing what they do in their GLSL front-end: generate a "conditional break" inside the "loop body" (i.e. before the "loop continue" block declared by OpLoopMerge), and then always have unconditional backedges, but that's arguably worse-quality SPIR-V.

(not to mention that spirv-opt could convert to the "more idiomatic" form, undoing that compatibility effort)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant