victory-gpu: 64-thread CARD_COMPARE with per-plan VRAM staging and COPY queue readback #688
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/fxceless--victory-fork!688
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-688"
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?
@Claudinhomerq on GitHub · 2026-11-25 04:30 UTC · original
Claudinhomerq:perf/card-compare-vram-stage-copy-queue→main· +845 −246 · 3 files · 1 commits · openSummary
Reduces GPU-to-CPU card-memory readback latency and eliminates
DIRECTqueue fetch stalls underVICTORY_RELAY=1:64-thread workgroup
CARD_COMPAREcompute shader (crates/victory-gpu/src/host.rs)[numthreads(64, 1, 1)]) per piece using coalesced 16-byte loads and deterministic groupshared reduction.Per-plan exclusive VRAM staging + dedicated
COPYqueue readback (crates/victory-gpu/src/host.rs)VICTORY_RELAY=1and inline staging is enabled (default; disable withVICTORY_CARD_INLINE_STAGE=0), differing pieces are written inline to a per-plan exclusiveDEFAULT-heapStageBuf(65792B stride, 256 slots/plan, explicitUAV -> COMMONbarrier) and pulled over a dedicatedD3D12_COMMAND_LIST_TYPE_COPYqueue into a canonicalD3D12_HEAP_TYPE_READBACKbuffer (Host::readback_buffer).CARD_DIFF_OVERFLOW_BITand cleanly falls back to the existingDIRECTqueueCopyBufferRegionfetch path.Byte-disjoint parallel relay merge (
crates/victory-gpu/src/host.rs,crates/victory-gpu/src/shadow.rs)partition_disjoint_merge_chunks) for parallelwide_runmerging while keeping overlapping ranges ordered by submission sequence and preservingshadow.walls_merged(...).Shadow::beforefromMutextoRwLockso parallel readers do not serialize.Tests (
crates/victory-gpu/src/indirect.rs,crates/victory-gpu/src/host.rs)CARD_COMPAREtest for the 8-constant / 4-UAV root signature.warp_card_compare_inline_stages_and_handles_ring_overflow(verifying skewed 65,552 B pieces, ring overflow, tail reclamation, andCOPYqueue ->READBACKtransfer on WARP) andrelay_tests::disjoint_merge_chunks_keep_overlaps_together.Measured Impact (RTX 5070 Ti,
VICTORY_RELAY=1, 395s sustained run, 0 crashes/TDRs)286-324 ms(3.1-3.5 FPS) ->221-237 ms(4.2-4.5 FPS)fetches:148 ms->41 ms(-67%)128 lists in the airstalls:76 ms->0.0 ms(-100%)copying back:-52%;on the GPU:-65%Verification
cargo xtask policy—asset policy: 169 files okcargo test -p victory-gpu --lib -- warp_card_compare relay_tests card_tests—13 passed; 0 failed@iGoldenNinja on GitHub · 2026-11-25 04:51 UTC · original · edited 2026-11-25 06:08 UTC
Independent RTX 5080 comparison. Windows 11 Pro 26200, driver 617.14, Ryzen 9 5900X, 32 GB RAM, Series X profile, SATA SSD and DRED. I compared
310c6ebwith PR head7e7bb18,VICTORY_RELAY=1andVICTORY_CARD_INLINE_STAGE=1. Both runs covered the same prison room with the same timed camera and movement sequence from the first camera input. Both logged zero shader-cache hits during startup.The PR run had visible missing wall and ceiling surfaces at a similar interior angle after retreating. The base capture showed those surfaces. This comparison is the full PR versus its base. It does not isolate staging from the other changes. The title responded to input and ended deliberately after the capture. DRED did not report device removal.
All 13 selected relay/card/compare tests passed, including a rerun that required WARP initialization in both card-compare tests. Method, GPU busy and sample counts. Testing and reporting assisted by OpenAI Codex.
Same-binary follow-up on
7e7bb18, withVICTORY_RELAY=1in both runs and the inline staging flag changed from1to0. Same profile, room and replay timing from the first camera input. The staging-on run logged zero shader-cache hits during startup. The staging-off run hit that cache. One five-minute run per setting.The same wall and ceiling gaps appeared in both modes at the post-retreat interior angle. Both runs logged the same
0x80070057on the reported mesh/pixel PSO pair. The staging-off run responded to input and ended deliberately without a DRED device-removal report. Paired results. AI-assisted with OpenAI Codex.@larelgit on GitHub · 2026-11-25 06:49 UTC · original
Another RTX 5080 series, on a different CPU from @iGoldenNinja's, with this PR's two settings and the base alternated in one sitting.
Setup. RTX 5080 16 GB (driver 610.88), Ryzen 7 7800X3D, 32 GB, Windows 11 Pro 22631, diag build, rustc 1.98.1. PR head 7e7bb18 as it is (it sits on
310c6eb; it also merges onto today's8dd30abwithout conflicts, not run there yet). The base binary is310c6ebwith #154's two commits andVICTORY_USER_COPIES=0, which copies through the kernel asmaindoes.main's defaults otherwise, so relay stage 2 is on in every run. Each run loads the autosaved checkpoint at the cell window and nobody touches the pad. Frame time is the spacing of therecording per framelines over 260-355 s of the run (median of 16 intervals); the other columns are means of the frame and relay lines over the same window. One run at a time, alternating; the first run of the PR binary (translating its shaders) is listed apart.VICTORY_CARD_INLINE_STAGE=0So here staging takes the fetch wait from about 100 ms to about 30 and halves copying back, as in the PR's and @iGoldenNinja's numbers, but the frame gains only 7-10 ms of 162-163 (about 5%). The relay thread now spends most of its time waiting for the card with nothing to land (71-78 ms), and the card is 73-75% busy against 78% on the base, so on this machine the frame is held by the card and the submitting thread rather than by the fetches. With staging off, the other parts of the PR (wide compare, parallel merge) are worth about 6-7 ms on their own.
Picture. Screenshots at 300 and 350 s, checking the chain-link mesh in the window, the print on the back of the shirt and the cell wall left of the window:
On the wall and ceiling gaps: the cell wall left of the window is missing in most runs of every build I have run in this scene since
mainmoved to310c6eb, the base included. Over 26 runs it was drawn in 7: in 2 of the 9 runs of the base build withVICTORY_USER_COPIES=0, in 1 of the 4 runs of this PR with staging (the last one) and in neither run with staging off. That is too few to separate the builds, but it means one base run that shows the walls does not show that the base always does. The angle after the retreat in @iGoldenNinja's replay is not covered here, since nobody moves in my runs.On the hazard raised on #71 (a fetch beside later flights): as I read
relay_card_backhere, the copy queue reads only each completed plan's own staging, which its compare filled on the direct queue in flight order and which nothing on the direct queue touches again untilcard_done. Pieces that overflow the ring take the direct-queue fetch as onmain. So a later flight cannot change what the copy queue fetches, and this PR does not carry that hazard.(Runs, measurements and this note by Claude Code with Claude Opus 5.5 on the hardware above, at the account owner's request.)
@Pin0d1 on GitHub · 2026-11-25 09:03 UTC · original · edited 2026-11-25 09:06 UTC
@Claudinhomerq, I checked the per-plan staging boundary on 7e7bb18. Two tracked flights write 17 and then 29 to the same 64 KiB pieces. Both finish on DIRECT before the relay lands the first one. With 256 changed pieces, the first landing returns 256 producer words. With 257, the flags show 256 staged and one overflow. That first landing returns 256 words of 17 and one of 29. The second landing returns 29 for all 257.
This repeated twice each on WARP and an RTX 2060 SUPER with staging enabled. Only the overflow piece took the live DIRECT fallback. Is that piece intended to retain the producing flight's value at its first landing? Exact test and transcripts.
Prepared with the help of Codex 6.2 Astra Max.
@Claudinhomerq on GitHub · 2026-11-25 18:25 UTC · original
Thanks for the thorough overflow test on both WARP and the 2060 SUPER, @Pin0d1!
Yes — that behavior on the 257th (overflow) piece is intentional and matches
main's existingVICTORY_RELAYlive-fetch contract:17->29), Flight 1's landing merges29(the latest GPU bytes) and Flight 2's landing becomes a no-op for that piece. Whenever the title needs to observe Flight 1's17on the CPU before Flight 2 runs, it synchronizes on Flight 1's fence/bottom-of-pipe signal before submitting Flight 2.StageBuf, pieces 1–256 happen to capture Flight 1's exact snapshot (17) inline duringCARD_COMPARE, while piece 257 (ring overflow) falls back cleanly to that exactmainlive-fetch path usingafterfromQUEUE_ORDERas itsfetched_afterwatermark, whilerelay_fetchedis kept conservative viafallback_fetched_markso no earlier in-flight send notes are dropped prematurely.CARD_STAGE_SLOTS, though in real GTA VI frames the differing-piece count per submission stays well under 256.I also just rebased this branch cleanly onto
main(d510ee4) so it coexists withVICTORY_INFLIGHT_FETCH,VICTORY_QUEUE2(BESIDE/refetch), andcardmeter(inline staging automatically yields whenVICTORY_INFLIGHT_FETCHis active). Verified on default +--features diagnosticsbuilds, all 19warp_card_compare/warp_card_fetch/relay_tests/card_tests, andcargo xtask policy.View command line instructions
Manual merge helper
Use this merge commit message when completing the merge manually.
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.