Skip to content

[upstream #1055] kernelx: queue CopyPageMappingsBatchX records the physical page each GPU-view page shows - #95

Closed
ufoptg wants to merge 2 commits into
mainfrom
upstream-pr/1055
Closed

ufoptg wants to merge 2 commits into
mainfrom
upstream-pr/1055

Conversation

@ufoptg

@ufoptg ufoptg commented Nov 24, 2026

Copy link
Copy Markdown
Owner

Queue method #31 of the newer layout (#29 of the older), CopyPageMappingsBatchX, maps pages of the title's memory into GPU views. It was a stub. This PR decodes its batches and records, for each 64 KiB page of a GPU view, the physical page it shows. It can then say where XCL keeps that page's data now. Nothing reads that record yet, so textures are unchanged. First of the PRs planned in xcl-dev#1031 (see the correction there).

What is in it

  • crates/xcl/src/hle/kernelx.rs, mirrors:
    • apply_batches(count, batches, pool, pool_pages) decodes one call:
      • a batch is 24 bytes: destination (u64), range count (u32), and a pointer to the ranges at +16;
      • a range is kind, start, count (u32 each). Kind 0 maps count pool pages from start; kind 1 maps pool page start at each of count pages; kind 2 unmaps; kind 3 keeps.
    • The whole call is checked before anything is recorded. Batches and ranges must be readable, pool ranges must stay inside pool_pages, the kind must be known, and the call may name at most 2^20 pages. A bad call records nothing.
    • Only pages inside a known GPU view are recorded. The retail title maps into nothing else; other pages are counted as "elsewhere".
    • Each recorded page keeps its pool page and the physical page the title had mapped there (Shown).
    • mapped_source(va) answers what the method put under va:
      • Some(Some(a)): a is where XCL keeps that physical page now (page_now), or the pool page itself when the title had mapped none there;
      • Some(None): the page is unmapped;
      • None: the method never touched the page.
    • released now also drops a released view's recorded pages.
  • crates/xcl/src/hle/kernelx.rs, physical pages:
    • Away::title remembers, per address, the page the title mapped there last.
    • On the console a page stays mapped at every address it was mapped at. XCL keeps its data in one place, the address it was mapped at last (move_away).
    • The retail title maps a streamed page into the pool, and most of them into the CPU view behind the GPU view too. So the pool address alone gives the wrong place for most pages; the physical page gives the right one.
    • page_now(page) gives where the page's data is: its address away from home, else its home.
  • crates/xcl/src/hle/d3d12x/real.rs: queue [upstream #1133] Scripts: pr_check refuses smoke blocks without a title, time or frames #29 (older numbering) calls apply_batches and returns S_OK as the stub did. It logs its totals at the first call and at powers of two, including how many mapped pages had a physical page, and warns once on a bad call.
  • Tests:
    • page_mappings_point_gpu_view_pages_at_pool_pages: synthetic batches covering:
      • all four kinds, a later call that remaps a page, and pages outside any GPU view;
      • bad calls: a range that leaves the pool after a good one, an unknown kind, unreadable ranges and unreadable batches;
      • release of the view.
    • a_gpu_view_page_shows_the_physical_page_where_it_is_kept: a real physical page is mapped into a pool and given to a GPU-view page. The page shows the pool. Once the page is also mapped at another address, the GPU-view page shows that address, with the same data.

On the retail title (the one in xcl-dev#505; main 67a3735 + this change, RTX 4080, A pressed through XCL_PRESS_AT; the run ends at +0x23cf683 as on main)

  • Every call decodes, and every page lands in the title's one GPU view (0xdffff0000, the view of 0x7ffff0000):

    [   64.828] D3D12.X: queue CopyPageMappingsBatchX: 256 calls; GPU-view pages so far: 18635 mapped (18635 to a physical page the title mapped there), 2188 unmapped; 0 pages elsewhere ignored (pool 0x180090000, 99776 pages of 64 KiB)
    
  • Where XCL keeps the physical pages. A local tracker, not part of this PR, followed each page. After 256 calls, of 34,872 mapped GPU-view pages:

    • 19,808 have their physical page at the CPU view's same offset. There the identity mirror (mirrors::source), which title_textures reads today, is right.
    • 15,064 have it still at the pool address. The CPU view's same offset is not committed there, so those parts of textures are uploaded as zeros today.
  • How textures sit on the map (local count, 111 s, 22,353 textures in the view):

    the texture's pages textures MB
    never touched by the method 0 0
    one run of consecutive pool pages 17,745 872
    all mapped, pool pages out of order 384 256
    some mapped, others unmapped or never mapped 2,306 4,219
    all unmapped 1,918 13
  • The next PR has title_textures read GPU-view textures page by page through mapped_source. It will re-check only the textures on pages that changed: the existing re-check of all GPU-view textures took 225 ms over 64k textures at 111 s, and there were 256 calls by 84 s.

Tested

  • NVIDIA GeForce RTX 4080 (driver 621.01), AMD Ryzen 9 9900X, Windows 11 Pro 26200, rustc 1.100.0, DXC 1.9.2609.5. Tests ran in debug, the title in release.
  • cargo test --workspace --no-fail-fast -- --test-threads=4 on c8d5020: 737 passed, 0 failed, 41 ignored. SKIPPED: gpu_geometry_wave32_prefix_count_over_a_mask, gpu_wave32_program_in_wave64_hardware (no wave64).

Regression run

main:

xcl-smoke v1
commit: 67a3735177f42cf8e5c886e67a974da7f87541b3
gpu: NVIDIA GeForce RTX 4080
title: RetailTitle
seconds: 60
exit: 0x0
frames shown: 1582 (PresentX 1583)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 16549 MB

PR:

xcl-smoke v1
commit: c8d50207968796c163a5659b17d313e4a6c1b11a
gpu: NVIDIA GeForce RTX 4080
title: RetailTitle
seconds: 60
exit: 0x0
frames shown: 1661 (PresentX 1661)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 15714 MB

Not tested

  • AMD and Intel GPUs. The change does not touch the GPU path, but no run was made there.
  • Other titles.
  • Pages the title frees while a GPU view still maps them. page_now then finds no page, and the pool address is answered.

Reference
The batch and range layout comes from VIctory's description of this method (crates/victory-gpu/src/queue.rs). I read it as a reference only; no code was taken. The decode matches what the retail title passes (xcl-dev#1031).

AI use

  • Claude Code (Claude Opus 5.5) wrote the code, the tests and this description, ran the title and the tests, and read the logs.

🤖 Generated with Claude Code


Mirror of xcl-dev#1055 (auto-synced, do not edit).

Xeltax and others added 2 commits November 24, 2026 11:46
…ew's pages show

Queue method #31 (#29 of the older layout) maps pages of the title's
memory into GPU views; it was a stub. Its batches are now decoded and
checked against the batch count and the pool, and each 64 KiB page of
a GPU view keeps the pool page it shows, or none (kernelx::mirrors).
A bad call records nothing. Releasing a view drops its pages.

Nothing reads the map yet: textures are unchanged; the queue logs its
counts. (xcl-dev#1031)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…eps it

The page-mapping method names pool pages; the console maps the physical
page under each. The title maps most of those pages into the CPU view
too, and XCL moves a page's data to where it was mapped last, so the
pool address alone is the wrong page for most of them. Each title
mapping is remembered per address (Away::title); a GPU-view page records
the physical page of its pool page and `mapped_source` answers where
that page is now (`page_now`), else the pool page itself. The queue log
counts the pages that had a physical page. (xcl-dev#1031)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@ufoptg

ufoptg commented Nov 25, 2026

Copy link
Copy Markdown
Owner Author

Upstream PR xcl-dev#1055 was closed or merged.

@ufoptg ufoptg closed this Nov 25, 2026
@ufoptg
ufoptg deleted the upstream-pr/1055 branch November 25, 2026 00:11
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.

2 participants