Submission split: card_record reads each copy's before hashes once (port of Biskwit/VIctory-reloaded 4d3eae2) #3881
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/3881"
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 JSa25 on 2026-11-30T10:12:21Z.
Fixes #
What it changes
With
VICTORY_SUBMIT_SPLIT=1, one thread prepares the next submission while the sending thread records and sends the one before it. The preparing side'scard_takemakes a copy's "before" hash buffer (Shadow::card_make_before;Card::beforeis a lock-freeOnceLock) withoutCARD_WORK, as the comment at its call site says. The sending thread holdsCARD_WORKwhile it records. (The comment insidecard_make_before, "the sole current caller already holdsCARD_WORK", is out of date.)card_recordasked whether a copy has its "before" buffer several times while recording one sync list:send::Own::record,card_has_before());COPY_DESTtoNON_PIXEL_SHADER_RESOURCE;card_before_gpu()).If the other thread makes the buffer between those reads, the first read says "none", so no barrier to a read state is recorded. A later read says "there", so a hash pass is recorded over a copy still in
COPY_DESTorUNORDERED_ACCESS.This change looks at each copy's buffer once, right after the sync list is taken (
befores), and gives that one answer to the sends, the transitions and the hash passes. A copy whose buffer appears later is hashed whole by the take that made it, which is behind this list on the queue.send::Own::recordtakes the answers as a newbeforesparameter. The compare lists recorded later incard_record(fromdeclaredandlooked) are not changed.This is a port of Biskwit/VIctory-reloaded 4d3eae2 (GPL-3.0-or-later, like this repository), adapted to main. We found the race by reading the code. We have not caught it in a log.
Why now: #3809 turns
VICTORY_SUBMIT_SPLIT=1on by default, and then this window exists in every run. With the split off, both sides run on one thread and nothing changes.How it was tested
VICTORY_SUBMIT_SPLIT=1.Vec<Option<u64>>per sync list. We did not A/B it for fps.41adb551plus this change (and other local switches) had no device loss. One of them, with an unrelated experimental shader switch also on, ended about 10 s into the world on "a host command list did not close (0x80070057)". That error was not in our 21 earlier logs, the command was not identified (no D3D12 debug layer installed), and it has not happened again in the run since.cargo testpassed for the crates it touches:cargo test --release --locked -p victory-gpu --lib -- --test-threads=1on this branch: 921 passed, 1 failed. On unchanged main41adb551the result is identical: the same 921 passed and the same 1 failed.shader_cache::tests::every_switch_of_the_translator_is_in_the_key, which reports "VICTORY_SCALAR_SPLITS is not read by the translator any more".card_steps,menu,pool,resource). Each passes alone; see #3668.cargo check --release --locked -p victory: passes.Checked for overlap
card_before/card_record/send::take. It touches the same functions, and this change is small enough to rebase either way.AI use: Claude Code (Claude Opus 5.5) prepared this branch, ran the tests and wrote this text. Posted with the account owner's approval.
Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by tyr0nsur on 2026-11-30T10:23:05Z.
I found a second ordering case after the sync-list snapshot at
ba9fd3b. With split submission, A's take can fail the first hash-buffer allocation. B's take can retry and publish the buffer before the sender records A. B's whole fill still runs behind A on the queue. A can therefore select a declared compare or lazy compare using hashes it cannot yet rely on, even with a consistent sync snapshot.The follow-up stores the filling submission's existing
sent_asalongside the GPU address in theOnceLock. The sync pass, declared ranges, looked ranges, lazy sweep and compute compare all check it. A uses the existing conservative copy-back and B can fill and use its buffer in queue order. This keeps the PR's single sync snapshot.The new regression forces the first reservation to fail and the second to allocate a real D3D12 buffer. It failed on this PR head because the earlier submission could see that buffer. It passed with the patch on an RTX 4060 and WARP. The focused diagnostics suite passed 15 tests. This is a synthetic allocation-order test.
Companion commit
Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by akimfomin on 2026-11-30T10:37:24Z.
@tyr0nsur I carried your
a36da0b5follow-up and @JSa25’s snapshot onto the pinned Lab control, preserving its coalesced copy plan and borroweddeclared/lookediterators. The exact generated allocation-order regression executed on our Windows RTX 4070 Ti SUPER. Submission 10 rejected the allocation first filled by submission 11, and 11 and 12 both saw the expected address. Five send-plan tests also passed. A full-RT walk is running on the combined port. I’ll keep the split setting opt-in while collecting gameplay evidence.Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by JSa25 on 2026-11-30T15:16:54Z.
Thanks @tyr0nsur. I reviewed it and pulled your commit in as it is, with your authorship kept (
59c79f39after the rebase). The numbering holds: with the relay on, both take paths number fromQUEUE_ORDER, and without it every take is 0, so nothing changes there.I also rebased the branch onto
c71899d9, since main had moved.send::Own::recordnow runs on the scratch guard andcopy_runs, andhost.rsuseslooked.iter(&declared). It shows as mergeable again. Two notes from that:Main's lib tests don't compile at
c71899d9. The compare-prelude UAV test (990be53f) callscard_passwith 5 arguments since #3838 addedcapture. With, [0, 0, 0]added to its two calls, which is not part of this PR,cargo test --release --locked -p victory-gpu --lib -- --test-threads=1gives:shader_cache::tests::every_switch_of_the_translator_is_in_the_keyandlist::thin::tests::bindings_record_no_work).The extra pass is your
later_hash_allocation_is_hidden_from_an_earlier_submission, which ran on an RTX 5090 rather than skipping.One ungated read is left, and it's harmless. The new compare prelude's UAV barrier list takes
card_sides()'sbeforeforcomparedranges.comparedistwin && fits, and everytwinis now the gatedcard_before_gpu(sent_as), so this only adds barriers for buffers this submission may use.Thanks also @akimfomin for running the regression on the Lab branch.
Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by mstrmoos on 2026-11-30T19:22:36Z.
Picked onto our branch with #3753, #3756, #3760, #3881, #3832, #3858 and four that have since merged (#3818, #3850, #3874, #3871). #3760 needed a hand merge on top of the others.
All of victory-gpu's and victory-shader's tests passed. On the RTX 5080 16 GB, Ryzen 7 9800X3D, Windows 11, Series X profile, same save and 90 s bench route each run, the frame median went from 40.4 to 39.1 ms for the whole set. I didn't measure the PRs one by one, so this is evidence of no regression rather than this PR's own gain. Screenshots looked clean.
Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by Zeyphers on 2026-11-30T20:20:11Z.
Merged onto main
84bd61e2and benched on an RTX 2080 Super 8 GB and Ryzen 7 5800X (Series S, DLSS Quality, standing scene, 180 s): 9.4 fps median vs 9.2–9.7 baseline, so no measurable change on this CPU-bound rig. Two baseline runs differed by about 0.5 fps, so that's the noise. Only one run per PR, in a standing scene, not a walk.Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by trustno1-coder on 2026-12-01T18:48:02Z.
Closing this as part of moving main to the texture and video-memory rework (v2026.12.01.01-test). A lot of the code changed, and this pull request no longer applies cleanly to it; it would need to be rewritten against the new main rather than rebased. Thank you for the work. If the change is still needed, please open a new pull request based on the current main.
Pull request closed