GPU: eliminate redundant per-draw/dispatch D3D12 state calls, cache ID3D12GraphicsCommandList6, and remove double shadow::find #2215
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2217"
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 RVZO6 on 2026-11-25T08:06:05Z.
Every draw, mesh dispatch, and compute dispatch currently re-issues redundant D3D12 command-list state calls even when the host command list already has the exact same state bound:
State::bind()re-emits all root CBVs, SRVs, UAVs, and 32-bit constants (includingp.marks,VIEW_STRIDES,view_addresses, andmemorytables) on every draw/dispatch even when the root signature and values are unchanged.State::prepare_for()re-scans all vertex buffers and callsIASetVertexBuffers/IASetIndexBufferon every draw even when VB/IB bindings,p.slots, andHostListdeferred copies have not changed.list.rsforwardsIASetPrimitiveTopology,RSSetViewports,RSSetScissorRects,OMSetBlendFactor, andOMSetStencilRefstraight onto the host command list without deduplication.State::dispatch_mesh()callslist.list.cast::<ID3D12GraphicsCommandList6>()(QueryInterface) on every mesh dispatch.readable()callsshadow::find()twice forView::Constanteven thoughlen <= s.left(address)guarantees the first lookup already covers[address, address + len).Claimed on #1633 (
https://github.com/Marvisak/VIctory/issues/1633#issuecomment-7155911614).The change
crates/victory-gpu/src/host.rs:list6: Option<ID3D12GraphicsCommandList6>once onHostListinHost::new_list().copy_epoch: AtomicU64+HostList::copy_epoch(), bumped indefer_copy,defer,defer_gpu_write, andreset.crates/victory-gpu/src/draw.rs&crates/victory-gpu/src/list.rs:HostStateCacheindraw.rs:bound_roots: [Vec<BoundParam>; 2]) while keeping allshadow::refresh,shadow::gpu_writes,memory_map, andmap.preciseside effects intact. Clears affected slots on root-signature switch, descriptor-heap switch, compute rebind (take_rebind()/execute_indirect),host_state_lost(), andreset(). Validatesp.marksup front and binds afterfor stageso depth-twin compute rebinds duringtables()cannot leave compute mark bindings unset.vb_dirty,ib_dirty,bound_vb_slots,bound_vb_epoch, andbound_ib_epochagainstlist.copy_epoch(), invalidating on VB/IB mutations, rectangle-list scratch expansion,p.slotsexpansion,copy_epochadvances,host_state_lost(), andreset().topology,viewports(bitwisef32::to_bits),scissors,blend_factor(bitwisef32::to_bits, normalizingNoneto[1.0; 4]per D3D12), andstencil_refrouted throughlist.rswith_state.State::dispatch_mesh()to use cachedlist.list6.as_ref().shadow::find(address, len)inreadable()forView::Constant.host_state_cache_dedups_root_params_and_invalidates_on_switches,host_state_cache_tracks_vb_ib_slots_mutations_and_copy_epoch, andhost_state_cache_dedups_fixed_function_state_bitwise.Not a duplicate of
No open PR or
CLAIMS.mdentry deduplicates per-draw/dispatch root parameters, VB/IB binds, or fixed-function D3D12 state, cachesID3D12GraphicsCommandList6onHostList, or removes the doubleshadow::findinreadable().Tested
windows-latestMSVC + Windows WARP SM 6.6 CI run45572159221(Clippyclean,Clippy, diagnostics buildclean,Tests:715 passed; 0 failed; 10 ignored,victory-gpu:157 passed; 0 failed; 2 ignored+1 passed,xtask:6 passed; 0 failed):draw::tests::host_state_cache_dedups_root_params_and_invalidates_on_switches ... okdraw::tests::host_state_cache_tracks_vb_ib_slots_mutations_and_copy_epoch ... okdraw::tests::host_state_cache_dedups_fixed_function_state_bitwise ... okNot run: the title; any hardware GPU. The title was not used in these tests.
AI-assisted: T3 Code (Antigravity, gemini-4-neon)
Imported from Marvisak/VIctory. Originally posted by DenRakEiw on 2026-11-25T08:22:55Z.
Review: APPROVED
Verified locally merged onto
origin/main(940d32f, Windows 11 x64, NVIDIA GeForce RTX 5090, Rust 1.98.1 MSVC):cargo test -p victory-gpu --lib draw::tests::— 8 passed, 0 failed on RTX 5090cargo clippy -p victory-gpu --all-targets— 0 warningscargo xtask policy— ok (183 files ok)Clean elimination of redundant per-draw/dispatch D3D12 state calls, cached
ID3D12GraphicsCommandList6, and removal of duplicateshadow::find. Looks great.AI-assisted (Gemini 4 Neon).
Imported from Marvisak/VIctory. Originally posted by catminou4 on 2026-11-25T08:48:22Z.
Review: COMMENTED
Eliminates redundant per-draw/dispatch D3D12 state tracking via a BoundParam model of last-bound root values (+777/-138). Static review only: victory-gpu/victory-hle are Windows-only (D3D12/windows-sys); not compiled or tested on this macOS arm64 host. rustc 1.98.1. Largest refactor in this wave; worth a Windows hardware pass before merge.
Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T13:30:34Z.
Automated triage for the maintainers.
This pull request no longer merges cleanly into
main(conflicts incrates/victory-gpu/src/draw.rs,crates/victory-gpu/src/host.rs,crates/victory-gpu/src/list.rs). It will be reviewed once it is rebased onto the currentmain. The earlier verdict (needs-work) was for an older state ofmain.Generated by Claude Code
Imported from Marvisak/VIctory. Originally posted by RVZO6 on 2026-11-25T17:14:01Z.
Closing to keep the queue clean:
draw.rs/host.rsmoved significantly on13f91caand I do not have a title run to profile per-draw D3D12 state savings.Pull request closed