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

Open
Lkxex wants to merge 3 commits from upstream-pr/1166 into main
Lkxex commented 2026-11-25 22:24:36 +00:00 (Migrated from github.com)

Imported from fxceless/victory-fork. Originally posted by Lkxex on 2026-11-25T22:24:36Z.


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.

<!-- greyfinch-sync:fxceless/victory-fork:issue:6614993861 --> Imported from [fxceless/victory-fork](https://github.com/fxceless/victory-fork/pull/1166). Originally posted by [Lkxex](https://github.com/Lkxex) on 2026-11-25T22:24:36Z. --- ## 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.
Dathinel commented 2026-11-25 23:09:58 +00:00 (Migrated from github.com)

Imported from fxceless/victory-fork. Originally posted by Dathinel on 2026-11-25T22:41:57Z.


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.

<!-- greyfinch-sync:fxceless/victory-fork:comment:7176682140 --> Imported from [fxceless/victory-fork](https://github.com/fxceless/victory-fork/pull/1166#issuecomment-7176682140). Originally posted by [Dathinel](https://github.com/Dathinel) on 2026-11-25T22:41:57Z. --- 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.
HAL9000RELOADED commented 2026-11-26 00:06:08 +00:00 (Migrated from github.com)

Imported from fxceless/victory-fork. Originally posted by HAL9000RELOADED on 2026-11-25T23:25:50Z.


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.
<!-- greyfinch-sync:fxceless/victory-fork:comment:7177549091 --> Imported from [fxceless/victory-fork](https://github.com/fxceless/victory-fork/pull/1166#issuecomment-7177549091). Originally posted by [HAL9000RELOADED](https://github.com/HAL9000RELOADED) on 2026-11-25T23:25:50Z. --- 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 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/1166:upstream-pr/1166'
git switch 'upstream-pr/1166'

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/1166'
git switch 'upstream-pr/1166'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/1166'
git switch 'upstream-pr/1166'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/1166'
git switch 'main'
git merge --squash 'upstream-pr/1166'
git switch 'main'
git merge --ff-only 'upstream-pr/1166'
git switch 'main'
git merge 'upstream-pr/1166'
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
fxceless/victory-fork!1163
No description provided.