Reuse group barriers across Wave32 LDS reads #152

Open
github-bot wants to merge 1 commit from github-bot/gh-152 into main AGit
Owner

@⁠gomeaw on GitHub · 2026-11-26 08:01 UTC · original
gomeaw:fix/reuse-wave32-lds-read-barriers → main · +120 −9 · 4 files · 1 commits · open

Addresses the split-LDS barrier lead in #143.

The Wave32 lowering emitted a full group barrier before every LDS read, including consecutive reads and reads directly after an explicit full group barrier. Once all lanes have synchronized, a run of read-only LDS instructions can share that ordering. A write or atomic still has its own barrier. The proof starts again at block boundaries and after other instructions, apart from wait-count and no-op instructions. Fence-only diagnostics retain the original per-access fences.

Windows CI measured seven barriers on the original emitter and four with this patch in a synthetic two-half shader. The native Wave64 form kept its one explicit barrier. The SDK validator accepted the Wave32 shader at default settings, at VICTORY_SHADER_OPT=127, and with group waits disabled for diagnostics. The Windows shader suite passed 287 tests.

The fixture reads across the two halves before and after an overwrite and checks all 64 threads when a Wave32 device is available. Hosted CI validates the emitted shader, and a physical RTX run is needed for those output and frame-time measurements.

The translator version changes so the A/B uses the newly emitted DXIL.

The NVIDIA A/B builds isolate this shader change. The combined Windows run passed 301 shader tests and the optimized diagnostics build.

**@⁠gomeaw** on GitHub · 2026-11-26 08:01 UTC · [original](https://github.com/avatarmanz/VIctory-7900XTX/pull/152) `gomeaw:fix/reuse-wave32-lds-read-barriers` → `main` · +120 −9 · 4 files · 1 commits · open Addresses the split-LDS barrier lead in #143. The Wave32 lowering emitted a full group barrier before every LDS read, including consecutive reads and reads directly after an explicit full group barrier. Once all lanes have synchronized, a run of read-only LDS instructions can share that ordering. A write or atomic still has its own barrier. The proof starts again at block boundaries and after other instructions, apart from wait-count and no-op instructions. Fence-only diagnostics retain the original per-access fences. [Windows CI](https://github.com/gomeaw/VIctory-7900XTX/actions/runs/45779150178) measured seven barriers on the original emitter and four with this patch in a synthetic two-half shader. The native Wave64 form kept its one explicit barrier. The SDK validator accepted the Wave32 shader at default settings, at `VICTORY_SHADER_OPT=127`, and with group waits disabled for diagnostics. The Windows shader suite passed 287 tests. The fixture reads across the two halves before and after an overwrite and checks all 64 threads when a Wave32 device is available. Hosted CI validates the emitted shader, and a physical RTX run is needed for those output and frame-time measurements. The translator version changes so the A/B uses the newly emitted DXIL. [The NVIDIA A/B builds](https://git.gtahub.st/github/avatarmanz--VIctory-7900XTX/issues/143) isolate this shader change. The [combined Windows run](https://github.com/gomeaw/VIctory-7900XTX/actions/runs/45779543859) passed 301 shader tests and the optimized diagnostics build.
Reuse a barrier after an explicit full-group wait or an all-lane block entry. Preserve the barriers that order writes and atomics and start the read phase afresh at block boundaries and after other operations. Cover cross-half reads on both sides of a write and verify the actual DXIL barrier count.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 08:04:20 +00:00
Author
Owner

@⁠Proudnoob4 on GitHub · 2026-11-26 08:08 UTC · original

Awesome turnaround picking up the split_lds read-run lead!

Sharing a physical RTX 4080 16 GB (Windows 10, i5-13600K, Series S, render_scale=0.6667, RT skipped) data point from our own equivalent split_lds RaR + post-s_barrier barrier coalescing test (bundled with fast float VICTORY_NV_FLOAT=7 and 64-byte multi-texture D3D12_TEXTURE_BARRIER inspection):

  • Baseline (Pass 7, warm cache, n=96 settled 5s intervals, making=0): median 27.20 fps (36.7 ms), p90 27.80, max 28.60, 0 stutters >55 ms, GPU P0 2805 MHz / 99.8 W / 99% util / 7% VRAM util.
  • With split_lds RaR/post-s_barrier coalescing + NV_FLOAT=7 + -30 global UAV barriers/frame (Pass 9, warm cache, n=71 settled 5s intervals, making=0): median 27.00 fps (37.1 ms), p90 27.70, max 28.30, 0 stutters >55 ms, GPU P0 2790 MHz / 99.4 W / 99% util / 7% VRAM util.
  • Correctness: 0 visual regressions in extracted 10-minute frames (pass9_t540.png) and all 63 local shader/GPU tests passed.

Diagnostic takeaway for RTX 4080

Even combining split_lds read-run barrier coalescing, fewer float ALU ops, and 30 fewer global UAV barriers/frame left RTX 4080 frame time flat at ~37 ms while drawing only ~99 W (~31% of TDP) at 99% reported GPU util and 7% VRAM util. That strongly suggests our bottleneck in this scene is not shader ALU or split_lds barriers, but rather command-list / barrier / prelude / card-step serialization.

I'm running an av#106 VICTORY_GPU_TIMING=1 + VICTORY_D3D12_DRED=1 diagnostics pass next on the warm cache to get the exact per-list GPU breakdown (title's vs preludes vs steps vs compares vs others) and will report what actually owns those 37 ms.

**@⁠Proudnoob4** on GitHub · 2026-11-26 08:08 UTC · [original](https://github.com/avatarmanz/VIctory-7900XTX/pull/152#issuecomment-7186235210) Awesome turnaround picking up the `split_lds` read-run lead! Sharing a physical **RTX 4080 16 GB (Windows 10, i5-13600K, Series S, `render_scale=0.6667`, RT skipped)** data point from our own equivalent `split_lds` RaR + post-`s_barrier` barrier coalescing test (bundled with fast float `VICTORY_NV_FLOAT=7` and 64-byte multi-texture `D3D12_TEXTURE_BARRIER` inspection): - **Baseline (Pass 7, warm cache, `n=96` settled 5s intervals, `making=0`):** median **`27.20 fps` (`36.7 ms`)**, `p90 27.80`, `max 28.60`, `0` stutters `>55 ms`, GPU `P0 2805 MHz / 99.8 W / 99% util / 7% VRAM util`. - **With `split_lds` RaR/post-`s_barrier` coalescing + `NV_FLOAT=7` + `-30` global UAV barriers/frame (Pass 9, warm cache, `n=71` settled 5s intervals, `making=0`):** median **`27.00 fps` (`37.1 ms`)**, `p90 27.70`, `max 28.30`, `0` stutters `>55 ms`, GPU `P0 2790 MHz / 99.4 W / 99% util / 7% VRAM util`. - **Correctness:** 0 visual regressions in extracted 10-minute frames (`pass9_t540.png`) and all 63 local shader/GPU tests passed. ### Diagnostic takeaway for RTX 4080 Even combining `split_lds` read-run barrier coalescing, fewer float ALU ops, and 30 fewer global UAV barriers/frame left RTX 4080 frame time flat at `~37 ms` while drawing only `~99 W` (`~31%` of TDP) at `99%` reported GPU util and `7%` VRAM util. That strongly suggests our bottleneck in this scene is **not** shader ALU or `split_lds` barriers, but rather command-list / barrier / prelude / card-step serialization. I'm running an `av#106` `VICTORY_GPU_TIMING=1` + `VICTORY_D3D12_DRED=1` diagnostics pass next on the warm cache to get the exact per-list GPU breakdown (`title's` vs `preludes` vs `steps` vs `compares` vs `others`) and will report what actually owns those `37 ms`.
Author
Owner

@⁠Aniseto on GitHub · 2026-11-26 17:37 UTC · original

Ran the Wave32 LDS barrier fixture at bb61bb7 on an NVIDIA Blackwell desktop part:

Environment: Windows 11 Pro build 26200 x64, NVIDIA GeForce RTX 5070 Ti (Blackwell, 32-lane waves only, 16 GB) driver 32.0.16.2124, Intel Core i5-12400F, 64 GB RAM, Rust 1.98.1 (pinned by rust-toolchain.toml), MSVC 14.44.35207, DXC 1.9.2609.5 (shared env), debug build.

. D:\AVATAR-OPS\env-avatar.ps1
$env:VICTORY_D3D12_ADAPTER = 'NVIDIA'
cargo test --locked -p victory-shader --lib wave32_lds_read_runs_share_a_barrier -- --nocapture --test-threads=1
1 passed; 0 failed; 0 ignored; 0 measured; 290 filtered out      (exit 0)

The test printed wave32 LDS barriers: 4; wave64 LDS barriers: 1 and all 64 lanes observed the old and new LDS values: the wave32 dispatch ran on the real adapter and checked all 64 threads, which is the physical RTX run the description asks for. The wave64 count is from translation only; this card has no native 64-lane waves. The thread has no prior report from this adapter.

Not tested: frame-time measurements, a retail title, native wave64 hardware, AMD and Intel GPUs, Wine, release profile, game data.

AI-assisted (OpenCode), model: DeepSeek V4.1 Flash Free - checked out the PR's head commit in a detached worktree, built it, ran the tests, wrote this report; the worktree was not modified; no game data was used.

**@⁠Aniseto** on GitHub · 2026-11-26 17:37 UTC · [original](https://github.com/avatarmanz/VIctory-7900XTX/pull/152#issuecomment-7199352611) Ran the Wave32 LDS barrier fixture at `bb61bb7` on an NVIDIA Blackwell desktop part: Environment: Windows 11 Pro build 26200 x64, NVIDIA GeForce RTX 5070 Ti (Blackwell, 32-lane waves only, 16 GB) driver 32.0.16.2124, Intel Core i5-12400F, 64 GB RAM, Rust 1.98.1 (pinned by `rust-toolchain.toml`), MSVC 14.44.35207, DXC 1.9.2609.5 (shared env), debug build. ``` . D:\AVATAR-OPS\env-avatar.ps1 $env:VICTORY_D3D12_ADAPTER = 'NVIDIA' cargo test --locked -p victory-shader --lib wave32_lds_read_runs_share_a_barrier -- --nocapture --test-threads=1 1 passed; 0 failed; 0 ignored; 0 measured; 290 filtered out (exit 0) ``` The test printed `wave32 LDS barriers: 4; wave64 LDS barriers: 1` and `all 64 lanes observed the old and new LDS values`: the wave32 dispatch ran on the real adapter and checked all 64 threads, which is the physical RTX run the description asks for. The wave64 count is from translation only; this card has no native 64-lane waves. The thread has no prior report from this adapter. Not tested: frame-time measurements, a retail title, native wave64 hardware, AMD and Intel GPUs, Wine, release profile, game data. AI-assisted (OpenCode), model: **DeepSeek V4.1 Flash Free** - checked out the PR's head commit in a detached worktree, built it, ran the tests, wrote this report; the worktree was not modified; no game data was used.
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/152/head:github-bot/gh-152'
git switch 'github-bot/gh-152'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-152'
git switch 'github-bot/gh-152'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-152'
git switch 'github-bot/gh-152'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-152'
git switch 'main'
git merge --squash 'github-bot/gh-152'
git switch 'main'
git merge --ff-only 'github-bot/gh-152'
git switch 'main'
git merge 'github-bot/gh-152'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.