D3D12.X: queue #31 (newer layout) is CopyPageMappingsBatchX – the retail title's streamed pages never reach its GPU views #1031
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
goal:world-load
good first issue
help wanted
invalid
keep-open
off-goal
question
stale
test-only
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/xcl-dev--xcl#1031
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
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?
@Xeltax on GitHub · 2026-11-24 10:34 UTC · original
Queue method #31 of the newer layout (#29 of the older) is a page-mapping batch. The retail title uses it to map its streamed pages into GPU views. XCL stubs it, so tens of thousands of textures in GPU views read the wrong memory.
What the method is
CopyPageMappingsBatchX(count, batches, pool, pool_pages, flags):u64 destination,u32 range count, and a pointer to the ranges at +16;u32 kind, start, count;kind0:countpool pages fromstart; 1: pool pagestartat each ofcountdestination pages; 2: unmapped; 3: left as it is;The layout comes from VIctory's
crates/victory-gpu/src/queue.rs, which implements it. That file is GPL-3.0; I read it as a reference only and took no code. The decode below matches it on the retail title.Measured
Retail title 1.0.2.1,
main077ce40plus a local decoder in the queue stub (not posted), RTX 4080, one world-loading run.poolis one region ofpool_pages 0x185c0= 6,236 MB, the "TileHeap …/6236 MB" in the title's crash context. It is not a GPU view.kernelx::mirrors), e.g.0x1eb70950000, the GPU view of0x1e570950000.mirrors::source(destination)equal topool + start × 64 KiB, the page the console maps there.title_texturesreads these textures from the CPU view at the same offset instead. The run logged 32,768+ textures in GPU views.So streamed world textures are read from memory the title never meant for them. This may be part of the black or wrong world (#878, #781). I don't claim it causes the #505 stall.
Plan, to avoid duplicate work
Three PRs, stacked:
kernelx: a per-page map for GPU views, fed by the queue method (decoded with bounds checks againstcountandpool_pages), andmirrorsanswering per page. Unit tests; textures unchanged, logging only.title_textures: read and watch a texture in a GPU view page by page through that map, gathering its pages into the upload. Re-upload when a page's mapping changes (gpu_view_map_gen).Is anyone already on this method? And is a page map read by
title_texturesthe model you'd want here, rather than real aliasing of the pages (placeholders)?AI use: Claude Code (Claude Opus 5.5) read VIctory's description, wrote the local decoder, ran the title on my machine and wrote this.
@Xeltax on GitHub · 2026-11-24 11:09 UTC · original
Correction to the measurement above: the stub is wrong for part of the pages, not all of them.
My "0 of 33,008" compared addresses, not pages:
kernelx,move_away).mirrors::source) can be the right page after all.I followed the page itself this time. A local tracker (not in #1055) records the page last placed at each pool address and where XCL keeps that page now. Retail title,
main67a3735+ #1055, RTX 4080, 256 calls, 34,872 mapped GPU-view pages:So about 43% of the mapped pages are read wrong, and what XCL reads for them is not committed: those parts of the textures go up as zeros. For one-run textures, the pool page holds data in 1,094 of 2,183 cases where the identity read finds nothing. That would fit "black after loading" (#878), though I have not shown that link.
What changes in the plan. #1055 will record the physical page that each GPU-view page shows, not the pool address, so the next PR can read wherever XCL keeps that page. I'm updating #1055 and its description.
AI use: Claude Code (Claude Opus 5.5) wrote the tracker, ran the title on my machine and wrote this.
@CharlyRien on GitHub · 2026-11-25 04:55 UTC · original
A second machine's census, plus what the issue does not cover yet: the buffers that translated shaders read in the GPU view. Short version: the batches look the same here (same-offset wrong for 56 – 59 % of mapped pages at 100 s), but buffer and root views in the GPU view are almost all right by same offset when the world starts and only drift later, so for them the first problem is #697 (the GPU view is outside the memory windows), not the stub.
Setup
main9e3831emerged locally with #1288, #1448, #684, #889, #1323, #929, #640, #1326, #1327, #1329; on top, by hand and uncommitted: #1791, a local equivalent of #1405, #1803, the decode-and-record part of #1055 (its lines, plus the older layout's slot 29 routed to it), a localtitle_texturesfix (described on #1405), a local readback change insparse.rs(one fence per title queue, see #1329), local DXC compile-time switches, and local logging. The census itself is local logging keyed on #1055's map: per destination page, where XCL keeps the named physical page now, and whether that is the CPU view's same offset.XCL_UMA_SHADOW=1 XCL_HEAP_WINDOWS=1 XCL_NETWORK=0 XCL_ACTIVITY=1 XCL_GPU_WAIT_RELEASE_MS=250, warm caches. Local switches: the title's own stall watchdog is neutralised; compute programs of 4 MB of DXIL or more are not handed to the driver. WindowsTdrDelay30 s. Two runs of the retail title: one stopped at 106 s, one ran to 203 s. The world starts at 88 – 94 s and then presents 1.3 – 1.5 frames per second.1. Same shape as measured above
pool_pages 0x185c0, as above); here it is outside every unified-memory window too.2. Readers other than textures (not covered by #1102, which resolves pages in
title_texturesonly)Every buffer view the title creates (whole-resource SRV / UAV) and every root view address it binds, checked page by page against the recorded map:
So when the world starts, same offset would give these views the right page; a per-page map starts to matter for them a minute or two later. What they read today is zeros for another reason: the GPU view is outside the windows, so translated shaders see nothing there whatever the mapping says (#697). A fix for #697 that makes GPU-view addresses reachable would need to resolve them through #1055's map rather than by same offset, or it will be right at first and then wrong for a growing share.
One caveat on "right": I did not count how many of the right pages have committed bytes in XCL. One address I probed was right by same offset in run 2 but its CPU-view page had never been touched (no bytes anywhere in XCL), and in run 1 the same address was a wrong page with data at the pool address.
Two groups are never destinations of a batch in either run: the 125 SRVs / 127 UAVs in the title's third 64 KiB-page reservation (the GPU-written buffers of #697), and the root views outside both the windows and the GPU view (7 171 addresses in run 1).
3. For the rebase of #1055
mainthe hunk that no longer applies is theVirtualFreeone inkernelx.rs(the code #1998 changed).Not tested: #1102 (textures) itself; whether resolving through the map changes the picture; AMD; current
main. The second run lost the device (0x887a0005) at 203.6 s as every long run does here, with or without #1803; nothing in this census ties that to the batches.AI use: Claude Code (Claude Fable 5.2 coordinating, Claude Opus 5.5 for the port, the census logging and the runs) did this and drafted the comment.
@adiologydev on GitHub · 2026-11-25 10:36 UTC · original
Plan, before any code: real aliasing of physical pages (one page, every address it is mapped at), as an answer to the question above. Taking it on unless someone already is or you'd rather not go that way.
Why. XCL keeps a physical page at one address at a time and copies it when the title maps it elsewhere (
kernelx::move_away). The console shows the page at every address it is mapped at. Xeltax's census above, done by page, has 15,064 of 34,872 GPU-view pages still at their pool address while the identity mirror reads the CPU view, and #1055 records the right page without anything reading it. Each copy-based reader (textures #1102, buffer views on #697) has to redo the lookup, and stays stale when the title writes through another view.Measured feasibility (a standalone test program, not XCL; RTX 5090 machine, Ryzen 9 7950X, Windows 11 26200):
SEC_RESERVEsection, each committed once. A page mapped into a placeholder at two addresses is the same memory: a write at one reads back at the other.VirtualAlloc2withMEM_REPLACE_PLACEHOLDER | MEM_WRITE_WATCH), so a sparse window can hold both.GetWriteWatchrefuses a range that contains views (error 87), so the watch scans the write-watched reservations, not the whole window.VirtualProtect0.5 µs, over 200 000 pages (no copy; today's remap copies 64 KiB).kernelx::lazydoes for first use) and marked dirty on the page, for all its views.Split (each its own PR, stacked, under ~400 lines; behind
XCL_PAGE_ALIAS=1until the last):kernelx: with the switch, mapping a page maps the section's slice at the address (nomove_away, no copy); unmapping keeps the placeholder. The title's 64 KiB-page reservations become placeholders. Tests: a write through one mapping reads back at the others, remap, unmap, free.CopyPageMappingsBatchXapplies its batches with the same mapping, on #1055's decoder (I'll build on #1055 rather than redo it), kind 1 (one pool page repeated) included.sparse: one video-memory tile per physical page, and every address of the page in a window maps that tile (UpdateTileMappingsto the same heap tile), so the GPU sees the aliases too and a page is uploaded once.Parts 1–3 already make the GPU view read the right pages on the CPU, and part 3 has
title_texturesread a texture in a GPU view at its own address instead of throughmirrors::source; 4–6 are what buffer and root views in the GPU view (#697) need. I'll post numbers from in-world runs on an RTX 5090 with each part.AI use: Claude Code (Claude Opus 5.5) wrote the feasibility test and this plan; I checked it.