Shaders: run LDS flag regions on 32-lane GPUs #4

Manually merged
github merged 3 commits from github-bot/gh-4 into main 2026-11-26 08:21:47 +00:00 AGit
Owner

@⁠gomeaw on GitHub · 2026-11-25 22:59 UTC · original
gomeaw:fix/wave32-lds-flags → main · +398 −2 · 3 files · 3 commits · merged 2026-11-26 08:17 UTC

Summary

Some console wave64 compute shaders retain WaveSize(64) on 32-lane hosts because a divergent region both reads and writes group-shared memory. NVIDIA rejects those pipelines. This adapts fxceless/victory-fork#592 by FrancescoGelosoEterea to this fork, with the original author and commit recorded.

The lowering allows this specific form only when the LDS accesses use constant addresses, stores write the same constant, and a missed read cannot affect any result that leaves the region. The group barriers stay on the converged edges. A region that writes another value keeps its original lowering. VICTORY_LDS_FLAGS=0 disables the new form.

Verification

  • On Windows x64, the original lowering produced Some(64) for the synthetic flag shader. The port produced Some(32) and still kept the two-value case at 64. The shader suite reported 281 passed, 4 ignored, and the asset policy passed. Windows comparison

  • The added test uses 14 dispatches and distinct output words for all 64 console lanes. It checks both sides of the scalar skip and active-lane counts on either side of 32. The hosted runner skipped the hardware dispatches. The original PR reports the reflection-tiling pipeline builds on an RTX 5070 Ti, and an independent contributor ran synthetic dispatches on an RTX 3050 Laptop GPU using that original PR.

  • On a physical RTX 5070 (12 GB, driver 621.24, Windows build 26300), an independent tester ran the added test both alone and with the wave64 suite. All 14 dispatches matched for all 64 output words in both runs. The companion tests selected wave32 for the single-value flag and wave64 for the two-value case. Hardware results

  • A separate NVIDIA test on upstream 0a43566 reproduced 0x80070057 for compute shader 2cc4c197ee29e291 during the opening prologue. Gameplay baseline

  • On a Radeon RX 6950 XT, an independent Windows run passed 278 shader tests on the base and 281 on this PR. That device skipped the 32-lane hardware dispatches. AMD regression check

  • On an RTX 3060 Ti 8 GB, an independent diagnostics run with VICTORY_TEXTURE_MAX=512 passed the same 14 hardware dispatches, reached a 3D cutscene past the frame-1798 transition where the tester previously saw upstream exit, and shut down cleanly. A matched run of shader 2cc4c197ee29e291 through the opening prologue is still pending. RTX 3060 Ti gameplay report

  • VICTORY_LDS_FLAGS now participates in the shader and pipeline cache keys. Three Windows warm --limit 0 runs verified that switching it on changes the pipeline fingerprint and switching it off restores the original fingerprint. Cache validation

To confirm this port on a 32-lane GPU, run cargo test --locked -p victory-shader --lib both_host_waves_observe_the_lds_flag_after_the_join -- --nocapture and check for the line reporting all 14 hardware dispatches. Further gameplay and performance comparisons are open.

AI-assisted with Codex. The tests use synthetic shaders.

**@⁠gomeaw** on GitHub · 2026-11-25 22:59 UTC · [original](https://github.com/avatarmanz/VIctory-7900XTX/pull/4) `gomeaw:fix/wave32-lds-flags` → `main` · +398 −2 · 3 files · 3 commits · merged 2026-11-26 08:17 UTC ## Summary Some console wave64 compute shaders retain `WaveSize(64)` on 32-lane hosts because a divergent region both reads and writes group-shared memory. NVIDIA rejects those pipelines. This adapts [fxceless/victory-fork#592](https://github.com/fxceless/victory-fork/pull/592) by FrancescoGelosoEterea to this fork, with the original author and commit recorded. The lowering allows this specific form only when the LDS accesses use constant addresses, stores write the same constant, and a missed read cannot affect any result that leaves the region. The group barriers stay on the converged edges. A region that writes another value keeps its original lowering. `VICTORY_LDS_FLAGS=0` disables the new form. ## Verification - On Windows x64, the original lowering produced `Some(64)` for the synthetic flag shader. The port produced `Some(32)` and still kept the two-value case at 64. The shader suite reported 281 passed, 4 ignored, and the asset policy passed. [Windows comparison](https://github.com/gomeaw/VIctory-7900XTX/actions/runs/45717398221) - The added test uses 14 dispatches and distinct output words for all 64 console lanes. It checks both sides of the scalar skip and active-lane counts on either side of 32. The hosted runner skipped the hardware dispatches. The original PR reports the reflection-tiling pipeline builds on an RTX 5070 Ti, and an independent contributor ran synthetic dispatches on an RTX 3050 Laptop GPU using that original PR. - On a physical RTX 5070 (12 GB, driver 621.24, Windows build 26300), an independent tester ran the added test both alone and with the wave64 suite. All 14 dispatches matched for all 64 output words in both runs. The companion tests selected wave32 for the single-value flag and wave64 for the two-value case. [Hardware results](https://git.gtahub.st/github/avatarmanz--VIctory-7900XTX/pulls/4) - A separate NVIDIA test on upstream `0a43566` reproduced `0x80070057` for compute shader `2cc4c197ee29e291` during the opening prologue. [Gameplay baseline](https://git.gtahub.st/github/avatarmanz--VIctory-7900XTX/pulls/4) - On a Radeon RX 6950 XT, an independent Windows run passed 278 shader tests on the base and 281 on this PR. That device skipped the 32-lane hardware dispatches. [AMD regression check](https://git.gtahub.st/github/avatarmanz--VIctory-7900XTX/pulls/4) - On an RTX 3060 Ti 8 GB, an independent diagnostics run with `VICTORY_TEXTURE_MAX=512` passed the same 14 hardware dispatches, reached a 3D cutscene past the frame-1798 transition where the tester previously saw upstream exit, and shut down cleanly. A matched run of shader `2cc4c197ee29e291` through the opening prologue is still pending. [RTX 3060 Ti gameplay report](https://git.gtahub.st/github/avatarmanz--VIctory-7900XTX/pulls/4) - `VICTORY_LDS_FLAGS` now participates in the shader and pipeline cache keys. Three Windows `warm --limit 0` runs verified that switching it on changes the pipeline fingerprint and switching it off restores the original fingerprint. [Cache validation](https://github.com/gomeaw/VIctory-7900XTX/actions/runs/45724117447) To confirm this port on a 32-lane GPU, run `cargo test --locked -p victory-shader --lib both_host_waves_observe_the_lds_flag_after_the_join -- --nocapture` and check for the line reporting all 14 hardware dispatches. Further gameplay and performance comparisons are open. AI-assisted with Codex. The tests use synthetic shaders.
A console wave64 program with LDS in a group over 32 threads runs on a
32-lane host as two host waves that meet at group barriers on the edges of
each lane-branch region. A region that both reads and writes LDS was
refused, since a read inside it may miss the other half's write.

That changes nothing the region leaves behind when it only raises a flag:
every access is a ds_read_b32/ds_write_b32 at a constant address, every
write stores the same constant, at most one address is both read and
written, every write a lane can reach after a read goes to that flag, the
region has no other effect, and no register it writes is live (lane by
lane) where a lane leaves it. A missed write then only keeps a lane going
as if the flag were down, and what it writes is the constant already
there. VICTORY_LDS_FLAGS=0 turns this off.

sr_tracing:CS_Tiling_Generate_Opaque (2cc4c197ee29e291) now translates in
waves of 32 and its pipeline is created on an RTX 5070 Ti. Translating
the whole shader pack for a 32-lane host, it is the only program whose
outcome changes.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
(cherry picked from commit 8bc48bf7eff5017ae2f43cfe55c12c88bfbbad2d)
Switching VICTORY_LDS_FLAGS changes the required wave size for the affected shaders. Use the same cache fingerprint path as the other wave64 lowering switches.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 03:31:11 +00:00
Author
Owner

@⁠Hussein5645 on GitHub · 2026-11-25 23:17 UTC · original

I reproduced 0x80070057 for compute shader 2cc4c197ee29e291 on NVIDIA while running AvatarManz main at 0a43566 through the opening prologue. This matches the shader targeted by fxceless/victory-fork#592. This is the baseline result. PR #4 is still to be tested on my machine.

**@⁠Hussein5645** on GitHub · 2026-11-25 23:17 UTC · [original](https://github.com/avatarmanz/VIctory-7900XTX/pull/4#issuecomment-7177371590) I reproduced 0x80070057 for compute shader 2cc4c197ee29e291 on NVIDIA while running AvatarManz main at 0a43566 through the opening prologue. This matches the shader targeted by fxceless/victory-fork#592. This is the baseline result. PR #4 is still to be tested on my machine.
Author
Owner

@⁠Adika713 on GitHub · 2026-11-25 23:31 UTC · original

Verified PR #4 at head 25025d2 on this host: AMD Radeon RX 6950 XT (RDNA2), Ryzen 5 3600, 32 GB RAM, Windows 11, rustc/cargo 1.98.1.

Commands and results:

cargo test --locked -p victory-shader --lib -- --test-threads=1
  • base 0a43566: 278 passed, 0 failed, 4 ignored; exit 0
  • PR #4 25025d2: 281 passed, 0 failed, 4 ignored; exit 0

The three added tests cover the wave-32 lowering decision and the negative two-value LDS case. I also ran the named dispatch test alone; it passes but prints not a 32-lane host, skipping flag dispatches. This RX 6950 XT reports WaveLaneCountMax != 32, and a temporary local WARP-forced probe also skipped, so I cannot claim the 14 hardware dispatches were executed here. That probe was reverted and the worktree is clean.

No game files were used and no in-game FPS was measured. From this host's CPU-only results, no changes requested.

AI-assisted: OpenCode, model Big Pickle. No game data.

**@⁠Adika713** on GitHub · 2026-11-25 23:31 UTC · [original](https://github.com/avatarmanz/VIctory-7900XTX/pull/4#issuecomment-7177683759) Verified PR #4 at head `25025d2` on this host: AMD Radeon RX 6950 XT (RDNA2), Ryzen 5 3600, 32 GB RAM, Windows 11, rustc/cargo 1.98.1. Commands and results: ```powershell cargo test --locked -p victory-shader --lib -- --test-threads=1 ``` - base `0a43566`: 278 passed, 0 failed, 4 ignored; exit 0 - PR #4 `25025d2`: 281 passed, 0 failed, 4 ignored; exit 0 The three added tests cover the wave-32 lowering decision and the negative two-value LDS case. I also ran the named dispatch test alone; it passes but prints `not a 32-lane host, skipping flag dispatches`. This RX 6950 XT reports `WaveLaneCountMax != 32`, and a temporary local WARP-forced probe also skipped, so I cannot claim the 14 hardware dispatches were executed here. That probe was reverted and the worktree is clean. No game files were used and no in-game FPS was measured. From this host's CPU-only results, no changes requested. AI-assisted: OpenCode, model Big Pickle. No game data.
Author
Owner

@⁠sawetco on GitHub · 2026-11-25 23:18 UTC · original · edited 2026-11-25 23:39 UTC

Tested 25025d2 on a physical GeForce RTX 5070 (12 GB), driver 621.24, Windows build 26300. I ran the requested both_host_waves_observe_the_lds_flag_after_the_join test twice, once on its own and once with the other wave64 tests, using the diag profile. Both runs reached the hardware assertion and printed:

all 14 flag dispatches passed on a 32-lane hardware adapter

All 64 output words matched for each of the seven active-lane counts with both scalar-skip values. The two companion tests also selected wave32 for the single-value flag and wave64 for the two-value case. This confirms the synthetic LDS case on this NVIDIA card.

Follow-up on the compute shader reported above. I also tested 2cc4c197ee29e291 from a local copy on the same RTX 5070. On main (0a43566), translate --validate --pipelines --list with host wave limit 32 validated the DXIL, but D3D12 rejected the compute pipeline with “The parameter is incorrect.” On this PR head, I ran the same container through the translator and the physical D3D12 device in separate processes, without a shader cache. With VICTORY_LDS_FLAGS=0 the pipeline was rejected. With VICTORY_LDS_FLAGS=1 it was created successfully. This verifies pipeline creation for the specific shader in the RTX prologue report. The per-lane dispatch check above uses the synthetic fixture.

**@⁠sawetco** on GitHub · 2026-11-25 23:18 UTC · [original](https://github.com/avatarmanz/VIctory-7900XTX/pull/4#issuecomment-7177380728) · edited 2026-11-25 23:39 UTC Tested 25025d2 on a physical GeForce RTX 5070 (12 GB), driver 621.24, Windows build 26300. I ran the requested `both_host_waves_observe_the_lds_flag_after_the_join` test twice, once on its own and once with the other wave64 tests, using the `diag` profile. Both runs reached the hardware assertion and printed: ```text all 14 flag dispatches passed on a 32-lane hardware adapter ``` All 64 output words matched for each of the seven active-lane counts with both scalar-skip values. The two companion tests also selected wave32 for the single-value flag and wave64 for the two-value case. This confirms the synthetic LDS case on this NVIDIA card. **Follow-up on the compute shader reported above.** I also tested `2cc4c197ee29e291` from a local copy on the same RTX 5070. On main (`0a43566`), `translate --validate --pipelines --list` with host wave limit 32 validated the DXIL, but D3D12 rejected the compute pipeline with “The parameter is incorrect.” On this PR head, I ran the same container through the translator and the physical D3D12 device in separate processes, without a shader cache. With `VICTORY_LDS_FLAGS=0` the pipeline was rejected. With `VICTORY_LDS_FLAGS=1` it was created successfully. This verifies pipeline creation for the specific shader in [the RTX prologue report](https://git.gtahub.st/github/avatarmanz--VIctory-7900XTX/pulls/4). The per-lane dispatch check above uses the synthetic fixture.
Author
Owner

@⁠spook40 on GitHub · 2026-11-25 23:42 UTC · original

Adding an in-game 32-lane NVIDIA run on RTX 3060 Ti (8 GB) (pr-4 branch, diag profile with --features diagnostics, VICTORY_TEXTURE_MAX=512):

  • Unit test: both_host_waves_observe_the_lds_flag_after_the_join passed (all 14 flag dispatches passed on a 32-lane hardware adapter).
  • In-game: Reached in-game 3D rendering (cutscene) past the frame-1798 transition where main previously exited with -1073741819 (0xC0000005), and shut down cleanly (title suspended; ending the title, host pipeline library saved 230833866 bytes).
**@⁠spook40** on GitHub · 2026-11-25 23:42 UTC · [original](https://github.com/avatarmanz/VIctory-7900XTX/pull/4#issuecomment-7177943791) Adding an in-game 32-lane NVIDIA run on **RTX 3060 Ti (8 GB)** (`pr-4` branch, `diag` profile with `--features diagnostics`, `VICTORY_TEXTURE_MAX=512`): * **Unit test:** `both_host_waves_observe_the_lds_flag_after_the_join` passed (`all 14 flag dispatches passed on a 32-lane hardware adapter`). * **In-game:** Reached in-game 3D rendering (cutscene) past the frame-1798 transition where `main` previously exited with `-1073741819` (`0xC0000005`), and shut down cleanly (`title suspended; ending the title`, host pipeline library saved `230833866` bytes).
Author
Owner

@⁠Marcosmarb on GitHub · 2026-11-25 23:53 UTC · original

Tested this port on a 32-lane GPU, as asked in the description.

Machine: Windows 11 Home (26200), AMD Ryzen 7 6800HS, 16 GB RAM, NVIDIA GeForce RTX 3050 Laptop GPU 4 GB (driver 32.0.16.2101). It is DXGI adapter 0 and the default device here; D3D12 reports waves of 32–32 lanes, SM 6.8, mesh shader tier 1. Rust 1.98.1 (MSVC), debug test profile.

Branch: 25025d2 (this PR).

cargo test --locked -p victory-shader --lib both_host_waves_observe_the_lds_flag_after_the_join -- --nocapture
all 14 flag dispatches passed on a 32-lane hardware adapter
test emit::wave64_tests::both_host_waves_observe_the_lds_flag_after_the_join ... ok

Whole shader suite on this branch: 281 passed; 0 failed; 4 ignored.

For comparison, main at 0a43566 on the same machine: whole workspace 916 passed, 0 failed, 45 ignored; shader suite 278 passed, 0 failed, 4 ignored.

Not tested: anything in-game (synthetic tests only, no title files), and VICTORY_LDS_FLAGS=0.

Tested with the help of Claude Code.

**@⁠Marcosmarb** on GitHub · 2026-11-25 23:53 UTC · [original](https://github.com/avatarmanz/VIctory-7900XTX/pull/4#issuecomment-7178176077) Tested this port on a 32-lane GPU, as asked in the description. **Machine:** Windows 11 Home (26200), AMD Ryzen 7 6800HS, 16 GB RAM, NVIDIA GeForce RTX 3050 Laptop GPU 4 GB (driver 32.0.16.2101). It is DXGI adapter 0 and the default device here; D3D12 reports waves of 32–32 lanes, SM 6.8, mesh shader tier 1. Rust 1.98.1 (MSVC), debug test profile. **Branch:** `25025d2` (this PR). ``` cargo test --locked -p victory-shader --lib both_host_waves_observe_the_lds_flag_after_the_join -- --nocapture all 14 flag dispatches passed on a 32-lane hardware adapter test emit::wave64_tests::both_host_waves_observe_the_lds_flag_after_the_join ... ok ``` Whole shader suite on this branch: `281 passed; 0 failed; 4 ignored`. For comparison, `main` at `0a43566` on the same machine: whole workspace `916 passed, 0 failed, 45 ignored`; shader suite `278 passed, 0 failed, 4 ignored`. Not tested: anything in-game (synthetic tests only, no title files), and `VICTORY_LDS_FLAGS=0`. Tested with the help of Claude Code.
Author
Owner

@⁠MoonYueya on GitHub · 2026-11-26 05:28 UTC · original

Tested on an RTX 3080 10 GB, driver 32.0.16.1742, Ryzen 7 7700, 31.1 GB RAM, Windows 11 26300, merged into MoonYueya/VIctory-Kira a3de053 on top of e2a28ec together with the other open NVIDIA PRs (#47 #48 #24 #23 #78 #42 #66 #18 #10 #4 #58 #17).

  • cargo test --workspace --locked --no-fail-fast -- --test-threads=1: 934 passed, 0 failed, 45 ignored after this PR was merged (never below the count before it; the branch started at 923).
  • VICTORY_LDS_FLAGS is on by default; the flag-region tests pass here. It conflicted only in appended test modules (both kept).
  • With everything merged, three unattended runs reached the world with no device removal, panic or untranslated shader.

What this does not show: the PR was not run in the game on its own, so this is unit tests plus a combined run, not an in-game verification of this PR by itself; nothing here is about picture quality.

AI-assisted.

**@⁠MoonYueya** on GitHub · 2026-11-26 05:28 UTC · [original](https://github.com/avatarmanz/VIctory-7900XTX/pull/4#issuecomment-7183520045) Tested on an RTX 3080 10 GB, driver 32.0.16.1742, Ryzen 7 7700, 31.1 GB RAM, Windows 11 26300, merged into [MoonYueya/VIctory-Kira](https://github.com/MoonYueya/VIctory-Kira) `a3de053` on top of `e2a28ec` together with the other open NVIDIA PRs (#47 #48 #24 #23 #78 #42 #66 #18 #10 #4 #58 #17). - `cargo test --workspace --locked --no-fail-fast -- --test-threads=1`: **934 passed, 0 failed, 45 ignored** after this PR was merged (never below the count before it; the branch started at 923). - `VICTORY_LDS_FLAGS` is on by default; the flag-region tests pass here. It conflicted only in appended test modules (both kept). - With everything merged, three unattended runs reached the world with no device removal, panic or untranslated shader. What this does **not** show: the PR was not run in the game on its own, so this is unit tests plus a combined run, not an in-game verification of this PR by itself; nothing here is about picture quality. *AI-assisted.*
Author
Owner

@⁠avatarmanz on GitHub · 2026-11-26 07:56 UTC · original

Merged into main in the next push (tests pass); thanks.

**@⁠avatarmanz** on GitHub · 2026-11-26 07:56 UTC · [original](https://github.com/avatarmanz/VIctory-7900XTX/pull/4#issuecomment-7185997425) Merged into main in the next push (tests pass); thanks.
github manually merged commit a5e4233870 into main 2026-11-26 08:21:47 +00:00
This discussion has been locked. Commenting is limited to contributors.
No description provided.