Skip to content

Shaders: one console wave sharing LDS runs in the console flow on 32-lane hosts - #439

Open
r4tedx wants to merge 84 commits into
Marvisak:mainfrom
r4tedx:shader/console-flow-lds
Open

r4tedx wants to merge 84 commits into
Marvisak:mainfrom
r4tedx:shader/console-flow-lds

Conversation

@r4tedx

@r4tedx r4tedx commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

Needs a BVH builder gate when merged alone. This PR makes some BVH builder programs translate while a sibling stage can stay refused on a 32-lane host. A half-run builder crashed the title at load in neonbyte1's runs (see the comment below and #2118, comment 7179788584). Merge it together with, or after, an all-or-none builder gate such as #2118.

Current head e2d3cfd (2026-11-26), on top of e9f18c9 below, still with main at 63bcca4. New since e9f18c9: the placed-UAV test fix merged up from #223; steven-seagull27's partial-group reductions and f16 whole-wave sums from fork PR #19 (611184e, f968c54, author kept) and 2658128; e2d3cfd keeps LDS, whole-wave sections and *permute* in halves out of programs that reach title memory (root_memory, from latentdev's patch). An earlier commit on top, 7587052, was removed from the branch by a force-push: its test encodings were taken from one of the title's programs, which the asset policy does not allow. At 2658128, WARP only: cargo xtask policy ok, clippy clean, VICTORY_WARP=1 cargo test --locked -p victory-shader --lib -- --test-threads=1 343 passed, 4 failed, 3 ignored (the same 4 main failures as below). Nobody has run these split tests on 32-lane hardware at this head. No title run for this update.

At e9f18c9, merged with main at 63bcca4 (merges only, no rebase: main into #223, then each PR's new head into the one above it). With main's growth, crates/victory-shader/src/emit/lower.rs would pass the asset policy's 512 KiB limit, so #233 first moves lower.rs's inline tests into emit/lower/tests.rs, unchanged but for one indent level, (desplmfao's idea, beside main's emit/lower/bvh.rs). Here lower.rs is 506,583 bytes. The conflict resolutions follow kawaii-shakal's notes, and each merge commit lists them. Local verification at this head and at the head of each PR under it, on Windows 11 with the software renderer only (WARP, no hardware adapter for this update): cargo xtask policy ok; cargo clippy --locked -p victory-shader --all-targets -- -D warnings clean; VICTORY_WARP=1 cargo test --locked -p victory-shader --lib -- --test-threads=1: 341 passed, 4 failed, 3 ignored. The 4 failures are main's own: on main 63bcca4 the same command gives 298 passed and the same 4 failed. They are synthetic_tests whose "hardware" pass VICTORY_WARP=1 puts on WARP. No title run for this update. AI-assisted (Claude).

Stacked on #320, which is on #233, which is on #223. They are one line of work and merge in that order; each PR's diff contains the ones under it. The commits that are new here start at 7388024 (table below). Head: e2d3cfd.

History, 2026-11-24: The whole stack was rebased onto main 8e79c80 on 2026-11-24 (upstream merged about 55 PRs that day and added CI). New upstream tests call emit and build lower::Parts directly, so the wave-range argument and the two fields this stack adds are given to them in the commits that introduce them (in #223, #233 and #320). CI's first run on these PRs failed in tests, not in clippy: GitHub's runner has no GPU and lists Windows' software renderer (4-lane waves) as an adapter, and tests here assumed every listed adapter runs 32-lane waves. The tests are fixed where they were introduced: the hardware-adapter list leaves that renderer out by its ids and name, and the one test that takes the default device accepts a host without 32-lane waves. No translator code changed. The test-only commit e6936e3 (the lane-read loop test skips hosts without SM 6.6) is folded into #320, where that test is added, so 16 commits are new here. Each commit builds on its own. The head before the rebases was 055aef9. Commit ids in testers' reports below and in older comments are from before the rebases; the table gives each commit's old id.

No new features will be added to this PR. It has grown as testers and contributors reported things; from here it only gets fixes for what review finds. The next step of the work (groups of more than 64 threads) is on a fork branch and is not part of this.

What

#233 runs console wave64 compute programs on hosts without 64-lane waves (NVIDIA) as two 32-lane waves, in the "console flow" where a program needs its whole wave. It still stopped programs that share LDS inside one wave, and a few other forms. This PR takes those:

  • One console wave sharing LDS without s_barrier. The console runs an instruction in all 64 lanes before the next, so a lane reads what another lane wrote one instruction earlier. In the console flow both halves reach every LDS access together, so a group barrier before each access puts it after every earlier one.
  • Whole-wave sections (reductions and prefix sums) in groups of exactly 64 threads: each half's result is exchanged and combined, integers and floats.
  • ds_bpermute_b32, which did not translate on any host: a read within the lane's own 32-lane half.
  • Selects on masks held as numbers, on every host.
  • Loop-carried mask joins in the console structure.
  • Refusals that say why (... in a group of more than 64 threads, ds_permute across the halves, a whole-wave section), and a translate --validate line that prints a failing module's thread-group size, wave size and dx.op names.

Nothing changes for programs that translated before, with two exceptions measured below: on hosts that run 64-lane waves about 18 title programs with a lane read in a divergent branch change from the per-lane form to the console flow, and programs both forms refuse may report a different reason.

Commits new in this PR

commit by what test id before the rebase
7388024 me single-wave LDS in the console flow; specific refusal reasons one_wave_shares_lds_in_instruction_order, lds_order_holds_when_one_half_is_busy 88cb024
c7806a8 me translate --validate prints what a refused module declares and calls the_last_modules_summary_... 9745f35
a31c82e @Raxstreams integer whole-wave reductions and prefix sums across the halves (reviewed here) its prefix test 9b73d66
b0f64c9, 6090b47 me tests for the above (sum, max, min, or, masked sum); plan document whole_wave_reductions_join_both_host_waves, masked_whole_wave_sum_straddles_the_halves 3925b8f, e49302a
fa72507 me test only: LDS written and read in different exec-masked blocks, the pattern measured on #189 lds_written_and_read_in_different_masked_blocks a32c177
ddaae36 me the startup warning's text (a review nit from #233) none 8876ed3
ab7882d @Raxstreams ds_bpermute_b32 as an in-half read (r4tedx/VIctory#2) its two tests 416714c
826577e me more tests for it (masks over both halves, groups of 128 / 48 / 32, beside a lane read) backward_permute_in_other_masks_groups_and_forms f653ea4
00888ac me float sum, min, max and prefix sums across the halves float_whole_wave_reductions_join_both_host_waves, masked_and_prefix_float_sums_cross_the_halves 965ce30
783feee me plan document only none 2467891
e461457 me compute v_cndmask_b32 takes masks held as numbers; fixes the high dword of such a wave64 mask when two instructions write it selects_on_masks_held_as_numbers d2189ff
1c06edd @ifBars loop-carried inputs of console mask joins (r4tedx/VIctory#6) lane_read_loop_with_a_joined_exec_back_edge 9e98b2b
04971f8 me that test dispatched on every hardware adapter same 901eef9
f12df1e me a lane read in a divergent branch beside a whole-wave section takes the console flow on 64-lane hosts too; a mask copied dword by dword no longer recurses until the stack runs out (reachable since #233; found with @aycow's fixture) lane_reads_in_branches_beside_a_whole_wave_section, a_mask_copied_dword_by_dword_stops_instead_of_recursing e4d899f
1ca87f7 MichaelSmithAI (r4tedx#5) a numeric select nothing consumes no longer makes a program declare the console wave size (a side effect of d2189ff) selects_from_independently_written_mask_words 055aef9

Measured

On the title, by testers on their own copies

RTX 3070 Ti Laptop, driver 610.88, four-build comparison: across three runs containing #439, DRED named compute 42683eebec081520, dispatched as (128, 64, 1), at device removal on its first world dispatch. On main the driver refused this pipeline and the run later hung in ExecuteIndirect. With #578 alone the run lasted 420 s and dropped 85–98% of world draws. The separate RTX 3070 skip run below used a different stack and driver.

On an RTX 3070 with the #439 1ca87f7 integration stack and loop limit 32, skipping direct and indirect dispatches of 42683eebec081520 still ended in device removal at menu frame 1880. DRED named an indirect mesh operation with a null u9 and empty breadcrumbs. The faulting operation is undetermined. RTX 3070 skip run

Nobody has run the title on a head after f653ea4. The world hang (#71) is unchanged by this stack at the default loop limit.

Locally: an offline translate over a local copy of the title's shaders

victory translate --host-lanes 32-32 --validate --list (and 32-64): CPU only, no pipelines, nothing launched or rendered. Counts and reasons only; nothing from the title is in this PR. At 055aef9 (before the rebases), and again after the first rebase on main 2e4e280 with the same results; not rerun on 8e79c80, which merged more shader PRs:

  • For a 32..32 host: 1,691 of 2,581 compute programs emitted, 1,637 validated. Vertex, pixel and mesh counts are those of main. A tester's count at f653ea4 (1,668) matches mine at that head. For a 32..64 host: 1,735 emitted, 1,681 validated, which a tester measured independently on an RX 9070 with pipelines created (1,735 / 1,681 / 1,735).
  • All 54 compute modules that fail validation give the stage-incompatibility message and call sample (see the note below).
  • Step by step, program by program, with 0 programs lost at every step: float reductions +8, loop-carried joins +9, the e4d899f rule +6 (32..32) and +12 (32..64), numeric selects +3 (32..64 only). On the tester tree, which has the descriptor PRs, the numeric-select commit is worth 24.
  • Still stopped for wave size on a 32..32 host: 43 programs in groups of more than 64 threads, 4 whole-wave sections in other group sizes, 2 section steps the simulation does not follow.
  • On a 32..64 host about 18 programs that translated per lane before e4d899f now take the console flow (they have a lane read in a divergent branch beside a whole-wave section).

Validation note

Compute programs that sample with implicit derivatives (image_sample) are emitted as dx.op.sample, which validator 1.6 / 1.7 rules do not allow outside pixel shaders. main emits 23 such modules; this stack lets more such programs translate, so more of them appear (54 here). The cause is not in this stack: diagnosis with a hand-assembled reproduction. #180 replaces these samples and #201 tracks the class; a census rerun measured #180 taking the class to 0 on main. Merging #180 first, or together, keeps those modules from reaching a driver unvalidated.

How this relates to other open PRs

docs/wave64-on-wave32.md shows as deleted in this diff, with this PR's plan text in it: #233 folded the plan into docs/architecture.md, and the merge carries that up. The design notes are in this description.

Not verified

  • No console hardware. Expected values in the tests follow the ISA's semantics. Why ds_bpermute_b32 stays in each half: AMD, "RDNA 2" Instruction Set Architecture Reference Guide (30 Nov 2020), §10.4.4 "LDS Lane-permute Ops", pp. 96–97: "in wave64 mode the permute operates only across 32 lanes at a time of each half of a wave64 … it executes as if were two independent wave32's. Each half-wave can use indices in the range 0-31 to reference lanes in that same half-wave", "only index bits [6:2] are used", "Reading from disabled lanes returns zero". The lowering follows this (lane ((addr + offset) >> 2) & 31 in the reader's half, 0 where it is inactive). The opcode table's pseudocode (§12.13, p. 206) writes mod 64, which disagrees with §10.4.4; we follow §10.4.4. ds_permute_b32 is not translated yet and still keeps a program out of the split.
  • Nothing after f653ea4 has been run in the title, by anyone. The local run only translates and validates.
  • What the barriers and guards cost on real dispatches, beyond the one frame-time figure above.
  • A float sum across the halves adds each half's sum last: one more order of additions, so its last bits may differ, as they already may within one host wave.
  • Of the LDS tests, one needs the barrier before each LDS access on an RTX 5070 (masked write and masked read with no branch between: the lower half reads 0 in 20 of 20 runs without it). The others pass either way on that card, so they check the result and not the need.
  • Masks copied dword by dword (EXEC restored with two s_mov_b32) stop with a reason; following them is not done.

Tested

Historical, at an earlier head: Independent Windows 10 22H2 run on an RTX 4060 Ti at c153b21 with #175 and #362: 155 shader tests passed, 0 failed, 1 benchmark ignored. The split-wave and joined-back-edge tests executed on hardware and returned exact results. WARP, DXIL validation, and compiler-dependent comparisons had skips. Hardware run and skip breakdown

Windows 11, an NVIDIA RTX 5070 (32..32) and an AMD Radeon iGPU (RDNA2, 32..64) in one machine. Every test in the table is hand-assembled GFX10, validated by dxil.dll, dispatched on each hardware adapter and compared lane by lane with the console's result, except the two that only check what the translator emits (the_last_modules_summary_..., selects_from_independently_written_mask_words).

  • Historical, before the merge of main 63bcca4: At 1ca87f7, on main 8e79c80, with the commands upstream's CI runs: cargo clippy --workspace --all-targets --locked -- -D warnings and the same with --all-features are clean at the head of each of the four PRs; cargo test --workspace --locked: 346 passed, 0 failed, 6 ignored (RTX 5070 + Radeon iGPU). Under the CI runner's conditions emulated here (the software renderer as the default device and no hardware adapter listed) the shader crate's tests pass at each head, the GPU ones by skipping. Before the rebases, cargo test --workspace at 055aef9: 299 passed, 0 failed, 4 ignored.
  • cargo xtask policy: ok at that head and, after the tests move, at e9f18c9.
  • Others ran the split tests on an RTX 4070 SUPER, 5080, 5090, a GTX 1660 Ti (Windows 10 with the Agility SDK) and the shader crate's tests on macOS.

AI-assisted. The tests are synthetic and do not use the title. The counts under "Locally" come from the offline translate run described there.

🤖 Generated with Claude Code

@Raxstreams

Copy link
Copy Markdown

On an RTX 3080 Ti (32 lanes), I replayed 77 captured compute shaders that the #414 translator had rejected for wave64 lanes or shared LDS. With this change applied, 20 of 77 passed both DXIL validation and actual D3D12 compute pipeline creation. The other 57 still failed. This is offline pipeline coverage. I have not verified the dispatch outputs for these shaders.

@r4tedx
r4tedx marked this pull request as draft November 24, 2026 03:34
@DaviTostes

Copy link
Copy Markdown

Verified 88cb024 on Arch Linux x86_64 (rustc 1.98.1, cargo test -p victory-shader): 58 passed, 0 failed, 0 ignored.

Not covered: the new console-wave LDS paths executed on a Windows/Wine GPU (parser/emit tests only here) and title behaviour (no game data).

@r4tedx

r4tedx commented Nov 24, 2026

Copy link
Copy Markdown
Contributor Author

Thank you. 20 of 77 passing both checks is a useful floor, and the 57 are the more interesting part.

Could you post how the 57 split, as counts only?

No game data used on my side. AI-assisted.

@DaviTostes

Copy link
Copy Markdown

Re-checked the new head 9745f35 (“translate: say what a module the validator refuses declares and calls”) on Arch Linux x86_64 (rustc 1.98.1): cargo test -p victory-shader 58 passed, 0 failed, 0 ignored — same result as 88cb024, no regression from the force-push.

@SpaghettiMaster545

Copy link
Copy Markdown

Tested with the title at 9745f35 (this PR with the #223 / #233 / #320 stack under it), merged onto main d2a4bae. The same setup as my runs on #320: RTX 5070 Ti, driver 621.24 (32-lane waves), Ryzen 7 9800X3D, Windows 11 10.0.26100, Rust 1.98.1, diag build, its own empty VICTORY_CACHE_DIR, VICTORY_KEYS into story mode, until the host GPU failure (#71).

Program by program:

against gained lost notes
main d2a4bae 71 0 of main's 119 driver-refused compute programs, 70 run now (26 with #320 alone), 45 stop in translation, 4 not reached
#320 a5ba4a4 45 0 a wave64 group sharing LDS without barriers on a host without 64-lane waves: 38 → 0

Not tested: a 64-lane adapter, a release build, image results, cargo test on this head.

(Claude Code, Claude Opus 5.5: ran the title and compared the logs program by program.)

@r4tedx

r4tedx commented Nov 24, 2026

Copy link
Copy Markdown
Contributor Author

Thank you, that is exactly the split I was after: 70 of main's 119 driver-refused programs running, nothing lost, and the rest now named (whole-wave sections 24, groups of more than 64 threads 20).

That orders what comes after this PR: whole-wave sections in the console flow first, then groups of several console waves. I am not stacking either on top yet. #320 and this PR are drafts because a whole-title validate run found 20 modules the console flow emits that dxil.dll refuses, and a title run cannot show those. If you ever run victory translate --validate over the same files on this head, the validator lines (they now carry thread-group size, wave size and the dx.op operations of our module, nothing of the console program) are what would unblock both.

I have added your numbers to the description.

No game data used on my side. AI-assisted.

@Raxstreams

Copy link
Copy Markdown

Following the offline check above, I tested integer whole-wave scans across the two hardware waves. The synthetic 64-lane prefix sum reads back exactly on an RTX 3080 Ti, including 528 for lane 32. The follow-up against this PR's head is r4tedx#1.

In a local integration build the material-tile initialization shader passed offline D3D12 compute pipeline creation and dispatched during the opening scene. The final scene color was still dark in the captured frame.

@upipibi upipibi mentioned this pull request Nov 24, 2026
@r4tedx
r4tedx marked this pull request as ready for review November 24, 2026 04:16
r4tedx added a commit to r4tedx/VIctory that referenced this pull request Nov 24, 2026
…64 stack

For testers: the wave64 stack (Marvisak#223, Marvisak#233, Marvisak#320, Marvisak#439) with Marvisak#180, whose
sampleGrad form makes compute programs that sample with implicit
derivatives pass dxil.dll validation.

One conflict, in emit/lower.rs, where a compute program is found to
need the console's lanes: Marvisak#180's quad gradients read within four lanes,
so they go with DPP and ds_swizzle among the reads that stay inside a
32-lane half, and such a program runs on a 32-lane host in two halves.

Checked on an RTX 5070 and a Radeon iGPU: cargo test --workspace passes,
and a hand-assembled compute image_sample validates and samples the
right value in groups of 64x1x1, 8x8x1, 32x1x1, 128x1x1 and 4x4x2.
r4tedx added a commit to r4tedx/VIctory that referenced this pull request Nov 24, 2026
…73d66, and Marvisak#180)

The wave64 stack (Marvisak#223, Marvisak#233, Marvisak#320, Marvisak#439, with Peter Bonanni's
whole-wave sections across the halves, 9b73d66) merged with Marvisak#180 (twin
descriptor loads and quad gradients for compute samples), at 24b3bcc.
That commit has one parent (e49302a); Marvisak#180's changes come in without
its commits. Marvisak#233 is in this tree as 1eb9995, the same tree as
3098672, so each file was merged with 3098672 as the base instead of
the e0865d2 git chooses.

Conflict resolutions:
- emit/wave.rs, v_permlane16/x16 in whole-wave sections: Marvisak#98's "every
  lane active" and 9b73d66's "or fi set" are both kept, for both
  instructions.
- emit/lower.rs, Lower::new: Marvisak#320's test for lane reads and writes in
  divergent programs counts live instructions only, as Marvisak#233's does
  with Marvisak#309 (dead SGPR-spill lane instructions are no lane reads).
  Marvisak#307's waterfall arm of v_readfirstlane still comes before the
  console-flow arm; Marvisak#320 adds no arm of its own.
- Compute samples with implicit derivatives (Marvisak#160, Marvisak#180, Marvisak#306): Marvisak#180
  decides plain and biased samples, all of Marvisak#160's forms of them
  (implicit_derivatives from sample_form: _o, _cl, cube, a16), with
  Marvisak#160's bias address (bias_at) and level clamp; Marvisak#306's validator 1.8
  is now declared only for what still uses the host's derivatives in
  compute (comparison samples, op 64). The Marvisak#306 test of image_sample
  now asserts no 1.8 (48-byte PSV0) and still validates and creates
  the pipeline; a twin test with image_sample_c asserts 1.8.
- sgpr_spill test (Marvisak#309): without forwarding, the per-lane form still
  stops with "a lane mask holding lanes elsewhere read as data", but
  emit now takes the console flow (Marvisak#320); the test checks both, and
  that forwarded spills do not ask for the console flow.
- Mechanical: per_lane_only in two hand-built Parts in emit/lower.rs
  tests; emit/mod.rs module order (split_tests before threading).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
r4tedx added a commit to r4tedx/VIctory that referenced this pull request Nov 24, 2026
Marvisak#320 and Marvisak#439 (with peter-bonanni's 9b73d66) are in, with Marvisak#180, whose
quad gradients fix the compute samples that failed validation. Records
the in-title measurement by testers and this merge's resolutions.

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

Halfect commented Nov 24, 2026

Copy link
Copy Markdown
Contributor

64-lane AMD result for e49302a: AMD Radeon 610M, driver 32.0.21030.2001, Windows 11 build 22631; D3D12 reports 32..64 lanes. I ran translate --validate --pipelines --list --jobs 8 on this head and main d2a4bae, explicitly selecting the Radeon adapter.

All 22,178 emitted modules on this head successfully created D3D12 pipelines. Across 25,889 shared program labels, the comparison against main found 0 DXIL-validation gains/losses and 0 pipeline-creation gains/losses. The aggregate compute totals were 1,715 emitted / 1,672 validated / 1,715 pipelines here versus 1,693 / 1,670 / 1,693 on main; these are whole-stack totals and are not attributed to Wave64 alone.

Full stage table, label-exclusion rule and reason changes: #293 (comment)

Offline only; no title executable or world run. AI-assisted (Kimi).

@Halfect

Halfect commented Nov 24, 2026

Copy link
Copy Markdown
Contributor

Follow-up correction to my 64-lane comparison: after normalizing the instruction offset present only on failure labels, the matched result is 22 pipeline-creation gains, 2 DXIL-validation gains, and 0 losses across 25,912 shared labels. The 22 gains are a lane-mask join of an untracked mask → ok, accounting for the aggregate compute increase from the underlying stack.

Details: #293 (comment)

The earlier stage totals were correct; the initial 0-gain figure omitted these emit-to-success transitions. No 64-lane regression was found.

@evan-kolberg

Copy link
Copy Markdown

I ran the generated masked-LDS test at exact head e2d3cfd50715954fb89ff462edb37a0c4395ecd0 on an Apple M4 Pro using CrossOver 26.3.0.39832 and D3DMetal 4.0 beta 3. The AMD64 test PE was built from the clean head, and the test process mapped D3DMetal.

emit::split_tests::lds_written_and_read_in_different_masked_blocks passed. All three cases logged split true and matched all 128 readback words each (two 64-thread groups). This covered the all-lanes write followed by lower-half reads, the delayed upper-half writer, and upper-half writes followed by lower-half reads without branches. The test exercises the generated non-root-memory LDS path.

@chippy01

Copy link
Copy Markdown

@r4tedx I ran this stack's split tests on 32-lane hardware at e2d3cfd: an RTX 3070 Ti (driver 621.24, 32-lane waves only) and the Radeon iGPU of a Ryzen 9 7900X, on Windows 11.

Tests

  • cargo test --locked -p victory-shader --lib -- --test-threads=1: 344 passed, 3 failed, 3 ignored. The 3 failures are a_heap_buffer_read_by_element_takes_the_views_stride, a_heap_buffer_read_where_no_buffer_view_is_reads_zeros and gathers_at_a_level_match_the_hardware, and they fail on main on this machine too. I skipped heap_direct_texture_reads_mark_their_heap_index, which crashes the test process here on main as well.
  • split_tests and lane_read_loop_tests (38 tests): all pass. On the 3070 Ti all 81 split cases are exact (split true), and so are the 9 other cases and the 8 nested-EXEC ranges. The Radeon runs the same 81 cases natively (split false), also exact.

Translate (translate --list --validate --host-lanes 32-32 over shaders.rpf, the executable, XboxBvhBuilder.dll and the FidelityFX DLL): 2,661 of 2,763 compute programs emitted, 1,926 of them validated.

One finding: groups whose rows a 32-lane wave may tile. The split forms keep the console's [numthreads]. The relabelling assumes each host wave holds a 32-aligned run of flat ids, but NVIDIA fills the waves of a 32 x 2 group with 16 x 2 tiles (#2126 measured the same). I added a local probe to split_tests that runs your program_3d in other shapes:

group RTX 3070 Ti (split) Radeon (native wave64)
32 x 2 x 1 32 of 64 lanes differ exact
32 x 1 x 2 exact exact
16 x 4 x 1 exact exact

In the title this concerns CS_AmbientMapSky32, CS_AmbientMapSkyLocal32 and CS_AmbientMapSkyClassified32, all 32 x 2 x 1 and all emitted here. CS_ComputeTerrainVisibility (6 x 6 x 1, a width that is not a power of two) is in the class #2126 measured too, but I didn't probe it here. #2633 refuses these groups. #2126 hands each wave its ids by ticket instead, which would fix them here as well.

Next to the halves stack. Locally I have #2633 plus four follow-ups. They keep the per-lane form and trade through group-shared memory only at blocks every thread of the group reaches. That covers lane reads, first lanes, ballots and wave reductions, plus barriers for one wave's LDS. Everywhere else they refuse. Over the 415 wave64 programs that need their console lanes:

programs
translate on both 128
only on this stack 205
only on the halves stack 7
on neither 75
  • The 205 are all one-wave groups. They're what the console flow is for: LDS written and read in lane branches (125), masks (47), first lanes (17) and reductions (11) inside branches, the 4 tiled groups above, and 1 lane read.
  • The 7 are groups of 128 or more threads sharing LDS, whose reads across the halves all happen where every thread meets.
  • Of the 75, this stack refuses 43 as groups of more than 64 threads, 12 as implicit-derivative samples, 11 as programs reaching title memory, and 9 for other reasons.

The two seem to fit as tiers. The halves trades cost a group barrier pair per read, and they work in groups of any size where every thread meets. The console flow takes the divergent rest of one-wave groups.

The multi-wave branch. I also ran shader/wave64-lds-groups-2 at f7a85cf on the same machine.

  • split_tests: 43 passed, 1 failed. groups_whose_waves_part_match_the_console_on_every_adapter fails its case "both sides in the first wave's region" (128 threads) on the 3070 Ti (split). In the first console wave, lanes 20-63 store 2 where the console stores 3, so the side of the two-sided branch those lanes should take isn't taken. The rest is right: lanes 0-19 store 2 and the second wave stores 7, as on the console. It fails the same way when run alone.
  • The test's earlier cases are exact on both adapters: a loop the waves leave apart (128 and 256 threads), two exits, nested loops. So are groups_sharing_lds_match_the_console_on_every_adapter and groups_of_several_console_waves_run_as_one_host_group_each.
  • translate --list --validate --host-lanes 32-32 there: 2,722 of 2,760 compute programs emitted, all of them validated.

Logs on request. AI-assisted (Claude Code).

@latentdev

Copy link
Copy Markdown

IMPLICIT_SAMPLE_IN_HALVES: with #180's quad gradients, the programs it stops run in halves on a 4090

The comment above that refusal says a title run lost its device twice with these samples in the console flow in halves. I tried #180's lowering in exactly that place, on an RTX 4090 at e2d3cfd. The lowering is sampleGrad with coarse gradients from the console quad's lanes: lane 1 minus lane 0 across, lane 2 minus lane 0 down, read with waveReadLaneAt, and a bias scales them by 2^bias. Because the halves are split at 32, a console quad (lanes 4k..4k+3) is always within one host wave, at host lanes lane & ~3 and the three after it. The refusal becomes let quad_grad = matches!(op, 60 | 61) && !self.s.pixel && self.console_cf && self.split;. When that's set, the 60/61 arms emit sampleGrad.f32 (op 63) with those gradients and an undefined clamp.

The programs it brings back. They were the largest class of dropped work left in the prologue world here, mostly indirect dispatches:

program dropped per frame
ptfx_prerender:ptfx_CS_lightAtlas_Sprite (2561af9577c47289) 19
ptfx_CS_lightAtlas_Trail / _NonLocalLights_Sprite / _NonLocalLights_Trail (c06aa621, cabb8759, e8f6ae05) 4.5 / 4.5 / 1
indirect_light_probes:CS_IrradianceCache_Shade (a53a7977fe762268) 2
scattering_transmittance_system:CS_DensityShadowMapMips (5b2ce592c3a5dd09) 1
vfx_proj_decal_vbuffer:CS_ProjDecalResolve_Scalarized / _Vectorized (e4a9f58e, c4183d3c) 1 each

What I checked:

  • implicit_sample(true) translates for the 32-lane target and the module passes dxil.dll.
  • The full warm-up refuses 247 programs instead of 259.
  • In the title, all eight programs bind and run, and indirect kind 2: no host pipeline drops go from 26.6 to 1.3 per frame.
  • One run went 7.5 minutes with no hang. It ended in a 0x887A0005 removal with empty breadcrumbs, which on this 31 GB PC has been the machine running out of memory, with or without this change.

So the device losses behind the refusal may have come from the invalid sample in compute rather than from sampling in halves.

Not checked:

  • Pixel-exact agreement with the console.
  • Partial quads: waveReadLaneAt of an inactive host lane is undefined in DXIL, while the console reads the register.

@JurajSimicevic

Copy link
Copy Markdown

RTX 5080 (Blackwell), Windows, in the title at e2d3cfd: the whole prison cell renders. It's the most complete picture this card has given me, and I compared it on the same card and scene with the halves stack (#2176 / #2711 / #2925).

Setup: RTX 5080, driver 617.42, Windows 11 26200.

Tests on this card: cargo test -p victory-shader --lib --locked -- --test-threads=1 split_tests console: 44 passed.

same card, same scene this PR halves: #2176 + #2711 (VICTORY_WAVE32_APPROX=1) + #2925
compute pipelines skipped, shader does not translate (translate --cache --pipelines) 89 166
pipelines the host refuses 0 1
device removed no (12 min in the world) no
the cell all of it lit and textured: beds, shelves, door, corridor, walls parts dark or missing
green/red cast on the walls yes yes

Not tested: more than one run; this PR without #2118; other scenes.

Local diagnostics only. No game data: counts and pixel statistics.

AI-assisted.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.