GPU: batch host mirroring for contiguous descriptor copies #3263
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/3265"
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 Marvisak/VIctory. Originally posted by yumaste on 2026-11-26T15:03:19Z.
CopyDescriptorsSimple currently looks up the shader-visible destination heap and locks its pending queue separately for every descriptor. A contiguous, aligned copy into one heap now looks it up once. Pending indices are appended together. Initialized heaps use the existing sync_slots path in bounded batches to skip host slots whose record is already current. Ranges crossing heap boundaries or using a different stride retain the existing per-slot lookup.
An exact self-copy skips the guest byte write and still mirrors the destination, so records written directly into the heap can still become visible. Overlapping ranges with different starts still use memmove semantics. The change is shared across D3D12 adapters and adds no driver-specific defaults.
A synthetic 304-descriptor copy goes from 304 registry lookups to one on this path. The regression covers lazy heap initialization and verifies that a self-copy mirrors a new slot, clears a stale slot, and retains an occupied slot beyond the first batch. The full WARP GPU suite passed twice (247 passed, one ignored); strict Clippy passed. Scoped the existing test-only preparation hook to its own test thread after observing an unrelated test consume the hook during a parallel run. The new regression also passed on a physical NVIDIA RTX 5080 Laptop GPU with both PRs applied. AMD hardware validation remains open. No title files were used.
Inspired by reducing descriptor-store work and batching heap-record work in cool_fox.
Imported from Marvisak/VIctory. Originally posted by Dukestar69 on 2026-11-26T15:08:17Z.
Review: APPROVED
Reviewed the diff and verified locally on Windows 11 x64 (RTX 5090 + WARP):
mirror_copyunder oneSHADER_HEAPSlookup (with 256-slotsync_slotschunks and a clean fallback for cross-heap/mismatched-stride ranges) and making the test hookWHILE_PREPARINGthread-local are clean and sound.cargo test -p victory-gpu --lib descriptor:: -- --test-threads=1 --skip dynamic_slots_are_held_until_released(RTX 5090): 22 passed, 0 failed (includingdescriptor_copies_mirror_batched_slots_before_and_after_host_creation).VICTORY_FORCE_WARP=1 cargo test -p victory-gpu --lib descriptor::tests::descriptor_copies_mirror_batched_slots_before_and_after_host_creation -- --test-threads=1(WARP): 1 passed, 0 failed.cargo clippy -p victory-gpu --all-targets -- -D warnings: clean.cargo clippy -p victory-gpu --features diagnostics --all-targets -- -D warnings: clean.cargo xtask policy: 191 files ok.Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).
Imported from Marvisak/VIctory. Originally posted by oni-swr on 2026-11-26T16:10:03Z.
WARP verification report (test report only, no code changes)
6c8fc75463bcca43(control); WARP software adapter forced withVICTORY_WARP=1 VICTORY_D3D12_WARP=1,--features diagnostics, d3d10warp.dll 10.0.26100.9818; dxil.dll 1.8.2502.11 (Windows Kit 10.0.26100.0, viaVICTORY_DXIL).--exact),-j 4, synthetic tests only, no game data. Command:cargo test -p victory-gpu --lib --features diagnostics -j 4 -- --exact <test>.descriptor::tests::descriptor_copies_mirror_batched_slots_before_and_after_host_creation: passes on the PR (1 passed). The changed testsdescriptor::host::tests::a_slot_rewritten_while_its_view_is_prepared_views_the_new_recordanddescriptor::host::tests::views_bound_while_another_slot_gets_its_texture_do_not_waitalso pass (1 passed each).victory-gpulib suite: PR 247 passed, 0 failed, 1 ignored (1 run); main 246 passed, 0 failed, 1 ignored. No failures.AI-assisted: verification by Claude Code (Claude Sonnet 5.5)
Imported from Marvisak/VIctory. Originally posted by Kajanos on 2026-11-26T17:36:46Z.
This PR and #3055 merge cleanly but don't compile together. On
main63bcca4+ #3147 + #3047 + #3048 + #3258 #3274 #3061 #3248 #3246 + #3265 + #3055 + #3068:#3055 replaces the runtime use of
HostHeap::sync_slotswithsync_rangesand leavessync_slotsunder#[cfg(test)], while this PR adds a runtime call to it indescriptor.rs. Whichever lands second needs a rebase onto the other. Both batch heap syncs, so they may also overlap in intent. In that stack I kept #3055 and left this one out.AI-assisted (Claude Code)
Imported from Marvisak/VIctory. Originally posted by KainanP on 2026-11-27T13:06:18Z.
I measured this against
HostHeap::sync_slots/copy costs in the shape #3425 and borosf's Arc row report, on an RTX 4060 Laptop. It's a large win on the path it targets.Bench:
copy_simple_benchonbench/sync-slots(f233390e, on top off34bcfb8; both commits cherry-pick onto this PR cleanly). Each frame, 393,216 slots are copied withcopy_simplein runs of 1/8/64/1024 to random places in a 2^20-slot placed view heap. Each row runs without and with 5 title threads writing a view every 20 µs. After each row, it checks that every slot's view address is the one its record names. Base63bcca4vs this PR's head6c8fc754, interleaved, medians of 3 runs:Copies of records the slots already hold (borosf's "heap slots the title copied": 493,568 slots in 36.6 ms is ~74 ns/slot; base here is 71 ns/slot, so this looks like the in-game case):
Copies that change every record (65,536 slots/frame, 2 runs): the same alone (~45-60 ms both; making the views dominates), and faster under contention for runs ≥ 8 (runs of 64: 167-177 → 50-71 ms; runs of 1024: 167-174 → 45-56 ms). Runs of 1 are unchanged, as expected.
Correctness: 0 wrong slots in every row and run. The PR doesn't touch
sync_heaps. In the same harness's heap-sync bench, it sits within noise of base (×0.81-1.04), which I used as the noise control for the other PRs.AI use: Claude Code (Claude Opus 5.5).
Imported from Marvisak/VIctory. Originally posted by reallyvibe on 2026-11-29T00:22:14Z.
#3139 breaks this PR the same way #3055 does, and the one-line fix costs most of this PR's gain
Following up on Kajanos's note about #3055 above. #3139 (
63d630a0) also keepsHostHeap::sync_slotsonly as a#[cfg(test)]wrapper aroundsync_ranges. #3139 and this PR (6c8fc754) merge with no conflict (treefa989c0b, either order), but on that tree:cargo build -p victory-gpu --libfails:E0599: no method named sync_slots found for reference &HostHeapatdescriptor.rs:193:34;cargo test -p victory-gpu --lib --no-runbuilds, because the test-only wrapper exists. Acargo testrun doesn't show the break; only a non-test build (CI's clippy) does, and only on the merged tree.Whichever of the two lands second needs a change. I tried two:
host.sync_ranges(&[(from, to)], start, step);inmirror_copy. The same line also works against #3055. It builds and passes the correctness checks run here: clippy is clean (default and--all-features), WARPdescriptor::passes 26/26, and with the batched call turned into a no-op this PR's test fails ("a raw write cleared slot 0"). But it gives back most of this PR's gain. Each 256-slot batch then payssync_ranges'sread_into(ReadProcessMemory) plus its range and buffer setup, wheresync_slotsread the records directly.descriptor/host.rs): keepsync_slotsas a production single-range sync with plain reads, i.e. main's body using #3139'swith_views. This PR's call site stays as it is, and #3139'ssync_heapspath still goes throughsync_ranges. It preserves this PR's benchmark performance (table below), and passes clippy (default and--all-features) and WARPdescriptor::26/26. Its assumption that the records' backing memory stays mapped still needs verification: holdingSHADER_HEAPSdoes not necessarily stop those pages from being unmapped, and a self-copy (dst == src) skips the actual copy, so nothing has just written them. The patch's "a descriptor copy just wrote them" comment doesn't cover that case. #3139 movedsync_rangestoread_intofor an earlier probe-to-read race; F3 reintroduces plain reads on the copy path.KainanP's
copy_simple_bench(f233390e), same-record copies, 393,216 slots/frame, no title threads, release, median of 6 interleaved processes, ms:0 wrong slots in every row. With F1, runs of 8 come out slower than main. A diagnostic that swaps
read_intofor a plain copy insidesync_rangescuts F1's runs of 8 from 54 to 28 ms, soReadProcessMemoryis about two thirds of the overhead and per-call setup is the rest. With 5 title threads, the runs of 64 come out at 68 ms on this PR, 120 ms with F1 and 72 ms with F3 (noisy here). Windows 11, Ryzen 7 7445HS, RTX 4050 Laptop and Radeon 740M (default D3D12 adapter, not logged), a loaded 16 GB machine, synthetic data only.F3 against the merged tree (experimental)
Of the 184 open PRs that touch these two files, this is the only one that adds a non-test
sync_slotscall. The others call it only from tests, or edit thesync_heapscall, which conflicts visibly.AI-assisted (Claude Code).
Imported from Marvisak/VIctory. Originally posted by zed6000 on 2026-11-29T17:41:52Z.
A/B of this PR on an RX 7900 XTX (native Windows 11, AMD driver 32.0.32029.2010, Ryzen 9 7900X3D), from neonbyte1/VIctory#64.
6c8fc7547merged onto the neonbyte1/VIctory integration tree8d9b82fd9. The conflicts were adjacent additions, and the merge iseb0d613beon zed6000/VIctory brancheval/64-3265. The control is the same tree without the PR. Both are diag builds sharing one warm pipeline library.heap slots the title copiedtitle threads waiting to write viewsdescriptor::tests 53/53, the PR's new test included.CopyDescriptorsSimple, so the 28 → 5 ms copy figure from #3425 is not checked by this. What it shows is that, in this scene on this card, the frame does not move with the PR. On this box the frame follows the heap sync's holds and the view writers' wait (neonbyte1/VIctory#146), and those stay where they were.AI-assisted (Claude), posted for zed6000; counts and times from VIctory's own report lines; no game data shared.
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.