D3D12.X: stage GPU-view CopyMemoryToMemoryX sources and shift newer CL1 remaps #1985
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1995"
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 raylitebull on 2026-11-25T00:29:41Z.
Stages GPU-view
CopyMemoryToMemoryXsource ranges (kernelx::mirrors::source_range,resolve_readable_source,list_x::MIRRORS) and shifts vacated older CL1 command-list remap slots104/105to console-extension stubs whenQUEUE_SHIFTED == true.Part of #1833.
What is in it
crates/xcl/src/hle/kernelx.rs: addmirrors::source_range(va, len)enforcing(va - gpu) + len <= sizeend-of-range bounds on GPU mirror reservations (preserved alongside#1985'smirrors::gpu_views_of).crates/xcl/src/hle/d3d12x/list_x.rs: routecopy_memory_x(saturating_addoverlap check) throughresolve_readable_source, and keylist_x::MIRRORSby(title_start, cpu_src_start, len, uma_mirror)so repeatedgpu_vabinds hitmirrored(va, bytes)directly with zero per-drawVirtualQuerywhilesync_title_buffersreads fromcpu_src_start.crates/xcl/src/hle/d3d12x/real.rs: route vacated older CL1 slots104/105to console-extension stubs whenQUEUE_SHIFTED == trueand add unit testsresolve_readable_source_accepts_direct_and_rejects_unmappedandnewer_cl1_slots_shift_older_cl1_remaps_by_two.Tested
rustc 1.99.1 (58cf8f9c3 2026-10-13), rebased cleanly ontof368928(bdfb2fb).cargo check --workspace --tests: passed onbdfb2fb.cargo test -p xcl --lib resolve_readable_source_accepts_direct_and_rejects_unmapped: passed onbdfb2fb.cargo test -p xcl --lib newer_cl1_slots_shift_older_cl1_remaps_by_two: passed onbdfb2fb.50ef7dc): verified across AMD Radeon RX 9070 (1635/1623frames, 0 device removals/crashes,@Toons29), NVIDIA RTX 3060 Ti, and Intel Arc A770.Regression run
bdfb2fb1by@Toons29(AMD Radeon RX 9070, 60 s retail title smoke vs1a0bbe3a):0device removals,0crashes,1628 -> 1627frames (100%),14561 -> 14598 MBpeak commit (100%).Not tested
scripts/smoke.ps1pair on rebased headbdfb2fb, fullcargo test --workspacesuite, runtime GPU execution across AMD / NVIDIA / Intel hardware, and Linux/Wine/vkd3d-proton.AI use
f368928, and unit tests; the author reviewed the diff and test output.Imported from ivall/xcl. Originally posted by eizispark on 2026-11-25T00:41:35Z.
Hardware test report — commit
3fcc982@raylitebull Verified
3fcc9822e736b4e616d22d3f18140957a2952667on AMD Radeon RX 9070 XT (RDNA4, native wave32 + wave64): pass, with the 60 sxcl-smokepair against ancestormain(8e87fc7).Tested
32.0.32015.16001), 32 GB RAM,rustc 1.100.0 (0ef1bc386 2026-11-09), debug tests + release smokecargo test --workspace --no-fail-fast -- --test-threads=4:997 passed, 2 failed, 45 ignored(8 skipped), with0new failures:hle::d3d12x::list_x::tests::resolve_readable_source_accepts_direct_and_rejects_unmapped,hle::d3d12x::real::map_tests::newer_cl1_slots_shift_older_cl1_remaps_by_two) and alld3d12x,list_x, ande2e(test_title_runs_and_game_folder_is_untouched) GPU tests passed#1679AMD fuzz seeds failed (gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_1seed 722,gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_3seed 1599)8 skipped: 6gpu::recomp::lower_dxil::testsf16/f32 direct-DXIL per-lane cases refused where#1426semantics differ from the console's;shaders::tests::pso_measurement_compiles_an_exact_synthetic_record(Windows Developer Mode required,0x887A002D);heap_window_out_of_memory_falls_back_to_the_switch_form: no heap windowsCopyMemoryToMemoryX stagedfired0times during the unattended 60 s boot/menu window (0unmappedCopyMemoryToMemoryXwarnings logged there either; the unattended smoke run stops in menus before entering the 3D world)Regression run (
scripts/smoke.ps1, 60 s, warm shader/driver cache)main(8e87fc7b62a87ea589ccb9ea6182f514016cf7db):PR (
3fcc9822e736b4e616d22d3f18140957a2952667):Not tested
CopyMemoryToMemoryXsources and newer-layoutResolveSubresourceRegion(#110) executeAI use
Imported from ivall/xcl. Originally posted by raylitebull on 2026-11-25T00:43:28Z.
@eizispark Thank you for the RX 9070 XT verification (997 passed,
Imported from ivall/xcl. Originally posted by gsucristo on 2026-11-25T00:57:08Z.
Technical review findings:
Major
list_x.rs,resolve_readable_source):kernelx::mirrors::source(va)only checksva < gpu + sizefor the start address, not that[va, va + len)stays within the GPU mirror reservation ((va - gpu) + len <= size). If a copy spans past the end of the mirror reservation and another readable CPU allocation sits adjacent to the CPU backing view,readable(cpu, len)succeeds andcopy_nonoverlappingreads out-of-bounds memory.VirtualQueryregression ingpu_vafor GPU-view buffers (list_x.rs,gpu_va): Whenvais a GPU view (src_va != va),mirror_of(src_va, bytes, what)registers the mirror undersrc_va, notva. Subsequent binds ofvamissmirrored(va, bytes)and fall through toresolve_readable_source(twoVirtualQuerywalks +mirrorslock) on every draw.Minor
dst < effective_src + size && effective_src < dst + sizeincopy_memory_xcan overflow on hugesize(preferchecked_add/saturating_add).QUEUE_SHIFTED == true, older CL1 slots104/105stay mapped to PC60/61(AtomicCopyBufferUINT/UINT64) instead of being unmapped/stubbed.Imported from ivall/xcl. Originally posted by raylitebull on 2026-11-25T01:15:45Z.
Thanks for the careful review and catches,
@gsucristo!Updated
#1995cleanly onto0f293be(50ef7dc):kernelx.rs): addedmirrors::source_range(va, len)enforcing(va - gpu) + len <= sizeinsideresolve_readable_sourceso reads crossing the end of a GPU mirror reservation are rejected.list_x::MIRRORSkeyed bycpu_src_start(list_x.rs): changed theMIRRORScache value to track(title_start, cpu_src_start, len, uma_mirror)so repeatedgpu_vabinds of GPU-view buffers hitmirrored(va, bytes)directly with zero per-drawVirtualQuerywhilesync_title_buffersreads fromcpu_src_start.saturating_add& vacated CL1 slots (list_x.rs,real.rs): switchedcopy_memory_x's overlap check tosaturating_add, and routed vacated older CL1 slots104/105to console-extension stubs whenQUEUE_SHIFTED == true.Verified locally (
cargo check --workspace --tests+resolve_readable_source_accepts_direct_and_rejects_unmapped+newer_cl1_slots_shift_older_cl1_remaps_by_two:2 passed, 0 failed).Imported from ivall/xcl. Originally posted by Anon64 on 2026-11-25T01:47:36Z.
Regression run for this PR: head
3fcc982, based onmain80f4819. RTX 3060 12 GB (581.80, wave32), Windows 11 26200, release,XCL_NETWORK=0, A pressed every 4 s from 20 s,scripts/smoke.ps1on a retail title for 60 s, in one batch with themainrun.main
80f4819:this PR:
No device removals or crashes; 101 % of main's frames, 93 % of its peak commit.
Not tested: the whole suite; world loading; whether the title reaches all of the changed code in these 60 s (default settings:
XCL_DIRECT_DXILandXCL_HEAP_WINDOWSunset).Written with Claude Code (Claude Opus 5.5) from runs on this machine.
Imported from ivall/xcl. Originally posted by JJAutoCompare on 2026-11-25T02:49:01Z.
Empirical verification — PR #1995 (
50ef7dcbb6300119933dade417edf88cca64e055)Tested clean detached PR head
50ef7dcbb6300119933dade417edf88cca64e055on STOR-WINLAB.Environment
26200.9974, AMD Ryzen 7 3800X, Intel Arc A770 16 GiB (driver32.0.101.9175, wave range 8–32,DoublePrecisionFloatShaderOps=0,d3d12SDKLayers.dllabsent).rustc 1.100.0 (0ef1bc386 2026-11-09)(CARGO_INCREMENTAL=0, debug info 0). Standalone DXC/DXIL1.9.2609.5was onPATH; the test title logged Windows SDK DXC1.9.2602.17(21d28f72).Tested
cargo build --workspaceandcargo test --workspace --no-runexited 0 outside the GPU lock.cargo test -p xcl --lib <name> -- --nocapture): 3 passed, 0 failed, 0 ignored, 0 skipped (all 3 also passed in full suite):resolve_readable_source_accepts_direct_and_rejects_unmappednewer_cl1_slots_shift_older_cl1_remaps_by_twolayout_split_keeps_the_runtime_on_the_pc_methodCopyMemoryToMemoryXscratch copy.cargo test --workspace --no-fail-fast -- --test-threads=4(underInvoke-ArcTest.ps1, exited 101): 1,041 passed, 26 failed, 45 ignored across 20 test harnesses, with 23SKIPPEDlines across 13 tests (excluded from coverage; 18 wave64, 3 refused wave32 f16 lowerings, 1 driver-cache disable0x887A002D, 1 heap-window fallback; missing debug-layer early return captured separately).xcl --libnative D3D12 shader tests (21CreateComputePipelineState0x80070057+ 4 shader output assertions) and 1 ine2e(test_title_runs_and_game_folder_is_untouched,RSSetDepthBiasX#94 blue vs green). Re-runningtest_title_runs_and_game_folder_is_untouchedon parent commit0f293bec8fd53b1478328627a1f08a6155dd2813under the same Arc lock reproduced the identical depth-bias failure, confirming it predates PR #1995.Not tested
scripts/smoke.ps1, D3D12 debug layer, live GPU-view reservation copy / vertex-index refresh, and title dispatch through shifted CL1 slots.AI use
gpt-6.2-sol,reasoningEffort: high) ran the build and verification. Coordinator #2 (T3 Code / Antigravity,gemini-4-neon) verified counts againstpr1995-suite.logand published this report.Imported from ivall/xcl. Originally posted by DavidM1911 on 2026-11-25T03:42:39Z.
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 Toons29 on 2026-11-25T03:47:46Z.
Regression run of
bdfb2fb1on the retail title, for this PR's Regression run section. Both blocks are fromscripts/smoke.ps1as printed, not edited:mainon1a0bbe3a, this PR on its head commit with no uncommitted changes, same title and time.Against the limits in CONTRIBUTING.md: 100 % of
main's frames, 100 % of its peak commit, no crash, no device removal.AMD Radeon RX 9070 (RDNA4, driver 32.0.32029.2010), Ryzen 7 7800X3D, 32 GB, Windows 11 build 26300, Rust 1.100.0,
cargo build --release -p xcl, 60 s,XCL_NETWORK=0. This is a regression check only: it does not show whether the run reaches the code this PR changes.AI use: Claude Code (Claude Opus 5.5) built both trees and ran
scripts/smoke.ps1; both blocks are exactly as printed, and I approved posting this.upstream-sync referenced this pull request2026-11-25 10:09:30 +00:00
Imported from ivall/xcl. Originally posted by raylitebull on 2026-11-25T10:38:09Z.
Thanks @Toons29 for running and sharing the exact-head 60 s
scripts/smoke.ps1pair on50ef7dc(0 device removals, 0 crashes) — added to the PR description!Imported from ivall/xcl. Originally posted by raylitebull on 2026-11-25T10:44:10Z.
Rebased
#1995cleanly ontof368928in commitbdfb2fb:crates/xcl/src/hle/kernelx.rsadjacency conflict cleanly alongside#1985(mirrors::gpu_views_of+mirrors::source_rangeside-by-side insidekernelx::mirrors).cargo check --workspace --tests,resolve_readable_source_accepts_direct_and_rejects_unmapped, andnewer_cl1_slots_shift_older_cl1_remaps_by_twodirectly onbdfb2fb.Imported from ivall/xcl. Originally posted by raylitebull on 2026-11-25T18:15:40Z.
Thanks @Toons29 for running and sharing the exact-head 60 s
scripts/smoke.ps1pair onbdfb2fb1(0device removals,0crashes,1628 -> 1627frames) — absorbed into the PR description!Imported from ivall/xcl. Originally posted by pickles976 on 2026-11-25T18:41:43Z.
Tested an adapted integration of this PR on Linux/Wine with vkd3d-proton and an RTX 4060 Laptop GPU (8 GiB), using the GTA VI Xbox 1.0.2.1 title through its initial world-load path. The integration also contains #877 and the Wine native-vtable changes from closed #1395, which this title currently needs to boot with stock assert-enabled vkd3d-proton.
Build/tests:
hle::d3d12x::list_x::tests::resolve_readable_source_accepts_direct_and_rejects_unmapped: passedhle::d3d12x::real::map_tests::newer_cl1_slots_shift_older_cl1_remaps_by_two: passedRuntime result: the title reached illustrated loading screens and sustained 29.8 fps over the last 300 presents before my 7.5 GiB VRAM safety guard terminated it. DirectStorage reported 0 failed requests and there was no crash/device removal. However, the real 16 KiB operation this was intended to cover still took the fallback, not the new staging path:
Correction after source review: the absence of a staged-copy log does not prove
resolve_readable_sourcereturnedNone. Staging is gated bydst_uma.is_some()first. The destination0x3d5be890is below the logged UMA base0x400000000, so this observed call does not establish coverage of the PR’s GPU-source resolver. The failing copy also needs a non-UMA destination path; my earlier inference blaming source readability was unsupported.The control also reached this fallback. These results verify build/unit tests and boot/loading regression only, not successful GPU-view staging or playable gameplay. AI-assisted test and source review.
Imported from ivall/xcl. Originally posted by Oliwettoo on 2026-11-25T22:15:42Z.
Review on
bdfb2fb(read from the diff, not built or run). The end-of-range fix and the(title, cpu_src, len, mirror)re-keying look right to me; two points not raised above:copy_memory_xruns while the title records the list, and copiessrc_cpuinto upload memory right then; on the console,CopyMemoryToMemoryXreads its source when the GPU executes it. If the title (or earlier GPU work in the same submission) writes that source betweenCopyMemoryToMemoryXandExecuteCommandLists, the destination gets the old bytes.gpu_vaalready binds "a copy made now", so there is precedent, but for an explicit copy command it's a semantic change worth stating in the description, or the CPU copy could be deferred to submit (the waysync_title_buffersrefreshes mirrors before a draw).apply_newer_cl1_remaps) can be reviewed, tested and reverted independently; CONTRIBUTING asks for one logical change per PR.Imported from ivall/xcl. Originally posted by Oliwettoo on 2026-11-25T22:34:10Z.
Heads-up for whichever of these merges second: #1995 and #2478 (stacked on #2437) both rewrite the per-draw mirror sync in
list_x.rs, andgit merge-treereports a conflict between their heads. Beyond the text conflict:MIRRORS(title_start, cpu_src_start, len, mirror), so a mirror of a GPU-view address copies from its CPU backing.mirror_sources, theGetWriteWatchinwritten_pages,MIRROR_STALE) works on the title address.Combined as they are, a GPU-view mirror's
GetWriteWatchfails, so the draw copies the whole range every time. That stays correct, but it loses #2478's saving for exactly the buffers #1995 adds. Switching the write-watch and stale-page lookups tocpu_src_startwhen resolving would keep both. (Read from the diffsa6ec51e/bdfb2fb, not run.)Imported from ivall/xcl. Originally posted by DavidM1911 on 2026-11-26T06:51:28Z.
Re-verification on RTX 3060 Ti (Windows 11), new head merged with current
main:cargo test -p xcl --lib: 1 failure under parallel scheduling; clean on--test-threads=1rerun (1307 passed, 0 failed, 27 ignored, 78s). Intermittent single-test flake — tracked in #1978.Thanks!
— Devin
Imported from ivall/xcl. Originally posted by luckyteagirl on 2026-11-26T09:03:30Z.
Review: COMMENTED
On
bdfb2fb, a GPU-view address can retain the wrong CPU backing after release and reuse.gpu_vareturns an existingmirrored(va, bytes)entry before callingresolve_readable_source;MIRRORSrecords the original(title_start, cpu_src_start, ...)and is not invalidated bykernelx::mirrors::released, which only removes the reservation mapping.For example, reserve GPU view B paired with CPU view A1, bind B once, release B, then reserve B again paired with a newer CPU view A2. A subsequent bind of B finds the old mirror, and
sync_title_buffersrefreshes it from A1 (or leaves prior bytes if A1 is no longer readable), rather than A2. The new title address is valid but draws can use stale vertex/index data. The fresh reservation lookup used byCopyMemoryToMemoryXdoes not prevent this draw path.Could the cached entry be checked against the current reservation identity before reuse, or invalidated/replaced when the GPU-view mapping changes? A focused release-and-rebind fixture with different bytes in A1 and A2 would cover it. I reviewed source only; I did not run a title or GPU repro.
Imported from ivall/xcl. Originally posted by upipibi on 2026-11-26T17:47:32Z.
NVIDIA test report for
bdfb2fb16: RTX 3070 8 GB (driver 616.56), Windows 11 26100, Rust 1.100.0, debug. Merge-basef368928.PR tests
resolve_readable_source_accepts_direct_and_rejects_unmappedandnewer_cl1_slots_shift_older_cl1_remaps_by_two: 3 of 3 runs passed.cargo test -p xcl --lib -- --skip hle::xaudio2 --test-threads=4: 1125 passed, 1 failed, 26 ignored. The failure,device_x::tests::pc_resource_desc_strips_uav_on_unsupported_formats_and_msaa(format 85 kept), fails the same on the merge-base (1123 passed, 1 failed; see #2242). 24 SKIPPED lines (no wave64, translator-refused per-lane forms). No device resets. Tests only, no title run.AI-assisted (Claude Code, Claude Sonnet 5.5).
Imported from ivall/xcl. Originally posted by thehollowedone on 2026-11-26T18:46:40Z.
Follow-up to the GPU-view lifetime review, checked on current head
bdfb2fb16da4d1ebb93229333b2d4b4fd8e55da7.I reproduced the release/rebind case with a synthetic test that calls the production
gpu_vapath. B was first paired with A1 (0x11 bytes); after releasing and reusing B with A2 (0x22 bytes), the unmodified head reused B's old mirror.cargo test --offline --locked -p xcl --lib gpu_view_rebind_uses_the_new_cpu_backing -- --test-threads=1 --nocapture: 0 passed, 1 failed on the unmodified head. The mirror pointer stayed the same.The candidate below invalidates only lookup entries overlapping a GPU view when it is paired, released, or loses its CPU backing. It retains existing mirror allocations for recorded commands. I kept the original forward lookup order, so an overlapping newer mirror does not change which mirror an existing binding refreshes. I also moved the alignment check outside the
MIRRORSlock so this newkernelx::mirrors::STATE → MIRRORSpath does not invert that lock order. With the candidate, the focused test is 1 passed, 0 failed, 0 ignored, andcargo test --offline --locked -p xcl --lib hle::d3d12x::list_x::tests -- --test-threads=4is 35 passed, 0 failed, 0 ignored.git diff --checkis clean.This is a candidate for the author to adapt, not a verified retail fix. I did not run the full workspace suite, a paired title smoke, or GPU rendering. The test uses synthetic memory on Windows with an RTX 3080 Ti (driver 621.35), rustc 1.99.1. Concurrent release of a source while another thread copies it remains a separate lifetime question.
Candidate patch and regression test
AI use: Codex (GPT-6.2 Sol) wrote and ran the regression and candidate patch, reviewed the changed code, and drafted this comment.
Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T06:26:16Z.
Review (head
bdfb2fb1, diff read, not a merge-check; it conflicts with main and CI /PR descriptionare red, so not built or run):082dcd7e: GPU-view addresses now go to their view window, filled before the list runs (list_x.rs~3792), and "the CPU-side buffer mirrors never take a view address", which this PR'sMIRRORSre-keying goes against. Its staging (list_x.rs~2133) also copied the source when the list was recorded, not when it runs.real.rs~7717) only compares constant tables and never runsapply_newer_cl1_remaps, and the shading-rate methods 124/125 -> 126/127, which main's comment (~11597) says also moved, aren't handled.Fine:
mirrors::source_rangechecks the end of the range correctly and the overlap check usessaturating_add. Recommendation: close; if a newer-layout title is shown calling #106-#111, a smallD3D12.X:PR could add those entries (and 126/127) toNEWER_LIST_SLOTS/console_remapwith a test that builds the command-list class and checks the slot targets.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.