Skip to content

Prevent ray queries hoisted out of loops from generating invalid code - #9945

Open
Vecvec wants to merge 7 commits into
gfx-rs:trunkfrom
Vecvec:msl-fix-rq-hoist
Open

Prevent ray queries hoisted out of loops from generating invalid code#9945
Vecvec wants to merge 7 commits into
gfx-rs:trunkfrom
Vecvec:msl-fix-rq-hoist

Conversation

@Vecvec

@Vecvec Vecvec commented Jul 25, 2026

Copy link
Copy Markdown
Contributor

Connections
Should fix #9890

Description
When a variable is used in a loop, it must be zero initialized to prevent previous states from being used. naga did this, but also emitted zero initializes for ray queries which is invalid. This caused validation errors on all platforms (a disallowed store on msl, an invalid zero-value on spirv, and a crash on hlsl). This instead adds a Begin ray query function which behaves as if the ray query was a new variable (zeroing its tracker) and uses this for ray query variables in loops. This PR also includes validation against stores.

Naming is rather bad, so suggestions are welcome.

Testing
adds a snapshot test for the loops and also a wgsl errors test for the store validation

Squash or Rebase?
Squash

Checklist

  • I self-reviewed and fully understand this PR.
  • WebGPU implementations built with wgpu may be affected behaviorally.
  • Validation and feature gates are in place to confine behavioral changes.
  • Tests demonstrate the validation and altered logic works.
  • CHANGELOG.md entries for the user-facing effects of this change are present.
  • The PR is minimal, and doesn't make sense to land as multiple PRs.
  • Commits are logically scoped and individually reviewable.
  • The PR description has enough context to understand the motivation and solution implemented.

@inner-daemons
inner-daemons self-requested a review July 27, 2026 20:09
@inner-daemons inner-daemons self-assigned this Jul 29, 2026
@Vecvec
Vecvec force-pushed the msl-fix-rq-hoist branch from 7bced28 to a19b076 Compare July 31, 2026 19:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

MSL: ray_query variable assignment = intersection_query{}; uses deleted operator= for hoisted nested-scope declarations

2 participants