shader(opt): update barrier state on Op::VolatileLoad #3106

Open
RanoGames wants to merge 1 commit from upstream-pr/3106 into main
RanoGames commented 2026-11-29 20:02:43 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by RanoGames on 2026-11-29T20:02:43Z.


What it changes

Fixes BARRIERS pass handling of Op::VolatileLoad in crates/victory-shader/src/emit/bitcode/opt.rs:

  • Module::merge previously had no match arm for Op::VolatileLoad(ptr), so it fell through to _ => {} instead of updating barriers like Op::Load(ptr).
  • Because barriers.adj was not cleared across Op::VolatileLoad, an intervening volatile load between two barriers (such as barrier(11); VolatileLoad(lds); barrier(9);) falsely triggered adjacent-barrier elimination and deleted the second barrier, while barriers.rar also missed SharedGlobal loads and Unknown resets.
  • Added an Op::VolatileLoad(ptr) arm that traces the pointer and calls barriers.on_load(root) when BARRIERS is enabled (or barriers.reset() otherwise), without participating in LOADS deduplication.
  • Added unit test emit::bitcode::opt::tests::volatile_load_resets_barrier_adjacency_without_deduplicating.

How it was tested

  • GPU and profile (Series X or S, resolution, DLSS, frame generation, ray tracing): N/A (unit-tested bitcode optimizer pass)
  • Before: BARRIERS eliminated barrier(9) after barrier(11); Op::VolatileLoad(lds);.
  • After: Op::VolatileLoad clears barriers.adj and updates barriers.rar without being deduplicated by LOADS.
  • For shader changes, the wave sizes tested (32 and/or 64 lanes): N/A (target-independent DXIL bitcode pass)
  • cargo test passed for the crates it touches: yes (cargo test --locked -p victory-shader --lib barrier tests: 3 passed, 0 failed; cargo xtask policy --staged passed)

Checked for overlap

  • I searched the open and closed pull requests for VolatileLoad (0 PRs).
<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:issue:5554567149 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/3106). Originally posted by [RanoGames](https://github.com/RanoGames) on 2026-11-29T20:02:43Z. --- ## What it changes Fixes `BARRIERS` pass handling of `Op::VolatileLoad` in `crates/victory-shader/src/emit/bitcode/opt.rs`: - `Module::merge` previously had no match arm for `Op::VolatileLoad(ptr)`, so it fell through to `_ => {}` instead of updating `barriers` like `Op::Load(ptr)`. - Because `barriers.adj` was not cleared across `Op::VolatileLoad`, an intervening volatile load between two barriers (such as `barrier(11); VolatileLoad(lds); barrier(9);`) falsely triggered adjacent-barrier elimination and deleted the second barrier, while `barriers.rar` also missed `SharedGlobal` loads and `Unknown` resets. - Added an `Op::VolatileLoad(ptr)` arm that traces the pointer and calls `barriers.on_load(root)` when `BARRIERS` is enabled (or `barriers.reset()` otherwise), without participating in `LOADS` deduplication. - Added unit test `emit::bitcode::opt::tests::volatile_load_resets_barrier_adjacency_without_deduplicating`. ## How it was tested - GPU and profile (Series X or S, resolution, DLSS, frame generation, ray tracing): N/A (unit-tested bitcode optimizer pass) - Before: `BARRIERS` eliminated `barrier(9)` after `barrier(11); Op::VolatileLoad(lds);`. - After: `Op::VolatileLoad` clears `barriers.adj` and updates `barriers.rar` without being deduplicated by `LOADS`. - For shader changes, the wave sizes tested (32 and/or 64 lanes): N/A (target-independent DXIL bitcode pass) - `cargo test` passed for the crates it touches: yes (`cargo test --locked -p victory-shader --lib` barrier tests: 3 passed, 0 failed; `cargo xtask policy --staged` passed) ## Checked for overlap - [x] I searched the open and closed pull requests for `VolatileLoad` (0 PRs).
dyshay commented 2026-11-29 20:46:52 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by dyshay on 2026-11-29T20:46:52Z.


Merged into our fork's integration branch for testing (dyshay/VIctory-NVIDIA, branch janus-prs). I read the full diff first: no network access, process spawning, binaries, build or dependency changes, or game data. It builds with --profile diag --features diagnostics, and the CPU tests of the touched crates pass. A run on an RTX 4090 is queued (Series S with ray tracing, DLSS Quality). Frame times will follow here.

<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:comment:7262352321 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/3106#issuecomment-7262352321). Originally posted by [dyshay](https://github.com/dyshay) on 2026-11-29T20:46:52Z. --- Merged into our fork's integration branch for testing ([dyshay/VIctory-NVIDIA](https://github.com/dyshay/VIctory-NVIDIA/tree/janus-prs), branch `janus-prs`). I read the full diff first: no network access, process spawning, binaries, build or dependency changes, or game data. It builds with `--profile diag --features diagnostics`, and the CPU tests of the touched crates pass. A run on an RTX 4090 is queued (Series S with ray tracing, DLSS Quality). Frame times will follow here.
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/3106:upstream-pr/3106'
git switch 'upstream-pr/3106'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/3106'
git switch 'upstream-pr/3106'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/3106'
git switch 'upstream-pr/3106'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/3106'
git switch 'main'
git merge --squash 'upstream-pr/3106'
git switch 'main'
git merge --ff-only 'upstream-pr/3106'
git switch 'main'
git merge 'upstream-pr/3106'
git push origin 'main'
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
trustno1-coder/VIctory-NVIDIA!3106
No description provided.