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

Merged
cxchhh merged 1 commit from upstream-pr/11 into main 2026-11-24 20:35:04 +00:00
cxchhh commented 2026-11-24 19:48:11 +00:00 (Migrated from github.com)

Imported from fxceless/victory-fork. Originally posted by cxchhh on 2026-11-24T19:48:11Z.


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

<!-- greyfinch-sync:fxceless/victory-fork:issue:6590059288 --> Imported from [fxceless/victory-fork](https://github.com/fxceless/victory-fork/pull/11). Originally posted by [cxchhh](https://github.com/cxchhh) on 2026-11-24T19:48:11Z. --- 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)
upstream-sync closed this pull request 2026-11-24 21:30:15 +00:00
fxceless commented 2026-11-24 21:30:39 +00:00 (Migrated from github.com)

Imported from fxceless/victory-fork. Originally posted by fxceless on 2026-11-24T20:35:06Z.


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.

<!-- greyfinch-sync:fxceless/victory-fork:comment:7143771500 --> Imported from [fxceless/victory-fork](https://github.com/fxceless/victory-fork/pull/11#issuecomment-7143771500). Originally posted by [fxceless](https://github.com/fxceless) on 2026-11-24T20:35:06Z. --- 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.
Mesrine67 commented 2026-11-24 21:30:41 +00:00 (Migrated from github.com)

Imported from fxceless/victory-fork. Originally posted by Mesrine67 on 2026-11-24T20:58:23Z.


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.

<!-- greyfinch-sync:fxceless/victory-fork:comment:7144303781 --> Imported from [fxceless/victory-fork](https://github.com/fxceless/victory-fork/pull/11#issuecomment-7144303781). Originally posted by [Mesrine67](https://github.com/Mesrine67) on 2026-11-24T20:58:23Z. --- 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.
SkillIssueXO commented 2026-11-24 21:30:41 +00:00 (Migrated from github.com)

Imported from fxceless/victory-fork. Originally posted by SkillIssueXO on 2026-11-24T20:58:23Z.


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.

<!-- greyfinch-sync:fxceless/victory-fork:comment:7144303719 --> Imported from [fxceless/victory-fork](https://github.com/fxceless/victory-fork/pull/11#issuecomment-7144303719). Originally posted by [SkillIssueXO](https://github.com/SkillIssueXO) on 2026-11-24T20:58:23Z. --- 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.
Mesrine67 commented 2026-11-24 21:30:41 +00:00 (Migrated from github.com)

Imported from fxceless/victory-fork. Originally posted by Mesrine67 on 2026-11-24T21:00:48Z.


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.

<!-- greyfinch-sync:fxceless/victory-fork:comment:7144357978 --> Imported from [fxceless/victory-fork](https://github.com/fxceless/victory-fork/pull/11#issuecomment-7144357978). Originally posted by [Mesrine67](https://github.com/Mesrine67) on 2026-11-24T21:00:48Z. --- 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.
SkillIssueXO commented 2026-11-24 21:30:45 +00:00 (Migrated from github.com)

Imported from fxceless/victory-fork. Originally posted by SkillIssueXO on 2026-11-24T21:26:57Z.


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.

<!-- greyfinch-sync:fxceless/victory-fork:comment:7144943684 --> Imported from [fxceless/victory-fork](https://github.com/fxceless/victory-fork/pull/11#issuecomment-7144943684). Originally posted by [SkillIssueXO](https://github.com/SkillIssueXO) on 2026-11-24T21:26:57Z. --- 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.
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!11
No description provided.