Skip to content

Title textures: the write watch scans in a few calls, not thousands - #551

Merged
ivall merged 1 commit into
xcl-dev:mainfrom
duudiis:pr-watch-gap
Nov 24, 2026
Merged

ivall merged 1 commit into
xcl-dev:mainfrom
duudiis:pr-watch-gap

Conversation

@duudiis

@duudiis duudiis commented Nov 24, 2026

Copy link
Copy Markdown
Contributor

Before each submit, title_textures::refresh asks the write watch which pages the CPU wrote. The watched ranges (title textures and mapped sparse tiles) were merged only across gaps under 1 MiB, so on a retail game that streams its world the look made thousands of GetWriteWatch calls before every submit. A call costs about 3.5 µs however little it covers, while one call over 2 GiB of committed pages takes about 1.3 ms (a small GetWriteWatch benchmark on this machine), so the calls, not the bytes, were the cost: sampling the title's threads during its intro video put the submitting thread at 42 % in GetWriteWatch (on a local build with other changes, not on main).

This merges ranges up to 64 MiB apart into one scan. The pages in a gap are reported as written too, which the uploads already tolerate: they keep to the textures and tiles they track. The merged ranges are also clipped to the write-watched regions with a binary search per region instead of a pass over every merged range for each region; both lists run to thousands while a game streams.

I searched open and closed PRs for "write watch", "WATCH_GAP", "watch_ranges" and "GetWriteWatch calls" first. #486 (skip unchanged uploads) and #440 / #451 / #455 / #458 / #465 (faster detile and upload) work on the uploads after the look; none of them changes the look itself, so this should stack with them.

What is in it

  • crates/xcl/src/hle/d3d12x/title_textures.rs: WATCH_GAP 1 MiB → 64 MiB (with the measurements in its comment); watch_ranges clips with partition_point per region; watch_ranges_clip_and_merge checks the new gap, a merged range over two regions given in either order, and a region between and past the merged ranges.

Tested

  • Intel Core i7-14700KF, NVIDIA GeForce RTX 5070 (12 GB), Windows 11 Pro 10.0.26300, Rust stable (MSVC), release build.
  • cargo build --workspace then cargo test --workspace --release -- --test-threads=4 on 712bbbe: 677 passed, 0 failed, 41 ignored (lib 637 / 0 / 21).
  • SKIPPED on this adapter: gpu_geometry_wave32_prefix_count_over_a_mask and gpu_wave32_program_in_wave64_hardware (no wave64).
  • A retail title, scripts/smoke.ps1 -Seconds 60, main and this PR in turns, five pairs (frames shown, main → PR): 469 → 536, 561 → 369, 555 → 524, 547 → 556, 944 → 1517. No device removal or crash in any of the ten runs; the PR's peak commit was at or below main's each time (14,604 – 15,067 MB vs 15,057 – 15,962 MB).
  • The 60 s runs end on the title's start screen and the loading before its intro video, where only ~2.6 GB is watched, and their frame counts vary more from run to run on this machine than the change can move them (I take the 561 → 369 pair for that noise: a cargo build may have run beside it, I did not check). The pair below is the fourth.

Regression run

main:

xcl-smoke v1
commit: 7ebf1b8044bef8f0ef296eb36e85010cceb4633a
gpu: NVIDIA GeForce RTX 5070
title: NYCMain
seconds: 60
exit: 0x0
frames shown: 547 (PresentX 547)
presents per 2 s (last 3): 14 13 14
device removals: 0
crashes: 0
peak commit: 15057 MB

this PR's head:

xcl-smoke v1
commit: 712bbbe4e5163b5fe479cccfa0b3ff636ecf8fd8
gpu: NVIDIA GeForce RTX 5070
title: NYCMain
seconds: 60
exit: 0x0
frames shown: 556 (PresentX 556)
presents per 2 s (last 3): 14 13 14
device removals: 0
crashes: 0
peak commit: 15055 MB

Not tested

  • AMD and other NVIDIA GPUs; an AMD CPU.
  • The effect on its own over longer play: the 60 s runs end on the title's start screen / loading, so they cover the look's cost there, not in its world.

AI use

  • Claude Code with Claude Opus 5.5: found the cost with a sampling profiler and a GetWriteWatch benchmark, wrote the change, its test and this description. I ran the tests and the smoke runs on the hardware above.

A write-watch call costs about 3.5 µs however little it covers, while one
call over 2 GiB of committed pages takes about 1.3 ms (measured with a
small GetWriteWatch benchmark on Windows 11). With ranges merged only
across gaps under 1 MiB, the look before each submit made thousands of
calls over a retail game's mapped sparse tiles: its intro video had the
submitting thread at 42 % in GetWriteWatch (sampled). Ranges under 64 MiB
apart are now one scan; the pages in a gap are reported written as well,
which the uploads already tolerate (they keep to what they track).

The ranges are clipped to the write-watched regions with a binary search
per region instead of a pass over every merged range for each region:
both lists run to thousands while a game streams its world.

Assisted-by: Claude Code (Claude Opus 5.5)
@thehollowedone

Copy link
Copy Markdown

I checked the boundary where a merged range produces more dirty pages than the 16,384-entry buffer. A scratch test used XCL’s watch_ranges on a Windows write-watch allocation with two one-page ranges separated by just under 64 MiB. They merged into one range. After writing all 16,385 pages, repeated GetWriteWatch calls with reset reported 16,384 pages, then 1, then 0. The returned addresses matched every written page exactly once. Tested commit 712bbbe

With the scratch test added, cargo test --offline --locked -p xcl --lib watch_ -- --test-threads=1 --nocapture reported 2 passed, 0 failed, 0 ignored, including the PR’s range test. Windows 11 build 26300, Ryzen 7 9800X3D, Rust 1.99.1 MSVC, debug. This run checked clipping and the Windows reset batches. It did not measure upload performance, run the full workspace, or use retail data.

AI use

Codex with GPT-6.2 Sol wrote and ran the scratch check and drafted this report.

@Kalmarv

Kalmarv commented Nov 24, 2026

Copy link
Copy Markdown
Contributor

One point on the wider gap, not covered by the boundary test above: a write to a page in a merged gap is reset by a look that watches it for nobody. If the page is wanted later, the first look that watches it no longer reports that write. With a 1 MiB gap the same happens only within 1 MiB of a watched range.

The test below, CPU only, on main 508a0c7 with this PR (712bbbe) merged:

  • one 64 MiB write-watched allocation, two wanted pages 32 MiB apart, and page p between them;
  • p is written, then looked at once through watch_ranges (as refresh_once does), and then added to the wanted ranges;
  • the next look must report p.

It passes on main and fails with this PR:

the write to 0x1f116180000 was reset by a look that watched it for nobody
test (in title_textures.rs's tests)
/// A page the CPU writes while no texture or mapped tile wants it, and that is wanted later (a
/// tile mapped after the write), is reported by the first look that watches it.
#[test]
fn a_write_before_its_page_is_wanted_is_found_once_it_is() {
    use windows_sys::Win32::System::Memory::{VirtualAlloc, VirtualFree, MEM_COMMIT, MEM_RELEASE, MEM_RESERVE, PAGE_READWRITE};
    const MEM_WRITE_WATCH: u32 = 0x20_0000;
    const SIZE: usize = 64 << 20;
    unsafe {
        let base = VirtualAlloc(std::ptr::null(), SIZE, MEM_RESERVE | MEM_COMMIT | MEM_WRITE_WATCH, PAGE_READWRITE) as usize;
        assert!(base != 0);
        let regions = [(base, SIZE)];
        let look = |ranges: &[(usize, usize)]| {
            let mut found = Vec::new();
            let mut buf = vec![std::ptr::null_mut::<c_void>(); 16384];
            let mut page = 0u32;
            for &(b, s) in ranges {
                let mut n = buf.len();
                assert_eq!(GetWriteWatch(WRITE_WATCH_FLAG_RESET, b as *const c_void, s, buf.as_mut_ptr(), &mut n, &mut page), 0);
                found.extend(buf[..n].iter().map(|&p| p as usize));
            }
            found
        };
        // two wanted pages 32 MiB apart; `p` between them, wanted by nobody yet
        let (a, b, p) = (base, base + (32 << 20), base + (16 << 20));
        let wanted = vec![(a, a + 0x1000), (b, b + 0x1000)];
        look(&watch_ranges(&regions, wanted.clone())); // a clean start
        (p as *mut u8).write_volatile(1);
        look(&watch_ranges(&regions, wanted.clone())); // a look before `p` is wanted
        let mut later = wanted;
        later.push((p, p + 0x1000));
        let found = look(&watch_ranges(&regions, later));
        VirtualFree(base as *mut c_void, 0, MEM_RELEASE);
        assert!(found.contains(&p), "the write to {p:#x} was reset by a look that watched it for nobody");
    }
}

Where XCL relies on that report (from the code on 508a0c7; not run on a GPU):

  • sparse::before_execute uploads only pages of tiles that already have video memory (sparse.rs:1368). Any other page a look reports is dropped, and its watch state has been reset.
  • A tile can get video memory after the CPU wrote its page:
    • When take_tile finds no video memory, ensure_mapped stops (sparse.rs:724). The committed pages after that have no tile. place_buffer maps such tiles later (sparse.rs:1458), without copying what the CPU wrote there.
    • In MapTitlePhysicalPages, the page's contents are copied to at (kernelx.rs:1198) before sparse::committed(at) gives its tile video memory (kernelx.rs:1204). A look on another thread between the two reports and resets the copied page and then drops it.
  • In both cases the write reaches the GPU only through the look after the tile is mapped. With this PR that holds only for pages more than 64 MiB from a watched range.
  • Textures are not affected: a new entry, and one whose source changes, is uploaded whole (pending).

Question for @duudiis: does "the uploads keep to what they track" in the new WATCH_GAP comment mean to cover tiles mapped after a write? If not, one option is for a tile that gets video memory late to have its CPU pages uploaded at mapping time. That would also cover the 1 MiB case on main. The other is to keep the 1 MiB gap where a range ends next to committed pages without a tile. I have not tried either.

The cost side, on a retail title (RTX 5070 Ti, Ryzen 9 9950X, release, 60 s of the first menus with no input, one run each; main 508a0c7 and 508a0c7 with this PR merged, 04d7261):

sparse submits looks main ms a look this PR ms a look
16 → 128 112 0.348 0.321
128 → 1024 (uploads) 896 0.796 0.802
1024 → 4096 3072 0.939 0.964
  • In the last phase the look makes 69 calls over 1,641 MB on main and 19 calls over 2,218 MB with this PR. A third run, main with only counters added (7a8255c, local), took 0.83 ms in the same phase, so the spread between runs is larger than the difference: no saving here, and no loss either. The title has 69 ranges in this phase; the PR's case is thousands.
  • During the upload phase the wider ranges reported 27 % more written pages a look (434 against 342): the pages in the gaps, whose watch state the point above is about.

Tested

  • The title runs above: no crash or device removal in either.
  • The test above, debug build, Windows 11 26200, Ryzen 9 9950X, CPU only:
    • main 508a0c7: passes;
    • main + this PR (712bbbe), merge 9a6cf82: fails as quoted.

Not tested

  • A lost write on the GPU or in a title: the two paths above are from reading the code.
  • How often a title commits sparse pages without a tile, or maps physical pages during a submit.
  • World loading, where the look is slower; AMD.

🤖 Claude Opus 5.5

@duudiis

duudiis commented Nov 24, 2026

Copy link
Copy Markdown
Contributor Author

Thanks, both of you. @Kalmarv, you're right: "the uploads keep to what they track" does not cover a tile that gets video memory after its page was written. A look that watches that page for nothing resets its report, and sparse::before_execute drops pages of tiles without video memory, so the write only reaches the GPU when the page is written again. The wider gap makes that window much larger, and your numbers show no gain on main to pay for it.

I'm turning this into a draft. The fix I'm testing follows your first option: each tile ensure_mapped gives video memory is noted, and at the next before_execute all of its committed pages go through scan_page, so only what differs from what the GPU has is sent. That also covers the 1 MiB case on main and the MapTitlePhysicalPages copy-then-map race. Its unit test writes a page before its tile is mapped and checks that the page is sent once the tile is mapped, only committed pages are sent, and nothing is sent twice. I'll push it here, with your test and fresh smoke runs, once I can rerun them on the title. Until then the PR stays a draft.

AI use: Claude Code with Claude Opus 5.5 checked the review against the code, wrote the fix and its test, and drafted this reply.

@MesshM

MesshM commented Nov 24, 2026

Copy link
Copy Markdown

Test run of 712bbbe4e5163b5fe479cccfa0b3ff636ecf8fd8 on AMD RDNA4; the PR was tested on NVIDIA only. I merged it onto current main 3db536e locally (clean merge) and tested that tree.

Tested

  • AMD Radeon RX 9060 XT 16 GB (RDNA4, native wave64), driver 32.0.32029.2010; Ryzen 7 5700X, 64 GB RAM, Windows 11 Pro build 26200, Rust 1.100.0 stable-x86_64-pc-windows-msvc, debug
  • cargo build --workspace + cargo test --workspace -- --test-threads=4 on the merge: 686 passed, 0 failed, 41 ignored, exit code 0; xcl lib tests 646 passed, 0 failed, 21 ignored
  • 0 SKIPPED; watch_ranges_clip_and_merge passes.

Review: The new loop gives the same pieces as the old one: each region looks up the first merged range ending after its base and takes those starting before its end, so every piece stays inside one region, now with a binary search instead of a pass over all merged ranges per region. A question rather than a finding: refresh calls GetWriteWatch with WRITE_WATCH_FLAG_RESET (title_textures.rs:687), so with 64 MiB gaps the pages in a gap get their write bits reset too. That is fine for pages nothing tracks yet only if whatever starts tracking them later (a texture placed there, a sparse tile mapped there) uploads its contents fully at that point rather than relying on earlier write-watch bits. I did not trace every path that starts tracking, so I cannot say it always does.

Not tested: no retail title or regression run (I have no unpacked game), no XCL_SAMPLE_* tests, release build; the PR's head on its old base was not run, only its merge onto main.

Run and review by Claude Code (Claude Opus 5.5) on this machine; the review points were checked against the code.

@Chrysana

Copy link
Copy Markdown

Test report for 712bbbe on an AMD GPU and an AMD CPU, which Not tested lists: no regression, and no measurable gain on this machine, where main already holds 30 fps through the intro video.

Setup: AMD Radeon RX 9070 XT 16 GB, driver 32.0.32015.2008, AMD Ryzen 7 9800X3D, 31 GB RAM, Windows 11 25H2 build 26200.9974, rustc 1.100.0 x86_64-pc-windows-msvc, DXC 1.9.2602.17. Retail title 1.0.2.1. Debug build for the tests, release builds for the runs.

Tests: cargo test --workspace --no-fail-fast -- --test-threads=4 at 712bbbe: 677 passed, 0 failed, 41 ignored, the same counts as in the description. SKIPPED: the two debug-layer tests (the D3D12 debug layer isn't installed here).

Title runs: scripts/smoke.ps1 -Game <folder> -Seconds 60 with XCL_PRESS_A_AT=14,17,21, same saved state. 712bbbe's base 7ebf1b8 doesn't have #451, so it was also merged onto main 9ce2070 (clean, local merge eba6025, not pushed):

build frames peak commit
main 9ce2070 1507, 1536 15685, 16054 MB
712bbbe merged onto 9ce2070 1504, 1541 16140, 16008 MB
712bbbe (its own base, video at ~6 fps without #451) 545 15937 MB
  • Both merged runs reached the video and held 30 fps through it, like main, so a cost the change removes can't show in frames here. I have no direct measure of the time in GetWriteWatch from title_textures: XCL's sparse windows timing: write-watch log line is the sparse-window path, which this PR doesn't change.
  • No crash or device removal in any run.

Regression run:

main:

xcl-smoke v1
commit: 9ce2070eccf436d7bd38601c90407da447df34f3
gpu: AMD Radeon RX 9070 XT
title: retail-title
seconds: 60
exit: 0x0
frames shown: 1536 (PresentX 1536)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 16054 MB

PR merged onto main:

xcl-smoke v1
commit: eba602527af0289749ca53679774b9b1b76a575e
gpu: AMD Radeon RX 9070 XT
title: retail-title
seconds: 60
exit: 0x0
frames shown: 1504 (PresentX 1504)
presents per 2 s (last 3): 61 60 60
device removals: 0
crashes: 0
peak commit: 16140 MB

PR head:

xcl-smoke v1
commit: 712bbbe4e5163b5fe479cccfa0b3ff636ecf8fd8
gpu: AMD Radeon RX 9070 XT
title: retail-title
seconds: 60
exit: 0x0
frames shown: 545 (PresentX 546)
presents per 2 s (last 3): 12 13 14
device removals: 0
crashes: 0
peak commit: 15937 MB

Not tested: the time spent in GetWriteWatch itself (no profile taken); world streaming past the intro; Kalmarv's point about writes in a merged gap.

AI use: Claude Code with Claude Opus 5.5 built the commits, ran the tests and the title runs, read the logs, and wrote this report. The runs were made on my machine.

@Kalmarv

Kalmarv commented Nov 24, 2026

Copy link
Copy Markdown
Contributor

@Chrysana, thanks for the AMD runs. One correction: the sparse windows timing: write-watch N ms (M dirty pages) line is this PR's own look. refresh_once times its GetWriteWatch loop (title_textures.rs:673–700 at 712bbbe) and records it with sparse::note_watch (sparse.rs:1339; printed at sparse.rs:1410). So that line on main against the PR is the direct measure of the call-count change. Our per-look numbers on an RTX 5070 Ti are in the review above. On the first menus (sparse submits 1024 → 4096) a look took 0.94 ms on main and 0.96 ms with this PR, within the spread between runs.

🤖 Claude Opus 5.5

gustavsi added a commit to gustavsi/xcl that referenced this pull request Nov 24, 2026
…-watch merge

Integrates upstream PRs ivall#594, ivall#640, and ivall#551:
- Order reserved-texture tile unmaps behind known title queues with GPU
  fences before releasing tiles back to pools (ivall#594).
- Add opt-in XCL_PAGE_BUDGET_MB to evict LRU CPU-filled title textures
  when texture page pools hit the cap, remapping and re-uploading on use
  (ivall#640), preventing unbounded VRAM growth during world streaming.
- Merge write-watch scan gaps up to 64 MiB and clip regions with binary
  search to cut GetWriteWatch overhead during streaming (ivall#551).
gustavsi added a commit to gustavsi/xcl that referenced this pull request Nov 24, 2026
…-watch merge

Integrates upstream PRs xcl-dev#594, xcl-dev#640, and xcl-dev#551:
- Order reserved-texture tile unmaps behind known title queues with GPU
  fences before releasing tiles back to pools (xcl-dev#594).
- Add opt-in XCL_PAGE_BUDGET_MB to evict LRU CPU-filled title textures
  when texture page pools hit the cap, remapping and re-uploading on use
  (xcl-dev#640), preventing unbounded VRAM growth during world streaming.
- Merge write-watch scan gaps up to 64 MiB and clip regions with binary
  search to cut GetWriteWatch overhead during streaming (xcl-dev#551).
gustavsi added a commit to gustavsi/xcl that referenced this pull request Nov 24, 2026
…-watch merge

Integrates upstream PRs xcl-dev#594, xcl-dev#640, and xcl-dev#551:
- Order reserved-texture tile unmaps behind known title queues with GPU
  fences before releasing tiles back to pools (xcl-dev#594).
- Add opt-in XCL_PAGE_BUDGET_MB to evict LRU CPU-filled title textures
  when texture page pools hit the cap, remapping and re-uploading on use
  (xcl-dev#640), preventing unbounded VRAM growth during world streaming.
- Merge write-watch scan gaps up to 64 MiB and clip regions with binary
  search to cut GetWriteWatch overhead during streaming (xcl-dev#551).
@iggyvilla

Copy link
Copy Markdown
Contributor

Test report for 712bbbe4e5163b5fe479cccfa0b3ff636ecf8fd8 on an AMD RDNA2 card (Navi 23), testing the current draft head against its merge base 7ebf1b8044bef8f0ef296eb36e85010cceb4633a (not merged onto current main).

Tested

  • AMD Radeon RX 6650 XT (RDNA2, gfx1032), driver 32.0.21045.29003; AMD Ryzen 7 5700X, 31.9 GB RAM, Windows 11 Home build 26300.9974; rustc 1.100.0 stable-x86_64-pc-windows-msvc; no XCL_SAMPLE_* set.
  • Clean detached worktrees at head 712bbbe and base 7ebf1b8.
  • cargo build --workspace then cargo test --workspace --no-fail-fast -- --test-threads=4 on 712bbbe (debug): 674 passed, 3 failed, 41 ignored, exit 101. xcl lib: 634 passed, 3 failed, 21 ignored.
  • The 3 failures are pre-existing on this card: placed_title_textures_share_vram_and_preserve_pixels (3D 64x64x64 4 mips: subresource 2 mismatch, D3D12.X: map a one-slice title texture's packed mips where D3D12 addresses them #470) and two PoisonError cascades it causes in transitions_apply_when_their_list_is_submitted (title_textures.rs:1327) and d32s8_targets_take_their_own_size_of_video_memory (vram.rs:778, fixed by Tests: a panicking title-texture test no longer poisons the others #673). The PR adds no failure.
  • No SKIPPED lines at this head on this card.
  • scripts/smoke.ps1 -Seconds 60 with XCL_NETWORK=0, base and head built release from their own worktrees, two pairs (base → head, then head → base):
pair base 7ebf1b8 frames head 712bbbe frames peak commit (base → head)
1 737 807 15759 → 15764 MB
2 751 787 15760 → 15762 MB

All four runs: exit 0x0, 0 device removals, 0 crashes, on AMD Radeon RX 6650 XT. Head is at or above base in both pairs within normal run-to-run variance; peak commit is within 5 MB. No regression is measurable here.

  • sparse windows timing: write-watch on the last log line of pair 2: head 1984 ms (274779 dirty pages) (787 frames), base 1957 ms (268066 dirty pages) (751 frames) — a 1.4 % difference, within noise. These 60 s runs end on the start screen / loading before the intro video (~2.6 GB watched), so the call-count saving is not exercised yet; this run checks only that nothing regresses.

Base block (pair 1):

xcl-smoke v1
commit: 7ebf1b8044bef8f0ef296eb36e85010cceb4633a
gpu: AMD Radeon RX 6650 XT
title: GTA6.Xbox.v1.0.2.1-CYBERLEEK
seconds: 60
exit: 0x0
frames shown: 737 (PresentX 737)
presents per 2 s (last 3): 0 15 11
device removals: 0
crashes: 0
peak commit: 15759 MB

Head block (pair 1):

xcl-smoke v1
commit: 712bbbe4e5163b5fe479cccfa0b3ff636ecf8fd8
gpu: AMD Radeon RX 6650 XT
title: GTA6.Xbox.v1.0.2.1-CYBERLEEK
seconds: 60
exit: 0x0
frames shown: 807 (PresentX 807)
presents per 2 s (last 3): 0 18 17
device removals: 0
crashes: 0
peak commit: 15764 MB

Not tested

  • No run past the intro video into gameplay (where the watched ranges grow to the thousands of calls this PR targets).
  • Not merged onto current main; head and base were tested on 7ebf1b8.
  • The 64 MiB-gap write/reset case raised in review was not tested here.

AI use
opencode with DeepSeek V4.1 Flash (opencode-go/deepseek-v4.1-flash) ran the build, the tests and the smoke runs and drafted this report.

@milas6669

Copy link
Copy Markdown
Contributor

Regression run of 712bbbe4e516 (PR head, built as it is, not merged onto main) against main e50836b, on a retail title.

Tested

  • NVIDIA GeForce RTX 3070 (32-lane waves), Intel i9-10900KF, Windows 11 Pro 10.0.26200, rustc 1.100.0, release builds
  • scripts/smoke.ps1 -Seconds 60, the same title and time for both, one run each, main first:

main (e50836b):

xcl-smoke v1
commit: e50836bdf6f5c026f281d545ed86fb2f07ba6e6a
gpu: NVIDIA GeForce RTX 3070
title: dumped
seconds: 60
exit: 0x0
frames shown: 287 (PresentX 287)
presents per 2 s (last 3): 9 10 10
device removals: 0
crashes: 0
peak commit: 15863 MB

this PR (712bbbe):

xcl-smoke v1
commit: 712bbbe4e5163b5fe479cccfa0b3ff636ecf8fd8
gpu: NVIDIA GeForce RTX 3070
title: dumped
seconds: 60
exit: 0x0
frames shown: 245 (PresentX 245)
presents per 2 s (last 3): 5 6 6
device removals: 0
crashes: 0
peak commit: 15746 MB

What this does and does not say

  • It is a regression check: no crash, no device removal, and the frame count and peak commit are within the limits in CONTRIBUTING.md (at least 80 % of main's frames, at most 125 % of its peak commit).
  • It is not a speed measurement. One 60 s run varies a lot here: four runs of main on this machine gave 424, 359, 370 and 287 frames. A difference of this size between main and the PR is inside that noise.

Not tested

  • cargo test on this head (I did not run the test suite for this report)
  • AMD / wave64 hardware, visual correctness (I did not look at the picture)

AI use

  • Claude Code, Claude Sonnet 5.5, ran the commands and wrote this report.

gustavsi added a commit to gustavsi/xcl that referenced this pull request Nov 24, 2026
…-watch merge

Integrates upstream PRs ivall#594, ivall#640, and ivall#551:
- Order reserved-texture tile unmaps behind known title queues with GPU
  fences before releasing tiles back to pools (ivall#594).
- Add opt-in XCL_PAGE_BUDGET_MB to evict LRU CPU-filled title textures
  when texture page pools hit the cap, remapping and re-uploading on use
  (ivall#640), preventing unbounded VRAM growth during world streaming.
- Merge write-watch scan gaps up to 64 MiB and clip regions with binary
  search to cut GetWriteWatch overhead during streaming (ivall#551).
abilliontokens added a commit to abilliontokens/xcl that referenced this pull request Nov 24, 2026
…copy

A compute pipeline's first bind waits for its build. When a worker is
already building it, the title's thread waited on that one build for as
long as it took: on a retail title's world loading (RTX 5060 Ti, main
f4ce27c) cdb showed 10 of 11 DXC threads and 10 of 11 pipeline workers
parked, one build in flight, and the render thread in resolve_wait's
condvar. Frames stopped, and the title's watchdog crashed it at +0x23cf683
at 93-101 s on four runs (xcl-dev#232, xcl-dev#581), with and without xcl-dev#690's preloading.

After a grace period (250 ms; XCL_PSO_HELP_MS, 0 = off) the waiting thread
builds a second copy itself, and the first of the two to finish is the
pipeline (complete: the later one is released). go_background supplies the
second copy's build; the descriptor is shared read-only (SharedDesc). A
pipeline no run used still waits for its worker as before.

Measured, same input and caches, 300 s runs that reach world loading:
crash at 152.6 s instead of 93.4 / 100.4 s; 2669 frames instead of 1324 /
1443; background pipelines built 50987 against 121 / 866 on main. It does
not reach gameplay: the next wait on the title's thread is the title-texture
write-watch refresh (xcl-dev#551) and XMemMapPhysicalPagesScatter (xcl-dev#156).

Assisted-by: Claude Code (Claude Opus 5.5)
@milas6669

milas6669 commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

Correction: please disregard the speed-up and write-watch numbers in my first version of this comment. I attributed them to this PR and that was wrong. The earlier text is replaced by what I can actually support.

I ran this PR merged onto main beaa245 (clean merge, only title_textures.rs differs) on a retail title, and compared it with main beaa245 without the PR. The first main run was the one that looked slow. I then ran the same main binary again (checked byte for byte), and it behaves like the PR build.

Tested

  • NVIDIA GeForce RTX 3070 (8 GB VRAM, 32-lane waves), Intel i9-10900KF, 32 GB RAM, Windows 11 Pro 10.0.26200, rustc 1.100.0, release builds, XCL_NETWORK=0, scripts/smoke.ps1 with 600 s (main) and a memory watchdog that kills the run at 24 GB (PR) / 27 GB (main, second run)
run frames presented fps over the last 300 write-watch (sparse windows timing) process commit video memory local
main, 1st run (after a rebuild) 3000 at 486 s 4–8 55298 ms for 510960 dirty pages (about 108 µs a page) flat, 15.4–17.3 GB 6.5–7.7 GB
main + this PR 3000 at 110 s 26–30 16850 ms for 1914297 dirty pages (about 9 µs a page) 22.5 GB at 130 s, killed at 24.4 GB 10.6 GB at 130 s
main again, same binary as the 1st run 1800 at 68 s 26–30 17706 ms for 2193526 dirty pages (about 8 µs a page) 27.4 GB at 114 s, killed at 27.0 GB 13.8 GB at 114 s

Not tested

  • a clean A/B with both builds starting from the same cache state (I did not clear the caches between runs)
  • cargo test on this head; AMD / wave64 hardware; visual correctness

AI use

  • Claude Code, Claude Sonnet 5.5, ran the commands and wrote this correction.

gustavsi added a commit to gustavsi/xcl that referenced this pull request Nov 24, 2026
…-watch merge

Integrates upstream PRs ivall#594, ivall#640, and ivall#551:
- Order reserved-texture tile unmaps behind known title queues with GPU
  fences before releasing tiles back to pools (ivall#594).
- Add opt-in XCL_PAGE_BUDGET_MB to evict LRU CPU-filled title textures
  when texture page pools hit the cap, remapping and re-uploading on use
  (ivall#640), preventing unbounded VRAM growth during world streaming.
- Merge write-watch scan gaps up to 64 MiB and clip regions with binary
  search to cut GetWriteWatch overhead during streaming (ivall#551).
@AlexLopezDevelop

Copy link
Copy Markdown

Tested on RTX 2080 Ti (Turing, driver 621.24) + Intel i9-9900K, Windows 11, 32 GB, retail 1.0.2.1, merged onto #891 + #631 (XCL_PSO_WAIT_MS=50), DXC 1.9.2609, first-run setup walked by hand. One run each, so treat the numbers as indicative.

[  8.647] sparse windows timing: write-watch    93 ms (   5836 dirty pages) … upload  26 ms
[ 26.223] sparse windows timing: write-watch   885 ms ( 312368 dirty pages) … upload 146 ms
[ 36.061] sparse windows timing: write-watch  4293 ms ( 409605 dirty pages) … upload 170 ms
[ 57.598] sparse windows timing: write-watch 12345 ms ( 854932 dirty pages) … upload 276 ms
[ 94.577] sparse windows timing: write-watch 30610 ms (1664016 dirty pages) … upload 365 ms

Not tested: the full cargo test suite; a smoke.ps1 pair (an unattended run stays before the first-run setup).

AI-assisted (Claude Code, Claude Opus 5.5).

@ivall
ivall merged commit afe4226 into xcl-dev:main Nov 24, 2026
1 check passed
@ivall

ivall commented Nov 24, 2026

Copy link
Copy Markdown
Collaborator

Merged (02bfd1d), from the draft: AlexLopezDevelop's run shows the menus going from 2-4 to ~6.8 fps on a CPU where the look dominates, and it stacks with #693. Checked on main 02bfd1d together with #891, #693, #551 and #631: cargo test --workspace -- --test-threads=4 green (685 lib tests), and a retail run through the menus and intro into the start of the world load with XCL_PSO_WAIT_MS=50: no crash, no device removal.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

9 participants