GPU: batch resource barriers, reuse draw scratch buffers, range-lock copy_simple, and pool list uploads #1382
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1382"
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 wbkepler on 2026-11-24T17:40:06Z.
Summary
Rebased cleanly onto
upstream/main(ffe310e):HostListResourceBarriercalls (coalescing same-resource transitionsA->B->CintoA->C, cancellingA->B->Around-trips, and deduplicating consecutive global UAV barriers) and flushes once beforeDraw/Dispatch/Copy/Resolve/Clear/ExecuteIndirect/Close.Vecs across draws and resets indraw::State::bindandState::tables, and replaces small heapVecs inset_targets/SetDescriptorHeapswith fixed stack arrays.descriptor::copy_simpleviamirror_rangeandviews_at_batchsoSHADER_HEAPS,pending,VIEWS,made, andkeptare acquired once per copy range instead of per slot.HostList::uploadallocations onto 512-byte-alignedScratchupload chunks (plus a small capped pool for oversized>4 MiBuploads) reused acrossHostList::reset().copy_simpleparity, and pooled upload reuse across resets.Verification
cargo clippy -p victory-gpu --all-targets&-p victory --features diagnostics --all-targets— passedcargo test -p victory-gpu— passedcargo xtask policy— passedImported from Marvisak/VIctory. Originally posted by catminou4 on 2026-11-24T20:49:53Z.
Review: COMMENTED
Static review only: victory-gpu is Windows-only (D3D12/windows_sys) — nothing compiles or runs on macOS; this is source review of a large diff plus the PR's own Windows tests.
Resource barriers are batched (queue_barrier/queue_transition/flush_barriers with pending_barrier_count), draw scratch buffers are reused, and copy ranges are range-locked (mirror_range/views_at_batch + copy_simple_range_lock_matches_single_slot_mirroring test comparing batched vs single-slot mirroring). Batching barriers changes ordering only if flush points are right — the mirror-equivalence test is the key evidence; please make sure flush_barriers is called at every point the old code submitted. Windows-only.
Imported from Marvisak/VIctory. Originally posted by wbkepler on 2026-11-24T22:02:56Z.
Rebased onto
70564aeasbf8a9b2(squashed to one commit; conflicts resolved by re-applying each part on top of upstream's new code).Kept, adapted to upstream
ensure_state, title barriers and barrier groups queue per host list and go out in oneResourceBarrierbefore the next command. Every path that records a command or its own barrier flushes first. That covers draws, dispatches, mesh and indirect work (before the clamp and beforedone), copies, resolves, RTV/DSV/UAV clears, texture uploads and alias copies,twin::route(so queued transitions land before the depth/twin copy),external::host_texture/record, and the diagnostics read-backs.close()flushes as well. Folding no longer touches split barriers. A cancelledUAV -> X -> UAVnow becomes a UAV barrier instead of disappearing, so back-to-back shader writes stay ordered.HostList::upload: unchanged in intent. It hands out 512-byte aligned scratch slices and keeps up to 2 big buffers across resets.bind_heaps(memory heap first, as upstream orders it).Dropped as superseded
tables()scratch rewrite. Upstream no longer makes every constant-buffer table fresh, sofresh/madestay emptyVec::new()(no allocation) on the common path.HostHeap::mirror_range. Upstream'sHostHeap::mirrorchanged a lot (stride table,viewed, placed textures, buffer views made on write), so a copy of it would drift.copy_simplenow looks the heap up and takespendingonce per range, then calls upstream'smirrorper slot. Slots past the heap still go one by one..rev()inshader_slot(not needed).Verification: clippy
-D warnings(victory-gpu, and victory with diagnostics),cargo test -p victory-gpuandcargo xtask policyall pass. New tests: barrier folding/flush on the device, upload pooling across resets, and per-slot mirroring bycopy_simple. Two tests fail identically on plainupstream/mainon this host:dynamic_slots_are_held_until_releasedandlists_share_a_table_and_copies_keep_their_views.Interaction with #1331: #1331 already conflicts with
upstream/mainitself, in the same 2 places, and this PR adds no new conflict region. The resolution:State::bind, keep upstream'stake_rebind+memory_heap+self.bind_heaps(list, memory_heap).bind_heaps: build the host heap array first, then compare and store the host heaps'as_raw()identities inhost_heapsinstead of the title addresses inwant. This needs room for the memory heap's identity too.#[cfg(test)] mod testsat the end ofdraw.rs.AI-assisted (Claude Code); checked on Windows 11 / RTX 5090.
Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T01:24:46Z.
Automated triage for the maintainers.
Needs rebase. This pull request conflicts with
main(conflicting:crates/victory-gpu/src/host.rs). It will be reviewed once it is rebased onto the currentmain.Generated by Claude Code
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.