Preserve packed Wave32 scalar words in the adaptive shadow pass #2220

Open
github-bot wants to merge 13 commits from github-bot/gh-2220 into main AGit
Owner

@⁠BlackpawNR on GitHub · 2026-11-29 10:41 UTC · original
BlackpawNR:fix/shader-mask-branch → main · +956 −830 · 36 files · 13 commits · open

Follows #1809 and addresses the FullAdaptive refusal reported in #154 and #1396.

What changes

The Wave32 adaptive shadow-ray compute shader dbdbf36298727135 stops at 0xae80. A vector compare reads a packed scalar key. The structurizer also tracks that key as a lane predicate. Rebuilding its scalar bits with a ballot would discard bits belonging to inactive lanes. Microsoft’s WaveActiveBallot reference

After that specific refusal, the compute lowerer retries once and keeps the numeric result of scalar AND, OR and XOR writes to ordinary SGPRs when both operands already have full-word representations. It keeps the lane predicate for its existing consumers and recomputes joins on the retry. Reachable inputs still require a full word.

The descriptor follow-up uses the final DXIL branch condition, after wave-wide decisions and loop limits. A literal condition can select only one of two distinct successors. The predecessor stays in the DXIL graph, with an unused phi input for any unavailable value on the impossible edge. Strict transitive join checking follows the edges that can carry a value. In FullAdaptive, the edge at 0x87f8 that would carry the stale descriptor words is impossible. The other edge loads the data the shader uses.

Verification

Tested against 829188e9 on a GeForce RTX 5070 Ti with driver 621.40, targeting 32-lane host waves. Both builds used the same five locally supplied shadow compute programs. Resolution, DLSS and frame generation do not enter this offline test.

Check Upstream This branch
Programs accepted by the Microsoft DXIL validator 4/5 5/5
Hardware D3D12 compute pipelines created 4/5 5/5
Compute shaders validated and made into hardware pipelines with strict joins 4/5 5/5
Programs stored by the runtime preloader in an empty cache 4/5 5/5
  • The four previously successful serialized shader records, including their bindings, have identical SHA-256 hashes across the two caches.

  • The synthetic regression fails on the base with the same lane-mask refusal. On the RTX, eight dispatches check both paths into a scalar join, partial and empty execution masks, and high tag bits in 8- and 32-thread groups. A second regression covers unavailable predicate bits. The synthetic tests also pass with VICTORY_STRICT_JOINS=1.

  • Before the join follow-up, seven interleaved repeat runs of victory shaders --jobs 1 took a median of 479 ms upstream and 205 ms patched for the affected shader. Upstream retried translation on every launch. A previously cached sibling measured 206 ms and 202 ms respectively. These are whole-process preload times.

  • The final optimized host-enabled shader suite passed 465 tests with 9 ignored. With VICTORY_STRICT_JOINS=1, the new literal-edge regression passes on this branch and fails on the base. The separate reachable-missing-value regression and the packed scalar GPU readbacks also pass in strict mode. The staged asset-policy check passed.

  • All-features Clippy with warnings denied reports the same four pre-existing findings as the upstream base.

Copied-save gameplay comparison

Compared the same upstream base and the patched runner on identical copies of a waterfront free-roam save. Both use the same Series X preset, 2560×1440 output, DLSS Quality requested, frame generation off, and a fixed camera. The diagnostics builds have identical build-compatibility fixes and dispatch counters. Those counters cover direct and indirect requests, including failed pipeline binds, using container identity and native instruction bytes. Timing uses the last 30 seconds of continuous gameplay in each run, from the individual intervals between the title’s presents.

Test Stock rendered FPS Patched rendered FPS
Unchanged save, first run 3.52 21.38
Unchanged save, second run 21.24 21.65
Additional copy with ray-traced LOD light shadows enabled 21.36 21.55

The main runs were ordered stock, patched, patched, stock. The first stock run lost much of the shadow on the ground and picnic table. Stock reproduced those shadows on the second run, as did both patched runs. All six runs requested CS_TraceShadowRays_Checkerboard. The counters saw zero requests for FullAdaptive or its four siblings. All 50 named shadow compute shaders recorded in the first stock run emitted byte-identical DXIL with both translators.

Both builds requested the ray-tracing structure builder. During gameplay it reported 50 of its 53 pipelines unavailable, with D3D12 0x8007000e failures. Across all pipeline types, the first stock run logged 170 such failures against distinct keys. The second stock run logged 85. One of the failing builder shaders created a hardware pipeline in isolation. The slow stock run did not reproduce. A gameplay frame-rate or shadow improvement from FullAdaptive remains unverified.

FullAdaptive in gameplay

The game selects Checkerboard when rtLocalShadows is Low (0). A nonzero setting selects a sequence of six passes, with FullAdaptive fourth. Both stock console profiles tested selected Checkerboard on the waterfront. Changing the time to 23:00 alone still selected Checkerboard. For the comparison below, the copied Series X session loaded a bundled graphics preset with local and directional RT shadows set to High. The game then requested FullAdaptive through its usual render path.

All three runs used the same save, viewpoint, night-time setting and output settings described above. FPS is the mean over the final 30 seconds of individual rendered presents, with frame generation off. The command counts come from the last cumulative sample of each run.

Build FullAdaptive requests D3D12 indirect commands recorded Mean rendered FPS
Stock 564 0 12.40
Patched 482 0 10.63
Patched, same pipeline prepared during loading (diagnostic) 858 858 16.36

Stock refused the shader at 0xae80. The patched runner translated it, then D3D12 returned E_OUTOFMEMORY (0x8007000E) when creating the compute pipeline during gameplay. A second trace confirmed this failure and recorded zero commands from 494 requests. With the identical translated shader and root signature prepared during loading, D3D12 created the pipeline in 5.34 seconds. The renderer then recorded an ExecuteIndirect call for each of the 858 requests observed. The GPU workgroup counts in the indirect argument buffer remain unmeasured.

The waterfront ground, fence and bench looked similar in all three captures. The ray-tracing structure builder reported 46 or 47 of its 53 pipelines unavailable in these runs. The early-creation experiment changed scheduling and is confined to the diagnostic runner. These results verify the translation fix in gameplay. A repeatable improvement in shadows or rendered FPS remains unverified.

Checked for overlap

  • Searched for the shader hash, FullAdaptive, the failing offset and lane-mask changes. #1809 identified this remaining case. #2001 and #2011 cover Wave64 lowering, and #2059 handles partial EXEC for vector selects.
  • #2261 changes the retry order for Wave64 folding and links this Wave32 fix as related.
**@⁠BlackpawNR** on GitHub · 2026-11-29 10:41 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/2220) `BlackpawNR:fix/shader-mask-branch` → `main` · +956 −830 · 36 files · 13 commits · open Follows #1809 and addresses the FullAdaptive refusal reported in #154 and #1396. ## What changes The Wave32 adaptive shadow-ray compute shader `dbdbf36298727135` stops at `0xae80`. A vector compare reads a packed scalar key. The structurizer also tracks that key as a lane predicate. Rebuilding its scalar bits with a ballot would discard bits belonging to inactive lanes. [Microsoft’s WaveActiveBallot reference](https://learn.microsoft.com/en-us/windows/win32/direct3dhlsl/waveballot) After that specific refusal, the compute lowerer retries once and keeps the numeric result of scalar AND, OR and XOR writes to ordinary SGPRs when both operands already have full-word representations. It keeps the lane predicate for its existing consumers and recomputes joins on the retry. Reachable inputs still require a full word. The descriptor follow-up uses the final DXIL branch condition, after wave-wide decisions and loop limits. A literal condition can select only one of two distinct successors. The predecessor stays in the DXIL graph, with an unused phi input for any unavailable value on the impossible edge. Strict transitive join checking follows the edges that can carry a value. In FullAdaptive, the edge at `0x87f8` that would carry the stale descriptor words is impossible. The other edge loads the data the shader uses. ## Verification Tested against `829188e9` on a GeForce RTX 5070 Ti with driver 621.40, targeting 32-lane host waves. Both builds used the same five locally supplied shadow compute programs. Resolution, DLSS and frame generation do not enter this offline test. | Check | Upstream | This branch | | --- | ---: | ---: | | Programs accepted by the Microsoft DXIL validator | 4/5 | 5/5 | | Hardware D3D12 compute pipelines created | 4/5 | 5/5 | | Compute shaders validated and made into hardware pipelines with strict joins | 4/5 | 5/5 | | Programs stored by the runtime preloader in an empty cache | 4/5 | 5/5 | - The four previously successful serialized shader records, including their bindings, have identical SHA-256 hashes across the two caches. - The synthetic regression fails on the base with the same lane-mask refusal. On the RTX, eight dispatches check both paths into a scalar join, partial and empty execution masks, and high tag bits in 8- and 32-thread groups. A second regression covers unavailable predicate bits. The synthetic tests also pass with `VICTORY_STRICT_JOINS=1`. - Before the join follow-up, seven interleaved repeat runs of `victory shaders --jobs 1` took a median of 479 ms upstream and 205 ms patched for the affected shader. Upstream retried translation on every launch. A previously cached sibling measured 206 ms and 202 ms respectively. These are whole-process preload times. - The final optimized host-enabled shader suite passed 465 tests with 9 ignored. With `VICTORY_STRICT_JOINS=1`, the new literal-edge regression passes on this branch and fails on the base. The separate reachable-missing-value regression and the packed scalar GPU readbacks also pass in strict mode. The staged asset-policy check passed. - All-features Clippy with warnings denied reports the same four pre-existing findings as the upstream base. ## Copied-save gameplay comparison Compared the same upstream base and the patched runner on identical copies of a waterfront free-roam save. Both use the same Series X preset, 2560×1440 output, DLSS Quality requested, frame generation off, and a fixed camera. The diagnostics builds have identical build-compatibility fixes and dispatch counters. Those counters cover direct and indirect requests, including failed pipeline binds, using container identity and native instruction bytes. Timing uses the last 30 seconds of continuous gameplay in each run, from the individual intervals between the title’s presents. | Test | Stock rendered FPS | Patched rendered FPS | | --- | ---: | ---: | | Unchanged save, first run | 3.52 | 21.38 | | Unchanged save, second run | 21.24 | 21.65 | | Additional copy with ray-traced LOD light shadows enabled | 21.36 | 21.55 | The main runs were ordered stock, patched, patched, stock. The first stock run lost much of the shadow on the ground and picnic table. Stock reproduced those shadows on the second run, as did both patched runs. All six runs requested `CS_TraceShadowRays_Checkerboard`. The counters saw zero requests for `FullAdaptive` or its four siblings. All 50 named shadow compute shaders recorded in the first stock run emitted byte-identical DXIL with both translators. Both builds requested the ray-tracing structure builder. During gameplay it reported 50 of its 53 pipelines unavailable, with D3D12 `0x8007000e` failures. Across all pipeline types, the first stock run logged 170 such failures against distinct keys. The second stock run logged 85. One of the failing builder shaders created a hardware pipeline in isolation. The slow stock run did not reproduce. A gameplay frame-rate or shadow improvement from FullAdaptive remains unverified. ### FullAdaptive in gameplay The game selects Checkerboard when `rtLocalShadows` is Low (0). A nonzero setting selects a sequence of six passes, with FullAdaptive fourth. Both stock console profiles tested selected Checkerboard on the waterfront. Changing the time to 23:00 alone still selected Checkerboard. For the comparison below, the copied Series X session loaded a bundled graphics preset with local and directional RT shadows set to High. The game then requested FullAdaptive through its usual render path. All three runs used the same save, viewpoint, night-time setting and output settings described above. FPS is the mean over the final 30 seconds of individual rendered presents, with frame generation off. The command counts come from the last cumulative sample of each run. | Build | FullAdaptive requests | D3D12 indirect commands recorded | Mean rendered FPS | | --- | ---: | ---: | ---: | | Stock | 564 | 0 | 12.40 | | Patched | 482 | 0 | 10.63 | | Patched, same pipeline prepared during loading (diagnostic) | 858 | 858 | 16.36 | Stock refused the shader at `0xae80`. The patched runner translated it, then D3D12 returned `E_OUTOFMEMORY` (`0x8007000E`) when creating the compute pipeline during gameplay. A second trace confirmed this failure and recorded zero commands from 494 requests. With the identical translated shader and root signature prepared during loading, D3D12 created the pipeline in 5.34 seconds. The renderer then recorded an `ExecuteIndirect` call for each of the 858 requests observed. The GPU workgroup counts in the indirect argument buffer remain unmeasured. The waterfront ground, fence and bench looked similar in all three captures. The ray-tracing structure builder reported 46 or 47 of its 53 pipelines unavailable in these runs. The early-creation experiment changed scheduling and is confined to the diagnostic runner. These results verify the translation fix in gameplay. A repeatable improvement in shadows or rendered FPS remains unverified. ## Checked for overlap - [x] Searched for the shader hash, FullAdaptive, the failing offset and lane-mask changes. #1809 identified this remaining case. #2001 and #2011 cover Wave64 lowering, and #2059 handles partial EXEC for vector selects. - #2261 changes the retry order for Wave64 folding and links this Wave32 fix as related.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-29 10:44:36 +00:00
Keep a phi predecessor for the DXIL graph, but mark its input unused when the emitted branch selects the other edge unconditionally. Record the final condition after wave-wide decisions and loop limits so dynamic paths still require their values. Cover direct and nested joins and a reachable missing value.

Co-authored-by: Codex <[email protected]>
Keep the packed Wave32 scalar retry within the upstream ray-query and particle lowering flow, rebuilding active ray-query plans on retry. Combine impossible-edge filtering with folded Wave64 mask-join propagation and retain the upstream constructor interface.

Replace the upstream title-derived metadata fixture with synthetic records so the merged tree passes the asset-policy check while preserving version 0x403 coverage.

Validated with Rust 1.98.1: 333 shader tests passed, both strict-join regressions passed, the synthetic metadata regression passed, and staged asset policy passed.

Co-authored-by: Codex <[email protected]>
This pull request has changes conflicting with the target branch.
  • apps/victory/src/play.rs
  • crates/victory-gpu/src/shadow.rs
  • crates/victory-hle/src/modules/xmem.rs
  • crates/victory-shader/src/native.rs
  • scripts/play-nvidia.ps1
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/2220/head:github-bot/gh-2220'
git switch 'github-bot/gh-2220'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-2220'
git switch 'github-bot/gh-2220'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-2220'
git switch 'github-bot/gh-2220'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-2220'
git switch 'main'
git merge --squash 'github-bot/gh-2220'
git switch 'main'
git merge --ff-only 'github-bot/gh-2220'
git switch 'main'
git merge 'github-bot/gh-2220'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No reviewers
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.

Dependencies

No dependencies set

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