WIP: [pr-performance][INTEL] Card steps: gather the reads into the buffer between in one dispatch per host copy #49

Draft
kisekinopureya wants to merge 21 commits from kisekinopureya/Darner:kisekinopureya/pr/card-steps-gather into main
Contributor

Contributor role (optional)

  • Fluxer ID: 1576376229534109696

What it changes

When flights in the air hold a submission up, its copies and fills are done on the card: the places
they read are first copied into a 4 MiB buffer of ours, one CopyBufferRegion each. On an Arc A770
in the chase after the prison, 2,000-3,300 of these a frame (a few hundred bytes each, the title's
constants) took the submitting thread 120-206 ms a frame to record, about 65 us a copy, all of it in
the driver. With late wait 3 (up to 9,600 steps a frame) the stage took 1.2-2.8 s a frame.

With DARNER_CARD_STEPS_GATHER (on by default on an Intel card, through INTEL_DEFAULTS):

  • Reads: written to a table in upload memory, one table per list of ours (65,536 entries).
  • Copying: one compute dispatch per host copy read does the copies, 64 threads an entry.
  • Fallback: a read not on 4 bytes, or past the table, is still a copy.
  • Writes: the steps' writes are unchanged.

A new frame-rate line gives the reads gathered, the dispatches and the reads still copied.
DARNER_CARD_STEPS_GATHER=0 turns it off.

How it was tested

  • Tested revision: 21e9b74622 (rebased onto 1a5286a7; the gates re-run there) (gates); the game on the same change before the rebase (base branch a90712d0 on the old main 28ef3ddb), built in a worktree.
  • Commands and results:
    • cargo clippy --workspace --all-targets --locked -- -D warnings: clean.
    • The same with --all-features: clean.
    • DARNER_D3D12_DEBUG=1 cargo test --profile diag -p darner-gpu --features diagnostics --lib card_steps:::
      31 passed, at 720719e1fe after the rebase too. This includes the new
      the_gather_reads_what_copies_would (aligned and unaligned reads, two levels, bytes compared
      with what copies give), with no debug-layer messages.
    • The shader cache, menu, panel, card steps and switch unit tests: 104 passed (before the rebase).
    • cargo xtask policy: ok (base branch).
  • Gameplay: Arc A770, Series S, 1920x1080, DARNER_XESS=1 DARNER_XESS_MODE=ultraperformance,
    same route both times (the prison, the chase after the QTE, driving).
    • Recording the steps went from 120-206 ms a frame to 0.2-0.6 ms; every read was gathered, none
      copied.
    • The card went from about 10% to about 78% busy between pipeline waits.
    • 11 minutes with no device loss.
    • Two later runs with the gather (and DARNER_SCREEN_WAIT_MS=0) lost the device after about 11.5
      and 13.5 minutes. The second was traced: it stopped in a mesh-shader draw, not in a gather
      dispatch (the traced run in the shared record).
  • Before and after: A770, record alone (a throwaway timing test, not in the PR):
    • 8,000 reads: 27 ms with copies, 0.10 ms gathered.
    • 16,000 reads: 91 ms against 0.18 ms.
  • Coverage gaps:
    • Not run on NVIDIA or AMD with the switch on (off by default there).
    • Not run with late wait 3, where the stage took the longest.
    • The chase is still slow, for another reason: the waits for new screen-pass pipelines
      (80 s in 3 minutes).
    • cargo test --release --features diagnostics makes rustc crash with an access violation on
      this machine while building the test binary (twice; not checked without this change), so the diag
      profile was used.

Checklist

  • This PR contains one change based on main.
  • The diff follows docs/asset-policy.md.
  • I recorded this PR's dependencies below.
    • Depends on #44 (INTEL_DEFAULTS in switch.rs), then #43, #33, #31

Checked for overlap

  • I searched the open pull requests for the same issue and for the files this touches.
  • Related PRs: CodeFloe #288 (merged, in main) also changes crates/darner-gpu/src/host/card_steps.rs.

🤖 Generated with Claude Code

## Contributor role (optional) - Fluxer ID: 1576376229534109696 ## What it changes When flights in the air hold a submission up, its copies and fills are done on the card: the places they read are first copied into a 4 MiB buffer of ours, one `CopyBufferRegion` each. On an Arc A770 in the chase after the prison, 2,000-3,300 of these a frame (a few hundred bytes each, the title's constants) took the submitting thread 120-206 ms a frame to record, about 65 us a copy, all of it in the driver. With late wait 3 (up to 9,600 steps a frame) the stage took 1.2-2.8 s a frame. With `DARNER_CARD_STEPS_GATHER` (on by default on an Intel card, through `INTEL_DEFAULTS`): - **Reads:** written to a table in upload memory, one table per list of ours (65,536 entries). - **Copying:** one compute dispatch per host copy read does the copies, 64 threads an entry. - **Fallback:** a read not on 4 bytes, or past the table, is still a copy. - **Writes:** the steps' writes are unchanged. A new frame-rate line gives the reads gathered, the dispatches and the reads still copied. `DARNER_CARD_STEPS_GATHER=0` turns it off. ## How it was tested - Tested revision: 21e9b74622 (rebased onto `1a5286a7`; the gates re-run there) (gates); the game on the same change before the rebase (base branch a90712d0 on the old `main` 28ef3ddb), built in a worktree. - Commands and results: - `cargo clippy --workspace --all-targets --locked -- -D warnings`: clean. - The same with `--all-features`: clean. - `DARNER_D3D12_DEBUG=1 cargo test --profile diag -p darner-gpu --features diagnostics --lib card_steps::`: 31 passed, at 720719e1fe after the rebase too. This includes the new `the_gather_reads_what_copies_would` (aligned and unaligned reads, two levels, bytes compared with what copies give), with no debug-layer messages. - The shader cache, menu, panel, card steps and switch unit tests: 104 passed (before the rebase). - `cargo xtask policy`: ok (base branch). - Gameplay: Arc A770, Series S, 1920x1080, `DARNER_XESS=1 DARNER_XESS_MODE=ultraperformance`, same route both times (the prison, the chase after the QTE, driving). - Recording the steps went from 120-206 ms a frame to 0.2-0.6 ms; every read was gathered, none copied. - The card went from about 10% to about 78% busy between pipeline waits. - 11 minutes with no device loss. - Two later runs with the gather (and `DARNER_SCREEN_WAIT_MS=0`) lost the device after about 11.5 and 13.5 minutes. The second was traced: it stopped in a mesh-shader draw, not in a gather dispatch (the traced run in the shared record). - Before and after: A770, `record` alone (a throwaway timing test, not in the PR): - 8,000 reads: 27 ms with copies, 0.10 ms gathered. - 16,000 reads: 91 ms against 0.18 ms. - Coverage gaps: - Not run on NVIDIA or AMD with the switch on (off by default there). - Not run with late wait 3, where the stage took the longest. - The chase is still slow, for another reason: the waits for new screen-pass pipelines (80 s in 3 minutes). - `cargo test --release --features diagnostics` makes rustc crash with an access violation on this machine while building the test binary (twice; not checked without this change), so the diag profile was used. ## Checklist - [ ] This PR contains one change based on `main`. - [x] The diff follows `docs/asset-policy.md`. - [x] I recorded this PR's dependencies below. - Depends on #44 (`INTEL_DEFAULTS` in `switch.rs`), then #43, #33, #31 ## Checked for overlap - [x] I searched the open pull requests for the same issue and for the files this touches. - Related PRs: CodeFloe #288 (merged, in `main`) also changes `crates/darner-gpu/src/host/card_steps.rs`. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
The vendor is part of the host settings and the translation fingerprint
(lower::host_intel, set when the device is made), for the Intel-only forms
that follow.

In VIctory-NVIDIA this came with leaving the particle light atlas
unfolded on Intel cards (the folded CS_lightAtlas programs hung an Arc
A770's device in the prison cell in three runs of three). Darner already
leaves it unfolded on every card (UNFOLDED_BY_DEFAULT), so only the vendor
detection is ported.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
(cherry picked from commit 18e8c457d1c80244e9da74b094dc70311e397428)
tiled_lighting:CS_ClusterLightsWorldSpace (groups of 64) fell back to an
approximate local-waves form, each host wave building its own half of a
console wave's light lists: the blocky checkerboard on lit surfaces seen
on an Arc A770. It joins the wave-wide-by-default list. Adds the ignored
forms_of_dumped_containers diagnostic test.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
(cherry picked from commit e5b1788c470b8fd9c70e3b5092d8f814d7de332d)
A first-lane read in the wave-wide form exchanged the two halves' "has a
lane" flags and then their values, four group barriers. Both words now go
through one exchange of four LDS words a console wave (two barriers),
falling back to the two exchanges where private LDS is short. On the
Arc A770 the light clustering's dispatch went from 228 to about 125 ms a
frame (127 to 75 barrier sites). The forms test can also save each
translation (DARNER_FORMS_OUT).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
(cherry picked from commit b173c163cfae6716acbc1a4c30621d4a0d6f4bff)
tiled_lighting:CS_ClusterLightsWorldSpace was made exact (wave-wide
branches) for the Arc's checkerboard, which turned out to be the
shadow masks' LDS race. On an A770 its exact form costs most of the
frame: in a replay of the prison cell 244 of 523 ms on the card. In its
approximate form the frame took 281 ms, with a picture as close to the
exact one (46.3 dB) as two runs of the exact form are to each other.
On an Intel card it now keeps that form; DARNER_CLUSTER_LIGHTS_EXACT=1
restores the exact one (in the shader cache key). Other cards are
unchanged.

In a five-minute XeSS quality run the cell went from about 2.2 to
4.5-5.8 fps. That run lost the device once after 110 s; a repeat with
full DRED did not.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
(cherry picked from commit 128101fe53959fbf2ce97004ed31d33eae9b46ea)
Docs that stay in VIctory-NVIDIA (the Arc tracker, the XeSS notes) are
named as its; the product is Darner.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
(cherry picked from commit 594c87446d023c4268dcfd482d1bdd989ac4fe48)
Co-Authored-By: Claude Opus 5.5 <[email protected]>
(cherry picked from commit 1045f0ce51fab3a70dc8e1d1f0f6d39a82e3e419)
From the Whiplash-NVIDIA tree: one host wave of 32 lanes runs one console
wave of 64, each thread running console lanes n and n + 32. Every per-lane
branch is taken wave-wide (structure_wide); LDS inside the wave is ordered
by fences, not group barriers; the only barrier added is on entry, where a
group of several console waves numbers them. It is tried after the folded
form and before the approximate and wave-wide forms, and only when asked
for: DARNER_WAVE_PAIRS=1 (every wave64 compute program) or
DARNER_PAIRED_ONLY=<digest prefix or program text>, both in the shader
cache key.

Differences from Whiplash-NVIDIA: a dispatch counted in threads, and wave
sums of 16-bit floats and of doubles, are refused in this form.

emit/paired_tests.rs (four tests: LDS and lane reads across the halves
without barriers, waves looping apart, permutes and lane writes, a wave OR
in a lane branch) pass on an Arc A770. docs/arc-perf-comparison.md compares
this tree's Arc frame time with the Whiplash AMD and NVIDIA trees.

Darner: tried right after the fold closure is defined (Darner folds later in its ladder), and refused for programs with lifted ray queries, whose per-block state is one lane's.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
(cherry picked from commit 7c7c0948eb38d2d451a0ce5a65266ca1bf3629d6)
What the merge of arc-perf-compare into intel-arc decided: on an Intel
card tiled_lighting:CS_ClusterLightsWorldSpace takes the paired form
(falling to the approximate one if the lowering refuses it), and
DARNER_CLUSTER_LIGHTS=approximate or exact picks another (replacing
DARNER_CLUSTER_LIGHTS_EXACT, in the shader cache key). Other cards keep
the wave-wide form. Replay of the prison cell on an A770: wave-wide
523 ms a frame on the card, approximate 281 ms, paired 289 ms; against
the wave-wide picture paired 50.0 dB, approximate 46.3 dB, two
wave-wide runs 46.2 dB. DARNER_WAVE_PAIRS=0 turns the paired default
off.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
(cherry picked from commit 90a9963c85b4d2278af6977332aa27acc3cfff9a)
A program named there now takes the paired form before the plain
lowering, which may translate a console wave64 program as two host
waves exchanging cross-lane values through group barriers. Refused, the
program goes on as before. Defaults are unchanged.

For CS_GenerateMaterialMasks on an Arc A770 this removed its five group
barriers: its list replayed alone fell from 38.6 to 27.0 ms and the
picture is 61.2 dB from the default. The whole frame did not change
(about 182 ms either way): the card had filled those waits with the
next lists' work, so the frame is bound by total work. Recorded in
docs/arc-a770.md.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
(cherry picked from commit 1da6dbb8742d6588a8e2a671d93bcb5fd148d833)
Docs that stay in VIctory-NVIDIA (the Arc tracker, the XeSS notes) are
named as its; the product is Darner.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
(cherry picked from commit 096379aa62bf4bd4fdd2263f2122c4902b2ae3a5)
On an Intel card, unless their variables are set:

- deferred_tiled:CS_DepthProcessingHBO takes the paired form first
  (DARNER_HBO_PAIRED=0: not; in the shader cache key). Its plain
  lowering trades values through 26 group barriers; paired it
  validates with 13, reached by the group's one host wave.
- DARNER_LAZY_COMPARE_MB=64 and DARNER_LAZY_NARROW=1,
  DARNER_CARD_STEPS_JOIN=4096, DARNER_TABLE_SAME=1,
  DARNER_ROOT_SAME=1, DARNER_THIN_COALESCE=1, from a table in
  switch.rs that the host fills in when it finds the card (logged).

None was run on the card before being made a default: the first run
should check skinned characters and the ambient occlusion.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
(cherry picked from commit 8b260025a3287f475162d06a106b65763a7199d8)
The cell runs put the +30% (4.3 to 5.6 fps) in DARNER_LAZY_COMPARE_MB
and DARNER_CARD_STEPS_JOIN. DARNER_LAZY_NARROW, DARNER_TABLE_SAME,
DARNER_ROOT_SAME and DARNER_THIN_COALESCE each moved fps by less than
run-to-run noise and are no longer defaults (still `1` to set). HBO
paired stays.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
(cherry picked from commit 253c9ffd0411b06fffe62a2d66fed545e531685e)
At stage 3 (the default with the relay on) the present no longer
settles the flights in the air, and on the Arc A770 skinned characters
were drawn with vertices thrown across the screen (the café cutscene,
the prison-cell doorway) in every watched run but one; at stages 1 and
2, and with the relay off, in none. Stage 2 cost about 8% (median 4.8
fps against 5.2), stage 1 about 15%, the relay off 44%.

late_stage reads DARNER_LATE_WAIT through crate::switch, so an Intel
card takes 2 unless it is set. Untried in a run with this build: the
log line "switches an Intel card gets unless set" should name it.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
(cherry picked from commit 3eb678e441dfedd1b15c09504fc4592924cc8f1f)
tiled_lighting:CS_GenerateMaterialMasks is one console wave of 64 lanes
to a group; its plain lowering is two host waves trading values through
five group barriers. A replay of the prison cell on the Arc A770, ten
loops with the two forms in turn from one load, took 180.1 ms on the
card paired against 205.6 plain (-25 ms, 12%), the loops' pictures the
same. Left out entirely the program saved 21.7 ms, more than any other
in the frame. DARNER_MASKS_PAIRED=0 (in the shader cache's key): not.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
(cherry picked from commit bf2873628ae3d6bbe7d18fe141db0042f2546e7a)
terrain CS_ComputeFeedbackList, the two particle lightAtlas programs,
CS_WriteRasterClassificationResults and CS_ProjDecalResolve_Scalarized
were the frame's other console wave64 programs lowered as two host
waves trading values through barriers. Paired together, a replay of the
prison cell on the Arc A770 took 200.6 ms on the card against 209.9
(ten loops, in turn, one load), the loops' pictures the same as the
plain forms'. With the material masks they make one list by digest,
INTEL_PAIRED; DARNER_INTEL_PAIRS=0 (replacing DARNER_MASKS_PAIRED)
turns all six off. Not DARNER_WAVE_PAIRS=1 for everything: Whiplash
found one program drawing dark slabs paired.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
(cherry picked from commit 76b0873e92513227c8d3778c1cdc3e9f12500569)
Measured again with --compare --replicas 4 (eight loops, each form
prepared four times, run in turn): the material masks paired save 11.9
ms of the cell frame (the earlier 25.4 was a single-instance figure),
the HBO pass 16.6 ms, but the five other wave64 programs together 1.1
ms, within the noise. Those five are left out of INTEL_PAIRED again.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
(cherry picked from commit 2b7300b49ff778c70be357da2deb192e9b132bd4)
Docs that stay in VIctory-NVIDIA (the Arc tracker, the XeSS notes) are
named as its; the product is Darner.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
(cherry picked from commit 886f2faa16d11ac0d25b4d8d4217592f3c61e1aa)
Docs that stay in VIctory-NVIDIA (the Arc tracker, the XeSS notes) are
named as its; the product is Darner.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
(cherry picked from commit b317a85538a5d807b389dea6cefeb91b169ed3b7)
A test that makes a device on an Intel card sets the host's vendor for
the whole test run, and every test after it would read the Intel
defaults (DARNER_LATE_WAIT, DARNER_CARD_STEPS_JOIN,
DARNER_LAZY_COMPARE_MB) where the others read them unset.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
(cherry picked from commit 265da19cec8efe86b9404e0a30b2a30644e44655)
Docs that stay in VIctory-NVIDIA (the Arc tracker, the XeSS notes) are
named as its; the product is Darner.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Each submission whose copies and fills are done on the card copies the
places they read into a buffer of ours first: one CopyBufferRegion each.
On an Arc A770 in the chase after the prison, 2,000-3,300 of these a frame
(a few hundred bytes each, the title's constants) took the submitting
thread 120-206 ms a frame to record, about 65 us a copy, all of it in the
driver; with late wait 3 (9,600 steps a frame) 1.2-2.8 s.

With DARNER_CARD_STEPS_GATHER (on by default on an Intel card) the reads
are written to a table in upload memory instead, and a compute dispatch
for each host copy read copies them (64 threads an entry). A read not on
4 bytes, or past the table's 65,536 entries, is still a copy.

Measured on the A770: recording 8,000 reads 27 ms with copies, 0.10 ms
gathered; 16,000 reads 91 ms against 0.18 ms. In play, the chase with
XeSS ultra performance: the stage went from 120-206 ms a frame to
0.2-0.6 ms, every read gathered, and the card from about 10% to 78% busy
between pipeline waits.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
(cherry picked from commit a90712d02ff84db072265cd36339f6739e6072f8)
kisekinopureya force-pushed kisekinopureya/pr/card-steps-gather from 720719e1fe to 21e9b74622 2026-12-03 21:13:23 +00:00 Compare
This pull request is marked as a work in progress.
This branch is out-of-date with the base branch
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u 'kisekinopureya/pr/card-steps-gather:kisekinopureya-kisekinopureya/pr/card-steps-gather'
git switch 'kisekinopureya-kisekinopureya/pr/card-steps-gather'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'kisekinopureya-kisekinopureya/pr/card-steps-gather'
git switch 'kisekinopureya-kisekinopureya/pr/card-steps-gather'
git rebase 'main'
git switch 'main'
git merge --ff-only 'kisekinopureya-kisekinopureya/pr/card-steps-gather'
git switch 'kisekinopureya-kisekinopureya/pr/card-steps-gather'
git rebase 'main'
git switch 'main'
git merge --no-ff 'kisekinopureya-kisekinopureya/pr/card-steps-gather'
git switch 'main'
git merge --squash 'kisekinopureya-kisekinopureya/pr/card-steps-gather'
git switch 'main'
git merge --ff-only 'kisekinopureya-kisekinopureya/pr/card-steps-gather'
git switch 'main'
git merge 'kisekinopureya-kisekinopureya/pr/card-steps-gather'
git push origin 'main'
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
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.

Dependencies

No dependencies set

Reference
TrustNo1/Darner!49
No description provided.