D3D12.X: the per-draw mirror sync copies without asking readable() #2427
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/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?
Imported from ivall/xcl. Originally posted by KOLESNiii on 2026-11-25T18:54:10Z.
Stacked 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_pages(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_pages; 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_pages(pub(super)), added in the rebase. It iscopy_committed_regionwithout the zeroing of unreadable pages thatmainadded for texture reads (b84e0378). With that zeroing, the sync would overwrite such a page of the mirror with zeros, andthe_mirror_sync_copies_around_a_page_the_title_made_unreadablewould fail.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.
Current head
1de6652e(rebased ontomain765b2c5bto resolve conflicts): the suite has not been rerun on it; the counts below are from the earlier heads they name.Rebased onto
main336fdddaon 2026-11-28.cargo build --workspace && cargo test --workspace --no-fail-fast -- --test-threads=4onedee42d3: 2126 passed, 9 failed, 48 ignored; 25 SKIPPED (21no wave64, 3 refused #1426 forms, 1no heap windows). The 9 failures are #3093's, the same 9 tests that fail onmain336fddda(2122 passed, 9 failed, 48 ignored, same skips). The results below are from before the rebase.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
Current head
1de6652e, rebased ontomain765b2c5bon 2026-11-28 to resolve conflicts withmain. RTX 2070 SUPER, the retail game, 60 s,XCL_PRESS_AT=25:A,XCL_PREPARE=0(no startup shader preparation), release builds; each run started from a copy of the same DXIL cache (one queue job:main, then PR heads one after the other).main:This PR's head:
Not tested
XCL_PREPARE=0): shaders are built when the title first uses them, onmainand on this PR alike.AI use
main336fddda, ran the suite and the regression runs and updated this description.🤖 Generated with Claude Code
Imported from ivall/xcl. Originally posted by SlopTart on 2026-11-25T19:46:24Z.
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.Imported from ivall/xcl. Originally posted by DavidM1911 on 2026-11-25T19:54:42Z.
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!
Imported from ivall/xcl. Originally posted by bmjask on 2026-11-25T20:49:15Z.
Review: COMMENTED
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.
Imported from ivall/xcl. Originally posted by emirduran707 on 2026-11-25T20:50:12Z.
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
Imported from ivall/xcl. Originally posted by KOLESNiii on 2026-11-25T22:39:32Z.
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)
Imported from ivall/xcl. Originally posted by DavidM1911 on 2026-11-26T02:12:22Z.
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
upstream-sync referenced this pull request2026-11-26 07:02:13 +00:00
xcl nvprofileputs xcl.exe in an NVIDIA profile with a bigger shader heap (#2403) #2580Imported from ivall/xcl. Originally posted by Prime1997 on 2026-11-26T13:06:14Z.
Review: COMMENTED
Good within the reviewed scope; retain for integration. The owned-memory mirror-copy change is worth keeping. It copies the readable portions around inaccessible pages and preserves prior destination bytes for inaccessible spans.
PR head
e4269721c2795213b996c09ce0b90daf4c461287integrated locally with current mainb49be1836844fe0b0cdb3211dce3cb7fb4e21ac7. The detached worktree remains at main with the combined changes staged, treee2e760fee2adae36ee394e4ef9affaa79ea87b2a; it is an uncommitted integration candidate, not a clean PR-head run. Source patch SHA-256e7b219da2d886b5b1885a4fc3d0d469df9f3f15f87b2beb9e468a4ada1dfdd0c.Targeted result: 2 passed, 0 failed, 0 ignored, 0 skipped. Each exact filter ran in a fresh process:
hle::d3d12x::list_x::tests::the_mirror_sync_copies_around_a_page_the_title_made_unreadablehle::d3d12x::list_x::tests::the_mirror_sync_copies_whole_buffers_around_a_page_the_title_made_unreadableBuild:
cargo test --locked --offline -p xcl --lib --no-run --message-format=json --target-dir <isolated-target>. Run:<test-exe> <each-exact-filter-above> --exact --test-threads=1 --nocapture. Private executable/target paths are placeholders. Windows 11 Pro 26200, i5-10400, 32 GiB RAM, Rust 1.100.0 MSVC debug. These selected fixtures did not dispatch GPU work.Not tested: These are two owned-memory CPU fixtures, not GPU mirror coherence or a title performance measurement. The integration includes the PR stack parent #2416; it is not a standalone top-commit test. No whole suite or retail smoke was run for this batch; this is not merge certification.
AI use: Codex (GPT-6) reviewed source, ran the selected tests and verified raw results. Optional temporary Discord for coordinating contributor work, testing and comparing results.
Imported from ivall/xcl. Originally posted by Decodere on 2026-11-26T17:11:01Z.
Independent RTX 4060 (8 GB) / Windows 11 release verification of PR #2437 at
e4269721c2795213b996c09ce0b90daf4c461287(2 commits on merge-baseorigin/maine1d84b7d9153f86a97d2ec5d209d196046fc0bea; stacked on parent PR #241649f04749263990a586038c9adb19bba1eaac1828). Measurements and targeted test results only; not a full source review.Setup
7956 MiBreported by D3D12), driver32.0.16.2114(NVIDIA621.14, WDDM 3.2)31.9 GiBusable), Windows 11 Home26200rustc 1.100.0 (0ef1bc386 2026-11-09), DXC1.9.2609.5, release builds, warm DXIL/pipeline caches, quiet machine (zero concurrent builds/tests during timed runs)title: 29640639viascripts/smoke.ps1 -Seconds 60(XCL_NETWORK=0, default flags, no input)Targeted RTX 4060 release unit & GPU tests (
e4269721)cargo test --release -p xcl --lib the_mirror_sync_copies_around_a_page_the_title_made_unreadable -- --nocapture: 1 passed, 0 failed, 0 ignored (0.02 s,0SKIPPED).cargo test --release -p xcl --lib the_mirror_sync_copies_whole_buffers_around_a_page_the_title_made_unreadable -- --nocapture: 1 passed, 0 failed, 0 ignored (0.02 s,0SKIPPED).cargo test --release -p xcl --lib the_mirror_sync_counts_only_once_xcl_activity_enables_it -- --nocapture: 1 passed, 0 failed, 0 ignored (0.02 s,0SKIPPED).cargo test --release -p xcl --lib a_mirror_sync_row_with_no_finished_draw_is_still_logged -- --nocapture: 1 passed, 0 failed, 0 ignored (0.00 s,0SKIPPED).cargo test --release -p xcl --lib hle::d3d12x::title_textures::(3 consecutive parallel passes): 19 passed, 0 failed, 0 ignored on all 3 passes (0.82 s/0.80 s/0.79 s,0SKIPPED).cargo test --release -p xcl --lib hle::d3d12x::list_x::(3 consecutive parallel passes): 44 passed, 0 failed, 0 ignored on all 3 passes (0.78 s/0.77 s/0.78 s,0SKIPPED).Paired 60 s RTX 4060 smoke (merge-base
e1d84b7dvse4269721)Both runs completed cleanly at steady 60/2 s pacing with
0device removals and0crashes (e4269721vse1d84b7dxcl.log:6,176/6,115 MBvs6,116/6,116 MBpeak/end local VRAM,4,682 MBvs4,650 MBend non-local VRAM,19,459vs19,261translated draws /1,024dispatches with0skipped).Merge-base
origin/main(e1d84b7d):PR #2437 head (
e4269721):Limits of coverage
e4269721(only the 4 targeted tests individually, 3 parallel passes each oftitle_textures::andlist_x::, release build, and paired 60 s smokes).XCL_ACTIVITY=1or heavy in-world mirrored-buffer churn; copying around unreadable pages withoutreadable()was exercised by the targeted release unit tests above rather than live unreadable-page faults during the smoke.RTX 4060) on native Windows 11; no AMD, Intel, or Wine/Linux run on this host.AI use
Ran the targeted release unit/GPU tests, release build, and paired quiet 60 s smoke runs with assistance from Google Antigravity (Gemini 4 Neon); all test counts, timings, memory figures, and smoke blocks were extracted directly from
cargo test,xcl.log, andscripts/smoke.ps1outputs.Imported from ivall/xcl. Originally posted by thehollowedone on 2026-11-26T18:53:10Z.
Independent Windows RTX 3080 Ti test of PR #2437 head
e4269721c2795213b996c09ce0b90daf4c461287, stacked on #2416 at49f04749. Clean detached checkout; NVIDIA RTX 3080 Ti (driver 621.35), Windows 11 build 26300, rustc 1.99.1 MSVC, DXC 1.8.2502.11.Tested
cargo build --offline --locked --workspace: passed.cargo test --offline --locked -p xcl --lib the_mirror_sync_copies_ -- --test-threads=1 --nocapture: 2 passed, 0 failed, 0 ignored, covering both new inaccessible-page mirror-copy tests.cargo test --offline --locked --workspace --no-fail-fast -- --test-threads=4 --nocapture: 1,426 passed, 1 failed, 46 ignored across 37 test targets. There were 25 GPU skip notices: 21 no wave64, 3 unsupported per-lane forms (#1426), and 1 no heap windows. These skips are not GPU coverage.gpu::recomp::pso::shader_cache_tests::console_mesh_caches_hlsl_compute_pass_in_memory_and_on_disk(cached_only console_mesh hit: "DXIL not compiled yet"). A separate exact-filter run also failed on this head (0 passed, 1 failed) and on its exact parent49f04749263990a586038c9adb19bba1eaac1828with the same error (0 passed, 1 failed). This comparison points to an existing failure on the stack parent; the full suite is still red here.Not tested: Retail title smoke or pacing, AMD/Intel GPUs, inaccessible-source behavior in a title run. The two focused fixtures are synthetic; I made no title-performance claim.
AI use: Codex (GPT-6.2 Sol) selected and ran the tests, checked the exact revisions and results, and drafted this report.
Imported from ivall/xcl. Originally posted by thehollowedone on 2026-11-26T18:58:19Z.
Correction to my earlier exact-head #2437 report: the shader-cache failure was sensitive to the DXIL cache location in this test environment.
On the same clean head
e4269721c2795213b996c09ce0b90daf4c461287, I setXCL_DXIL_CACHEto a fresh writable directory under this worktree, then rancargo test --offline --locked --workspace --no-fail-fast -- --test-threads=4 --nocapture. Result: 1,427 passed, 0 failed, 46 ignored across 37 targets, with the same 25 GPU skip notices (21 no wave64, 3 refused per-lane forms, 1 no heap windows).console_mesh_caches_hlsl_compute_pass_in_memory_and_on_diskpassed in the suite and in a separate exact-filter run (1 passed, 0 failed, 0 ignored). The two new mirror-copy tests had already passed 2/2 without this cache setting.Without that setting, the exact shader-cache filter failed on both this head and its parent with
DXIL not compiled yet. The test needs a persisted pass-through DXIL file for itscached_onlyrepeat; this controlled rerun is consistent with a default-cache-path problem here. I did not directly prove which default-path write failed. The earlier red suite should not be read as evidence that #2437 introduced a shader-cache regression.Same RTX 3080 Ti / Windows 11 setup as the linked report. No retail run or title pacing measurement. AI use: Codex (GPT-6.2 Sol) traced the cache path, ran the controlled tests, checked the results, and drafted this correction.
Imported from ivall/xcl. Originally posted by a-DuckGod on 2026-11-26T19:15:36Z.
Independent full-suite Windows 11 / NVIDIA test report on exact PR head
e4269721c2795213b996c09ce0b90daf4c461287(clean detached checkout; merge-basee1d84b7d; stacked on #2416).Tested
rustc 1.100.0 (0ef1bc386 2026-11-09)(x86_64-pc-windows-msvc), Windows SDK DXC1.8.2502.11, D3D12 debug layer installed, debug build.cargo build --workspace: succeeded.cargo test -p xcl --lib the_mirror_sync -- --nocapture: 3 passed, 0 failed, 0 ignored, 0 skipped (the_mirror_sync_copies_around_a_page_the_title_made_unreadable,the_mirror_sync_copies_whole_buffers_around_a_page_the_title_made_unreadable,the_mirror_sync_counts_only_once_xcl_activity_enables_it).cargo test -p xcl --lib a_mirror_sync_row_with_no_finished_draw_is_still_logged -- --nocapture: 1 passed, 0 failed, 0 ignored, 0 skipped.cargo test --workspace --no-fail-fast -- --test-threads=4: 1427 passed, 0 failed, 46 ignored (including alle2etests under the D3D12 debug layer and DRED).SKIPPEDGPU tests (25): 20no wave64(RTX 3080 Ti is 32-lane waves only), 3 per-lane #1426 refused forms (V_MUL_F16,V_PK_MUL_F16,V_CVT_F16_F32), 1shaders::tests::pso_measurement_compiles_an_exact_synthetic_record(cannot disable driver cache; Windows Developer Mode required), 1heap_window_out_of_memory_falls_back_to_the_switch_form(no heap windows).Not tested
scripts/smoke.ps1run,XCL_SAMPLE_*tests, AMD / Intel / native wave64 GPUs.AI use
e4269721(andcopy_committed_region), ran the build and tests, and drafted this report. I checked it before posting.Imported from ivall/xcl. Originally posted by KOLESNiii on 2026-11-26T19:35:38Z.
Thanks for the follow-up. That diagnosis is right, and the failure isn't in this PR: on
main,console_mesh_caches_hlsl_compute_pass_in_memory_and_on_diskwrites the pass-through MS DXIL to the default%LOCALAPPDATA%\xcl\dxil, and itscached_onlyrepeat needs that file. When the folder can't be written, the store fails silently and the repeat getsDXIL not compiled yet. I reproduced it by pointingLOCALAPPDATAat a file; with a writable default cache the test passes.AI use: Claude Code, Claude Opus 5.5.
Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T08:04:39Z.
Triage (#1607) – head
1de6652This is stacked on #2416; only the top commit belongs here. #2533 is stacked on this PR and contains this commit, so it is not a competing change. Main's
sync_title_buffersstill callsreadable()before every copy and before scanning the indices.The diff matches the description, with two mismatches: the description names the new helper
copy_committed_region_keeping, but the code addscopy_committed_pagesin title_textures.rs. The commit body also has a line missing before 'reprotects memory. kernelx does not see HeapFree…'. No problems found in the code. The branch conflicts with main.Recommendation: keep open.
AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human.
Imported from ivall/xcl. Originally posted by KOLESNiii on 2026-12-02T15:33:52Z.
@Foniass fixed both mismatches:
copy_committed_pages(the helper the sync calls,title_textures.rs), notcopy_committed_region_keeping;copy_committed_pagestoo.No code change. Rebased onto #2416's new head; new head
2935bc3b. Suite and smoke are queued again.— Claude Code (Claude Opus 5.5), on behalf of the PR author
Imported from ivall/xcl. Originally posted by Foniass on 2026-12-02T15:35:12Z.
Follow-up review (head
2935bc3b, since1de6652, diff read, not a merge-check; checks red):main, with the copy renamed totitle_textures::copy_committed_pagesasmainnow calls it and the commit message reworded (#2533 carries the same commits).New: none.
AI review: Claude Code (Claude Opus 5.5), posted by Foniass without a human check of each point.
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.