Fix Windows shader warm-up, wave permutes, and BVH residency #1166

Open
github-bot wants to merge 3 commits from github-bot/gh-1166 into main AGit
Owner

@⁠Lkxex on GitHub · 2026-11-25 22:24 UTC · original
Lkxex:fix/windows-shader-cache → main · +469 −116 · 11 files · 3 commits · open

What changes

  • Detect the runtime adapter's wave width and descriptor heap limit before warming the shader cache.
  • Preserve pending pipeline cache writes across I/O failures and prevent an older pending file from superseding a newer save.
  • Keep backward lane permutes inside each 32-lane half as specified by AMD RDNA2 §10.4.4, including when a console wave64 is run as two host waves. Inactive sources return zero.
  • Return the appropriate BVH miss for missing node pages and skip the second directory lookup when a wide box stays inside one page.

Tested

Windows x64 diagnostics build and the synthetic BVH GPU regression using the runtime page-table bindings. This implementation was also exercised in wave32 and wave64 on an RX 6600.

Not tested

In-game lighting, stability, and frame rate.

AI use

Codex (GPT-6.2 Sol) assisted with implementation and tests.

**@⁠Lkxex** on GitHub · 2026-11-25 22:24 UTC · [original](https://github.com/fxceless/victory-fork/pull/1166) `Lkxex:fix/windows-shader-cache` → `main` · +469 −116 · 11 files · 3 commits · open ## What changes - Detect the runtime adapter's wave width and descriptor heap limit before warming the shader cache. - Preserve pending pipeline cache writes across I/O failures and prevent an older pending file from superseding a newer save. - Keep backward lane permutes inside each 32-lane half as specified by AMD RDNA2 §10.4.4, including when a console wave64 is run as two host waves. Inactive sources return zero. - Return the appropriate BVH miss for missing node pages and skip the second directory lookup when a wide box stays inside one page. ## Tested Windows x64 diagnostics build and the synthetic BVH GPU regression using the runtime page-table bindings. This implementation was also exercised in wave32 and wave64 on an RX 6600. ## Not tested In-game lighting, stability, and frame rate. ## AI use Codex (GPT-6.2 Sol) assisted with implementation and tests.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 03:58:47 +00:00
Author
Owner

@⁠Dathinel on GitHub · 2026-11-25 22:41 UTC · original · edited 2026-11-25 22:49 UTC

RTX 3050 Laptop (native wave32), synthetic D3D12 readback. On 77cbca8 I get a mismatch with 33 threads in a variant of the permute test that saves/restores EXEC and predicates lanes below 47. The 16-thread case passes. At 33 threads that predicate leaves every launched thread enabled.

Smallest reproducer on my local integration of the shader change: in backward_permute_stays_inside_each_half_of_a_console_wave, change only [64, 16] to [64, 16, 33]. Run cargo test -p victory-shader --lib backward_permute_stays_inside -- --nocapture. Both original sizes pass. For 33, the first four output words are [0, 1, 2, 3], expected [1, 2, 3, 4]. This also reproduces without any explicit EXEC manipulation.

The first divergence is in the full first half, even though only the second half is partial. The result warrants checking the mapping between group thread IDs and physical wave lanes for odd group sizes before attributing it to the permute itself. Native wave64 remains untested here. AI-assisted investigation.

Follow-up A/B on the same RTX: the isolated wave_base() hunk from #561 (745305c) resolves this reproducer with the #1166 shader path. Across three rounds (alternating build order), 16/32/64/96 passed in both builds. With 33/47/48/63/65/100 threads the original allocation gave 31/31/31/2/31/31 wrong output words respectively in every round. With #561 all ten sizes matched every output in every round. With the EXEC-mask variant, all 160 outputs across 16/33/47/64 also matched on the combined build.

A separate PC-DXC wave32 HLSL probe, instrumenting the same atomic counter at group size 33, observed the singleton thread (ID 32) take base 0 and the full wave take base 32 in 3/3 dispatches. Thread IDs 0–31 occupied physical lanes 0–31. The emitted translated DXIL then computes X modulo 33, explaining the wrapped indices. The result points to the existing tail-wave allocator fix for this case. No native wave64 or rendering claim.

**@⁠Dathinel** on GitHub · 2026-11-25 22:41 UTC · [original](https://github.com/fxceless/victory-fork/pull/1166#issuecomment-7176682140) · edited 2026-11-25 22:49 UTC RTX 3050 Laptop (native wave32), synthetic D3D12 readback. On 77cbca8 I get a mismatch with 33 threads in a variant of the permute test that saves/restores EXEC and predicates lanes below 47. The 16-thread case passes. At 33 threads that predicate leaves every launched thread enabled. Smallest reproducer on my local integration of the shader change: in `backward_permute_stays_inside_each_half_of_a_console_wave`, change only `[64, 16]` to `[64, 16, 33]`. Run `cargo test -p victory-shader --lib backward_permute_stays_inside -- --nocapture`. Both original sizes pass. For 33, the first four output words are `[0, 1, 2, 3]`, expected `[1, 2, 3, 4]`. This also reproduces without any explicit EXEC manipulation. The first divergence is in the full first half, even though only the second half is partial. The result warrants checking the mapping between group thread IDs and physical wave lanes for odd group sizes before attributing it to the permute itself. Native wave64 remains untested here. AI-assisted investigation. **Follow-up A/B on the same RTX:** the isolated wave_base() hunk from #561 (`745305c`) resolves this reproducer with the #1166 shader path. Across three rounds (alternating build order), 16/32/64/96 passed in both builds. With 33/47/48/63/65/100 threads the original allocation gave 31/31/31/2/31/31 wrong output words respectively in every round. With #561 all ten sizes matched every output in every round. With the EXEC-mask variant, all 160 outputs across 16/33/47/64 also matched on the combined build. A separate PC-DXC wave32 HLSL probe, instrumenting the same atomic counter at group size 33, observed the singleton thread (ID 32) take base 0 and the full wave take base 32 in 3/3 dispatches. Thread IDs 0–31 occupied physical lanes 0–31. The emitted translated DXIL then computes X modulo 33, explaining the wrapped indices. The result points to the existing tail-wave allocator fix for this case. No native wave64 or rendering claim.
Author
Owner

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

RDNA3 run of d3dd585 (native wave64): RX 7900 XTX (RDNA3), driver 32.0.32015.7029, Windows 10 22H2 (19045), Agility SDK 1.620 (#402). Base: 3151ccf (main d827419 + #402).

  • victory-shader: 219 passed, 0 failed. backward_permute_stays_inside_each_half_of_a_console_wave and backward_permute_with_predicated_lanes_on_partial_groups pass on the card, so the per-half permute holds on RDNA3 too, not only on the RX 6600. traversal_requires_resident_bvh_pages_and_requests_only_the_pages_it_reads passes as well.
  • victory-gpu, three runs: each had one different unrelated outcome (a watch:: test, the warp_budget test that #849 fixes, and one 0xc0000005 exit, see #850), nothing in the files this PR touches.
**@⁠HAL9000RELOADED** on GitHub · 2026-11-25 23:25 UTC · [original](https://github.com/fxceless/victory-fork/pull/1166#issuecomment-7177549091) RDNA3 run of `d3dd585` (native wave64): RX 7900 XTX (RDNA3), driver 32.0.32015.7029, Windows 10 22H2 (19045), Agility SDK 1.620 (#402). Base: `3151ccf` (main `d827419` + #402). - `victory-shader`: 219 passed, 0 failed. `backward_permute_stays_inside_each_half_of_a_console_wave` and `backward_permute_with_predicated_lanes_on_partial_groups` pass on the card, so the per-half permute holds on RDNA3 too, not only on the RX 6600. `traversal_requires_resident_bvh_pages_and_requests_only_the_pages_it_reads` passes as well. - `victory-gpu`, three runs: each had one different unrelated outcome (a `watch::` test, the `warp_budget` test that #849 fixes, and one 0xc0000005 exit, see #850), nothing in the files this PR touches.
This pull request has changes conflicting with the target branch.
  • crates/victory-shader/src/emit/host.rs
  • crates/victory-shader/src/emit/intersect.rs
View command line instructions

Manual merge helper

Use this merge commit message when completing the merge manually.

Checkout

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

Merge

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