Shaders: restore parked lane-mask pairs a few instructions apart; relative VGPR reads keep parked lanes #11

Manually merged
github merged 1 commit from gh-pr/11/head into gh-pr/11/base 2026-11-26 03:34:33 +00:00
Owner

@⁠cxchhh on GitHub · 2026-11-24 19:48 UTC · original
cxchhh:fix/parked-mask-pairs → main · +56 −3 · 2 files · 1 commits · merged 2026-11-24 20:35 UTC

Three shaders that main drops every frame in the prologue now translate. The main one is the irradiance cache's shading pass. Without it, the bounce light in the probes is never computed, and everything the sun does not reach directly renders black.

Shader main (7b0f736) This PR
indirect_light_probes:CS_IrradianceCache_Shade #a53a7977fe762268 a lane mask holding lanes elsewhere read as data validated
indirect_light_probes:CS_IrradianceCache_ShadeSecondary #be14e72d86362031 same validated
billboard_nobump:CS_RaytracingResolve_a56bfb9c #7f05ddab771799a9 same validated

Tested on an RTX 4070, Series X profile

  • In the game, the first two get host pipelines and run every frame. Shadowed areas of the prologue then show indirect light instead of black. (The game run used the previous main, 578d459, plus this change.)
  • cargo test -p victory-shader --lib: 198 passed.
  • Offline, on this branch, over the 1138 ray-tracing, shadow and irradiance programs in shaders.rpf: 1132 validate, against 1130 on main. None that validates on main fails here.

What was wrong (ir.rs, unspill)

  1. A mask restored with work between its two halves. The console compiler parks a wave64 lane mask in two lanes of a spare VGPR. When it takes the mask back, it may schedule other instructions between the two v_readlane_b32 (Shade: v_readlane s10, v113, 6, then v_rcp_f32, then v_readlane s11, v113, 7). The pair rule only accepted the second restore right after the first, so the halves came back as two plain scalars. The mask was then read as data where it holds lanes that are not running.

    The restore now looks ahead within the block, the same way the save already did. The rule refuses the pair if anything in between:

    • reads or writes the second register,
    • writes the first register,
    • saves into either lane.
  2. An M0-relative read turned unspilling off for a whole program. effects lists v_movrels_b32 as reading every VGPR from its base up. That marked the parking VGPR (v144 in the billboard resolve) as an ordinary register, and no lane of it was unspilled. Relative reads no longer count against parking VGPRs. Relative writes (v_movreld, v_movrelsd, v_swaprel) still do.

Offline tooling (translate)

  • VICTORY_TRANSLATE_ONLY=<hash prefix>,... translates only those containers; the hash is the one run logs print. One shader takes seconds instead of a pass over the whole archive.
  • VICTORY_HOST_MAX_WAVE=32 calls set_host_max_wave the way the runtime does on NVIDIA. Without it, --pipelines reports E_INVALIDARG ("wave lane count of 64") for programs the runtime actually splits into two 32-lane waves.

Still failing on this card (not changed here)

  • sr_tracing:CS_Tiling_Generate_Opaque #2cc4c197ee29e291: it keeps 64-lane waves (LDS in a group of 64, mask as data, v_mbcnt) and is refused every frame. It may be behind blocky artifacts in reflections.
  • cascadeshadows_rendering:CS_ShadowRenderTiledCascadesAlphaCBPPPC: a lane mask exchanged where not every lane runs.
  • shadowmask:CS_TraceShadowRays_{Full,Half,Quarter,Eighth,FullAdaptive}: a descriptor read only as data.

🤖 Generated with Claude Code

**@⁠cxchhh** on GitHub · 2026-11-24 19:48 UTC · [original](https://github.com/fxceless/victory-fork/pull/11) `cxchhh:fix/parked-mask-pairs` → `main` · +56 −3 · 2 files · 1 commits · merged 2026-11-24 20:35 UTC Three shaders that `main` drops every frame in the prologue now translate. The main one is the irradiance cache's shading pass. Without it, the bounce light in the probes is never computed, and everything the sun does not reach directly renders black. | Shader | `main` (7b0f736) | This PR | |---|---|---| | `indirect_light_probes:CS_IrradianceCache_Shade` `#a53a7977fe762268` | a lane mask holding lanes elsewhere read as data | validated | | `indirect_light_probes:CS_IrradianceCache_ShadeSecondary` `#be14e72d86362031` | same | validated | | `billboard_nobump:CS_RaytracingResolve_a56bfb9c` `#7f05ddab771799a9` | same | validated | **Tested on an RTX 4070, Series X profile** - In the game, the first two get host pipelines and run every frame. Shadowed areas of the prologue then show indirect light instead of black. (The game run used the previous `main`, 578d459, plus this change.) - `cargo test -p victory-shader --lib`: 198 passed. - Offline, on this branch, over the 1138 ray-tracing, shadow and irradiance programs in `shaders.rpf`: 1132 validate, against 1130 on `main`. None that validates on `main` fails here. ## What was wrong (`ir.rs`, `unspill`) 1. **A mask restored with work between its two halves.** The console compiler parks a wave64 lane mask in two lanes of a spare VGPR. When it takes the mask back, it may schedule other instructions between the two `v_readlane_b32` (Shade: `v_readlane s10, v113, 6`, then `v_rcp_f32`, then `v_readlane s11, v113, 7`). The pair rule only accepted the second restore right after the first, so the halves came back as two plain scalars. The mask was then read as data where it holds lanes that are not running. The restore now looks ahead within the block, the same way the save already did. The rule refuses the pair if anything in between: - reads or writes the second register, - writes the first register, - saves into either lane. 2. **An `M0`-relative read turned unspilling off for a whole program.** `effects` lists `v_movrels_b32` as reading every VGPR from its base up. That marked the parking VGPR (`v144` in the billboard resolve) as an ordinary register, and no lane of it was unspilled. Relative reads no longer count against parking VGPRs. Relative writes (`v_movreld`, `v_movrelsd`, `v_swaprel`) still do. ## Offline tooling (`translate`) - `VICTORY_TRANSLATE_ONLY=<hash prefix>,...` translates only those containers; the hash is the one run logs print. One shader takes seconds instead of a pass over the whole archive. - `VICTORY_HOST_MAX_WAVE=32` calls `set_host_max_wave` the way the runtime does on NVIDIA. Without it, `--pipelines` reports `E_INVALIDARG` ("wave lane count of 64") for programs the runtime actually splits into two 32-lane waves. ## Still failing on this card (not changed here) - `sr_tracing:CS_Tiling_Generate_Opaque` `#2cc4c197ee29e291`: it keeps 64-lane waves (LDS in a group of 64, mask as data, `v_mbcnt`) and is refused every frame. It may be behind blocky artifacts in reflections. - `cascadeshadows_rendering:CS_ShadowRenderTiledCascadesAlphaCBPPPC`: a lane mask exchanged where not every lane runs. - `shadowmask:CS_TraceShadowRays_{Full,Half,Quarter,Eighth,FullAdaptive}`: a descriptor read only as data. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
The console compiler parks a wave64 lane mask in two lanes of a spare VGPR
and may restore the halves with other instructions between the two
v_readlane_b32. The pair restore now looks ahead in the block (nothing between
may touch the second register, write the first, or save into the lanes), so
the mask comes back as a mask. This lets indirect_light_probes
CS_IrradianceCache_Shade / ShadeSecondary translate: they were dropped every
frame, leaving the irradiance cache unlit and everything in shadow black.

An M0-relative read (v_movrels_b32) names every VGPR from its base up, which
marked the parking VGPR as an ordinary one and turned unspilling off for the
whole program. Relative reads no longer count there (relative writes still
do). billboard_nobump CS_RaytracingResolve_a56bfb9c translates with it.

translate: VICTORY_TRANSLATE_ONLY=<hash prefixes> limits a run to those
containers; VICTORY_HOST_MAX_WAVE=32 translates as on a 32-lane host, so
--pipelines matches what the runtime creates on NVIDIA.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 03:34:32 +00:00
github manually merged commit 58682d2756 into gh-pr/11/base 2026-11-26 03:34:33 +00:00
Author
Owner

@⁠fxceless on GitHub · 2026-11-24 20:35 UTC · original

Merged, thank you. Built, tested and run here on an RTX 4070: both irradiance programs translate and are bound with no errors, at a cost of about 40 ms of GPU time per frame. I could not yet make a like-for-like picture comparison (the camera differs between runs), so whether the shadowed areas gain light is still to be confirmed on this machine.

**@⁠fxceless** on GitHub · 2026-11-24 20:35 UTC · [original](https://github.com/fxceless/victory-fork/pull/11#issuecomment-7143771500) Merged, thank you. Built, tested and run here on an RTX 4070: both irradiance programs translate and are bound with no errors, at a cost of about 40 ms of GPU time per frame. I could not yet make a like-for-like picture comparison (the camera differs between runs), so whether the shadowed areas gain light is still to be confirmed on this machine.
Author
Owner

@⁠Mesrine67 on GitHub · 2026-11-24 20:58 UTC · original

Additional RDNA 2 verification on the merged change, using fxceless/victory-fork main at 4e17478:

  • Windows 11 Pro build 26300
  • AMD Radeon RX 6750 XT, driver 32.0.21045.29003
  • VICTORY_TRANSLATE_ONLY=a53a7977fe762268,be14e72d86362031,7f05ddab771799a9
  • victory translate shaders.rpf --validate --pipelines

All three targeted compute shaders translated, passed DXIL validation, and created D3D12 pipelines on this AMD card (3/3). This is translator/pipeline verification only; I did not run the title executable or claim a visual/gameplay result. No game assets are attached.

**@⁠Mesrine67** on GitHub · 2026-11-24 20:58 UTC · [original](https://github.com/fxceless/victory-fork/pull/11#issuecomment-7144303781) Additional RDNA 2 verification on the merged change, using `fxceless/victory-fork` main at `4e17478`: - Windows 11 Pro build 26300 - AMD Radeon RX 6750 XT, driver 32.0.21045.29003 - `VICTORY_TRANSLATE_ONLY=a53a7977fe762268,be14e72d86362031,7f05ddab771799a9` - `victory translate shaders.rpf --validate --pipelines` All three targeted compute shaders translated, passed DXIL validation, and created D3D12 pipelines on this AMD card (3/3). This is translator/pipeline verification only; I did not run the title executable or claim a visual/gameplay result. No game assets are attached.
Author
Owner

@⁠SkillIssueXO on GitHub · 2026-11-24 20:58 UTC · original

Independent Series X checkpoint test on an RTX 5070 Ti, native D3D12, 4e17478 built from source with diagnostics. Default watchdog and shader settings.

  • All three shaders in this PR created host pipelines and first bound at frame 1588. The frame traces at 1700, 1800, 1900 and 2000 each recorded two indirect dispatches for CS_IrradianceCache_Shade (a53a7977fe762268) and two for the billboard resolve (7f05ddab771799a9). ShadeSecondary (be14e72d86362031) bound, with zero dispatches in those four traces.
  • The normal window reached the prison interaction prompt. Parts of the room were still dark and surfaces were missing. The captures establish that this path still has lighting gaps. A matched-camera comparison with the irradiance passes disabled would isolate their visual contribution.
  • At frame 2000, CS_TraceShadowRays_Checkerboard (559d9f0184e15fe3) dispatched once and CS_ShadowRenderTiledCascadesAlphaCBPPPC (f133e35efed2a48a) was dropped once. At an effective host wave width of 32, the latter still failed offline at 0x1eb4, including with the wide-wave retry enabled offline. The five descriptor-read trace variants listed above also failed offline. None of those five appeared in the live first-bind log for this checkpoint run.

Counts and shader identifiers only. Test and report assisted by Codex.

**@⁠SkillIssueXO** on GitHub · 2026-11-24 20:58 UTC · [original](https://github.com/fxceless/victory-fork/pull/11#issuecomment-7144303719) Independent Series X checkpoint test on an RTX 5070 Ti, native D3D12, `4e17478` built from source with diagnostics. Default watchdog and shader settings. - All three shaders in this PR created host pipelines and first bound at frame 1588. The frame traces at 1700, 1800, 1900 and 2000 each recorded two indirect dispatches for `CS_IrradianceCache_Shade` (`a53a7977fe762268`) and two for the billboard resolve (`7f05ddab771799a9`). `ShadeSecondary` (`be14e72d86362031`) bound, with zero dispatches in those four traces. - The normal window reached the prison interaction prompt. Parts of the room were still dark and surfaces were missing. The captures establish that this path still has lighting gaps. A matched-camera comparison with the irradiance passes disabled would isolate their visual contribution. - At frame 2000, `CS_TraceShadowRays_Checkerboard` (`559d9f0184e15fe3`) dispatched once and `CS_ShadowRenderTiledCascadesAlphaCBPPPC` (`f133e35efed2a48a`) was dropped once. At an effective host wave width of 32, the latter still failed offline at `0x1eb4`, including with the wide-wave retry enabled offline. The five descriptor-read trace variants listed above also failed offline. None of those five appeared in the live first-bind log for this checkpoint run. Counts and shader identifiers only. Test and report assisted by Codex.
Author
Owner

@⁠Mesrine67 on GitHub · 2026-11-24 21:00 UTC · original

Wave-width cross-check on 4e17478, using an AMD Radeon RX 6750 XT (driver 32.0.21045.29003) and the two shader hashes from the recent checkpoint report:

  • Default translator settings: both containers translated, validated, and created D3D12 pipelines (2/2).
  • With VICTORY_HOST_MAX_WAVE=32: 559d9f0184e15fe3 still passes; f133e35efed2a48a (CS_ShadowRenderTiledCascadesAlphaCBPPPC) is refused at 0x1eb4 with a lane mask exchanged where not every lane runs. Totals are 1 emitted, validated, and created pipeline out of 2.

This reproduces the reported 32-lane limitation on a second GPU vendor. These are offline translate/pipeline tests only; no title executable was run.

**@⁠Mesrine67** on GitHub · 2026-11-24 21:00 UTC · [original](https://github.com/fxceless/victory-fork/pull/11#issuecomment-7144357978) Wave-width cross-check on `4e17478`, using an AMD Radeon RX 6750 XT (driver 32.0.21045.29003) and the two shader hashes from the recent checkpoint report: - Default translator settings: both containers translated, validated, and created D3D12 pipelines (2/2). - With `VICTORY_HOST_MAX_WAVE=32`: `559d9f0184e15fe3` still passes; `f133e35efed2a48a` (`CS_ShadowRenderTiledCascadesAlphaCBPPPC`) is refused at `0x1eb4` with `a lane mask exchanged where not every lane runs`. Totals are 1 emitted, validated, and created pipeline out of 2. This reproduces the reported 32-lane limitation on a second GPU vendor. These are offline translate/pipeline tests only; no title executable was run.
Author
Owner

@⁠SkillIssueXO on GitHub · 2026-11-24 21:26 UTC · original

Follow-up with a direct GPU readback of CS_IrradianceCache_Shade (a53a7977fe762268). Same RTX 5070 Ti and Series X checkpoint, on 4e17478 with a local diagnostics-only probe. For the first matching indirect call at each frame, I copied the clamped dispatch arguments and the bound 1280 × 2560 R11G11B10_FLOAT atlas before and after the call in the same command list. CPU reads ran after the submission fence. There were no pipeline skips or external count buffers.

Frame Workgroups Nonzero texels before → after Changed packed texels
1550 0 × 1 × 1 1,200 → 1,200 0
1750 4 × 1 × 1 7,600 → 7,600 202
1900 2 × 1 × 1 7,600 → 7,600 84
2100 0 × 1 × 1 7,600 → 7,600 0

The nonzero-work calls changed atlas contents. I sampled one call per frame, and this check does not measure the contribution to presented lighting. Aggregate counts only. Codex assisted with instrumentation and verification.

**@⁠SkillIssueXO** on GitHub · 2026-11-24 21:26 UTC · [original](https://github.com/fxceless/victory-fork/pull/11#issuecomment-7144943684) Follow-up with a direct GPU readback of `CS_IrradianceCache_Shade` (`a53a7977fe762268`). Same RTX 5070 Ti and Series X checkpoint, on `4e17478` with a local diagnostics-only probe. For the first matching indirect call at each frame, I copied the clamped dispatch arguments and the bound 1280 × 2560 `R11G11B10_FLOAT` atlas before and after the call in the same command list. CPU reads ran after the submission fence. There were no pipeline skips or external count buffers. | Frame | Workgroups | Nonzero texels before → after | Changed packed texels | | --- | --- | --- | --- | | 1550 | 0 × 1 × 1 | 1,200 → 1,200 | 0 | | 1750 | 4 × 1 × 1 | 7,600 → 7,600 | 202 | | 1900 | 2 × 1 × 1 | 7,600 → 7,600 | 84 | | 2100 | 0 × 1 × 1 | 7,600 → 7,600 | 0 | The nonzero-work calls changed atlas contents. I sampled one call per frame, and this check does not measure the contribution to presented lighting. Aggregate counts only. Codex assisted with instrumentation and verification.
This discussion has been locked. Commenting is limited to contributors.
No description provided.