Host: batch multi-span card rehash/compare passes (CARD_COMPARE_BATCH) and bitset piece joins #1633
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1633"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by Bazovsky on 2026-11-28T22:43:03Z.
Fixes #
What it changes
Reduces per-frame compute dispatch and CPU piece-joining overhead for card-resident buffer rehash and compare passes:
CARD_COMPARE_BATCHcompute shader (crates/victory-gpu/src/host.rs): adds a table-driven variant ofCARD_COMPAREwhose root SRV (t1) holds[piece, out_at_bytes]pairs in a 2 MiB upload ring (CardWork::jobs). Multiple disjoint rehash runs of a copy incard_before(sync pass) and multiple scattered declared spans sharing(buf_gpu, before_gpu, skew, size, mode)in the post-submission compare pass collapse into one batched dispatch per copy/mode (splitting at 65,535 thread groups and falling back cleanly to per-spanCARD_COMPAREif the jobs ring is full). Enabled by default;VICTORY_CARD_BATCH=0disables it.crates/victory-gpu/src/shadow.rs): replaces allocating and sorting tens of thousands of per-rangeCardSpanstructs incard_before(rehash_runs || send::own) withShadow::card_piece_runs/card_piece_runs_of, using a compactu64bitset over the copy's 64 KiB pieces.crates/victory-gpu/src/replay/play.rs,upcopies.rs): names the batch PSOCOMPARE_BATCH("victory: card compare batch") and includes it inhashandcomparespipeline sets so timing and--skip-hash-passesrecognise it cleanly.crates/victory-gpu/src/indirect.rs,shadow.rs): addswarp_card_compare_batch_matches_single_pass(runsCARD_COMPAREandCARD_COMPARE_BATCHside-by-side on WARP with an upload-heap jobs buffer across modes 0/1/2, duplicate mode-0 pieces, non-zeroskew, scattered pieces, and non-zerojob_base, asserting bit-exactdiffersandhashes) and fixed-seed randomized parity tests forcard_piece_runs_ofvsjoined_piece_runs.How it was tested
RUSTFLAGS="-C target-cpu=znver5") on cleanorigin/main(d4b5d51), 90 s same-session A/B runs (aligned steady window DLSS frames 100..1800, 0 D3D12 errors).d4b5d51): median 26.80 ms (37.3 fps), p95 36.30 ms, Prep 26.05 ms, GPU busy 63%, 251 hash passes/frame (356 compare passes/frame), 1,839 DLSS frames in 90 s.pr/card-compare-batch,4e1f3e8): median 25.40 ms (39.4 fps, +2.1 fps / +5.6%), p95 31.40 ms (-4.90 ms), Prep 23.80 ms (-2.25 ms), GPU busy 67%, 67 hash passes/frame (352 compare passes/frame), 1,999 DLSS frames (+160) in 90 s.CARD_COMPARE_BATCHuses no wave intrinsics (pure[numthreads(64, 1, 1)]+groupsharedreduction, token-identical hash body toCARD_COMPARE); tested on NVIDIA RTX 5090 (32 lanes) and Windows WARP (warp_card_compare_batch_matches_single_pass).cargo testpassed for the crates it touches: yes (victory-gpu: 552 passed, 0 failed — 515 non-watch + 37watch::testsserial;clippy+--features diagnosticscheck clean with 0 new warnings).Checked for overlap
CARD_COMPAREbatching or bitsetcard_piece_runs).Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by POMXARK on 2026-11-29T00:13:12Z.
@Bazovsky — ran a full 20-minute gameplay A/B of
CARD_COMPARE_BATCH+ bitsetcard_piece_runsstacked on top of#1637(Windows 11, RTX 5080 16 GB, Ryzen 7 5700X 8C/16T, 32 GB RAM, Series X 1440p, DLSS Quality + MFG 4x, release build, matched save & switches):Verification
card_piece_runs_bitset_matches_joined_piece_runs+warp_card_compare_batch_matches_single_pass+warp_card_compare_stores_the_hash_it_made_when_told3/3 PASS (0.29s).0errors over 20 minutes,refused=2, clean visuals across all 16 captured screenshots.20-minute A/B (
#1637baseline vs#1637 + #1633)#1637)CARD_COMPARE_BATCH)73.8 ms)70.3 ms)-3.5 ms)60.2 ms)58.5 ms)-1.7 ms)53.6 MB,2.02 MB/ms)59.0 MB, 2.08 MB/ms)103.2 ms,85.9 MB)95.6 ms,85.8 MB)-7.6 ms)card 8.9 ms)card 8.7 ms)>100ms(5s bins)Clean win across every bucket and frame-pacing metric! Note that post-submission
comparedispatches stayed ~328/f (vs 334/f) because most declared ranges haveindices.len() == 1per(buf_gpu, before_gpu, skew, size, mode)group, while sync-passhashdispatches collapsed by 70% (160 -> 48/f).Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by Bazovsky on 2026-11-29T01:43:26Z.
Thanks @POMXARK for the thorough 20-minute Ryzen 7 5700X + RTX 5080 A/B! Great to see the -70% sync hash dispatch drop (
160 -> 48/f), +4.8% ALL 3D p50 FPS, and -14.1 ms p95 confirmed on an 8C/16T + 5080 setup (and spot-on explanation for why post-submission compares mostly stay single-span).Rebased onto
origin/main(d585f88->330d1c2) and updatedCARD_COMPARE_BATCHto compile viacrate::hlsl::compile_forfor Wine/Proton DXC fallback parity (0fd34ca/8fb73e2). Verified withclippy(default +--features diagnostics, 0 new warnings) and native Windowsvictory-gputests (591/591 pass).Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by POMXARK on 2026-11-29T03:00:22Z.
@Bazovsky — following up on why post-submission
comparedispatches stay single-span (~315–328/f) even withCARD_COMPARE_BATCH: we prototyped and benchmarked a clean-room SM 5.1 bounded bindless multi-buffer variant (CARD_COMPARE_MULTI_BATCH, usingByteAddressBuffer bufs[1024] : register(t0, space1)andRWByteAddressBuffer hashes[1024] : register(u0, space2)with a 32-byte per-piece job[buf_idx, piece, out_at, skew, size, mode]) on native RTX 5080 D3D12.Hardware D3D12 Microbenchmark (NVIDIA RTX 5080, 17 submissions × 19 distinct buffers × 2 pieces = 646 pieces/f)
differsCARD_COMPARE)646(1 per span)0.094 ms/f0.099 ms/f0.192 ms/f17(-95%)0.014 ms/f(6.54xfaster)0.099 ms/f0.113 ms/f(1.70x)10.010 ms/f(9.03xfaster)0.111 ms/f0.121 ms/fUsing a bounded
[1024]table instead ofunboundedcompiles cleanly viacs_5_1/ DXC with zero special flags and keeps PIX/RenderDoc frame captures happy. Clean-room HLSL reference: https://github.com/POMXARK/bcpack-gpu-sdk/blob/main/shaders/card_compare_multi_batch.hlsl — could be a natural follow-up once #1633 lands!Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by NotADonky43 on 2026-11-29T03:27:15Z.
RTX 5070 Ti / Series X opening: applied the PR at
330d1c27on cumulative7f78e8f7(maind1486134). Four runs, control/candidate/candidate/control, same starting profile, 25,728 precompiled shaders and identical native library seed; warmed each executable. All four reached six settled heavy rendering reports. Send rehash dispatches/frame fell 216 → 65.5 and 218 → 67; piece counts stayed close (330 → 323 / 334 → 333). Post-list compare dispatches stayed near 350–360. Median of reported p95s (control vs candidate) 57.95 vs 62.35 ms, reverse 58.7 vs 57.0 ms. Peak process private GiB 26.48 vs 27.86 / 26.45 vs 27.34. Non-identical shots; this is mechanism confirmation, not evidence for an FPS win or a leak. Bitset range parity, the single vs batch shader outputs on both WARP and real hardware, and separate segmented upload GPU readback all passed locally.One portability issue I did find: with
VICTORY_CARD_BATCH=0setup still requires the second shader/PSO and 2 MiB job buffer; a failure caches the whole card path as unavailable. Source-only companion patch, applies to330d1c27(git am). It skips batch setup when disabled and keeps the single-span path on a healthy device if optional setup fails; a device loss still propagates. Native D3D12 tests exercised disabled (constructor must not be called), injected optional refusal, and real successful batch setup. Existing WARP and bitset tests and a release build passed. This is separate from the four timing runs. Posting the patch here rather than a duplicate parent PR: my fork credentials cannot push a branch with the parent’s newer workflow history.Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by Bazovsky on 2026-11-29T05:32:21Z.
Thanks @NotADonky43 for the RTX 5070 Ti verification (
216 -> 65.5/218 -> 67send rehash dispatches/f) and for catching theVICTORY_CARD_BATCH=0/ fallback portability bug!I applied your companion patch (
c6023a1, preserving authorship) directly onto this PR and verified it with:cargo xwin clippy(default) +--features diagnostics: 0 new warningsvictory-gputests: 591/591 PASS (553 + 38)host::card_compare_batch_is_optional --ignored: PASS (0.39son RTX 5090)And thanks @POMXARK for the bounded bindless
CARD_COMPARE_MULTI_BATCHprototype (646 -> 17dispatches/f,6.54xfaster CPU record, bit-exact 646/646) — agreed, that looks like a very clean follow-up PR once #1633 lands!Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by amazedturnip on 2026-11-29T05:38:41Z.
Tested on 9800X3D + RTX 5070 Ti 16 GB in a combined perf stack across 20+ min sessions. CARD_COMPARE_BATCH ran cleanly with zero shadow/copy corruption and lower submit-thread overhead.
Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by trustno1-coder on 2026-11-29T08:28:19Z.
Thank you! An earlier version of this pull request was merged into main with its original commits and is part of v2026.11.29.01, where you are credited. GitHub does not show it as merged because new commits were pushed here after that merge. It stays open so those newer commits can be looked at next.
Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by Bazovsky on 2026-11-29T11:01:43Z.
Thanks for merging the earlier version. The branch is rebased onto main (
829188e) and is now one commit: @NotADonky43's companion patch, ported onto the structure the combine gave the compare (CardShared).CardShared::batch: Option<CardBatch>, made only withVICTORY_CARD_BATCHon.victory-gputests (875 pass, plus the 40 ofwatch::testsrun one at a time),host::card_compare_batch_is_optional --ignoredpasses on an RTX 5090, and clippy reports nothing new inhost.rs. The diagnostics build does not compile on main itself at829188e(copystat.rs:1349,host.rs:9168), so it was not checked.One number for the bindless multi-batch idea above (@POMXARK). On a Ryzen 9 9950X3D + RTX 5090 (2560x1440, DLSS Quality, a steady scene with 333 compare passes a frame,
e1f2eb6+ this PR) I timed the parts ofcard_before: recording the compare list takes 0.30 ms a frame of the submitting thread's 25; the sync list takes 1.1 ms and taking the bytes out of the CPU sides 1.7 ms. So on this PC a follow-up that folds the compare passes has at most 0.3 ms a frame to gain.Measured unattended by an AI assistant (Claude Code) on my PC.
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.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.