Skip to content

[upstream #1102] D3D12.X: a texture in a GPU view reads the pages the page-mapping method put under it - #56

Closed
ufoptg wants to merge 3 commits into
mainfrom
upstream-pr/1102
Closed

ufoptg wants to merge 3 commits into
mainfrom
upstream-pr/1102

Conversation

@ufoptg

@ufoptg ufoptg commented Nov 24, 2026

Copy link
Copy Markdown
Owner

Stacked on xcl-dev#1055: only the last commit (59042fd) is this PR. I'll rebase it once xcl-dev#1055 is merged.

A texture in a GPU view now reads each of its 64 KiB pages from what queue #31 (CopyPageMappingsBatchX) mapped there:

  • a mapped page reads the physical page, where XCL keeps it;
  • an unmapped page reads as zeros;
  • a page the method never mapped reads the CPU view, as before.

On the retail title of xcl-dev#505 about 43% of the mapped pages had their physical page at the pool address, while the texture read the CPU view's same offset. That offset is not committed, so those parts of textures went up as zeros (xcl-dev#1031, the correction there).

What is in it

  • crates/xcl/src/hle/d3d12x/title_textures.rs:
    • Source replaces the single address a texture was read from. It is either one address (At, as before) or runs of the texture's bytes from several addresses (Pages; address 0 means zeros). Uploads, the unchanged-content check, the detile and the write watch all go through it.
    • source_of(va, len) builds it. A texture whose pages form one run comes back as At, so it costs what it did before. A texture outside GPU views, or one whose pages the method never mapped, is At(mirror_source(va)) as before.
    • recheck_gpu_view_sources re-reads the source only of the textures on pages the method changed, or whose physical page moved (mirrors::take_changed, found through by_va). Looking at all of them took 225 ms on 64k textures, and the method is called hundreds of times. A change of gpu_view_map_gen (physical pages mapped into a GPU view directly) still looks at all of them, as before.
  • crates/xcl/src/hle/kernelx.rs, mirrors:
    • the page table also keeps physical page → GPU-view pages, and the ranges changed since the last look;
    • page_moved(page) is called where a physical page is mapped, unmapped (unmap_away) or freed, so a texture follows its page when the title maps it into the CPU view too.
  • Tests:
    • a_page_mapped_texture_is_read_page_by_page: runs, zeros, the CPU view for untouched pages, one run as one address, the watched ranges and the dirty check.
    • gpu_mirror_upload_follows_cpu_writes_and_later_mapping_changes gets three steps on the GPU, each read back from the PC texture:
      • the pool page under the texture;
      • the same physical page after the title maps it into the CPU view, and a CPU write there;
      • zeros after the method unmaps the page.
    • Both tests fail with source_of reduced to the old mirror_source (checked).

On the retail title (main 67a3735 + xcl-dev#1055, with and without this PR; RTX 4080; A pressed through XCL_PRESS_AT; one run each)

  • Textures whose memory is all zero. XCL_TRACE_FRAME=1 logs how many textures are all zero in 16 samples of 4 KiB over their memory. The snapshots don't fall at the same moments in the two runs:

    snapshot all zero
    without this PR 57 s 6,119 of 15,726 (39%)
    without this PR 73 s 6,139 of 21,775 (28%)
    with it 63 s 2,734 of 14,424 (19%)

    A texture can be zero on purpose, so this is a trend rather than a count of fixed textures.

  • Nothing slower. Over the whole run (presents / submits / draws), and when the first #101 and the watchdog come:

    presents submits draws first #101 watchdog
    without this PR 1,765 8,790 15,750 77 s 108 s
    with it 1,730 8,695 15,359 80 s 110 s
  • 32,768+ textures were kept in step "with its pages", most of them as one run.

  • The run still ends at the title's watchdog (+0x23cf683), as on main. That stop is about stalled GPU work (Newer retail title (TitleID 7952987A): reaches world loading, then the title's GPU watchdog ("GPU Loc Sig") after ListX #101 stub xcl-dev/xcl#505), not about textures.

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 59042fd: 738 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: 59042fd2ec585767cb12a1c8ad21fcfefa836b72
gpu: NVIDIA GeForce RTX 4080
title: RetailTitle
seconds: 60
exit: 0x0
frames shown: 1658 (PresentX 1658)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 15791 MB

Not tested

  • AMD and Intel GPUs.
  • Whether the world looks right: the run still ends at the title's watchdog on this machine before the world is shown.
  • A page mapped both by the method and directly at the GPU-view address (XMemMapPhysicalPages into the view): the method's mapping wins here, whichever came last.

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#1102 (auto-synced, do not edit).

Xeltax and others added 3 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>
…hod put under it

Each 64 KiB page of a texture in a GPU view is read from what queue
#31 (CopyPageMappingsBatchX) mapped there: the physical page where
XCL keeps it, zeros for an unmapped page, the CPU view for a page the
method never mapped (`source_of`, `Source::Pages`). The textures on
the pages a call changes, or whose physical page moved, are looked at
again at the next submit (`mirrors::take_changed`, `page_moved`), not
all of them. Their writes are watched where the pages are. (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#1102 was closed or merged.

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