Skip to content

Shaders: the tiled cascade shadow programs translate exactly on 32-lane hosts - #1002

Open
brunofgmag wants to merge 1 commit into
fxceless:mainfrom
brunofgmag:fx-shadow-exact
Open

brunofgmag wants to merge 1 commit into
fxceless:mainfrom
brunofgmag:fx-shadow-exact

Conversation

@brunofgmag

Copy link
Copy Markdown

On a host with 32-lane waves (an RTX 4080 here), CS_ShadowRenderTiledCascadesAlphaCBPPPC (f133e35efed2a48a) was refused every frame with "a lane mask exchanged where not every lane runs" at 0x1eb4, so alpha-tested geometry cast no cascade shadows. Three programs of the same family (CS_ShadowRenderTiledCascadesCBPPPC 20b78ee12ecdb57d, CS_ShadowRenderTiledCascadesPPPC ce79e9eba7ae0348 and CS_ShadowRenderTiledMiscAlphaPPPC fa0bd10a35bfef3c) only translated through the approximate local-waves form. In game that drew the sun's light along characters' silhouettes in steps of about 16 pixels.

The ballot they need sits under per-lane regions that the retry forms could not remove. There were three reasons, and this PR fixes each one in ir.rs:

  • without_early_outs and without_skips now also take an s_cbranch_execnz over a far-jump trampoline (s_getpc_b64, s_add_u32, s_addc_u32, s_setpc_b64) to an end block. These programs are too long for a short branch to reach s_endpgm. A trampoline that does any work is still kept.
  • In the deep form of without_skips, a scalar phi whose arguments all resolve to one value counts as a copy of that value. The arguments are followed through copies and through other such phis. A phi that merges a real change is still a change.
  • unspill also pairs two lanes per save and restore site, not only per lane. The pairing is checked with reaching definitions, so a 64-bit exec saved into two VGPR lanes comes back as one mask even when one of those lanes holds another scalar elsewhere.

With the three fixes the ballot reaches the existing exact exchange_halves.

Measured with translate --list and VICTORY_HOST_WAVE=32 over 3,093 programs from one session:

  • 3,092 translated before this change and 3,093 after. No program that translated before is refused now.
  • 3,088 programs produce byte-identical DXIL.
  • The four above changed: f133 is new, and the other three moved from the approximate form to the exact one, with 47 to 153 group barriers each.

In game the steps along silhouettes are gone and frame time did not get worse (168 to 195 ms a frame in three runs, against about 200 to 240 before). No run lost the device.

The new tests in wave64_tests.rs are hand-written GFX10 words. One of them runs on the device and checks a gate where exactly one failing lane is in the upper half, which a per-half answer gets wrong. The victory-shader tests pass except stub_pipeline_is_created, which fails without dxil.dll on this machine as it does on main. Clippy for the workspace still stops at the four warnings that #982 fixes.

Copy link
Copy Markdown

Reproduced the f133e35efed2a48a failure on an RTX 3080 under Windows with the Series S profile. On a d44e4ae-based build, victory warm failed to translate it at GFX10 0x1eb4 with a lane mask exchanged where not every lane runs. An earlier gameplay trace also logged this exact shader as requested and unavailable at the first world frame. This is the pre-patch result. The PR still needs a run on this RTX 3080 to check the visual effect.

@tippythetaidum

Copy link
Copy Markdown

Tested in the title on an RTX 5080 16 GB (32-lane waves), driver 621.14, Windows 11, Series X profile: the stepped sunlight along the character's edge is gone.

Build: diagnostics build of main 3973179 + #24 + #927 + #823 + #606 + #956 + this PR + #907. Default settings apart from #956's two switches and a local diagnostic of mine, which touch texture uploads, not shadows.

Translation: f133e35efed2a48a now translates and is bound from the first world frame. On the same base without this PR it was shader does not translate ... a lane mask exchanged where not every lane runs, every run. 20b78ee12ecdb57d, ce79e9eba7ae0348 and fa0bd10a35bfef3c translate and are bound too. No shader failed to translate in the run.

Picture: the opening cell shot, the character from behind against the sunlit window, compared across three runs.

Stability: no errors and no device loss in the 10-minute run.

One run with the PR, one card.

AI-assisted (Claude Code, Claude Opus 5.5). Counts and descriptions only, nothing from the game attached.

oz-stanislav-zhukov added a commit to oz-stanislav-zhukov/victory-fork that referenced this pull request Nov 25, 2026
…mits on fork-fast)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Danigamer05

Copy link
Copy Markdown

Confirmed on Turing: RTX 2080 SUPER 8 GB (32-lane waves, driver 621.01), Ryzen 7 3700X, Windows 11, Series S profile.

Tree: vitutu1/victory-perf ffed22d + #683, #610, #823 and this PR (cherry-picked cleanly), diagnostics build.

  • Offline (victory translate --list, VICTORY_HOST_MAX_WAVE=32, the whole package): before, f133e35efed2a48a failed with "a lane mask exchanged where not every lane runs" at 0x1eb4. After: it translates, and 3 more compute programs and 1 pixel program that failed before translate too (2,723 → 2,726 of 2,734 compute, 14,211 → 14,212 of 14,259 vertex/pixel; I compared the counts and failure classes, not each program).
  • In game: before, the log dropped f133e35efed2a48a every frame. After, it is no longer in the dropped list (only 02384a60fda6f2d0 and 2da4beb386509b77 remain). Lucia's hair and shirt are lit in every captured frame from the prison-window shot onwards; in the run just before without this PR (same switches) she turned into a dark silhouette once the cell part started. Single runs each, and this kind of darkness varies from run to run, so take it as one data point. Frame time unchanged (3.6-3.9 fps both ways).
  • A related test: skipping all 18 CS_ShadowRenderTiled* programs instead (VICTORY_SKIP_PIPELINES) made people in the yard pure black silhouettes. So an unwritten shadow-map region reads as full shadow here, which fits the dark characters seen while only f133e35efed2a48a was dropped.

Numbers and text only. AI-assisted (Claude Code).

@HAL9000RELOADED

Copy link
Copy Markdown

RX 7900 XTX (RDNA3), Windows 10 + #402, main d510ee4: all 6 new tests pass. The hardware part of a_far_early_out_is_left_out_and_the_gate_counts_the_lanes_of_both_halves ran on the card ("ran on the hardware device…") and matched. With the tests alone on main, 3 of 6 fail: the two far early-out/skip ones and the parked pair one. Run table: #129 (#129 (comment)).

@Zayfway

Zayfway commented Nov 25, 2026

Copy link
Copy Markdown

Tested on a 32-lane card: on its own on main, and merged with #994 (which carries #993 and #854). AI-assisted (Claude Code); every number below is from runs on this machine.

Machine: RTX 3060 12 GB (driver 610.88), Ryzen 7 5700X, 16 GB RAM with a 32 GB pagefile, Windows 11 26300, Series X profile, diag build. Every run loads the same save at the prison window and is measured from world +120 s to +360 s. Switches: ASYNC_SUBMIT QUEUE2 TEXTURE_NO_WAIT COPY_PLAIN LEVELS_ON_DEMAND INDIRECT_GATHER.

tree frame (median) the sun's light along Lucia's silhouette
main 465b94f 264–274 ms (3.6–3.7 fps) steps of about 16 px along the shoulder, and blocky patches at the bottom of the screen
main + this PR 272 ms (3.6 fps) f133e35efed2a48a now translates and binds (on main it was dropped every frame), but the steps are still there: on the wall behind her, and on a door
main + this PR + #994 338 ms (2.9 fps; GPU 150–167 → 210 ms) no steps on the silhouette: the shoulder edge is smooth, with a soft rim of light. The window's dirty-glass and haze effect, missing on main, is drawn

So on this card, this PR is needed but not sufficient. The steps go away only together with #854/#993's exact 64-lane forms. In that tree the four programs the driver used to refuse with E_INVALIDARG (2cc4c197ee29e291, 369cbe906ea72764, 02384a60fda6f2d0, 2da4beb386509b77) build, and the offline census with VICTORY_HOST_WAVE=32 emits 26,135 of 26,136 programs. The one left is CS_TraceShadowRays_FullAdaptive, which these scenes do not use. Lanes on opaque masks go from 28,029 (main + this PR) to 5,459.

Merge. The merged tree is at Zayfway/victory-fork@integ/rtx3060 (7538ceb), with main + this PR + #994 + #1027. It had three conflicts:

One test of #993 needed a new expectation. a_mask_parked_in_lanes_another_scalar_shares_comes_back_whole_with_shared_slots expected the parked pair to come back as two scalars without the shared slots. With this PR's site_pairs it comes back as one mask in both cases. cargo test -p victory-shader --lib: 275 passed, 2 ignored.

Not tested:

nullexxx pushed a commit to nullexxx/victory-fork that referenced this pull request Nov 25, 2026
…less#1033)

ir::build fills every instruction's register lists twice. `effects()`
collects `Vec<Reg>` (two allocations), and the caller immediately maps
each one into `Vec<(Reg, Value)>` (two more), freeing the first pair. For
lists that are almost always two to four entries, that is four
allocations and two copies per instruction, on every instruction of every
program.

Have `effects()` and its helpers collect the `(Reg, Value)` pairs
directly, with the placeholder the SSA pass fills in. Two allocations per
instruction instead of four; `Inst` and everything downstream are
unchanged.

Measured with the synthetic bench in fxceless#1002 (no game data), ten
interleaved rounds per arm, nanoseconds per instruction, at 256/1k/4k/16k
instructions:

  ir::build   308 -> 269, 375 -> 324, 407 -> 340, 402 -> 353  (0.835-0.878)
  translation 898 -> 872, 898 -> 825, 951 -> 875, 956 -> 912  (0.919-0.971)

gfx10::decode, structure, lower and the rest are unchanged. The emitted
DXIL is byte-identical at all four sizes.

cargo test --workspace --locked: 342 passed, 0 failed, 7 ignored.
Both clippy configurations clean; cargo xtask policy ok.

Co-authored-by: pes7 <pes7@users.noreply.github.com>
PiloteCode pushed a commit to PiloteCode/victory-fork that referenced this pull request Nov 25, 2026
`Instruction::name()` binary-searches the opcode table, and the pipeline
asks about every instruction eight times per translation: `ir::build`,
`structure`, `resource` (which has the most call sites), `io` and
`lower`. The answer cannot change - the encoding and opcode are decoded
from the words and never rewritten - so resolve it once when the
instruction is built and read the field after that.

Measured with the synthetic bench from fxceless#1002 (no game data), sixteen
interleaved rounds per arm, best of each, nanoseconds per instruction, at
256/1k/4k/16k instructions:

  resource     17 -> 9, 15 -> 7, 24 -> 16, 23 -> 15    (0.47-0.67)
  lower       511 -> 479, 428 -> 411, 440 -> 401, 477 -> 428  (0.90-0.96)
  io           27 -> 23, 26 -> 21, 26 -> 22, 30 -> 22   (0.73-0.85)
  whole       926 -> 881, 920 -> 874, 958 -> 921, 1019 -> 939 (0.92-0.96)

`decode` pays the one search it used to be spared (112 -> 115 at 16k,
inside the run-to-run spread); every stage after it reads a field. The
emitted DXIL is byte-identical at all four sizes.

cargo test --workspace --locked: 342 passed, 0 failed, 7 ignored.
Both clippy configurations clean; cargo xtask policy ok.
tuffn3ss pushed a commit to tuffn3ss/victory-plus that referenced this pull request Nov 26, 2026
`Instruction::name()` binary-searches the opcode table, and the pipeline
asks about every instruction eight times per translation: `ir::build`,
`structure`, `resource` (which has the most call sites), `io` and
`lower`. The answer cannot change - the encoding and opcode are decoded
from the words and never rewritten - so resolve it once when the
instruction is built and read the field after that.

Measured with the synthetic bench from fxceless#1002 (no game data), sixteen
interleaved rounds per arm, best of each, nanoseconds per instruction, at
256/1k/4k/16k instructions:

  resource     17 -> 9, 15 -> 7, 24 -> 16, 23 -> 15    (0.47-0.67)
  lower       511 -> 479, 428 -> 411, 440 -> 401, 477 -> 428  (0.90-0.96)
  io           27 -> 23, 26 -> 21, 26 -> 22, 30 -> 22   (0.73-0.85)
  whole       926 -> 881, 920 -> 874, 958 -> 921, 1019 -> 939 (0.92-0.96)

`decode` pays the one search it used to be spared (112 -> 115 at 16k,
inside the run-to-run spread); every stage after it reads a field. The
emitted DXIL is byte-identical at all four sizes.

cargo test --workspace --locked: 342 passed, 0 failed, 7 ignored.
Both clippy configurations clean; cargo xtask policy ok.

(cherry picked from commit 146dfef)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants