D3D12.X: the per-draw mirror sync checks its source with readable() at every draw #2392
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
goal:world-load
good first issue
help wanted
invalid
keep-open
off-goal
question
stale
test-only
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/xcl-dev--xcl#2392
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
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?
@KOLESNiii on GitHub · 2026-11-25 17:43 UTC · original
Part of #2389.
On every draw with a mirrored vertex or index buffer,
sync_title_buffers(crates/xcl/src/hle/d3d12x/list_x.rs:3556-3562onmain3f4495a) checks the source range withgpu::shader::readablebefore copying it. The indexed path does the same over the index range (list_x.rs:3572). For more than 16 pages (64 KiB),resident_and_readablegives up andreadablewalks the range withVirtualQuery. The comment onresident_and_readable(gpu/shader.rs:232-238) measures that at 20–25 ms a call in a title's 2 GB block of committed memory.#693 took this check out of the bind for the same reason ("most of a retail title's render thread at a bind per draw"), but the per-draw copy still makes it. Any instanced draw, or any draw with a non-zero first instance, copies the whole buffer (
list_x.rs:3597). So a mirrored buffer of more than 64 KiB pays aVirtualQuerywalk on each of those draws.Proposal: check a mirror's source once, when
mirror_ofcreates the mirror (it already callsreadablethere), and keep the result until kernelx frees, decommits or reprotects memory in that range. A generation counter thatVirtualFree/VirtualProtect/ decommit bump would do: compare it per draw, and check again only when it has changed.Test: a mirrored range stays copied without a
readablecall while nothing is freed, and it is checked again (and skipped when it is no longer readable) after a decommit in that range.Found by code reading with Claude Code (Claude Opus 5.5); not measured yet. #2391 gives the numbers.