KernelX / title textures: a GPU view of the title's CPU memory reads the CPU view (retail intro video, no green screen) #283
No reviewers
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!283
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/283/head"
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?
@jessenic on GitHub · 2026-11-23 22:22 UTC · original
jessenic:fix/gpu-mirror-view→main· +309 −9 · 2 files · 2 commits · merged 2026-11-23 23:18 UTCStacked on #252: this branch contains #252's commit (862a0d4) followed by this one (94bfcf0). Review/merge #252 first; this PR's own diff is the last commit.
What was wrong
After the first A press, a retail game showed a solid green screen (
0x008700) for ~15 s before its menus. Green is what a YUV→RGB shader gives for zero luma and chroma. The draws in that stretch come from one pixel shader that samples three R8 planes (3840x2160 + 2x 1920x1080): the game's Bink video.BinkRegisterFrameBuffers(traced withXCL_TRACE_IMPORTS) gets frame buffers in one reservation, which the CPU decoder writes.XCL_WATCH_SRV-style logging of the views) lie at the same addresses + 0x6_0000_0000, in a second reservation.The game reserves 24 GB of 64 KiB pages twice in a row (flags
0x20402000): firstPAGE_READWRITE, thenPAGE_NOACCESS | PAGE_GRAPHICS_NOACCESS(0x801). It maps physical pages (XMemMapPhysicalPages, ~60k calls in the first minute) only into the first, never into the second, yet places GPU resources at the same offset in the second. On the console the second reservation is a GPU-only view of the first. Under XCL it was separate, empty memory.Change
kernelx::mirrors: a no-access graphics reservation of 64 KiB pages is paired with the most recent CPU-readable reservation of the same size (dropped when either is released).source(va)names the CPU-view address behind a GPU-view address.title_textures: a texture placed in a GPU view where nothing is mapped is kept in step with the same offset in the CPU view. Its bytes are read and its CPU writes watched there (Entry::src). Its title address (address():GetGPUVirtualAddress, GPU copies into it) stays the GPU view's.It needs the CPU view to be write-watched, which is what #252 adds for these fallback reservations.
Scope: only kept-in-step textures follow the CPU view. Buffers the title might place in such a GPU view are not covered. Mapping the same pages into both views (true aliasing through a section) would cover everything, but XCL's physical pages move between addresses by commit/decommit, and views of a section can neither be write-watched nor decommitted.
Testing
gpu_view_reservations_name_their_cpu_view(pairing, offsets, end of range, release).cargo test --workspace: 653 passed, 0 failed, 40 ignored (RTX 5070 Ti, driver 32.0.16.1088).XCL_PRESS_AT=45:A, frame dumps): the intro video plays after the A press instead of the green screen. 512+ textures found in the GPU view within 90 s.🤖 Generated with Claude Code
idxenreads from a CBV ignore the index – measured on Linux, Windows measurement wanted #307@Kalmarv on GitHub · 2026-11-23 22:25 UTC · original
A physical page mapped into a GPU view before its first use is not seen as mapped.
mirror_sourcedecides "mapped" byVirtualQuery(va).State == MEM_COMMIT. A page whose home was never used is mapped into plain address space only as reserved memory, committed at its first access (kernelx::lazy, onmainsince38b05b7). For such a page,mirror_sourcereturns the CPU view's address instead ofva.registercomputessrconce, so a texture placed on that page then reads, and watches, the CPU view rather than the page mapped under it. The title's later writes to the page commit it, but they are not uploaded.The test below, on
main9ab7d76with this PR (94bfcf0) merged, CPU only:mirrors::reservedthe way the fallback path does (0x2040_2000withPAGE_READWRITE, then with0x801).MapTitlePhysicalPages.mirror_sourcethen gives the CPU view's address before the page's first touch, andatafter it:test (in title_textures.rs's tests)
A possible fix: ask
kernelxwhether a physical page is mapped atva(its away map, which holds lazy pages too), not whether the address is committed.Your description says the retail game maps physical pages only into the CPU view, so this may not affect the intro video. It matters for any title that maps fresh pages into a GPU view and places textures there.
Tested
main9ab7d76+ #283 (94bfcf0), release build, Windows 11, Ryzen 9 9950X. CPU only: no D3D device is created. It fails on the "before" assertion; the "after" one holds.Not tested
vaafter the texture is registered (srcis fixed atregister). Not tested.🤖 Claude Opus 5.5
@mariuslozo-boop on GitHub · 2026-11-23 22:38 UTC · original
Test report on NVIDIA. This PR fixes the green intro here. Tested at
94bfcf0(with #252's862a0d4under it), merged onto main9ab7d76. I also ran head2a64505once, by hand (last row).Setup: RTX 5070 Ti (16 GB), driver 616.92 (32-lane waves), AMD Ryzen 7 7700X, 32 GB RAM, Windows 11 Pro 26300. Release build, DXC 1.8.2502.11, warm DXIL cache. Retail title 1.0.2.1.
XCL_NETWORK=0 XCL_RUN_SECONDS=<n> XCL_ACTIVITY=1 XCL_FRAME_DUMP=30 xcl.exe run <game folder>, no input. One run per build.9ab7d760xff008700×518400activity (2 s): 60 presents)03d4a86)0xff008700×51840094bfcf0activity (2 s): 7 presents); 592 frames in 65 s against about 1220 in the first 65 s on main2a64505+ #244, a person watching900 frames presented, 4.6 fps over the last 300(frames 600 to 900, 31 to 96 s)On main with temporary logging (one 40 s run), the logs match your description:
state 0x2000 protect 0x0);0 of 8294400 bytes of level 0 not zero;Not tested: head
2a64505with frame dumps; the case Kalmarv raised (a page mapped into the GPU view before its first use); AMD; more than one run.AI-assisted: Claude Code (Claude Fable 5.2 ran the builds and runs; Claude Opus 5.5 wrote this report). No game files attached.
@Cattn on GitHub · 2026-11-23 22:38 UTC · original
Confirmed on Windows + NVIDIA: the retail title's intro video plays instead of solid green.
Setup: RTX 4070 12 GB (driver 617.42), Ryzen 7 7800X3D, 32 GB RAM, Windows 11, DXC 1.9.2609, release build,
XCL_NETWORK=0.Stack: main
7a033c8+ #2037cbd008+ #187c74b03a+ #208a7ffb2f+ #24477905f6+ #252862a0d4+ this PR at94bfcf0. No queue #31 handling.Result:
kernelx: reservation 0x1fa22ba0000 (0x600000000 bytes, no CPU access) is the GPU view of 0x1f422ba0000.a texture at 0x1fe6556f000 lies in a GPU view of the title's CPU memory: kept in step with 0x1f86556f000.XCL_FRAME_DUMP=40) show full movie frames from ~78 s to ~148 s.0xff008700for every movie frame.XCL_RUN_SECONDS, with no crash or device removal. Video memory then grew from 8.8 to 17.6 GB during world loading, which is a separate issue (#248 and its PRs).@gw1337x on GitHub · 2026-11-23 22:44 UTC · original
Confirming on an AMD RX 7800 XT (16 GB, driver 32.0.32015.7029), GTA VI retail: with
main9ab7d76+ #244 + this PR the intro video plays instead of the green screen.About the low frame rate you noted: on this machine it was 8–9 presents per 2 s during the video. Timing the upload path (a local counter around each step of
title_textures::refresh/texture::upload_batch) put almost all of it in the detile:subresources(read +Chain::detile_level)detile_levelcomputesoffset_z(three divisions, six table lookups) and does a bounds-checked copy for every element – 8.3 M times for the 3840×2160 R8 plane, ~60 MB/s. The change below computes what the row and the block give once per row and once per block, and copies the rows of a linear level (the video planes arelayout 0x100) whole. Levels in the mip tail (origin != (0, 0)) keep the element-by-element form. A unit test compares it with the element-by-element form for every mode, element size and pipe configuration, levels in and out of the tail, two array slices, a base swizzle and a source cut short.It is a separate change from this PR (
gpu/tiling.rsonly) and it speeds up every kept-in-step upload, not only the video – here for anyone who wants to pick it up:diff (gpu/tiling.rs, +86)
Tested:
cargo test --release -p xcl --lib tiling: 12 passed, 0 failed (incl. the new test); the retail runs above (40 s each,XCL_PRESS_A_AT=14,XCL_ACTIVITY=1), onmain9ab7d76+ #244 + #283 plus local timing counters.Not tested: the whole workspace suite, NVIDIA, other titles; no
smoke.ps1blocks. After the video, while the title streams its world, the staging buffers created per batch and the synchronous wait become the larger cost – not addressed here.AI-assisted (Claude Code, Claude Opus 5.5).
@jessenic on GitHub · 2026-11-23 22:44 UTC · original
Thanks: both points are right. Fixed in a2bfbed (and the branch is rebased onto #252's updated head, 065be41).
Lazily mapped pages.
mirror_sourcenow askskernelx::physical_page_at(va), which looks in the away map (lazy pages included), before falling back toVirtualQuery. Your test is intitle_textures's tests asa_lazily_mapped_page_in_a_gpu_view_is_its_own_source, with credit. It fails on the "before" assertion without the fix and passes with it.srcfixed atregister(your "not tested" item).map_pagesandFreeTitlePhysicalPagesbumpkernelx::gpu_view_map_gen()when the address they touch lies in a GPU view. At the next look,title_texturesrechecks the source of the textures in GPU views (Entry::in_gpu_view), and one whose source changed reads from the new one and is uploaded again. Mappings outside GPU views don't bump the generation, so the retail game's ~54,000XMemMapPhysicalPagescalls a minute (all into the CPU view) cost nothing extra. The test registers a texture before the page is mapped and checks that the recheck moves its source to the mapped page and marks it for upload.Tests:
cargo test --workspace654 passed, 0 failed, 40 ignored (RTX 5070 Ti).Not re-run with the game for this commit. The PC's free commit has since dropped below XCL's 17 GB threshold (
UMA: 9542 MB of commit free), and in that mode the game stops on an assertion early even onmain7a033c8without any of this. These changes don't alter this game's path: it maps nothing into the GPU view, sophysical_page_atis false there and the generation never moves. I'll confirm with a run once there's memory again.🤖 Claude Opus 5.5
mainreaches on Windows; the obstacle is replaced vtables — proposal: proxies #175@theaustinayers on GitHub · 2026-11-23 22:52 UTC · original
Test report on a retail title: with this PR the intro video shows a picture instead of solid green.
What was run
mainat0e946cf, and a local merge ofmain+ #244 (77905f6) + this PR (94bfcf0), merge commitf13d68d(not pushed; both merges were clean). #244 is in the test tree becausemainalone crashes in the same stretch, see below.scripts/smoke.ps1 -Game <folder> -Seconds 120withXCL_PRESS_AT=20:AandXCL_FRAME_DUMP=1set in the shell (one scripted A press on the first screen, which starts the video; a frame capture every 120 frames). Release builds, no uncommitted changes, run one after the other. The data folder was not empty (uma_coherent.txtalready learned, 4.8 GB), so the order of the two runs does not matter (#284).gpu:line names the CPU's integrated graphics (firstWin32_VideoController); XCL ran on the RTX 5090.Result
0e946cf0xff008700on all 518,400 samples (solid green)0xc0000005at 87 s in title code, a write fault (2 crashes)0xc00000050x0I did not open the captures of this particular run. On another run of the same two changes (in my fork, on top of
9ab7d76) I did look at a capture from this stretch, and it was the title's intro video with a normal picture.main:
main + #244 + #283:
Not tested
main(its branch is behindmainand does not havescripts/smoke.ps1); I cannot say from these runs which of #244 and #283 accounts for the missing crash and the lower commit. The green → picture change is this PR's subject.Both runs were on my machine; Claude Code (Claude Fable 5.2) ran the script and wrote this report.
@simnJS on GitHub · 2026-11-23 22:56 UTC · original
Tested on Linux (Wine, NVIDIA): the intro video is no longer solid green – it shows the picture – but it plays at about 5 fps.
Tested commit:
2a64505(head of #283; stacked on #252, base7a033c8, 4 commits behindmain0e946cf, none touchingcrates/). Compared withmainat0e946cf, same machine, same protocol.Tested
x86_64-pc-windows-gnu.cargo build --release --locked --target x86_64-pc-windows-gnu -p xcl: builds, both commits.XCL_NETWORK=0 XCL_ACTIVITY=1 XCL_FRAME_DUMP=120, one 70 s run per build, the account prompt answered with a single A by hand (about 48 s into themainrun, about 30 s into the #283 run).maindumps the intro as solid(0,135,0)(frames 980–1220, mean colour unchanged).2a64505dumps the real picture: frame 380 mean(88,100,27), a jungle scene with the video's lettering; frame 260 of a second run of the same build with temporary logging(83,78,80). So the GPU view of the title's CPU memory (kernelx::mirrors) works under Wine: the log has "a texture at 0x… lies in a GPU view of the title's CPU memory: kept in step with 0x…" (rate-limited: 10 lines, 512 textures by 36 s).mainshows the green video at 59 per 2 s (30 fps) and #252 alone stays at 60 per 2 s (30 fps). Draws per 2 s are 54–72 during the video, so the GPU is not the limit. With a timer aroundtitle_textures::refresh(temporary, not in the PR) the title's submits spent 1.9–2.1 s of every 2 s in it, about 70 textures uploaded per 2 s (about 2 per submit, 60 ms a submit).GetWriteWatchis not the cost: the write-watch time the log reports for the sparse windows grew by 0.47 s over 20 s; the rest is in uploading the textures (I did not timeupload_allapart).WARN/ERROR: none – 57 distinct lines against 57 onmain(the same set once addresses are masked: the oneDirectStorage: EnqueueRequest: refusedline differs only in an address).Not tested
cargo test --workspace) andscripts/smoke.ps1were not run (they need Windows).AI use
@ryosen0 on GitHub · 2026-11-23 23:03 UTC · original
Data point from a different NVIDIA card (RTX 3060 Ti 8 GB, driver 32.0.16.1742, Ryzen 7 9800X3D, Windows 11, main
4017f8f+ #300 + #294, release,XCL_NETWORK=0): the Bink intro here is not green - it is skipped/black, and after the settings menus the screen is a solid colour.bink2scarlett.dllloads and attaches; the audio of the intro plays (with #294). At the solid-colour point the log shows:So on this card the visible failure may be one step earlier than the GPU-view aliasing (texture data never arrives, BCPack refused - #208/#273), or the same zero-read you describe with a different clear colour. Happy to run a build with this PR + #252 stacked and report what the intro does here.
AI use: GPT-6.2 Astra (API model selector) wrote this comment from our run's log; the human contributor observed the screen.
mainreaches on Windows; the obstacle is replaced vtables — proposal: proxies #175@mosin311aa on GitHub · 2026-11-23 23:08 UTC · original
Can confirm the same, the 5 FPS might be a separate problem
mainreaches on Windows; the obstacle is replaced vtables — proposal: proxies #175@CodeByCon on GitHub · 2026-11-23 23:09 UTC · original
Tested on AMD (RDNA3), since the PR's numbers are from an NVIDIA card.
Build:
mainaf20b4b+ #211 + #218 + #252 (e93dc9c) + #283 (9bd7635) + #244 (77905f6), release, Rust 1.99.Hardware: AMD RX 7800 XT (gfx1101), driver 32.0.32029.2010, Windows build 26300.9974.
Result: the intro video plays with its real picture. Without #283 the same build draws every movie frame as
0xff008700. Two runs with it: 45 s (263 presents) and 55 s (635 presents), both exit 0, no device removal. This also covers issue #280 on AMD, not just NVIDIA.Frame rate: the video ran at ~6 fps on this card with the detile as it is now;
Chain::detile_levelcopies a linear surface one element at a time, and a frame is three linear R8 planes (3840x2160 + 2x 1920x1080). A local change that copies a whole row formode == 0(rows are contiguous, padded to 256 B) took the detile from 32.7 ms to ~2 ms a frame and the video from ~6 to 14.4 fps over the last 300 frames. That is the "GPU-side upload" follow-up in the description, minus the GPU: most of the cost is the per-pixel loop, not the upload. Happy to test a version of it if you want it in this PR or a separate one.One thing to avoid: skipping the
read_committedcopy and detiling straight from the CPU view (saving one 8 MB copy per plane) crashed this title atgame+0x2215c35(write at 0) 5-10 s in, on repeated runs; keeping the copy is fine.Not tested: NVIDIA, other titles, whole workspace suite.
cargo test -p xcl --lib gpu::tiling: 12 passed, 0 failed (includes a new test for the linear row path).AI-assisted: DeepSeek V4.1 Flash wrote this report from our runs.
mainreaches on Windows; the obstacle is replaced vtables — proposal: proxies #175@gw1337x on GitHub · 2026-11-23 23:30 UTC · original
Follow-up to my detile comment above: with the detile fixed, the rest of the upload path showed up once the title streams its world after the video. Same machine (RX 7800 XT, GTA VI),
XCL_PRESS_A_AT=14,17,21,XCL_ACTIVITY=1, timing counters around each step.What it was:
texture::upload_batchmakes a new allocator, command list, fence and upload buffer for every batch, one upload buffer per texture (buffer(dev, total)), and then waits on the CPU (wait) before the title's submit continues. During world loading that became the cost:The change (
gpu/texture.rs,title_textures.rs):texture::Uploader, one per device: one command list, allocators and upload buffers reused once the GPU is past them, one fence. A batch's textures share one upload buffer (64 MiB and up), each at its own 512-aligned offset (record_upload_withtakes the staging memory from the caller;record_upload_stateskeeps its behaviour).title_textures::refreshmakes the title's queueWaiton the uploader's fence (only its own device's; a fence of another device left a queue's work unrun in the tests).XCL_SYNC_UPLOADS=1keeps the old path.diff on main
4017f8f(gpu/texture.rs, title_textures.rs: +215 −2)Tested:
main4017f8f:cargo test --release -p xcl --lib -- --test-threads=4: 612 passed, 0 failed, 20 ignored.main9ab7d76+ #244 + this PR + the detile change + these commits + timing counters): its lib suite 615 passed, 0 failed; 60–70 s runs, no device removal; the D3D12 debug layer shows no new message ids.Not tested: the diff on its own with the title; no
smoke.ps1blocks; NVIDIA. From ~50 s the frames drop again, but with the upload work idle by then (a thread dump showed the render thread in the driver's pipeline compiler) – not addressed here.It is separate from this PR; here for anyone who wants to pick it up.
AI-assisted (Claude Code, Claude Opus 5.5).
mainreaches on Windows; the obstacle is replaced vtables — proposal: proxies #175mainreaches on Windows; the obstacle is replaced vtables — proposal: proxies #175@ofc0urse on GitHub · 2026-11-24 00:23 UTC · original
Data point from another NVIDIA card: RTX 4060 Ti 8 GB, driver 621.24, Intel i5-14400F, 32 GB RAM, Windows 11.
Build: local release build of
mainc8e3ca0+ #235 + #252 + #283 (9bd7635) + #292/#269 + #244 + #254 + #267 + #306 + #314 + #322, plus local changes that are not in any PR. Run withxcl.exe run <game folder>andXCL_NETWORK=0.Tested: the Bink intro after account select shows the picture. Before #283 it was solid green on this machine.
Not tested: #283 alone on top of
main. Intro frame rate (not measured).AI use: Claude Code, Claude Opus 5.5 collected the build details and wrote this comment. I watched the intro on screen myself.
@xstraok on GitHub · 2026-11-24 00:26 UTC · original · edited 2026-11-24 00:30 UTC
@gw1337x Your detile diff, measured on Linux / RDNA4: it removes the slow stretch after the menus there too.
Where the time went (before):
maindb1ddb2+ #257, GTA VI 1.0.2.1. After the first A press the title held 5.8–8.8 fps for about a minute, then went back to 30. One title thread was at 97–101 % of a core for that whole stretch, and dropped to 34–41 % when fps recovered. WithXCL_THREAD_DUMP_AT=85,95,105, the render thread (the one that logsframes presented) had the same stack in all three dumps:PresentX/ExecuteCommandLists→real::queue_dispatch→title_textures::refresh→title_textures::subresources→Chain::detile_level→gpu::tiling::Layout::offset_zGPU busy stayed at 13–21 % (about 10 % when idle).
A/B: your
tiling.rsdiff applied unchanged. Two release builds ofmaina6f5f7a+ #257 (merged locally), one without the diff and one with it. 150 s each,XCL_ACTIVITY=1, A pressed by hand as soon as the prompt appeared.With the diff the title got through its first-run settings screens (minimap, brightness) to the loading screen within the 150 s; without it, it was still on those screens. On the loading screen DirectStorage streams 870–2560 requests per 2 s, some of them BCPack refusals (#208 / #233 / #273). Presents dropped to 7–47 per 2 s, two other threads were near 100 %, and the spinner froze about 8 s before the run ended. I haven't looked at what those threads were doing yet; it may be the upload_batch cost from your follow-up.
Unit tests, under Wine:
cargo test --release --target x86_64-pc-windows-gnu -p xcl --lib tiling: 12 passed, 0 failed, 0 ignored, includingfast_detile_matches_element_by_element. Dropping thehxterm from the per-block XOR makes that test fail, so it does catch a wrong fast path.Setup: RX 9060 XT (RADV, Mesa 26.2.6), Ryzen 5 7600, 32 GB, Arch Linux, kernel 7.2.15. Proton Experimental 11.0 (20261112) Wine, vkd3d-proton v3.1 + #257's patch, Proton's DXVK.
x86_64-pc-windows-gnu, release.XCL_NETWORK=0,XCL_COHERENT_MB=512(the learned 4095 MB window makes this setup crawl, see #284).Not tested: Windows, the whole workspace suite, NVIDIA, your
Uploaderdiff.Is anyone opening a PR for the detile change? If not, I can, credited to you. On a PR it would lack the Windows suite and
smoke.ps1blocks, which I can't produce from here.Measured and written with Claude Code (Claude Opus 5.5).
@grahamster2 on GitHub · 2026-11-24 00:42 UTC · original
Tested @gw1337x's patch from this comment (reused uploader without the CPU wait + detile fast path) on an NVIDIA card: the intro video goes from ~4.5 fps to 30 fps and world streaming starts ~88 s earlier.
Setup: RTX 3080 10 GB, driver 610.88 (plus an AMD iGPU, which XCL doesn't use), 32 GB RAM with ~15–17 GB taken by other programs. The retail title, release builds.
maindb1ddb2. The patch doesn't apply on the newestmaina6f5f7a(title_textures.rsconflicts), so I useddb1ddb2.db1ddb2+ both parts of the patch, as a local commit 203d1d9 (not pushed).2 runs per build,
XCL_NETWORK=0 XCL_ACTIVITY=1 XCL_PRESS_A_AT=14,17,21 XCL_RUN_SECONDS=180, warm cache. Numbers come from theactivity (2 s)lines.In A the video shows the same frames 6–7× slower: 99 s at ~4.5 fps vs 13 s at 30 fps, about 440 vs 400 frames. In both builds the presents drop to 1–10 per 2 s within ~15 s of world streaming starting.
Note on the watchdog: all 4 runs were stopped by my watchdog, which kills XCL when free physical RAM falls below 1.5 GB. That happened 14–18 s after world streaming started in both builds, at a commit of 22–25 GB. Since this machine has only ~15 GB free, that point is a RAM limit of mine and not a regression from the patch: A reaches it too, just 88 s later. The "max after" row therefore covers only those ~15 s.
scripts/smoke.ps1, 60 s. It presses nothing, so it stays on the menu. I replaced the title line; the rest is pasted as printed. Thegpu:line names the iGPU because the script takes the first adapter, but XCL logged that it ran on the RTX 3080.Not tested:
main, where the patch conflicts.Test runs and this report: Claude Code (Claude Opus 5.5).
mainreaches on Windows; the obstacle is replaced vtables — proposal: proxies #175