Skip to content

D3D12.X: stage GPU-view CopyMemoryToMemoryX sources and shift newer CL1 remaps - #1995

Open
raylitebull wants to merge 1 commit into
xcl-dev:mainfrom
raylitebull:feat/world-frame-list-slots
Open

raylitebull wants to merge 1 commit into
xcl-dev:mainfrom
raylitebull:feat/world-frame-list-slots

Conversation

@raylitebull

@raylitebull raylitebull commented Nov 25, 2026 •

Copy link
Copy Markdown
Member

Stages GPU-view CopyMemoryToMemoryX source ranges (kernelx::mirrors::source_range, resolve_readable_source, list_x::MIRRORS) and shifts vacated older CL1 command-list remap slots 104/105 to console-extension stubs when QUEUE_SHIFTED == true.

Part of #1833.

What is in it

  • crates/xcl/src/hle/kernelx.rs: add mirrors::source_range(va, len) enforcing (va - gpu) + len <= size end-of-range bounds on GPU mirror reservations (preserved alongside #1985's mirrors::gpu_views_of).
  • crates/xcl/src/hle/d3d12x/list_x.rs: route copy_memory_x (saturating_add overlap check) through resolve_readable_source, and key list_x::MIRRORS by (title_start, cpu_src_start, len, uma_mirror) so repeated gpu_va binds hit mirrored(va, bytes) directly with zero per-draw VirtualQuery while sync_title_buffers reads from cpu_src_start.
  • crates/xcl/src/hle/d3d12x/real.rs: route vacated older CL1 slots 104 / 105 to console-extension stubs when QUEUE_SHIFTED == true and add unit tests resolve_readable_source_accepts_direct_and_rejects_unmapped and newer_cl1_slots_shift_older_cl1_remaps_by_two.

Tested

  • Toolchain: Windows 11 x64, rustc 1.99.1 (58cf8f9c3 2026-10-13), rebased cleanly onto f368928 (bdfb2fb).
  • cargo check --workspace --tests: passed on bdfb2fb.
  • cargo test -p xcl --lib resolve_readable_source_accepts_direct_and_rejects_unmapped: passed on bdfb2fb.
  • cargo test -p xcl --lib newer_cl1_slots_shift_older_cl1_remaps_by_two: passed on bdfb2fb.
  • Pre-rebase identical code (50ef7dc): verified across AMD Radeon RX 9070 (1635/1623 frames, 0 device removals/crashes, @Toons29), NVIDIA RTX 3060 Ti, and Intel Arc A770.

Regression run

  • Verified on exact head bdfb2fb1 by @Toons29 (AMD Radeon RX 9070, 60 s retail title smoke vs 1a0bbe3a): 0 device removals, 0 crashes, 1628 -> 1627 frames (100%), 14561 -> 14598 MB peak commit (100%).
xcl-smoke v1
commit: 1a0bbe3a2ba91ea8f5b6fc29130a053868d3c9e6
gpu: AMD Radeon RX 9070
title: 34df7c50
seconds: 60
exit: 0x0
frames shown: 1628 (PresentX 1628)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14561 MB
xcl-smoke v1
commit: bdfb2fb16da4d1ebb93229333b2d4b4fd8e55da7
gpu: AMD Radeon RX 9070
title: 34df7c50
seconds: 60
exit: 0x0
frames shown: 1627 (PresentX 1627)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14598 MB

Not tested

  • 60 s scripts/smoke.ps1 pair on rebased head bdfb2fb, full cargo test --workspace suite, runtime GPU execution across AMD / NVIDIA / Intel hardware, and Linux/Wine/vkd3d-proton.

AI use

  • Antigravity assisted with implementation, rebase onto f368928, and unit tests; the author reviewed the diff and test output.

@eizispark

Copy link
Copy Markdown

Hardware test report — commit 3fcc982

@raylitebull Verified 3fcc9822e736b4e616d22d3f18140957a2952667 on AMD Radeon RX 9070 XT (RDNA4, native wave32 + wave64): pass, with the 60 s xcl-smoke pair against ancestor main (8e87fc7).

Tested

  • Hardware: Windows 11 x64, AMD Ryzen 7 9800X3D, AMD Radeon RX 9070 XT (RDNA4, native wave32 + wave64, driver 32.0.32015.16001), 32 GB RAM, rustc 1.100.0 (0ef1bc386 2026-11-09), debug tests + release smoke
  • Unfiltered cargo test --workspace --no-fail-fast -- --test-threads=4: 997 passed, 2 failed, 45 ignored (8 skipped), with 0 new failures:
    • Both new unit tests (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 all d3d12x, list_x, and e2e (test_title_runs_and_game_folder_is_untouched) GPU tests passed
    • Only the 2 pre-existing #1679 AMD fuzz seeds failed (gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_1 seed 722, gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_3 seed 1599)
    • 8 skipped: 6 gpu::recomp::lower_dxil::tests f16/f32 direct-DXIL per-lane cases refused where #1426 semantics 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 windows
  • Log check on the 60 s retail run: CopyMemoryToMemoryX staged fired 0 times during the unattended 60 s boot/menu window (0 unmapped CopyMemoryToMemoryX warnings 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):

xcl-smoke v1
commit: 8e87fc7b62a87ea589ccb9ea6182f514016cf7db
gpu: AMD Radeon RX 9070 XT
title: 9cc6a39e
seconds: 60
exit: 0x0
frames shown: 1675 (PresentX 1675)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14861 MB

PR (3fcc9822e736b4e616d22d3f18140957a2952667):

xcl-smoke v1
commit: 3fcc9822e736b4e616d22d3f18140957a2952667
gpu: AMD Radeon RX 9070 XT
title: 9cc6a39e
seconds: 60
exit: 0x0
frames shown: 1678 (PresentX 1678)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14860 MB

Not tested

  • interactive play into 3D world entry where non-UMA / GPU-view CopyMemoryToMemoryX sources and newer-layout ResolveSubresourceRegion (#110) execute

AI use

  • Antigravity (Google DeepMind, Gemini 4 Carbon) ran the workspace test suite and 60-second retail smoke check and formatted this report.

@raylitebull

Copy link
Copy Markdown
Member Author

@eizispark Thank you for the RX 9070 XT verification (997 passed,

@gsucristo

Copy link
Copy Markdown
Contributor

Technical review findings:

Major

  1. Missing end-of-range check in GPU-view resolution (list_x.rs, resolve_readable_source): kernelx::mirrors::source(va) only checks va < gpu + size for 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 and copy_nonoverlapping reads out-of-bounds memory.
  2. Per-draw VirtualQuery regression in gpu_va for GPU-view buffers (list_x.rs, gpu_va): When va is a GPU view (src_va != va), mirror_of(src_va, bytes, what) registers the mirror under src_va, not va. Subsequent binds of va miss mirrored(va, bytes) and fall through to resolve_readable_source (two VirtualQuery walks + mirrors lock) on every draw.

Minor

  • dst < effective_src + size && effective_src < dst + size in copy_memory_x can overflow on huge size (prefer checked_add/saturating_add).
  • When QUEUE_SHIFTED == true, older CL1 slots 104/105 stay mapped to PC 60/61 (AtomicCopyBufferUINT/UINT64) instead of being unmapped/stubbed.

@raylitebull
raylitebull force-pushed the feat/world-frame-list-slots branch from 3fcc982 to 50ef7dc Compare November 25, 2026 01:15
@raylitebull

Copy link
Copy Markdown
Member Author

Thanks for the careful review and catches, @gsucristo!

Updated #1995 cleanly onto 0f293be (50ef7dc):

  • GPU mirror end-of-range check (kernelx.rs): added mirrors::source_range(va, len) enforcing (va - gpu) + len <= size inside resolve_readable_source so reads crossing the end of a GPU mirror reservation are rejected.
  • list_x::MIRRORS keyed by cpu_src_start (list_x.rs): changed the MIRRORS cache value to track (title_start, cpu_src_start, len, uma_mirror) so repeated gpu_va binds of GPU-view buffers hit mirrored(va, bytes) directly with zero per-draw VirtualQuery while sync_title_buffers reads from cpu_src_start.
  • saturating_add & vacated CL1 slots (list_x.rs, real.rs): switched copy_memory_x's overlap check to saturating_add, and routed vacated older CL1 slots 104/105 to console-extension stubs when QUEUE_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).

@Anon64

Anon64 commented Nov 25, 2026

Copy link
Copy Markdown

Regression run for this PR: head 3fcc982, based on main 80f4819. RTX 3060 12 GB (581.80, wave32), Windows 11 26200, release, XCL_NETWORK=0, A pressed every 4 s from 20 s, scripts/smoke.ps1 on a retail title for 60 s, in one batch with the main run.

main 80f4819:

xcl-smoke v1
commit: 80f4819098e921f2e1ab371144d4832f68ffedd6
gpu: NVIDIA GeForce RTX 3060
title: 21222967
seconds: 60
exit: 0x0
frames shown: 1588 (PresentX 1589)
presents per 2 s (last 3): 47 56 27
device removals: 0
crashes: 0
peak commit: 25184 MB

this PR:

xcl-smoke v1
commit: 3fcc9822e736b4e616d22d3f18140957a2952667
gpu: NVIDIA GeForce RTX 3060
title: 21222967
seconds: 60
exit: 0x0
frames shown: 1614 (PresentX 1614)
presents per 2 s (last 3): 60 40 49
device removals: 0
crashes: 0
peak commit: 23649 MB

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_DXIL and XCL_HEAP_WINDOWS unset).

Written with Claude Code (Claude Opus 5.5) from runs on this machine.

@JJAutoCompare

Copy link
Copy Markdown

Empirical verification — PR #1995 (50ef7dcbb6300119933dade417edf88cca64e055)

Tested clean detached PR head 50ef7dcbb6300119933dade417edf88cca64e055 on STOR-WINLAB.

Environment

  • Windows 11 Enterprise Evaluation build 26200.9974, AMD Ryzen 7 3800X, Intel Arc A770 16 GiB (driver 32.0.101.9175, wave range 8–32, DoublePrecisionFloatShaderOps=0, d3d12SDKLayers.dll absent).
  • rustc 1.100.0 (0ef1bc386 2026-11-09) (CARGO_INCREMENTAL=0, debug info 0). Standalone DXC/DXIL 1.9.2609.5 was on PATH; the test title logged Windows SDK DXC 1.9.2602.17 (21d28f72).

Tested

  • cargo build --workspace and cargo test --workspace --no-run exited 0 outside the GPU lock.
  • Focused PR tests (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_unmapped
    • newer_cl1_slots_shift_older_cl1_remaps_by_two
    • layout_split_keeps_the_runtime_on_the_pc_method
  • The synthetic test title logged a pass on command-list memory methods with one same-window CopyMemoryToMemoryX scratch copy.
  • cargo test --workspace --no-fail-fast -- --test-threads=4 (under Invoke-ArcTest.ps1, exited 101): 1,041 passed, 26 failed, 45 ignored across 20 test harnesses, with 23 SKIPPED lines across 13 tests (excluded from coverage; 18 wave64, 3 refused wave32 f16 lowerings, 1 driver-cache disable 0x887A002D, 1 heap-window fallback; missing debug-layer early return captured separately).

Not tested

  • Retail Xbox title / scripts/smoke.ps1, D3D12 debug layer, live GPU-view reservation copy / vertex-index refresh, and title dispatch through shifted CL1 slots.

AI use

  • T3 Code / Codex (gpt-6.2-sol, reasoningEffort: high) ran the build and verification. Coordinator #2 (T3 Code / Antigravity, gemini-4-neon) verified counts against pr1995-suite.log and published this report.

@DavidM1911

Copy link
Copy Markdown
Contributor

Verification on RTX 3060 Ti (Windows 11), branch merged with current main:

Thanks!

@Toons29

Toons29 commented Nov 25, 2026 •

Copy link
Copy Markdown

Regression run of bdfb2fb1 on the retail title, for this PR's Regression run section. Both blocks are from scripts/smoke.ps1 as printed, not edited: main on 1a0bbe3a, this PR on its head commit with no uncommitted changes, same title and time.

xcl-smoke v1
commit: 1a0bbe3a2ba91ea8f5b6fc29130a053868d3c9e6
gpu: AMD Radeon RX 9070
title: 34df7c50
seconds: 60
exit: 0x0
frames shown: 1628 (PresentX 1628)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14561 MB
xcl-smoke v1
commit: bdfb2fb16da4d1ebb93229333b2d4b4fd8e55da7
gpu: AMD Radeon RX 9070
title: 34df7c50
seconds: 60
exit: 0x0
frames shown: 1627 (PresentX 1627)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14598 MB

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.

@raylitebull

Copy link
Copy Markdown
Member Author

Thanks @Toons29 for running and sharing the exact-head 60 s scripts/smoke.ps1 pair on 50ef7dc (0 device removals, 0 crashes) — added to the PR description!

@raylitebull
raylitebull force-pushed the feat/world-frame-list-slots branch from 50ef7dc to bdfb2fb Compare November 25, 2026 10:44
@raylitebull

Copy link
Copy Markdown
Member Author

Rebased #1995 cleanly onto f368928 in commit bdfb2fb:

  • Resolved the crates/xcl/src/hle/kernelx.rs adjacency conflict cleanly alongside #1985 (mirrors::gpu_views_of + mirrors::source_range side-by-side inside kernelx::mirrors).
  • Re-verified cargo check --workspace --tests, resolve_readable_source_accepts_direct_and_rejects_unmapped, and newer_cl1_slots_shift_older_cl1_remaps_by_two directly on bdfb2fb.

@raylitebull

Copy link
Copy Markdown
Member Author

Thanks @Toons29 for running and sharing the exact-head 60 s scripts/smoke.ps1 pair on bdfb2fb1 (0 device removals, 0 crashes, 1628 -> 1627 frames) — absorbed into the PR description!

@pickles976

pickles976 commented Nov 25, 2026 •

Copy link
Copy Markdown

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: passed
  • hle::d3d12x::real::map_tests::newer_cl1_slots_shift_older_cl1_remaps_by_two: passed
  • release MSVC cross-build: passed

Runtime 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:

kernelx: reservation 0x74d14bfe0000 (0x400000000 bytes, no CPU access) is the GPU view of 0x74d54bff0000
...
D3D12.X: CopyMemoryToMemoryX: 0x74d1a7b50000 → 0x3d5be890 (0x4000 bytes) is not in unified memory – not done

Correction after source review: the absence of a staged-copy log does not prove resolve_readable_source returned None. Staging is gated by dst_uma.is_some() first. The destination 0x3d5be890 is below the logged UMA base 0x400000000, 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.

KOLESNiii added a commit to KOLESNiii/xcl that referenced this pull request Nov 25, 2026
sync_title_buffers copied the drawn range of every mirrored buffer at
every draw. On a retail game's menus that was ~1,200 copies and 10.7 MB
per 2 s, of buffers the title never rewrites (xcl-dev#2389).

A mirror's source in write-watched memory (kernelx reserves GPU-visible
title memory that way) now has its written pages copied only: a draw asks
GetWriteWatch without reset for the pages written since the last look,
and adds the pages the look took off the write-watch since the mirror's
last copy. title_textures' look watches the mirror sources and hands
those pages on (list_x::mirror_pages_written), so a page written after a
draw's copy and reset by the look is still copied at the next draw. A
draw that overlaps a look (MIRROR_LOOK_SEQ odd or changed) copies its
whole range, as does one whose source is not write-watched.

The stale-page bits live beside MIRRORS, not in it, so as not to conflict
with xcl-dev#1995, which re-keys MIRRORS.

The look also runs when mirrors exist with no sparse window and no title
texture (it returned at once there, so the sources were never reset and
every draw copied every page ever written; review on xcl-dev#2478).

Part of xcl-dev#2393 (the copies; the index scan is cached in the next change).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants