Skip to content

Spread dispatches: VICTORY_SPREAD_LEAN runs the records within 65,535 groups through the plain signature (off by default; #1338) - #1352

Merged
fxceless merged 1 commit into
fxceless:mainfrom
grosterr:pr/spread-lean
Nov 26, 2026
Merged

fxceless merged 1 commit into
fxceless:mainfrom
grosterr:pr/spread-lean

Conversation

@grosterr

Copy link
Copy Markdown
Contributor

What

Since 06702fe an indirect dispatch of a program that takes the spread words goes through a command signature that sets two root constants (row, asked x) and then dispatches, 20 bytes a record. That holds for every such dispatch, whatever it asks for.

With VICTORY_SPREAD_LEAN=1 (or alt: twenty seconds each way, each change logged), the clamp writes a batch of up to 64 dispatch records twice:

  • plain [x, y, z] records from byte 0, with the records past 65,535 groups in x left empty;
  • at (records * 12 + 7) & ~7, a predicate word: 1 when any record that runs is spread;
  • 8 bytes on, [row, asked x, x, y, z] records, with only the spread records filled.

The dispatch is then recorded as ExecuteIndirect with the plain DISPATCH signature, SetPredication(EQUAL_ZERO) on the word, ExecuteIndirect with the spread signature, and predication off again.

  • Nothing is clamped to 65,535 groups. On our RTX 3060, VICTORY_DISPATCH_SPREAD=0 lost the device while loading in 2 of 4 runs.
  • Larger batches (more than one clamp group) take the spread signature as before. The predicate is written by the group's first thread after a group barrier, so one group is a hard limit here.
  • The bound program's spread words are 0 for the plain records. Its bind sets them that way for an indirect dispatch, as it did before.

The clamp also counts, in the budget buffer's words 3-5, the spread-eligible records over 65,535 groups and within it, and the groups past 65,535. The frame line says them:

dispatches spread across z ... per frame: 0.00 direct, 989.25 indirect (989.25 lean), records: 0.75 over 65,535 (+21231 extra groups), 1097.50 at or under 65,535

Measured (RTX 3060 12 GB, Ryzen 7 5700X, Series X profile, prison prologue)

The run was on our branch, which has this change on 06702fe + ceb9e1f and the #770 stack. Standing still at one spot, =alt, 9 pairs, warm pipeline library, world frames only:

lean ON lean off
frame 208 ms 225 ms
on the GPU 91 ms 108 ms
preparing 78 ms 74 ms
copying back 45 ms 45 ms

The card's time was lower in every pair: −22, −19, −9, −19, −16, −7, −1, −13, −8 ms (median −12.8). Preparing pays about 4 ms for two executions and the predication instead of one.

Of the ~890-990 spread-signature executions a frame, 0.4-1.2 a frame pass 65,535 groups.

A micro-benchmark of 1,000 single-record executions of an empty dispatch on the same card, card time:

signature card time
spread signature 1.88 ms
plain signature 0.06 ms
spread signature behind a predicate that is 0 0.53 ms

In a real frame the difference is much larger, so the driver probably serialises around executions that set root constants.

This branch is the change alone, rebased on e4245f3 (the clamp's new group charge and gather segments). It was built and tested, but not run in game on this exact base.

Tests

  • warp_spread_lean_routes_small_and_large_records_and_counts_them: a mixed batch (100, 100,000 and 65,535 groups), and an all-small batch. It checks the plain and spread arrays, the predicate word, and the counters.
  • warp_spread_lean_executes_same_group_ids_as_spread_for_100k_groups: 100,000 groups and 100 groups through the two executions under predication. It checks that the same group ids run, and that the predicate is set and clear respectively.
  • Under VICTORY_D3D12_DEBUG=1: indirect 19 passed. Whole victory-gpu --lib (--test-threads=1): 224 passed. Clippy on the workspace is clean, and --features diagnostics builds.

Not tried on AMD, hence off by default. With it unset, nothing changes apart from the three counters.

🤖 Generated with Claude Code

… groups through the plain signature (off by default)

An indirect dispatch of a program that takes the spread words goes through
a command signature that sets two root constants and then dispatches. On an
RTX 3060 that costs about 13 ms of the card's time a frame, for ~1,000 such
executions, of which ~1 a frame asks for more than 65,535 groups in x.

With VICTORY_SPREAD_LEAN=1 (or alt, twenty seconds each way) a batch of up
to 64 records is clamped into two arrays: plain [x, y, z] records for the
plain dispatch signature, with the records past 65,535 left empty, and
[row, asked x, x, y, z] records for the spread signature, with only those
filled. A predicate word between them is 1 when a record that runs is
spread. The dispatch is recorded as the plain execution, then the spread
one under SetPredication(EQUAL_ZERO). Nothing is clamped to 65,535 groups
either way. Larger batches take the spread signature as before.

The clamp also counts, in the budget buffer's next words, the
spread-eligible records over 65,535 groups and within it, and the groups
past 65,535; the frame line says them.

Measured on an RTX 3060 12 GB, standing still with =alt, 9 pairs: the
card's time 91 against 108 ms (lower in every pair, median -12.8 ms),
frame 208 against 225 ms, preparing +4 ms. WARP tests: the routing and
counts of a mixed batch, and equal group ids at 100,000 groups through the
two executions.

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

Copy link
Copy Markdown

Tested on Linux/Proton (GE-Proton11-14 + vkd3d-proton, RTX 5080 16 GB, Series X profile, diag build with frame capture enabled, warm shader cache, merged on e4245f3 alongside #1350 and our Linux DXC/copy-plain test stack):

  • Unit tests under Proton: indirect:: with VICTORY_SPREAD_LEAN=1 — 19 passed, 0 failed, 2 ignored (both new warp_spread_lean_* tests passed).
  • Control (without #1352, VICTORY_DISPATCH_SPREAD default on): 1.7–2.0 fps (505–600 ms/frame, copying back 247–360 ms), 1,066 indirect dispatches/frame through the spread signature.
  • With #1352 (VICTORY_SPREAD_LEAN=1): 3.7–4.3 fps (234–272 ms/frame, copying back 80–100 ms) — >2x faster while keeping full lighting/volumetrics intact (visually verified across captured world frames).
  • Lean routing breakdown: 826–1,050 indirect dispatches/frame routed lean; only 0.40–1.25 records/frame exceeded 65,535 groups (1,062–1,155 at or under 65,535).

(AI-assisted testing and summary.)

@grosterr

Copy link
Copy Markdown
Contributor Author

Thanks for running it under Proton. Your counters match ours: ~1,000 executions a frame through the spread signature, about one record a frame past 65,535. So the cost is the signature itself, and it is clearly worse under vkd3d (copy-back alone 247–360 → 80–100 ms there) than on Windows.

With two independent results, on Windows/NVIDIA (card −12.8 ms) and on Linux/vkd3d (frame more than halved), the switch could be on by default, at least on NVIDIA and under vkd3d. A run of VICTORY_SPREAD_LEAN=alt on an AMD card would settle whether it can be on everywhere. Happy to change the default in this PR if that is preferred.

@Filip722

Copy link
Copy Markdown
Contributor

I ran a same-process alternating comparison on the RTX 5060 Laptop 8 GB with an Intel Core 7 240H, Bazzite 44, NVIDIA 615.78.08, GE-Proton11-14 and vkd3d-proton 3.2.0. Base was 52ac4ec with the #257 loop-latch fix and the same offline Series S prison checkpoint. Both phases used the same executable, rendering scale and initial caches. Three settled 18-second windows per mode exclude the first and last second of each switch interval.

Lean Original
Median window throughput, unique completed DXGI Presents 4.301 FPS 4.332 FPS
Host frame-group median 242.3 ms 242.4 ms
Host preparation median 149.3 ms 155.6 ms
Host copy-back median 126.6 ms 117.3 ms
Minimum free VRAM in measured windows 790 MiB 805 MiB

The lean arm routed a median 913 indirect dispatches per frame through the new path. The steady checkpoint showed similar throughput in the two modes. The build exited cleanly.

Both new cases and all 19 indirect tests passed on the physical RTX. I explicitly selected the hardware adapter in the fixture and used the existing local DXC fallback for the test worker. Under GE-Proton, the WARP-only fixture otherwise returned early after DXGI supplied a hardware adapter.

Assisted by Codex (GPT-6.2-Sol High).

@grosterr

Copy link
Copy Markdown
Contributor Author

Thanks, that is the case we had no data for: a laptop part, Series S, preparation and copy-back above 240 ms together. The routing count matches ours and BitWuehler's (~900-1,000 indirect dispatches a frame through the plain signature).

A neutral frame there is what we would expect. The switch only takes work off the card, and on your run the frame is held by the host side (preparation 149-156 ms, copy-back 117-127 ms). On our RTX 3060 the card was the limit, so 12.8 ms of card time came off and the frame dropped by about 9 ms. If the card time per frame was logged in the same windows, it would show whether the saving is there and just hidden behind the host side.

With three setups now, nothing got worse in any of them: Windows desktop, card −12.8 ms; Proton on a 5080, frame more than halved; Proton on a 5060 Laptop, no change. I think that is enough to turn it on by default. AMD is still unmeasured.

About the fixture: the early return under GE-Proton is WarpHarness::new(), which all the indirect tests share, so it is not specific to these two tests. If it helps, a follow-up could print why a WARP test was skipped instead of passing silently.

grosterr added a commit to grosterr/victory-fork that referenced this pull request Nov 26, 2026
…to exp/rtx3060-m

Combines exp/rtx3060-l (L1 wave, fxceless#854 paired form, fxceless#864, fxceless#812, fxceless#768, LEVELS_ON_DEMAND, RAM_SAFE) with fxceless main e4245f3 (fxceless#927, fxceless#646, DIRTY_4K, GATHER_SEGMENTS, PAGE_WRITES, group-budget indirect clamp, WAVE_WIDE_ONLY) and PR fxceless#1352 SPREAD_LEAN (bit 32, LEAN_RECORDS=64, spread budget counters 3-5).

Co-Authored-By: Antigravity <noreply@anthropic.com>
@fxceless
fxceless merged commit a7ee5df into fxceless:main Nov 26, 2026
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.

4 participants