KernelX / title textures: a GPU view of the title's CPU memory reads the CPU view (retail intro video, no green screen) #283

Manually merged
github merged 2 commits from gh-pr/283/head into gh-pr/283/base 2026-11-26 04:18:38 +00:00
Owner

@⁠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 UTC

Stacked 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 with XCL_TRACE_IMPORTS) gets frame buffers in one reservation, which the CPU decoder writes.
  • The textures the shader samples (XCL_WATCH_SRV-style logging of the views) lie at the same addresses + 0x6_0000_0000, in a second reservation.
  • A readback showed both the textures and the memory at their own addresses all zero.

The game reserves 24 GB of 64 KiB pages twice in a row (flags 0x20402000): first PAGE_READWRITE, then PAGE_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

  • New unit test 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).
  • Retail run (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.
  • Cost: the 4K planes are uploaded (CPU detile) every video frame: 12.4 fps during the video vs 17 fps of green before. A GPU-side upload of planes that change every frame would be a follow-up.

🤖 Generated with Claude Code

**@⁠jessenic** on GitHub · 2026-11-23 22:22 UTC · [original](https://github.com/xcl-dev/xcl/pull/283) `jessenic:fix/gpu-mirror-view` → `main` · +309 −9 · 2 files · 2 commits · merged 2026-11-23 23:18 UTC **Stacked 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 with `XCL_TRACE_IMPORTS`) gets frame buffers in one reservation, which the CPU decoder writes. - The textures the shader samples (`XCL_WATCH_SRV`-style logging of the views) lie at **the same addresses + 0x6_0000_0000**, in a second reservation. - A readback showed both the textures and the memory at their own addresses all zero. The game reserves 24 GB of 64 KiB pages twice in a row (flags `0x20402000`): first `PAGE_READWRITE`, then `PAGE_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 - New unit test `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). - Retail run (`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. - Cost: the 4K planes are uploaded (CPU detile) every video frame: 12.4 fps during the video vs 17 fps of green before. A GPU-side upload of planes that change every frame would be a follow-up. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
A retail game reserves 24 GB of 64 KiB pages (VirtualAlloc flags 0x20402000) and commits
2.2 GB of large pages with a graphics protection (flags 0x20003000, protection 0x2404).
Neither fits a sparse or the coherent window, so both fell through to plain memory without
MEM_WRITE_WATCH. Textures the title places there are kept in step with the memory
(d3d12x::title_textures), which relies on GetWriteWatch to see CPU writes: they were
uploaded once, empty, and never again (128+ textures in the first 45 s).

One of them is the game's 2048x2048 A8_UNORM glyph atlas, which the CPU fills as text is
laid out. Its GPU copy stayed zero, so every glyph drawn from it (the x-height letters:
a c e m n o r s u v w x z) was missing from the menus; letters drawn by the vector path
(ascenders, descenders, capitals) were fine. Found by a GPU readback of the atlas (zero)
against its CPU view (glyphs) while the menu was on screen.

The fallback VirtualAlloc now reserves GPU-visible memory (gpu_visible_fallback:
MEM_GRAPHICS, MEM_LARGE_PAGES / MEM_64K_PAGES, or a PAGE_GRAPHICS_* protection) with
MEM_WRITE_WATCH and records it with the graphics reservations (reserve_watched), whose
ranges title_textures watches.

Cost, measured on the game (RTX 5070 Ti): the write-watch scan goes from ~0.5 ms to
2.0-2.7 ms a submit once the menus have loaded, ~5-6 GB of kept-in-step textures now
being scanned; 1093 frames in 80 s against 1297.

Test: gpu_visible_fallback_memory_is_write_watched calls the fallback directly (through
VirtualAlloc the unified-memory windows take these sizes when they have room); it fails
without MEM_WRITE_WATCH.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
A retail game reserves 24 GB of 64 KiB pages twice in a row (VirtualAlloc flags
0x20402000): once PAGE_READWRITE, once PAGE_NOACCESS | PAGE_GRAPHICS_NOACCESS (0x801). It
maps physical pages only into the first (XMemMapPhysicalPages, ~54,000 calls in the first
minute), yet places GPU resources at the same offset in the second: its Bink video planes
are decoded by the CPU into the first view (BinkRegisterFrameBuffers), and the video shader
samples R8 textures at those addresses plus the reservation's size. On the console the
second reservation is a GPU-only view of the first; here it was separate, empty memory, so
the video drew zero luma and chroma: a green screen for ~15 s after the first A press.

kernelx::mirrors pairs such a no-access graphics reservation of 64 KiB pages with the most
recent CPU-readable one of the same size (forgotten when either is released).
title_textures keeps a texture placed in the GPU view, where no physical page is mapped,
in step with the same offset in the CPU view: its bytes are read and its CPU writes watched
there (Entry::src), while its title address (GetGPUVirtualAddress, GPU copies into it)
stays the GPU view's. A page mapped at the address counts before its first use too
(kernelx::physical_page_at asks the away map, lazy pages included), and mapping or
unmapping pages inside a GPU view (gpu_view_map_gen) makes the textures there take their
source again at the next look, uploaded from the new one. Mappings elsewhere do not bump
it, so they cost nothing.

The 4K planes are now uploaded each video frame: 12.4 fps during the video against 17 fps
of green before (RTX 5070 Ti).

Tests: gpu_view_reservations_name_their_cpu_view;
a_lazily_mapped_page_in_a_gpu_view_is_its_own_source (by Kalmarv in the review, extended
with a texture registered before the mapping).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:18:36 +00:00
github manually merged commit 9bd763538a into gh-pr/283/base 2026-11-26 04:18:38 +00:00
Author
Owner

@⁠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_source decides "mapped" by VirtualQuery(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, on main since 38b05b7). For such a page, mirror_source returns the CPU view's address instead of va. register computes src once, 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 main 9ab7d76 with this PR (94bfcf0) merged, CPU only:

  • It reserves two 16 MiB ranges and records them with mirrors::reserved the way the fallback path does (0x2040_2000 with PAGE_READWRITE, then with 0x801).
  • It maps one fresh physical page into the GPU view with MapTitlePhysicalPages.
  • mirror_source then gives the CPU view's address before the page's first touch, and at after it:
source before the first touch 0x138955c0000 (the CPU view), after 0x138965c0000 (at)
assertion failed: a page mapped at the address but not used yet is its source too
test (in title_textures.rs's tests)
#[test]
fn a_lazily_mapped_page_in_a_gpu_view_is_its_own_source() {
    use crate::hle::kernelx;
    use windows_sys::Win32::System::Memory::{VirtualAlloc, VirtualFree, MEM_RELEASE, MEM_RESERVE, PAGE_READWRITE};
    const VIEW: usize = 16 << 20;
    unsafe {
        let Some(_) = crate::gpu::uma::get() else { return };
        let cpu = VirtualAlloc(std::ptr::null(), VIEW, MEM_RESERVE, PAGE_READWRITE) as usize;
        let gpu = VirtualAlloc(std::ptr::null(), VIEW, MEM_RESERVE, PAGE_READWRITE) as usize;
        kernelx::mirrors::reserved(cpu, VIEW, 0x2040_2000, 0x04);
        kernelx::mirrors::reserved(gpu, VIEW, 0x2040_2000, 0x801);
        assert_eq!(mirror_source(gpu + 0x2_0000), cpu + 0x2_0000); // nothing mapped: the CPU view
        let (mut n, mut pages) = (1usize, [0usize; 1]);
        assert_eq!(kernelx::AllocateTitlePhysicalPages(std::ptr::null_mut(), 0, &mut n, pages.as_mut_ptr()), 1);
        let at = gpu + 0x2_0000;
        assert_eq!(kernelx::MapTitlePhysicalPages(at as *mut c_void, 1, 0, 4, pages.as_mut_ptr()) as usize, at);
        let before = mirror_source(at);
        (at as *mut u32).write_volatile(7); // its first use commits it
        let after = mirror_source(at);
        let mut none = [0usize; 1];
        kernelx::MapTitlePhysicalPages(at as *mut c_void, 1, 0, 4, none.as_mut_ptr());
        kernelx::FreeTitlePhysicalPages(std::ptr::null_mut(), 1, pages.as_mut_ptr());
        kernelx::mirrors::released(cpu);
        VirtualFree(cpu as *mut c_void, 0, MEM_RELEASE);
        VirtualFree(gpu as *mut c_void, 0, MEM_RELEASE);
        assert_eq!(after, at);
        assert_eq!(before, at, "a page mapped at the address but not used yet is its source too"); // fails
    }
}

A possible fix: ask kernelx whether a physical page is mapped at va (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

  • The test above on main 9ab7d76 + #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

  • A title, and whether any title maps pages into a GPU view.
  • What happens when a page is mapped or unmapped at va after the texture is registered (src is fixed at register). Not tested.
  • Any fix.

🤖 Claude Opus 5.5

**@⁠Kalmarv** on GitHub · 2026-11-23 22:25 UTC · [original](https://github.com/xcl-dev/xcl/pull/283#issuecomment-7115741879) **A physical page mapped into a GPU view before its first use is not seen as mapped.** `mirror_source` decides "mapped" by `VirtualQuery(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`, on `main` since 38b05b7). For such a page, `mirror_source` returns the CPU view's address instead of `va`. `register` computes `src` once, 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 `main` `9ab7d76` with this PR (`94bfcf0`) merged, CPU only: - It reserves two 16 MiB ranges and records them with `mirrors::reserved` the way the fallback path does (`0x2040_2000` with `PAGE_READWRITE`, then with `0x801`). - It maps one fresh physical page into the GPU view with `MapTitlePhysicalPages`. - `mirror_source` then gives the CPU view's address before the page's first touch, and `at` after it: ``` source before the first touch 0x138955c0000 (the CPU view), after 0x138965c0000 (at) assertion failed: a page mapped at the address but not used yet is its source too ``` <details><summary>test (in title_textures.rs's tests)</summary> ```rust #[test] fn a_lazily_mapped_page_in_a_gpu_view_is_its_own_source() { use crate::hle::kernelx; use windows_sys::Win32::System::Memory::{VirtualAlloc, VirtualFree, MEM_RELEASE, MEM_RESERVE, PAGE_READWRITE}; const VIEW: usize = 16 << 20; unsafe { let Some(_) = crate::gpu::uma::get() else { return }; let cpu = VirtualAlloc(std::ptr::null(), VIEW, MEM_RESERVE, PAGE_READWRITE) as usize; let gpu = VirtualAlloc(std::ptr::null(), VIEW, MEM_RESERVE, PAGE_READWRITE) as usize; kernelx::mirrors::reserved(cpu, VIEW, 0x2040_2000, 0x04); kernelx::mirrors::reserved(gpu, VIEW, 0x2040_2000, 0x801); assert_eq!(mirror_source(gpu + 0x2_0000), cpu + 0x2_0000); // nothing mapped: the CPU view let (mut n, mut pages) = (1usize, [0usize; 1]); assert_eq!(kernelx::AllocateTitlePhysicalPages(std::ptr::null_mut(), 0, &mut n, pages.as_mut_ptr()), 1); let at = gpu + 0x2_0000; assert_eq!(kernelx::MapTitlePhysicalPages(at as *mut c_void, 1, 0, 4, pages.as_mut_ptr()) as usize, at); let before = mirror_source(at); (at as *mut u32).write_volatile(7); // its first use commits it let after = mirror_source(at); let mut none = [0usize; 1]; kernelx::MapTitlePhysicalPages(at as *mut c_void, 1, 0, 4, none.as_mut_ptr()); kernelx::FreeTitlePhysicalPages(std::ptr::null_mut(), 1, pages.as_mut_ptr()); kernelx::mirrors::released(cpu); VirtualFree(cpu as *mut c_void, 0, MEM_RELEASE); VirtualFree(gpu as *mut c_void, 0, MEM_RELEASE); assert_eq!(after, at); assert_eq!(before, at, "a page mapped at the address but not used yet is its source too"); // fails } } ``` </details> A possible fix: ask `kernelx` whether a physical page is mapped at `va` (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** - The test above on `main` `9ab7d76` + #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** - A title, and whether any title maps pages into a GPU view. - What happens when a page is mapped or unmapped at `va` after the texture is registered (`src` is fixed at `register`). Not tested. - Any fix. 🤖 Claude Opus 5.5
Author
Owner

@⁠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's 862a0d4 under it), merged onto main 9ab7d76. I also ran head 2a64505 once, 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.

build intro movie presents during the movie
main 9ab7d76 solid green: frames 320 to 740 are all 0xff008700×518400 ~30 a second (activity (2 s): 60 presents)
main + #236 (03d4a86) still green: frames 410 to 830 are all 0xff008700×518400 ~30 a second (60 in 2 s)
main + this PR 94bfcf0 the movie's picture: none of the 20 sampled frames (every 30th, up to 65 s) is green ~4 a second (7 to 9 in 2 s, e.g. activity (2 s): 7 presents); 592 frames in 65 s against about 1220 in the first 65 s on main
main + this PR at head 2a64505 + #244, a person watching the movie plays, visibly slow 900 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:

  • the nine movie planes (three 3840×2160 and six 1920×1080 R8) are placed in the graphics range at +0x6_0000_0000, in memory that is only reserved (state 0x2000 protect 0x0);
  • each is uploaded once, as zeros: 0 of 8294400 bytes of level 0 not zero;
  • 30 of the run's 123 large textures sit in that range, and all of them upload zeros.

Not tested: head 2a64505 with 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.

**@⁠mariuslozo-boop** on GitHub · 2026-11-23 22:38 UTC · [original](https://github.com/xcl-dev/xcl/pull/283#issuecomment-7116002958) Test report on NVIDIA. This PR fixes the green intro here. Tested at `94bfcf0` (with #252's `862a0d4` under it), merged onto main `9ab7d76`. I also ran head `2a64505` once, 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. | build | intro movie | presents during the movie | |---|---|---| | main `9ab7d76` | solid green: frames 320 to 740 are all `0xff008700×518400` | ~30 a second (`activity (2 s): 60 presents`) | | main + #236 (`03d4a86`) | still green: frames 410 to 830 are all `0xff008700×518400` | ~30 a second (60 in 2 s) | | main + this PR `94bfcf0` | **the movie's picture**: none of the 20 sampled frames (every 30th, up to 65 s) is green | ~4 a second (7 to 9 in 2 s, e.g. `activity (2 s): 7 presents`); 592 frames in 65 s against about 1220 in the first 65 s on main | | main + this PR at head `2a64505` + #244, a person watching | the movie plays, visibly slow | `900 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: - the nine movie planes (three 3840×2160 and six 1920×1080 R8) are placed in the graphics range at +0x6_0000_0000, in memory that is only reserved (`state 0x2000 protect 0x0`); - each is uploaded once, as zeros: `0 of 8294400 bytes of level 0 not zero`; - 30 of the run's 123 large textures sit in that range, and all of them upload zeros. **Not tested:** head `2a64505` with 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.
Author
Owner

@⁠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 + #203 7cbd008 + #187 c74b03a + #208 a7ffb2f + #244 77905f6 + #252 862a0d4 + this PR at 94bfcf0. No queue #31 handling.

Result:

  • The pairing is found once at start-up: kernelx: reservation 0x1fa22ba0000 (0x600000000 bytes, no CPU access) is the GPU view of 0x1f422ba0000.
  • The video's planes are kept in step through it: a texture at 0x1fe6556f000 lies in a GPU view of the title's CPU memory: kept in step with 0x1f86556f000.
  • Frame dumps (XCL_FRAME_DUMP=40) show full movie frames from ~78 s to ~148 s.
  • The same stack without this PR shows 0xff008700 for every movie frame.
  • After the movie: the first-boot screens, then a loading screen with its artwork. A 360 s run ended on 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).
**@⁠Cattn** on GitHub · 2026-11-23 22:38 UTC · [original](https://github.com/xcl-dev/xcl/pull/283#issuecomment-7116010282) 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` + #203 `7cbd008` + #187 `c74b03a` + #208 `a7ffb2f` + #244 `77905f6` + #252 `862a0d4` + this PR at `94bfcf0`. No queue #31 handling. **Result:** - The pairing is found once at start-up: `kernelx: reservation 0x1fa22ba0000 (0x600000000 bytes, no CPU access) is the GPU view of 0x1f422ba0000`. - The video's planes are kept in step through it: `a texture at 0x1fe6556f000 lies in a GPU view of the title's CPU memory: kept in step with 0x1f86556f000`. - Frame dumps (`XCL_FRAME_DUMP=40`) show full movie frames from ~78 s to ~148 s. - The same stack without this PR shows `0xff008700` for every movie frame. - After the movie: the first-boot screens, then a loading screen with its artwork. A 360 s run ended on `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).
Author
Owner

@⁠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 main 9ab7d76 + #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:

per 2 s during the video before after the change below
subresources (read + Chain::detile_level) ~1 850 ms ~450 ms
staging + copy recording ~60 ms ~440 ms
submit + wait ~30 ms ~210 ms
bytes uploaded ~230 MB ~1 600 MB
presents 8–9 60 (the title's 30 fps)

detile_level computes offset_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 are layout 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.rs only) 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)
diff --git a/crates/xcl/src/gpu/tiling.rs b/crates/xcl/src/gpu/tiling.rs
index 7d9f4be..4074307 100644
--- a/crates/xcl/src/gpu/tiling.rs
+++ b/crates/xcl/src/gpu/tiling.rs
@@ -395,6 +395,61 @@ impl Chain {
     /// level `i` of array slice `slice` (`src` = the slice's bytes) → linear rows of elements;
     /// bytes past the end of `src` read as 0
     pub fn detile_level(&self, src: &[u8], i: usize, slice: usize) -> Vec<u8> {
+        let l = self.levels[i];
+        // a level in the mip tail starts inside a block: element by element (small levels)
+        if l.origin != (0, 0) {
+            return self.detile_level_slow(src, i, slice);
+        }
+        let lay = &self.layout;
+        let e = 1usize << lay.elem_log2;
+        let (w, h) = (l.width, l.height);
+        let mut out = vec![0u8; w * h * e];
+        let (bw, bh, bd) = (lay.block_w, lay.block_h, lay.block_d);
+        let pitch_blocks = l.pitch.div_ceil(bw);
+        let hi = |t: &[u32], c: usize, b: usize| t[(c / b) % t.len()];
+        // linear: each row is contiguous (blocks of 256 B one row high, side by side)
+        if lay.mode == 0 && lay.base_xor == 0 {
+            let row = w * e;
+            for y in 0..h {
+                let o = l.offset + y * pitch_blocks * lay.block_bytes;
+                if o < src.len() {
+                    let n = row.min((src.len() - o) / e * e);
+                    out[y * row..y * row + n].copy_from_slice(&src[o..o + n]);
+                }
+            }
+            return out;
+        }
+        // tiled: what the row and the block give, once per row and per block (`offset_z`)
+        let z = lay.oz[slice % bd] ^ hi(&lay.hz, slice, bd);
+        for y in 0..h {
+            let yo = lay.oy[y % bh] ^ hi(&lay.hy, y, bh) ^ z;
+            let row_base = l.offset + (y / bh) * pitch_blocks * lay.block_bytes;
+            for bx in 0..w.div_ceil(bw) {
+                let bo = yo ^ lay.hx[bx % lay.hx.len()];
+                let base = row_base + bx * lay.block_bytes;
+                let x0 = bx * bw;
+                let n = bw.min(w - x0);
+                let d0 = (y * w + x0) * e;
+                if base + lay.block_bytes <= src.len() {
+                    for xi in 0..n {
+                        let o = base + ((lay.ox[xi] ^ bo) as usize ^ lay.base_xor);
+                        out[d0 + xi * e..d0 + xi * e + e].copy_from_slice(&src[o..o + e]);
+                    }
+                } else {
+                    for xi in 0..n {
+                        let o = base + ((lay.ox[xi] ^ bo) as usize ^ lay.base_xor);
+                        if let Some(s) = src.get(o..o + e) {
+                            out[d0 + xi * e..d0 + xi * e + e].copy_from_slice(s);
+                        }
+                    }
+                }
+            }
+        }
+        out
+    }
+
+    /// `detile_level` element by element (`element_at` for each)
+    pub fn detile_level_slow(&self, src: &[u8], i: usize, slice: usize) -> Vec<u8> {
         let l = self.levels[i];
         let e = 1usize << self.layout.elem_log2;
         let mut out = vec![0u8; l.width * l.height * e];
@@ -488,6 +543,37 @@ mod tests {
         }
     }
 
+    /// The fast `detile_level` (per row and per block) gives what the element-by-element one
+    /// gives: every mode, element size and pipe configuration, levels in and out of the tail,
+    /// array slices, a base swizzle, and a source cut short.
+    #[test]
+    fn fast_detile_matches_element_by_element() {
+        let mut modes = vec![0u32];
+        modes.extend(MODES);
+        for mode in modes {
+            for e in 0..5u32 {
+                for cfg in configs() {
+                    let Some(mut lay) = Layout::new(mode, e, cfg) else { continue };
+                    if mode != 0 {
+                        lay.base_xor = (0x5a5 << e) & (lay.block_bytes - 1) & !((1 << e) - 1);
+                    }
+                    let c = Chain::new(lay, 70, 37, 1, 4);
+                    let mut src = vec![0u8; c.slice_bytes * 2];
+                    for (k, b) in src.iter_mut().enumerate() {
+                        *b = (k as u32).wrapping_mul(2654435761).rotate_right(13) as u8;
+                    }
+                    for i in 0..c.levels.len() {
+                        for slice in 0..2 {
+                            assert_eq!(c.detile_level(&src, i, slice), c.detile_level_slow(&src, i, slice), "mode {mode} e {e} {cfg:?} level {i} slice {slice}");
+                        }
+                        let short = &src[..c.slice_bytes / 3];
+                        assert_eq!(c.detile_level(short, i, 0), c.detile_level_slow(short, i, 0), "mode {mode} e {e} {cfg:?} level {i}, cut short");
+                    }
+                }
+            }
+        }
+    }
+
     /// Every level of a chain (with a mip tail) gets its own elements: tiling all levels with
     /// distinct values and detiling them gives each back unchanged.
     #[test]

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), on main 9ab7d76 + #244 + #283 plus local timing counters.
Not tested: the whole workspace suite, NVIDIA, other titles; no smoke.ps1 blocks. 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).

**@⁠gw1337x** on GitHub · 2026-11-23 22:44 UTC · [original](https://github.com/xcl-dev/xcl/pull/283#issuecomment-7116115692) Confirming on an AMD RX 7800 XT (16 GB, driver 32.0.32015.7029), GTA VI retail: with `main` 9ab7d76 + #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: | per 2 s during the video | before | after the change below | |---|---|---| | `subresources` (read + `Chain::detile_level`) | ~1 850 ms | ~450 ms | | staging + copy recording | ~60 ms | ~440 ms | | submit + wait | ~30 ms | ~210 ms | | bytes uploaded | ~230 MB | ~1 600 MB | | presents | 8–9 | 60 (the title's 30 fps) | `detile_level` computes `offset_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 are `layout 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.rs` only) and it speeds up every kept-in-step upload, not only the video – here for anyone who wants to pick it up: <details><summary>diff (gpu/tiling.rs, +86)</summary> ```diff diff --git a/crates/xcl/src/gpu/tiling.rs b/crates/xcl/src/gpu/tiling.rs index 7d9f4be..4074307 100644 --- a/crates/xcl/src/gpu/tiling.rs +++ b/crates/xcl/src/gpu/tiling.rs @@ -395,6 +395,61 @@ impl Chain { /// level `i` of array slice `slice` (`src` = the slice's bytes) → linear rows of elements; /// bytes past the end of `src` read as 0 pub fn detile_level(&self, src: &[u8], i: usize, slice: usize) -> Vec<u8> { + let l = self.levels[i]; + // a level in the mip tail starts inside a block: element by element (small levels) + if l.origin != (0, 0) { + return self.detile_level_slow(src, i, slice); + } + let lay = &self.layout; + let e = 1usize << lay.elem_log2; + let (w, h) = (l.width, l.height); + let mut out = vec![0u8; w * h * e]; + let (bw, bh, bd) = (lay.block_w, lay.block_h, lay.block_d); + let pitch_blocks = l.pitch.div_ceil(bw); + let hi = |t: &[u32], c: usize, b: usize| t[(c / b) % t.len()]; + // linear: each row is contiguous (blocks of 256 B one row high, side by side) + if lay.mode == 0 && lay.base_xor == 0 { + let row = w * e; + for y in 0..h { + let o = l.offset + y * pitch_blocks * lay.block_bytes; + if o < src.len() { + let n = row.min((src.len() - o) / e * e); + out[y * row..y * row + n].copy_from_slice(&src[o..o + n]); + } + } + return out; + } + // tiled: what the row and the block give, once per row and per block (`offset_z`) + let z = lay.oz[slice % bd] ^ hi(&lay.hz, slice, bd); + for y in 0..h { + let yo = lay.oy[y % bh] ^ hi(&lay.hy, y, bh) ^ z; + let row_base = l.offset + (y / bh) * pitch_blocks * lay.block_bytes; + for bx in 0..w.div_ceil(bw) { + let bo = yo ^ lay.hx[bx % lay.hx.len()]; + let base = row_base + bx * lay.block_bytes; + let x0 = bx * bw; + let n = bw.min(w - x0); + let d0 = (y * w + x0) * e; + if base + lay.block_bytes <= src.len() { + for xi in 0..n { + let o = base + ((lay.ox[xi] ^ bo) as usize ^ lay.base_xor); + out[d0 + xi * e..d0 + xi * e + e].copy_from_slice(&src[o..o + e]); + } + } else { + for xi in 0..n { + let o = base + ((lay.ox[xi] ^ bo) as usize ^ lay.base_xor); + if let Some(s) = src.get(o..o + e) { + out[d0 + xi * e..d0 + xi * e + e].copy_from_slice(s); + } + } + } + } + } + out + } + + /// `detile_level` element by element (`element_at` for each) + pub fn detile_level_slow(&self, src: &[u8], i: usize, slice: usize) -> Vec<u8> { let l = self.levels[i]; let e = 1usize << self.layout.elem_log2; let mut out = vec![0u8; l.width * l.height * e]; @@ -488,6 +543,37 @@ mod tests { } } + /// The fast `detile_level` (per row and per block) gives what the element-by-element one + /// gives: every mode, element size and pipe configuration, levels in and out of the tail, + /// array slices, a base swizzle, and a source cut short. + #[test] + fn fast_detile_matches_element_by_element() { + let mut modes = vec![0u32]; + modes.extend(MODES); + for mode in modes { + for e in 0..5u32 { + for cfg in configs() { + let Some(mut lay) = Layout::new(mode, e, cfg) else { continue }; + if mode != 0 { + lay.base_xor = (0x5a5 << e) & (lay.block_bytes - 1) & !((1 << e) - 1); + } + let c = Chain::new(lay, 70, 37, 1, 4); + let mut src = vec![0u8; c.slice_bytes * 2]; + for (k, b) in src.iter_mut().enumerate() { + *b = (k as u32).wrapping_mul(2654435761).rotate_right(13) as u8; + } + for i in 0..c.levels.len() { + for slice in 0..2 { + assert_eq!(c.detile_level(&src, i, slice), c.detile_level_slow(&src, i, slice), "mode {mode} e {e} {cfg:?} level {i} slice {slice}"); + } + let short = &src[..c.slice_bytes / 3]; + assert_eq!(c.detile_level(short, i, 0), c.detile_level_slow(short, i, 0), "mode {mode} e {e} {cfg:?} level {i}, cut short"); + } + } + } + } + } + /// Every level of a chain (with a mip tail) gets its own elements: tiling all levels with /// distinct values and detiling them gives each back unchanged. #[test] ``` </details> **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`), on `main` 9ab7d76 + #244 + #283 plus local timing counters. **Not tested:** the whole workspace suite, NVIDIA, other titles; no `smoke.ps1` blocks. 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).
Author
Owner

@⁠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_source now asks kernelx::physical_page_at(va), which looks in the away map (lazy pages included), before falling back to VirtualQuery. Your test is in title_textures's tests as a_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.

src fixed at register (your "not tested" item). map_pages and FreeTitlePhysicalPages bump kernelx::gpu_view_map_gen() when the address they touch lies in a GPU view. At the next look, title_textures rechecks 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,000 XMemMapPhysicalPages calls 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 --workspace 654 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 on main 7a033c8 without any of this. These changes don't alter this game's path: it maps nothing into the GPU view, so physical_page_at is false there and the generation never moves. I'll confirm with a run once there's memory again.

🤖 Claude Opus 5.5

**@⁠jessenic** on GitHub · 2026-11-23 22:44 UTC · [original](https://github.com/xcl-dev/xcl/pull/283#issuecomment-7116119379) Thanks: both points are right. Fixed in a2bfbed (and the branch is rebased onto #252's updated head, 065be41). **Lazily mapped pages.** `mirror_source` now asks `kernelx::physical_page_at(va)`, which looks in the away map (lazy pages included), before falling back to `VirtualQuery`. Your test is in `title_textures`'s tests as `a_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. **`src` fixed at `register`** (your "not tested" item). `map_pages` and `FreeTitlePhysicalPages` bump `kernelx::gpu_view_map_gen()` when the address they touch lies in a GPU view. At the next look, `title_textures` rechecks 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,000 `XMemMapPhysicalPages` calls 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 --workspace` 654 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 on `main` `7a033c8` without any of this. These changes don't alter this game's path: it maps nothing into the GPU view, so `physical_page_at` is false there and the generation never moves. I'll confirm with a run once there's memory again. 🤖 Claude Opus 5.5
Author
Owner

@⁠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

  • main at 0e946cf, and a local merge of main + #244 (77905f6) + this PR (94bfcf0), merge commit f13d68d (not pushed; both merges were clean). #244 is in the test tree because main alone crashes in the same stretch, see below.
  • Command for both: scripts/smoke.ps1 -Game <folder> -Seconds 120 with XCL_PRESS_AT=20:A and XCL_FRAME_DUMP=1 set 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.txt already learned, 4.8 GB), so the order of the two runs does not matter (#284).
  • Ryzen 9 9950X3D, NVIDIA GeForce RTX 5090 (driver 32.0.16.2114), Windows 11 Pro 26300, Rust 1.100.0. The script's gpu: line names the CPU's integrated graphics (first Win32_VideoController); XCL ran on the RTX 5090.

Result

main 0e946cf main + #244 + #283
Captured frames after the press (most common texel) 20 s – 32 s: 0xff008700 on all 518,400 samples (solid green) 44 s, 76 s: many colours, no texel on more than 0.6 % of the samples (video frames)
Crash 0xc0000005 at 87 s in title code, a write fault (2 crashes) none in 120 s
Exit 0xc0000005 0x0
Frames shown none logged (did not reach its end) 670
Peak commit 29,259 MB 15,265 MB

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

xcl-smoke v1
commit: 0e946cfc68244edee1fba6e0425371f687a05ccd
gpu: AMD Radeon(TM) Graphics
title: NYCMain
seconds: 120
exit: 0xc0000005
frames shown: none logged (the run did not reach its end)
presents per 2 s (last 3): 0 0 2
device removals: 0
crashes: 2
peak commit: 29259 MB

main + #244 + #283:

xcl-smoke v1
commit: f13d68de9111d69cea7f34e803415954d555707c
gpu: AMD Radeon(TM) Graphics
title: NYCMain
seconds: 120
exit: 0x0
frames shown: 670 (PresentX 670)
presents per 2 s (last 3): 8 7 8
device removals: 0
crashes: 0
peak commit: 15265 MB

Not tested

  • This PR alone on current main (its branch is behind main and does not have scripts/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.
  • AMD GPUs; any other title.
  • The video's frame rate: the last "presents per 2 s" of the second run are 8, 7, 8, so it plays at about 4 fps here. I did not look into why.
  • Audio.

Both runs were on my machine; Claude Code (Claude Fable 5.2) ran the script and wrote this report.

**@⁠theaustinayers** on GitHub · 2026-11-23 22:52 UTC · [original](https://github.com/xcl-dev/xcl/pull/283#issuecomment-7116289553) Test report on a retail title: with this PR the intro video shows a picture instead of solid green. **What was run** - `main` at `0e946cf`, and a local merge of `main` + #244 (`77905f6`) + this PR (`94bfcf0`), merge commit `f13d68d` (not pushed; both merges were clean). #244 is in the test tree because `main` alone crashes in the same stretch, see below. - Command for both: `scripts/smoke.ps1 -Game <folder> -Seconds 120` with `XCL_PRESS_AT=20:A` and `XCL_FRAME_DUMP=1` set 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.txt` already learned, 4.8 GB), so the order of the two runs does not matter (#284). - Ryzen 9 9950X3D, NVIDIA GeForce RTX 5090 (driver 32.0.16.2114), Windows 11 Pro 26300, Rust 1.100.0. The script's `gpu:` line names the CPU's integrated graphics (first `Win32_VideoController`); XCL ran on the RTX 5090. **Result** | | main `0e946cf` | main + #244 + #283 | |---|---|---| | Captured frames after the press (most common texel) | 20 s – 32 s: `0xff008700` on all 518,400 samples (solid green) | 44 s, 76 s: many colours, no texel on more than 0.6 % of the samples (video frames) | | Crash | `0xc0000005` at 87 s in title code, a write fault (2 crashes) | none in 120 s | | Exit | `0xc0000005` | `0x0` | | Frames shown | none logged (did not reach its end) | 670 | | Peak commit | 29,259 MB | 15,265 MB | I 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: ``` xcl-smoke v1 commit: 0e946cfc68244edee1fba6e0425371f687a05ccd gpu: AMD Radeon(TM) Graphics title: NYCMain seconds: 120 exit: 0xc0000005 frames shown: none logged (the run did not reach its end) presents per 2 s (last 3): 0 0 2 device removals: 0 crashes: 2 peak commit: 29259 MB ``` main + #244 + #283: ``` xcl-smoke v1 commit: f13d68de9111d69cea7f34e803415954d555707c gpu: AMD Radeon(TM) Graphics title: NYCMain seconds: 120 exit: 0x0 frames shown: 670 (PresentX 670) presents per 2 s (last 3): 8 7 8 device removals: 0 crashes: 0 peak commit: 15265 MB ``` **Not tested** - This PR alone on current `main` (its branch is behind `main` and does not have `scripts/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. - AMD GPUs; any other title. - The video's frame rate: the last "presents per 2 s" of the second run are 8, 7, 8, so it plays at about 4 fps here. I did not look into why. - Audio. Both runs were on my machine; Claude Code (Claude Fable 5.2) ran the script and wrote this report.
Author
Owner

@⁠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, base 7a033c8, 4 commits behind main 0e946cf, none touching crates/). Compared with main at 0e946cf, same machine, same protocol.

Tested

  • Ubuntu 26.04, RTX 4080 SUPER (NVIDIA 595.99.02), Ryzen 9 7950X3D. Proton Experimental 11.0 Wine (not Windows), vkd3d-proton v3.1 (patched as in #257), DXVK 3.1.1, DXC 1.9.2609. Rust 1.99.1, release, x86_64-pc-windows-gnu.
  • cargo build --release --locked --target x86_64-pc-windows-gnu -p xcl: builds, both commits.
  • The retail game, 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 the main run, about 30 s into the #283 run).
  • Video: main dumps the intro as solid (0,135,0) (frames 980–1220, mean colour unchanged). 2a64505 dumps 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).
  • Frame rate: from the moment the video plays (36 s), presents per 2 s are 9–12 (median 11, about 5.5 fps; a second run of the same build: median 10.5). main shows 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 around title_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). GetWriteWatch is 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 time upload_all apart).
  • Stability: no crash and no device removal in 70 s. New WARN / ERROR: none – 57 distinct lines against 57 on main (the same set once addresses are masked: the one DirectStorage: EnqueueRequest: refused line differs only in an address).
  • The run ends in the video (about 5 fps, 70 s): I did not see what follows it, and the title's menus were not reached with #283 in these runs.

Not tested

  • Windows, AMD (including RDNA4); whether the low frame rate also happens there. The test suite (cargo test --workspace) and scripts/smoke.ps1 were not run (they need Windows).
  • Anything after the video; one run per build (plus one with temporary logging for #283), and the press time of A differs between runs.

AI use

  • Written with an AI coding agent from real runs (a person pressed A), then checked by the author.
**@⁠simnJS** on GitHub · 2026-11-23 22:56 UTC · [original](https://github.com/xcl-dev/xcl/pull/283#issuecomment-7116366180) **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, base `7a033c8`, 4 commits behind `main` `0e946cf`, none touching `crates/`). Compared with `main` at `0e946cf`, same machine, same protocol. **Tested** - Ubuntu 26.04, RTX 4080 SUPER (NVIDIA 595.99.02), Ryzen 9 7950X3D. Proton Experimental 11.0 Wine (not Windows), vkd3d-proton v3.1 (patched as in #257), DXVK 3.1.1, DXC 1.9.2609. Rust 1.99.1, release, `x86_64-pc-windows-gnu`. - `cargo build --release --locked --target x86_64-pc-windows-gnu -p xcl`: builds, both commits. - The retail game, `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 the `main` run, about 30 s into the #283 run). - Video: `main` dumps the intro as solid `(0,135,0)` (frames 980–1220, mean colour unchanged). `2a64505` dumps 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). - Frame rate: from the moment the video plays (36 s), presents per 2 s are 9–12 (median 11, about 5.5 fps; a second run of the same build: median 10.5). `main` shows 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 around `title_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). `GetWriteWatch` is 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 time `upload_all` apart). - Stability: no crash and no device removal in 70 s. New `WARN` / `ERROR`: none – 57 distinct lines against 57 on `main` (the same set once addresses are masked: the one `DirectStorage: EnqueueRequest: refused` line differs only in an address). - The run ends in the video (about 5 fps, 70 s): I did not see what follows it, and the title's menus were not reached with #283 in these runs. **Not tested** - Windows, AMD (including RDNA4); whether the low frame rate also happens there. The test suite (`cargo test --workspace`) and `scripts/smoke.ps1` were not run (they need Windows). - Anything after the video; one run per build (plus one with temporary logging for #283), and the press time of A differs between runs. **AI use** - Written with an AI coding agent from real runs (a person pressed A), then checked by the author.
Author
Owner

@⁠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.dll loads and attaches; the audio of the intro plays (with #294). At the solid-colour point the log shows:

DirectStorage: BCPack BC7: mode 7 unsupported ... E_DECOMPRESSION
DirectStorage: BCPack BC5: mode 5 unsupported ... E_DECOMPRESSION
DirectStorage: BCPack BC1: mode 1 unsupported ... E_DECOMPRESSION
D3D12.X: CopyMemoryToMemoryX: 0x125bb60000 -> 0x72a1e44f0 (0x4000 bytes) is not in unified memory - not done

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.

**@⁠ryosen0** on GitHub · 2026-11-23 23:03 UTC · [original](https://github.com/xcl-dev/xcl/pull/283#issuecomment-7116500547) 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.dll` loads and attaches; the audio of the intro plays (with #294). At the solid-colour point the log shows: ``` DirectStorage: BCPack BC7: mode 7 unsupported ... E_DECOMPRESSION DirectStorage: BCPack BC5: mode 5 unsupported ... E_DECOMPRESSION DirectStorage: BCPack BC1: mode 1 unsupported ... E_DECOMPRESSION D3D12.X: CopyMemoryToMemoryX: 0x125bb60000 -> 0x72a1e44f0 (0x4000 bytes) is not in unified memory - not done ``` 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.
Author
Owner

@⁠mosin311aa on GitHub · 2026-11-23 23:08 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.

Can confirm the same, the 5 FPS might be a separate problem

**@⁠mosin311aa** on GitHub · 2026-11-23 23:08 UTC · [original](https://github.com/xcl-dev/xcl/pull/283#issuecomment-7116592061) > Tested on Linux (Wine, NVIDIA): the intro video is no longer solid green – it shows the picture – but it plays at about 5 fps. Can confirm the same, the 5 FPS might be a separate problem
Author
Owner

@⁠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: main af20b4b + #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_level copies 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 for mode == 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_committed copy and detiling straight from the CPU view (saving one 8 MB copy per plane) crashed this title at game+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.

**@⁠CodeByCon** on GitHub · 2026-11-23 23:09 UTC · [original](https://github.com/xcl-dev/xcl/pull/283#issuecomment-7116612403) Tested on AMD (RDNA3), since the PR's numbers are from an NVIDIA card. **Build:** `main` `af20b4b` + #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_level` copies 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 for `mode == 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_committed` copy and detiling straight from the CPU view (saving one 8 MB copy per plane) crashed this title at `game+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.
Author
Owner

@⁠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_batch makes 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:

before after
submit + CPU wait per 2 s, during the video ~210 ms ~5 ms
presents per 2 s, 32–44 s (loading after the video) 39, 1, 0, 0, 1, … 60, 60, 53, 60, 60, 60, 60
upload buffers made by 60 s 3 742 (5 GB) 6 (384 MB)

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_with takes the staging memory from the caller; record_upload_states keeps its behaviour).
  • No CPU wait: before the title's work, title_textures::refresh makes the title's queue Wait on the uploader's fence (only its own device's; a fence of another device left a queue's work unrun in the tests).
  • The textures copied into are held until the GPU is past the copy: the title can release one meanwhile, and a final release with the copy in flight removed the device (found with the debug layer – the CPU wait had hidden it).
  • XCL_SYNC_UPLOADS=1 keeps the old path.
diff on main 4017f8f (gpu/texture.rs, title_textures.rs: +215 −2)
diff --git a/crates/xcl/src/gpu/texture.rs b/crates/xcl/src/gpu/texture.rs
index 1008d76..cff3864 100644
--- a/crates/xcl/src/gpu/texture.rs
+++ b/crates/xcl/src/gpu/texture.rs
@@ -225,6 +225,146 @@ pub unsafe fn upload_batch(dev: &ID3D12Device, queue: &ID3D12CommandQueue, items
     Ok(failed)
 }
 
+/// Uploads that do not wait: one command list, allocators and upload buffers reused once the
+/// GPU is past them, a fence the title's queues wait for on the GPU (`upload`). Made for the
+/// title textures kept in step with its memory: re-uploaded every frame (a video's planes,
+/// streaming), a new allocator, list, upload buffer and fence and a CPU wait for each batch held
+/// a retail game's frames for seconds while it loaded its world.
+pub struct Uploader {
+    fence: ID3D12Fence,
+    value: u64,
+    list: Option<ID3D12GraphicsCommandList>,
+    /// allocators and the fence value their last list ran to
+    allocs: std::collections::VecDeque<(ID3D12CommandAllocator, u64)>,
+    /// upload buffers in use: (fence value, buffer, bytes)
+    busy: std::collections::VecDeque<(u64, ID3D12Resource, u64)>,
+    /// the textures copied into, held until the GPU is past the copy (the title may release
+    /// one meanwhile: a final release with the copy in flight removed the device)
+    dests: std::collections::VecDeque<(u64, ID3D12Resource)>,
+    /// upload buffers the GPU is done with: (bytes, buffer)
+    free: Vec<(u64, ID3D12Resource)>,
+    free_bytes: u64,
+}
+
+// D3D12 objects are free-threaded
+unsafe impl Send for Uploader {}
+
+/// an upload buffer's bytes at least: the textures of a batch are placed in one, one after another
+const UPLOADER_CHUNK: u64 = 64 << 20;
+
+/// upload buffers kept for reuse at most
+const UPLOADER_FREE_CAP: u64 = 512 << 20;
+
+impl Uploader {
+    pub unsafe fn new(dev: &ID3D12Device) -> Result<Uploader, String> {
+        let fence: ID3D12Fence = dev.CreateFence(0, D3D12_FENCE_FLAG_NONE).map_err(err)?;
+        Ok(Uploader { fence, value: 0, list: None, allocs: Default::default(), busy: Default::default(), dests: Default::default(), free: Vec::new(), free_bytes: 0 })
+    }
+
+    /// The fence and the value the title's queues wait for to see every upload so far.
+    pub fn done_at(&self) -> (&ID3D12Fence, u64) {
+        (&self.fence, self.value)
+    }
+
+    unsafe fn recycle(&mut self) -> u64 {
+        let done = self.fence.GetCompletedValue();
+        while self.dests.front().is_some_and(|d| d.0 <= done) {
+            self.dests.pop_front();
+        }
+        while self.busy.front().is_some_and(|b| b.0 <= done) {
+            let (_, buf, bytes) = self.busy.pop_front().unwrap();
+            if self.free_bytes + bytes <= UPLOADER_FREE_CAP {
+                self.free_bytes += bytes;
+                self.free.push((bytes, buf));
+            }
+        }
+        done
+    }
+
+    /// A free upload buffer of `size` bytes or more (not over twice), else a new one (a power
+    /// of two from `UPLOADER_CHUNK`, so they can be reused). A batch's textures share one
+    /// (`upload`): a buffer each, of 1 MiB at least, made 5 GB of upload buffers in 18 s while
+    /// a retail game streamed thousands of small textures.
+    unsafe fn take(dev: &ID3D12Device, free: &mut Vec<(u64, ID3D12Resource)>, free_bytes: &mut u64, size: u64) -> Result<(ID3D12Resource, u64), String> {
+        let size = size.max(UPLOADER_CHUNK);
+        let best = free.iter().enumerate().filter(|(_, f)| f.0 >= size && f.0 <= size * 2).min_by_key(|(_, f)| f.0).map(|(i, _)| i);
+        if let Some(i) = best {
+            let (bytes, buf) = free.swap_remove(i);
+            *free_bytes -= bytes;
+            return Ok((buf, bytes));
+        }
+        let bytes = size.next_power_of_two();
+        Ok((buffer(dev, bytes)?, bytes))
+    }
+
+    /// `upload_batch` without the wait: the work goes to `queue`, and the title's queues wait
+    /// for `done_at` on the GPU before work that samples the textures.
+    pub unsafe fn upload(&mut self, dev: &ID3D12Device, queue: &ID3D12CommandQueue, items: &[(ID3D12Resource, Vec<Subresource>, Vec<D3D12_RESOURCE_STATES>)]) -> Result<Vec<(usize, String)>, String> {
+        if items.is_empty() {
+            return Ok(Vec::new());
+        }
+        let done = self.recycle();
+        let alloc = match self.allocs.front() {
+            Some((_, v)) if *v <= done => {
+                let (a, _) = self.allocs.pop_front().unwrap();
+                a.Reset().map_err(err)?;
+                a
+            }
+            _ => dev.CreateCommandAllocator(D3D12_COMMAND_LIST_TYPE_DIRECT).map_err(err)?,
+        };
+        let list = match &self.list {
+            Some(l) => {
+                l.Reset(&alloc, None).map_err(err)?;
+                l.clone()
+            }
+            None => {
+                let l: ID3D12GraphicsCommandList = dev.CreateCommandList(0, D3D12_COMMAND_LIST_TYPE_DIRECT, &alloc, None).map_err(err)?;
+                self.list = Some(l.clone());
+                l
+            }
+        };
+        let mut used: Vec<(ID3D12Resource, u64)> = Vec::new();
+        let mut failed = Vec::new();
+        // the buffer being filled: (buffer, its bytes, bytes used)
+        let mut cur: Option<(ID3D12Resource, u64, u64)> = None;
+        for (k, (res, subs, states)) in items.iter().enumerate() {
+            let (free, free_bytes) = (&mut self.free, &mut self.free_bytes);
+            let r = record_upload_with(dev, &list, res, subs, states, states, &mut |size| {
+                let fits = cur.as_ref().is_some_and(|c| c.2.next_multiple_of(512) + size <= c.1);
+                if !fits {
+                    if let Some((b, bytes, _)) = cur.take() {
+                        used.push((b, bytes));
+                    }
+                    let (b, bytes) = Self::take(dev, free, free_bytes, size)?;
+                    cur = Some((b, bytes, 0));
+                }
+                let c = cur.as_mut().unwrap();
+                let at = c.2.next_multiple_of(512);
+                c.2 = at + size;
+                Ok((c.0.clone(), at))
+            });
+            if let Err(e) = r {
+                failed.push((k, e));
+            }
+        }
+        if let Some((b, bytes, _)) = cur.take() {
+            used.push((b, bytes));
+        }
+        list.Close().map_err(err)?;
+        queue.ExecuteCommandLists(&[Some(windows::core::Interface::cast(&list).map_err(err)?)]);
+        self.value += 1;
+        queue.Signal(&self.fence, self.value).map_err(err)?;
+        for (b, bytes) in used {
+            self.busy.push_back((self.value, b, bytes));
+        }
+        for (res, _, _) in items {
+            self.dests.push_back((self.value, res.clone()));
+        }
+        self.allocs.push_back((alloc, self.value));
+        Ok(failed)
+    }
+}
+
 /// Record the copy of `subs` into `res` on `list` (barriers from `before` and back to `after`);
 /// the staging buffer returned must live until the list has run.
 pub unsafe fn record_upload(dev: &ID3D12Device, list: &ID3D12GraphicsCommandList, res: &ID3D12Resource, subs: &[Subresource], before: D3D12_RESOURCE_STATES, after: D3D12_RESOURCE_STATES) -> Result<ID3D12Resource, String> {
@@ -241,6 +381,20 @@ pub unsafe fn record_upload_states(
     subs: &[Subresource],
     before: &[D3D12_RESOURCE_STATES],
     after: &[D3D12_RESOURCE_STATES],
+) -> Result<ID3D12Resource, String> {
+    record_upload_with(dev, list, res, subs, before, after, &mut |size| buffer(dev, size).map(|b| (b, 0)))
+}
+
+/// `record_upload_states` with the staging memory from `staging`: an upload heap buffer and
+/// the offset (a multiple of 512) of the bytes asked in it.
+pub unsafe fn record_upload_with(
+    dev: &ID3D12Device,
+    list: &ID3D12GraphicsCommandList,
+    res: &ID3D12Resource,
+    subs: &[Subresource],
+    before: &[D3D12_RESOURCE_STATES],
+    after: &[D3D12_RESOURCE_STATES],
+    staging: &mut dyn FnMut(u64) -> Result<(ID3D12Resource, u64), String>,
 ) -> Result<ID3D12Resource, String> {
     validate_subresources(subs)?;
     let rd = res.GetDesc();
@@ -264,7 +418,10 @@ pub unsafe fn record_upload_states(
             ));
         }
     }
-    let up = buffer(dev, total)?;
+    let (up, base) = staging(total)?;
+    for fp in fps.iter_mut() {
+        fp.Offset += base;
+    }
     let mut p = std::ptr::null_mut();
     up.Map(0, None, Some(&mut p)).map_err(err)?;
     for ((s, fp), &nrows) in subs.iter().zip(&fps).zip(&rows) {
diff --git a/crates/xcl/src/hle/d3d12x/title_textures.rs b/crates/xcl/src/hle/d3d12x/title_textures.rs
index 2d8194e..e3066b9 100644
--- a/crates/xcl/src/hle/d3d12x/title_textures.rs
+++ b/crates/xcl/src/hle/d3d12x/title_textures.rs
@@ -314,6 +314,9 @@ pub(super) unsafe fn refresh(queue: *mut c_void) {
     }
     let _refresh = REFRESH.lock().unwrap();
     own_work(|| refresh_once(queue));
+    if !sync_uploads() {
+        wait_for_uploads(queue);
+    }
 }
 
 unsafe fn refresh_once(queue: *mut c_void) {
@@ -457,7 +460,23 @@ unsafe fn upload_all(todo: Vec<(ID3D12Resource, Upload)>) {
                 continue;
             }
         };
-        match own_work(|| texture::upload_batch(dev, &queue, &batch)) {
+        let r = if sync_uploads() {
+            own_work(|| texture::upload_batch(dev, &queue, &batch))
+        } else {
+            let mut ups = UPLOADERS.lock().unwrap();
+            let up = match ups.get_mut(&device) {
+                Some(u) => u,
+                None => match texture::Uploader::new(dev) {
+                    Ok(u) => ups.entry(device).or_insert(u),
+                    Err(e) => {
+                        warn(&e);
+                        continue;
+                    }
+                },
+            };
+            own_work(|| up.upload(dev, &queue, &batch))
+        };
+        match r {
             Ok(failed) => {
                 for (_, e) in failed {
                     warn(&e);
@@ -469,6 +488,43 @@ unsafe fn upload_all(todo: Vec<(ID3D12Resource, Upload)>) {
     }
 }
 
+/// `XCL_SYNC_UPLOADS=1`: each batch of uploads waited for on the CPU (as before `Uploader`)
+fn sync_uploads() -> bool {
+    static ON: std::sync::OnceLock<bool> = std::sync::OnceLock::new();
+    *ON.get_or_init(|| std::env::var("XCL_SYNC_UPLOADS").is_ok_and(|v| v.trim() == "1"))
+}
+
+/// the uploaders, per device (`texture::Uploader`)
+static UPLOADERS: Mutex<BTreeMap<usize, texture::Uploader>> = Mutex::new(BTreeMap::new());
+/// title queue → the upload fence value it last waited for
+static UPLOAD_WAITED: Mutex<BTreeMap<usize, u64>> = Mutex::new(BTreeMap::new());
+
+/// Before the title's work on `queue`: it waits on the GPU for the uploads made so far on its
+/// device (a fence of another device cannot be waited for: with two devices in one process – the
+/// tests – that left a queue's work unrun).
+unsafe fn wait_for_uploads(queue: *mut c_void) {
+    let Some(q) = ID3D12CommandQueue::from_raw_borrowed(&queue) else { return };
+    let ups = UPLOADERS.lock().unwrap();
+    if ups.is_empty() {
+        return;
+    }
+    let mut dev: Option<ID3D12Device> = None;
+    if q.GetDevice(&mut dev).is_err() {
+        return;
+    }
+    let Some(dev) = dev else { return };
+    let Some(up) = ups.get(&(dev.as_raw() as usize)) else { return };
+    let (fence, value) = up.done_at();
+    if value == 0 {
+        return;
+    }
+    let mut w = UPLOAD_WAITED.lock().unwrap();
+    if w.get(&(queue as usize)).copied().unwrap_or(0) < value {
+        let _ = q.Wait(fence, value);
+        w.insert(queue as usize, value);
+    }
+}
+
 /// `XCL_TRACE_FRAME`: how much of a title texture's top level is not zero, each time it is
 /// uploaded (the first 48 uploads of textures of 64x64 and more).
 fn note_content(va: usize, r: &ID3D12Resource, subs: &[texture::Subresource]) {

Tested:

  • The diff above on main 4017f8f: cargo test --release -p xcl --lib -- --test-threads=4: 612 passed, 0 failed, 20 ignored.
  • The retail numbers are from my local stack (main 9ab7d76 + #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.ps1 blocks; 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).

**@⁠gw1337x** on GitHub · 2026-11-23 23:30 UTC · [original](https://github.com/xcl-dev/xcl/pull/283#issuecomment-7117042860) 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_batch` makes 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: | | before | after | |---|---|---| | submit + CPU wait per 2 s, during the video | ~210 ms | ~5 ms | | presents per 2 s, 32–44 s (loading after the video) | 39, 1, 0, 0, 1, … | 60, 60, 53, 60, 60, 60, 60 | | upload buffers made by 60 s | 3 742 (5 GB) | 6 (384 MB) | **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_with` takes the staging memory from the caller; `record_upload_states` keeps its behaviour). - No CPU wait: before the title's work, `title_textures::refresh` makes the title's queue `Wait` on the uploader's fence (only its own device's; a fence of another device left a queue's work unrun in the tests). - The textures copied into are held until the GPU is past the copy: the title can release one meanwhile, and a final release with the copy in flight removed the device (found with the debug layer – the CPU wait had hidden it). - `XCL_SYNC_UPLOADS=1` keeps the old path. <details><summary>diff on main 4017f8f (gpu/texture.rs, title_textures.rs: +215 −2)</summary> ```diff diff --git a/crates/xcl/src/gpu/texture.rs b/crates/xcl/src/gpu/texture.rs index 1008d76..cff3864 100644 --- a/crates/xcl/src/gpu/texture.rs +++ b/crates/xcl/src/gpu/texture.rs @@ -225,6 +225,146 @@ pub unsafe fn upload_batch(dev: &ID3D12Device, queue: &ID3D12CommandQueue, items Ok(failed) } +/// Uploads that do not wait: one command list, allocators and upload buffers reused once the +/// GPU is past them, a fence the title's queues wait for on the GPU (`upload`). Made for the +/// title textures kept in step with its memory: re-uploaded every frame (a video's planes, +/// streaming), a new allocator, list, upload buffer and fence and a CPU wait for each batch held +/// a retail game's frames for seconds while it loaded its world. +pub struct Uploader { + fence: ID3D12Fence, + value: u64, + list: Option<ID3D12GraphicsCommandList>, + /// allocators and the fence value their last list ran to + allocs: std::collections::VecDeque<(ID3D12CommandAllocator, u64)>, + /// upload buffers in use: (fence value, buffer, bytes) + busy: std::collections::VecDeque<(u64, ID3D12Resource, u64)>, + /// the textures copied into, held until the GPU is past the copy (the title may release + /// one meanwhile: a final release with the copy in flight removed the device) + dests: std::collections::VecDeque<(u64, ID3D12Resource)>, + /// upload buffers the GPU is done with: (bytes, buffer) + free: Vec<(u64, ID3D12Resource)>, + free_bytes: u64, +} + +// D3D12 objects are free-threaded +unsafe impl Send for Uploader {} + +/// an upload buffer's bytes at least: the textures of a batch are placed in one, one after another +const UPLOADER_CHUNK: u64 = 64 << 20; + +/// upload buffers kept for reuse at most +const UPLOADER_FREE_CAP: u64 = 512 << 20; + +impl Uploader { + pub unsafe fn new(dev: &ID3D12Device) -> Result<Uploader, String> { + let fence: ID3D12Fence = dev.CreateFence(0, D3D12_FENCE_FLAG_NONE).map_err(err)?; + Ok(Uploader { fence, value: 0, list: None, allocs: Default::default(), busy: Default::default(), dests: Default::default(), free: Vec::new(), free_bytes: 0 }) + } + + /// The fence and the value the title's queues wait for to see every upload so far. + pub fn done_at(&self) -> (&ID3D12Fence, u64) { + (&self.fence, self.value) + } + + unsafe fn recycle(&mut self) -> u64 { + let done = self.fence.GetCompletedValue(); + while self.dests.front().is_some_and(|d| d.0 <= done) { + self.dests.pop_front(); + } + while self.busy.front().is_some_and(|b| b.0 <= done) { + let (_, buf, bytes) = self.busy.pop_front().unwrap(); + if self.free_bytes + bytes <= UPLOADER_FREE_CAP { + self.free_bytes += bytes; + self.free.push((bytes, buf)); + } + } + done + } + + /// A free upload buffer of `size` bytes or more (not over twice), else a new one (a power + /// of two from `UPLOADER_CHUNK`, so they can be reused). A batch's textures share one + /// (`upload`): a buffer each, of 1 MiB at least, made 5 GB of upload buffers in 18 s while + /// a retail game streamed thousands of small textures. + unsafe fn take(dev: &ID3D12Device, free: &mut Vec<(u64, ID3D12Resource)>, free_bytes: &mut u64, size: u64) -> Result<(ID3D12Resource, u64), String> { + let size = size.max(UPLOADER_CHUNK); + let best = free.iter().enumerate().filter(|(_, f)| f.0 >= size && f.0 <= size * 2).min_by_key(|(_, f)| f.0).map(|(i, _)| i); + if let Some(i) = best { + let (bytes, buf) = free.swap_remove(i); + *free_bytes -= bytes; + return Ok((buf, bytes)); + } + let bytes = size.next_power_of_two(); + Ok((buffer(dev, bytes)?, bytes)) + } + + /// `upload_batch` without the wait: the work goes to `queue`, and the title's queues wait + /// for `done_at` on the GPU before work that samples the textures. + pub unsafe fn upload(&mut self, dev: &ID3D12Device, queue: &ID3D12CommandQueue, items: &[(ID3D12Resource, Vec<Subresource>, Vec<D3D12_RESOURCE_STATES>)]) -> Result<Vec<(usize, String)>, String> { + if items.is_empty() { + return Ok(Vec::new()); + } + let done = self.recycle(); + let alloc = match self.allocs.front() { + Some((_, v)) if *v <= done => { + let (a, _) = self.allocs.pop_front().unwrap(); + a.Reset().map_err(err)?; + a + } + _ => dev.CreateCommandAllocator(D3D12_COMMAND_LIST_TYPE_DIRECT).map_err(err)?, + }; + let list = match &self.list { + Some(l) => { + l.Reset(&alloc, None).map_err(err)?; + l.clone() + } + None => { + let l: ID3D12GraphicsCommandList = dev.CreateCommandList(0, D3D12_COMMAND_LIST_TYPE_DIRECT, &alloc, None).map_err(err)?; + self.list = Some(l.clone()); + l + } + }; + let mut used: Vec<(ID3D12Resource, u64)> = Vec::new(); + let mut failed = Vec::new(); + // the buffer being filled: (buffer, its bytes, bytes used) + let mut cur: Option<(ID3D12Resource, u64, u64)> = None; + for (k, (res, subs, states)) in items.iter().enumerate() { + let (free, free_bytes) = (&mut self.free, &mut self.free_bytes); + let r = record_upload_with(dev, &list, res, subs, states, states, &mut |size| { + let fits = cur.as_ref().is_some_and(|c| c.2.next_multiple_of(512) + size <= c.1); + if !fits { + if let Some((b, bytes, _)) = cur.take() { + used.push((b, bytes)); + } + let (b, bytes) = Self::take(dev, free, free_bytes, size)?; + cur = Some((b, bytes, 0)); + } + let c = cur.as_mut().unwrap(); + let at = c.2.next_multiple_of(512); + c.2 = at + size; + Ok((c.0.clone(), at)) + }); + if let Err(e) = r { + failed.push((k, e)); + } + } + if let Some((b, bytes, _)) = cur.take() { + used.push((b, bytes)); + } + list.Close().map_err(err)?; + queue.ExecuteCommandLists(&[Some(windows::core::Interface::cast(&list).map_err(err)?)]); + self.value += 1; + queue.Signal(&self.fence, self.value).map_err(err)?; + for (b, bytes) in used { + self.busy.push_back((self.value, b, bytes)); + } + for (res, _, _) in items { + self.dests.push_back((self.value, res.clone())); + } + self.allocs.push_back((alloc, self.value)); + Ok(failed) + } +} + /// Record the copy of `subs` into `res` on `list` (barriers from `before` and back to `after`); /// the staging buffer returned must live until the list has run. pub unsafe fn record_upload(dev: &ID3D12Device, list: &ID3D12GraphicsCommandList, res: &ID3D12Resource, subs: &[Subresource], before: D3D12_RESOURCE_STATES, after: D3D12_RESOURCE_STATES) -> Result<ID3D12Resource, String> { @@ -241,6 +381,20 @@ pub unsafe fn record_upload_states( subs: &[Subresource], before: &[D3D12_RESOURCE_STATES], after: &[D3D12_RESOURCE_STATES], +) -> Result<ID3D12Resource, String> { + record_upload_with(dev, list, res, subs, before, after, &mut |size| buffer(dev, size).map(|b| (b, 0))) +} + +/// `record_upload_states` with the staging memory from `staging`: an upload heap buffer and +/// the offset (a multiple of 512) of the bytes asked in it. +pub unsafe fn record_upload_with( + dev: &ID3D12Device, + list: &ID3D12GraphicsCommandList, + res: &ID3D12Resource, + subs: &[Subresource], + before: &[D3D12_RESOURCE_STATES], + after: &[D3D12_RESOURCE_STATES], + staging: &mut dyn FnMut(u64) -> Result<(ID3D12Resource, u64), String>, ) -> Result<ID3D12Resource, String> { validate_subresources(subs)?; let rd = res.GetDesc(); @@ -264,7 +418,10 @@ pub unsafe fn record_upload_states( )); } } - let up = buffer(dev, total)?; + let (up, base) = staging(total)?; + for fp in fps.iter_mut() { + fp.Offset += base; + } let mut p = std::ptr::null_mut(); up.Map(0, None, Some(&mut p)).map_err(err)?; for ((s, fp), &nrows) in subs.iter().zip(&fps).zip(&rows) { diff --git a/crates/xcl/src/hle/d3d12x/title_textures.rs b/crates/xcl/src/hle/d3d12x/title_textures.rs index 2d8194e..e3066b9 100644 --- a/crates/xcl/src/hle/d3d12x/title_textures.rs +++ b/crates/xcl/src/hle/d3d12x/title_textures.rs @@ -314,6 +314,9 @@ pub(super) unsafe fn refresh(queue: *mut c_void) { } let _refresh = REFRESH.lock().unwrap(); own_work(|| refresh_once(queue)); + if !sync_uploads() { + wait_for_uploads(queue); + } } unsafe fn refresh_once(queue: *mut c_void) { @@ -457,7 +460,23 @@ unsafe fn upload_all(todo: Vec<(ID3D12Resource, Upload)>) { continue; } }; - match own_work(|| texture::upload_batch(dev, &queue, &batch)) { + let r = if sync_uploads() { + own_work(|| texture::upload_batch(dev, &queue, &batch)) + } else { + let mut ups = UPLOADERS.lock().unwrap(); + let up = match ups.get_mut(&device) { + Some(u) => u, + None => match texture::Uploader::new(dev) { + Ok(u) => ups.entry(device).or_insert(u), + Err(e) => { + warn(&e); + continue; + } + }, + }; + own_work(|| up.upload(dev, &queue, &batch)) + }; + match r { Ok(failed) => { for (_, e) in failed { warn(&e); @@ -469,6 +488,43 @@ unsafe fn upload_all(todo: Vec<(ID3D12Resource, Upload)>) { } } +/// `XCL_SYNC_UPLOADS=1`: each batch of uploads waited for on the CPU (as before `Uploader`) +fn sync_uploads() -> bool { + static ON: std::sync::OnceLock<bool> = std::sync::OnceLock::new(); + *ON.get_or_init(|| std::env::var("XCL_SYNC_UPLOADS").is_ok_and(|v| v.trim() == "1")) +} + +/// the uploaders, per device (`texture::Uploader`) +static UPLOADERS: Mutex<BTreeMap<usize, texture::Uploader>> = Mutex::new(BTreeMap::new()); +/// title queue → the upload fence value it last waited for +static UPLOAD_WAITED: Mutex<BTreeMap<usize, u64>> = Mutex::new(BTreeMap::new()); + +/// Before the title's work on `queue`: it waits on the GPU for the uploads made so far on its +/// device (a fence of another device cannot be waited for: with two devices in one process – the +/// tests – that left a queue's work unrun). +unsafe fn wait_for_uploads(queue: *mut c_void) { + let Some(q) = ID3D12CommandQueue::from_raw_borrowed(&queue) else { return }; + let ups = UPLOADERS.lock().unwrap(); + if ups.is_empty() { + return; + } + let mut dev: Option<ID3D12Device> = None; + if q.GetDevice(&mut dev).is_err() { + return; + } + let Some(dev) = dev else { return }; + let Some(up) = ups.get(&(dev.as_raw() as usize)) else { return }; + let (fence, value) = up.done_at(); + if value == 0 { + return; + } + let mut w = UPLOAD_WAITED.lock().unwrap(); + if w.get(&(queue as usize)).copied().unwrap_or(0) < value { + let _ = q.Wait(fence, value); + w.insert(queue as usize, value); + } +} + /// `XCL_TRACE_FRAME`: how much of a title texture's top level is not zero, each time it is /// uploaded (the first 48 uploads of textures of 64x64 and more). fn note_content(va: usize, r: &ID3D12Resource, subs: &[texture::Subresource]) { ``` </details> **Tested:** - The diff above on `main` `4017f8f`: `cargo test --release -p xcl --lib -- --test-threads=4`: 612 passed, 0 failed, 20 ignored. - The retail numbers are from my local stack (`main` `9ab7d76` + #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.ps1` blocks; 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).
Author
Owner

@⁠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 main c8e3ca0 + #235 + #252 + #283 (9bd7635) + #292/#269 + #244 + #254 + #267 + #306 + #314 + #322, plus local changes that are not in any PR. Run with xcl.exe run <game folder> and XCL_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.

**@⁠ofc0urse** on GitHub · 2026-11-24 00:23 UTC · [original](https://github.com/xcl-dev/xcl/pull/283#issuecomment-7118019415) 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 `main` `c8e3ca0` + #235 + #252 + #283 (`9bd7635`) + #292/#269 + #244 + #254 + #267 + #306 + #314 + #322, plus local changes that are not in any PR. Run with `xcl.exe run <game folder>` and `XCL_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.
Author
Owner

@⁠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): main db1ddb2 + #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. With XCL_THREAD_DUMP_AT=85,95,105, the render thread (the one that logs frames 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_z
GPU busy stayed at 13–21 % (about 10 % when idle).

A/B: your tiling.rs diff applied unchanged. Two release builds of main a6f5f7a + #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.

without with the diff
A pressed at 38 s 39 s
presents per 2 s, 40–122 s 10–14 44–60
frames shown in 150 s 1772 3196
device removals / crashes 0 / 0 0 / 0

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, including fast_detile_matches_element_by_element. Dropping the hx term 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 Uploader diff.

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.ps1 blocks, which I can't produce from here.

Measured and written with Claude Code (Claude Opus 5.5).

**@⁠xstraok** on GitHub · 2026-11-24 00:26 UTC · [original](https://github.com/xcl-dev/xcl/pull/283#issuecomment-7118079676) · 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):** `main` `db1ddb2` + #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. With `XCL_THREAD_DUMP_AT=85,95,105`, the render thread (the one that logs `frames 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_z` GPU busy stayed at 13–21 % (about 10 % when idle). **A/B:** your `tiling.rs` diff applied unchanged. Two release builds of `main` `a6f5f7a` + #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. | | without | with the diff | |---|---|---| | A pressed at | 38 s | 39 s | | presents per 2 s, 40–122 s | 10–14 | 44–60 | | frames shown in 150 s | 1772 | 3196 | | device removals / crashes | 0 / 0 | 0 / 0 | 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, including `fast_detile_matches_element_by_element`. Dropping the `hx` term 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 `Uploader` diff. 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.ps1` blocks, which I can't produce from here. Measured and written with Claude Code (Claude Opus 5.5).
Author
Owner

@⁠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.

  • A (base): main db1ddb2. The patch doesn't apply on the newest main a6f5f7a (title_textures.rs conflicts), so I used db1ddb2.
  • B (patch): 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 the activity (2 s) lines.

A1 A2 B1 B2
Intro video: presents per 2 s 7–10 (≈4.5 fps) 8–10 (≈4.5 fps) 60–61 (30 fps) 59–61 (30 fps)
Intro video: start → end 20 → 119 s 20 → 119 s 20 → 33 s 20 → 33 s
Menu after the video 60/2 s 60/2 s 60/2 s 60/2 s
World streaming starts 142 s 142 s 54 s 54 s
Max presents per 2 s after that 25 (12.5 fps) 29 (14.5 fps) 41 (20.5 fps) 55 (27.5 fps)
Run ended at 158 s, watchdog 156 s, watchdog 68 s, watchdog 72 s, watchdog
Commit at the end 22.7 GB 21.6 GB 23.5 GB 25.3 GB

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. The gpu: line names the iGPU because the script takes the first adapter, but XCL logged that it ran on the RTX 3080.

xcl-smoke v1
commit: db1ddb25f3ff0c1686eed8200d238ad35f895926
gpu: AMD Radeon(TM) Graphics
title: (the retail title)
seconds: 60
exit: 0x0
frames shown: 1470 (PresentX 1470)
presents per 2 s (last 3): 59 61 60
device removals: 0
crashes: 0
peak commit: 14805 MB
xcl-smoke v1
commit: 203d1d948626606b3ce2f7cafdde96a4aeeee8cb
gpu: AMD Radeon(TM) Graphics
title: (the retail title)
seconds: 60
exit: 0x0
frames shown: 1548 (PresentX 1548)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 15043 MB

Not tested:

  • Picture correctness. I can't see the screen, so I don't know whether the video frames or textures look right with the patch.
  • Anything past ~15 s of world streaming, because of the RAM limit above.
  • The newest main, where the patch conflicts.
  • Each half of the patch on its own.

Test runs and this report: Claude Code (Claude Opus 5.5).

**@⁠grahamster2** on GitHub · 2026-11-24 00:42 UTC · [original](https://github.com/xcl-dev/xcl/pull/283#issuecomment-7118348035) Tested @⁠gw1337x's patch from [this comment](https://github.com/ivall/xcl/pull/283#issuecomment-7117042860) (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. - **A (base):** `main` db1ddb2. The patch doesn't apply on the newest `main` a6f5f7a (`title_textures.rs` conflicts), so I used db1ddb2. - **B (patch):** 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 the `activity (2 s)` lines. | | A1 | A2 | B1 | B2 | |---|---|---|---|---| | Intro video: presents per 2 s | 7–10 (≈4.5 fps) | 8–10 (≈4.5 fps) | 60–61 (30 fps) | 59–61 (30 fps) | | Intro video: start → end | 20 → 119 s | 20 → 119 s | 20 → 33 s | 20 → 33 s | | Menu after the video | 60/2 s | 60/2 s | 60/2 s | 60/2 s | | World streaming starts | 142 s | 142 s | 54 s | 54 s | | Max presents per 2 s after that | 25 (12.5 fps) | 29 (14.5 fps) | 41 (20.5 fps) | 55 (27.5 fps) | | Run ended at | 158 s, watchdog | 156 s, watchdog | 68 s, watchdog | 72 s, watchdog | | Commit at the end | 22.7 GB | 21.6 GB | 23.5 GB | 25.3 GB | 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. The `gpu:` line names the iGPU because the script takes the first adapter, but XCL logged that it ran on the RTX 3080. ``` xcl-smoke v1 commit: db1ddb25f3ff0c1686eed8200d238ad35f895926 gpu: AMD Radeon(TM) Graphics title: (the retail title) seconds: 60 exit: 0x0 frames shown: 1470 (PresentX 1470) presents per 2 s (last 3): 59 61 60 device removals: 0 crashes: 0 peak commit: 14805 MB ``` ``` xcl-smoke v1 commit: 203d1d948626606b3ce2f7cafdde96a4aeeee8cb gpu: AMD Radeon(TM) Graphics title: (the retail title) seconds: 60 exit: 0x0 frames shown: 1548 (PresentX 1548) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 15043 MB ``` **Not tested:** - Picture correctness. I can't see the screen, so I don't know whether the video frames or textures look right with the patch. - Anything past ~15 s of world streaming, because of the RAM limit above. - The newest `main`, where the patch conflicts. - Each half of the patch on its own. Test runs and this report: Claude Code (Claude Opus 5.5).
This discussion has been locked. Commenting is limited to contributors.
No description provided.