GPU: eliminate redundant per-draw/dispatch D3D12 state calls, cache ID3D12GraphicsCommandList6, and remove double shadow::find #2217
No reviewers
Labels
No labels
accessibility
area: build
area: formats
area: gpu
area: loader
area: runtime
area: shader
bug
documentation
duplicate
enhancement
good first issue
gpu: amd
gpu: intel
gpu: nvidia
help wanted
host: wine
invalid
out of scope
question
request
run report
triage: confirmed
triage: has patch
triage: merge candidate
triage: needs info
triage: needs rebase
triage: needs work
triage: proposed close
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/Marvisak--VIctory!2217
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/2217/head"
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?
@RVZO6 on GitHub · 2026-11-25 08:06 UTC · original
RVZO6:rvzo/draw-state-dedup→main· +777 −153 · 3 files · 1 commits · closed without mergingEvery 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)
@Marvisak on GitHub · 2026-11-25 13:30 UTC · original · edited 2026-11-25 16:04 UTC
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
@RVZO6 on GitHub · 2026-11-25 17:14 UTC · original
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