D3D12.X: the per-draw mirror sync copies without asking readable() #2437
No reviewers
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!2437
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-2437"
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 18:54 UTC · original
KOLESNiii:d3d12x-mirror-sync-no-readable→main· +254 −8 · 3 files · 2 commits · openStacked on #2416; only the top commit (
D3D12.X: the per-draw mirror sync copies without asking readable()) belongs here.sync_title_bufferschecked every copy's source, and the indices it scans, withgpu::shader::readable. For a range with a page that is not resident, or over 16 pages, that walks the region withVirtualQuery; the measurement on #2389 saw single calls take 1.1–8.8 ms on the render thread inside a draw. The copy now usestitle_textures::copy_committed_region(ReadProcessMemory, which cannot fault), and the indices are scanned from the index buffer's mirror once copied there.Fixes #2392. Part of #2389.
This differs from the proposal in #2392 (check once per mirror, again after kernelx frees or reprotects memory): kernelx does not see
HeapFree, which releases large heap blocks inside ntdll, so that design still needed a copy that cannot fault, and with one the check had nothing left to protect. No kernelx change.What is in it
crates/xcl/src/hle/d3d12x/list_x.rs: the copy goes throughcopy_committed_region; a page the title freed or protected since keeps what the mirror had (before,readablefailed and none of the range was copied). Indices are read from the mirror; an index buffer without a mirror is still checked withreadable. Two tests:the_mirror_sync_copies_around_a_page_the_title_made_unreadable, andthe_mirror_sync_copies_whole_buffers_around_a_page_the_title_made_unreadablefor the other paths with a vertex page made unreadable (an index buffer without a mirror giving the vertex range, a draw with instances, an unreadable index buffer without a mirror: both copy the whole buffer around the page).crates/xcl/src/hle/d3d12x/title_textures.rs:copy_committed_regionispub(super).Tested
NVIDIA RTX 2070 SUPER (driver 32.0.16.2140), AMD Ryzen 5 3600XT, Windows 11 build 26300, Rust 1.100.0; tests in debug, runs in release.
cargo test --workspace -- --test-threads=4one426972(rebased onto #2416's review fix): 1427 passed, 0 failed, 46 ignored; 25 SKIPPED (21no wave64, 3 refused #1426 forms, 1no heap windows, as onmain).Both new tests fail without the change ("the first page is copied", "the whole buffer is copied") and pass with it.
Retail game, menus, 120 s (on the earlier head
bb9bea2) with its learned coherent window removed so mirrors are made (a 384 KiB index buffer and a 1.1 MiB vertex buffer at 32.5 s),XCL_ACTIVITYcounters from #2416, 43 two-second windows each, mean per 2 s:bb01e85)readable()calls, timereadable()The time
readable()took went to the copy instead: no change on average. The slowreadable()calls of #2389 (1–9 ms) did not occur in thebb01e85run, so this run does not show the stall going away; what the change removes is the code path that made it.Regression run
main:This PR:
Not tested
AI use
🤖 Generated with Claude Code
@SlopTart on GitHub · 2026-11-25 19:46 UTC · original
gpu_suite (cold cache): 160 passed / 4 failed, no crashes. Three are the known baseline trio on this lane; the fourth isgpu_promoted_uav_clear_values_pass_create_committed_resource, newly red on main since #2280 (report), unrelated to this PR.Targeted run of
the_mirror_sync_copies_around_a_page_the_title_made_unreadable: passed.@DavidM1911 on GitHub · 2026-11-25 19:54 UTC · original
Verification on RTX 3060 Ti (Windows 11), branch merged with current
main:cargo test -p xcl --lib: all passed, 0 failed, ~26 ignored. (Intermittent single-test flake / 0xc0000005 abort under parallel scheduling — tracked in #1978; clean on single-threaded rerun.)Thanks!
@emirduran707 on GitHub · 2026-11-25 20:50 UTC · original
Independent AMD RDNA4 (native wave64) test report on exact head
bb9bea21b5ab3520e4f8cfa1ffe5f4afd988efeb(clean detached checkout, no local changes).Tested
stable-x86_64-pc-windows-msvc), DXC 1.9.2602.17; tests debug, smoke release.cargo build --workspace && cargo test --workspace --no-fail-fast -- --test-threads=4: 1274 passed, 2 failed, 46 ignored; 8 SKIPPED (6 inlower_dxil::tests::{f16,f32}_programs_on_the_gpurefused by per-lane form;heap_window_out_of_memory_falls_back_to_the_switch_form;pso_measurement_compiles_an_exact_synthetic_record). All native wave64 GPU tests ran and passed.hle::d3d12x::list_x::tests::the_mirror_sync_copies_around_a_page_the_title_made_unreadable.gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_1seed 722 andfuzz_validate_and_gpu_3seed 1599) are pre-existing on unmodifiedmainon this GPU.Regression run (60 s retail-title smoke,
XCL_NETWORK=0, release)(Matched
main68a284abaseline on the same machine today: 1573 frames, 14420 MB peak, 0 device removals, 0 crashes.)Not tested
AI use
@KOLESNiii on GitHub · 2026-11-25 22:39 UTC · original
Thanks. On the three points:
XCL_ACTIVITYoverhead: fixed in #2416 (the counters are off untilhost_mainenables them forXCL_ACTIVITY). This PR is rebased onto it; head is nowc24fbbf, on #2416'sfdbb6fe.the_mirror_sync_copies_whole_buffers_around_a_page_the_title_made_unreadable. With a vertex page made unreadable it checks three things: an index buffer without a mirror gives the vertex range when it is readable; a draw with instances copies the whole buffer around the page; an unreadable index buffer without a mirror does the same. It fails without the change. A title run still does not reach these paths; that is under Not tested.cargo test --workspace -- --test-threads=4onc24fbbf(RTX 2070 SUPER): 1426 passed, 0 failed, 46 ignored, 25 SKIPPED. TheCIworkflow for this fork PR is waiting for a maintainer to approve it (action_required). New smoke block in the description.(Claude Code, Claude Opus 5.5)
@DavidM1911 on GitHub · 2026-11-26 02:12 UTC · original
Re-verification on RTX 3060 Ti (Windows 11), new head merged with current
main:cargo test -p xcl --lib: all passed, 0 failed, 27 ignored. The earlier merge conflict is resolved.Thanks!
— Devin
c24fbbff5etoe4269721c2@bmjask on GitHub · 2026-11-25 20:49 UTC · original · reviewed
No concrete source-level defect found. copy_committed_region preserves prior mirror bytes for inaccessible pages while copying surrounding committed data, and mirrored-index range selection matches what the GPU draws; the focused test is useful. Merge evidence is incomplete: no current Windows build/test, and title validation did not exercise inaccessible sources, whole-buffer copies, instancing, or unmirrored indices. The XCL_ACTIVITY overhead is inherited from stacked #2416 and should be addressed there.
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.