D3D12.X: the per-draw mirror sync copies only the pages the title wrote #2468

Closed
KOLESNiii wants to merge 3 commits from upstream-pr/2478 into main
KOLESNiii commented 2026-11-25 19:45:58 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by KOLESNiii on 2026-11-25T19:45:58Z.


Stacked on #2437 (itself on #2416); only the top commit (D3D12.X: the per-draw mirror sync copies only the pages the title wrote) belongs here.

sync_title_buffers copies the drawn range of every mirrored buffer at every draw, whether or not the title wrote it. For a source in write-watched memory (kernelx reserves GPU-visible title memory that way), a draw now copies only the pages written since they were last copied. On the one title measured, this is slower, not faster (see Tested): the title rewrites these pages every frame, so few copies are saved, and the GetWriteWatch call per draw costs more than they did. Opened as a draft for review of the approach and for numbers from other titles.

Part of #2393 (the copies). Part of #2389.

What is in it

  • After the rebase: main's copy_committed_region now zeroes a page it cannot read. The mirror sync here uses copy_committed_pages (title_textures.rs), the same copy without zeroing, so a page the title freed keeps the mirror's bytes instead of turning into zeros.
  • crates/xcl/src/hle/d3d12x/list_x.rs:
    • Which pages a draw copies: the pages on the write-watch (GetWriteWatch without reset), plus the pages a look took off it since the mirror's last copy (MIRROR_STALE, beside MIRRORS and not in it, to stay clear of #1995).
    • When it copies the whole range: when the source is not write-watched, or when a look overlapped the draw (MIRROR_LOOK_SEQ).
    • How much of a page: a page it copies is copied as far as it is in the mirror's source, not only the draw's part: its stale bit is cleared there, so another draw on the rest of the page would otherwise read old bytes (review below).
    • Test: the_mirror_sync_copies_only_the_pages_the_title_wrote.
  • crates/xcl/src/hle/d3d12x/title_textures.rs: the look watches the mirror sources (a new part of WATCH_CACHE's key) and hands the pages it takes off the write-watch to list_x::mirror_pages_written. Without that, a page written after a draw's copy and reset by the look would never be copied again. The look also runs when mirrors exist with no sparse window and no title texture (look_needed; review below). Tests: a_look_runs_for_buffer_mirrors_alone, and the_look_before_a_submit_lets_the_mirror_sync_skip_unwritten_pages, which goes through refresh.
  • crates/xcl/src/hle/kernelx.rs: reserve_watched is pub(crate), for that test's write-watched title memory.
  • Since the rebase onto ae5ae5a8, the mirror copies use #2437's copy_committed_region_keeping, which leaves an unreadable page's mirror bytes as they were (main now zeroes them in copy_committed_region).

Tested

  • Hardware: NVIDIA RTX 2070 SUPER (driver 32.0.16.2140), AMD Ryzen 5 3600XT, Windows 11 build 26300, Rust 1.100.0. Tests in debug, runs in release.

  • Rebased onto main 336fddda on 2026-11-28. cargo build --workspace && cargo test --workspace --no-fail-fast -- --test-threads=4 on 5f49085f: 2129 passed, 9 failed, 48 ignored; 25 SKIPPED (21 no wave64, 3 refused #1426 forms, 1 no heap windows). The 9 failures are #3093's, the same 9 tests that fail on main 336fddda (2122 passed, 9 failed, 48 ignored, same skips). The results below are from before the rebase.

  • Suite on 7e1d426 (rebased onto #2416's review fix): cargo test --workspace -- --test-threads=4: 1430 passed, 0 failed, 46 ignored; 25 SKIPPED (21 no wave64, 3 f16/f32 programs refused for wave32 (#1426), 1 no heap windows, as on main).

  • New tests:

    • the_mirror_sync_copies_only_the_pages_the_title_wrote fails on #2437's code ("unchanged since: nothing copied").
    • a_look_runs_for_buffer_mirrors_alone fails with the old early return.
    • the_look_before_a_submit_lets_the_mirror_sync_skip_unwritten_pages passes with and without the early-return fix on this machine: the test process has a sparse window, so it never reaches that return. It covers the path through the real look.
    • Its two draws on disjoint halves of one page after a look fail without the whole-page copy ("each draw on the page reads the title's bytes").
  • Measurement: retail game, menus, 120 s with its learned coherent window removed so mirrors are made. XCL_ACTIVITY counters from #2416, means per 2 s. The machine got slower during the day: #2437's head gave very different numbers in the morning and the afternoon, so only the afternoon runs compare with each other. These runs are of 2bdfb90, before the review fix. That fix changes only the case with no sparse window, and every run here had three.

    #2437, morning #2437, afternoon this PR, afternoon (2 runs)
    presents 60 steady 60, ~35 from 66 s ~35–50 / ~26–46
    copies / KB copied 1,197 / 10,766 871 / 7,833 747 / 6,714 and 720 / 6,473
    time in the sync: median, mean 4.74, 4.74 ms 30, 38 ms 65, 76 ms and 45, 80 ms
  • Write-watch vs. content: a temporary check, run once and not in this commit, compared every mirror with its source after each draw. It found no stale pages. Copies stayed at ~1,100–1,200 per 2 s, because the write-watch reports these pages written every frame, although #2389 found their bytes unchanged.

  • Device hang: one earlier 120 s run of this commit ended in a device hang (0x887a0006), and the title drew ~200 draws per 2 s instead of ~780 from the moment the mirrors appeared. The author saw the same hang on a run of main, and neither rerun of this commit hung, so it is not counted against this change. The cause is not known.

Regression run
After the rebase onto main 336fddda: RTX 2070 SUPER, the retail game, 60 s, XCL_PRESS_AT=25:A, XCL_PREPARE=0 (no startup shader preparation), release builds. One queue job of seven runs (main, then #2416, #2437, #2533, #2478, #2500, #3035, one after the other); the DXIL cache carries over from run to run.

xcl-smoke v1
commit: 336fdddafbcb3c3db753629f5f79a9f44b6c4b9d
gpu: NVIDIA GeForce RTX 2070 SUPER
title: retail game
seconds: 60
exit: 0x0
frames shown: 1253 (PresentX 1253)
presents per 2 s (last 3): 54 58 59
device removals: 0
crashes: 0
peak commit: 16597 MB
xcl-smoke v1
commit: 5f49085f9a29e3bcc3df19e81525f7625ecf5859
gpu: NVIDIA GeForce RTX 2070 SUPER
title: retail game
seconds: 60
exit: 0x0
frames shown: 1441 (PresentX 1441)
presents per 2 s (last 3): 60 60 61
device removals: 0
crashes: 0
peak commit: 16091 MB

Not tested

  • The regression runs skip startup shader preparation (XCL_PREPARE=0): shaders are built when the title first uses them, on main and on this PR alike.
  • Other titles: a title that does not rewrite its mirrored buffers every frame, where this should save the copies. None was available.
  • Writes the write-watch does not see: GPU writes into the source, and a title that resets the write-watch on its own memory. In both cases a draw would use stale data.
  • Other hardware: AMD and Intel GPUs, wave64.

AI use

  • Claude Code with Claude Opus 5.5: wrote the code, the test, the commit message and this description, and ran the tests and the runs.
  • Claude Code (Claude Opus 5.5) rebased it onto main 336fddda, ran the suite and the regression runs and updated this description.

🤖 Generated with Claude Code

<!-- greyfinch-sync:ivall/xcl:issue:5498024838 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2478). Originally posted by [KOLESNiii](https://github.com/KOLESNiii) on 2026-11-25T19:45:58Z. --- Stacked on #2437 (itself on #2416); only the top commit (`D3D12.X: the per-draw mirror sync copies only the pages the title wrote`) belongs here. `sync_title_buffers` copies the drawn range of every mirrored buffer at every draw, whether or not the title wrote it. For a source in write-watched memory (kernelx reserves GPU-visible title memory that way), a draw now copies only the pages written since they were last copied. **On the one title measured, this is slower, not faster** (see Tested): the title rewrites these pages every frame, so few copies are saved, and the `GetWriteWatch` call per draw costs more than they did. Opened as a draft for review of the approach and for numbers from other titles. Part of #2393 (the copies). Part of #2389. **What is in it** - After the rebase: `main`'s `copy_committed_region` now zeroes a page it cannot read. The mirror sync here uses `copy_committed_pages` (`title_textures.rs`), the same copy without zeroing, so a page the title freed keeps the mirror's bytes instead of turning into zeros. - `crates/xcl/src/hle/d3d12x/list_x.rs`: - **Which pages a draw copies:** the pages on the write-watch (`GetWriteWatch` without reset), plus the pages a look took off it since the mirror's last copy (`MIRROR_STALE`, beside `MIRRORS` and not in it, to stay clear of #1995). - **When it copies the whole range:** when the source is not write-watched, or when a look overlapped the draw (`MIRROR_LOOK_SEQ`). - **How much of a page:** a page it copies is copied as far as it is in the mirror's source, not only the draw's part: its stale bit is cleared there, so another draw on the rest of the page would otherwise read old bytes (review below). - **Test:** `the_mirror_sync_copies_only_the_pages_the_title_wrote`. - `crates/xcl/src/hle/d3d12x/title_textures.rs`: the look watches the mirror sources (a new part of `WATCH_CACHE`'s key) and hands the pages it takes off the write-watch to `list_x::mirror_pages_written`. Without that, a page written after a draw's copy and reset by the look would never be copied again. The look also runs when mirrors exist with no sparse window and no title texture (`look_needed`; review below). Tests: `a_look_runs_for_buffer_mirrors_alone`, and `the_look_before_a_submit_lets_the_mirror_sync_skip_unwritten_pages`, which goes through `refresh`. - `crates/xcl/src/hle/kernelx.rs`: `reserve_watched` is `pub(crate)`, for that test's write-watched title memory. - Since the rebase onto `ae5ae5a8`, the mirror copies use #2437's `copy_committed_region_keeping`, which leaves an unreadable page's mirror bytes as they were (`main` now zeroes them in `copy_committed_region`). **Tested** - **Hardware:** NVIDIA RTX 2070 SUPER (driver 32.0.16.2140), AMD Ryzen 5 3600XT, Windows 11 build 26300, Rust 1.100.0. Tests in debug, runs in release. - Rebased onto `main` `336fddda` on 2026-11-28. `cargo build --workspace && cargo test --workspace --no-fail-fast -- --test-threads=4` on `5f49085f`: 2129 passed, 9 failed, 48 ignored; 25 SKIPPED (21 `no wave64`, 3 refused #1426 forms, 1 `no heap windows`). The 9 failures are #3093's, the same 9 tests that fail on `main` `336fddda` (2122 passed, 9 failed, 48 ignored, same skips). The results below are from before the rebase. - **Suite** on `7e1d426` (rebased onto #2416's review fix): `cargo test --workspace -- --test-threads=4`: 1430 passed, 0 failed, 46 ignored; 25 SKIPPED (21 `no wave64`, 3 f16/f32 programs refused for wave32 (#1426), 1 `no heap windows`, as on `main`). - **New tests:** - `the_mirror_sync_copies_only_the_pages_the_title_wrote` fails on #2437's code ("unchanged since: nothing copied"). - `a_look_runs_for_buffer_mirrors_alone` fails with the old early return. - `the_look_before_a_submit_lets_the_mirror_sync_skip_unwritten_pages` passes with and without the early-return fix on this machine: the test process has a sparse window, so it never reaches that return. It covers the path through the real look. - Its two draws on disjoint halves of one page after a look fail without the whole-page copy ("each draw on the page reads the title's bytes"). - **Measurement:** retail game, menus, 120 s with its learned coherent window removed so mirrors are made. `XCL_ACTIVITY` counters from #2416, means per 2 s. The machine got slower during the day: #2437's head gave very different numbers in the morning and the afternoon, so only the afternoon runs compare with each other. These runs are of `2bdfb90`, before the review fix. That fix changes only the case with no sparse window, and every run here had three. | | #2437, morning | #2437, afternoon | this PR, afternoon (2 runs) | |---|---|---|---| | presents | 60 steady | 60, ~35 from 66 s | ~35–50 / ~26–46 | | copies / KB copied | 1,197 / 10,766 | 871 / 7,833 | 747 / 6,714 and 720 / 6,473 | | time in the sync: median, mean | 4.74, 4.74 ms | 30, 38 ms | 65, 76 ms and 45, 80 ms | - **Write-watch vs. content:** a temporary check, run once and not in this commit, compared every mirror with its source after each draw. It found no stale pages. Copies stayed at ~1,100–1,200 per 2 s, because the write-watch reports these pages written every frame, although #2389 found their bytes unchanged. - **Device hang:** one earlier 120 s run of this commit ended in a device hang (`0x887a0006`), and the title drew ~200 draws per 2 s instead of ~780 from the moment the mirrors appeared. The author saw the same hang on a run of `main`, and neither rerun of this commit hung, so it is not counted against this change. The cause is not known. **Regression run** After the rebase onto `main` `336fddda`: RTX 2070 SUPER, the retail game, 60 s, `XCL_PRESS_AT=25:A`, `XCL_PREPARE=0` (no startup shader preparation), release builds. One queue job of seven runs (`main`, then #2416, #2437, #2533, #2478, #2500, #3035, one after the other); the DXIL cache carries over from run to run. ``` xcl-smoke v1 commit: 336fdddafbcb3c3db753629f5f79a9f44b6c4b9d gpu: NVIDIA GeForce RTX 2070 SUPER title: retail game seconds: 60 exit: 0x0 frames shown: 1253 (PresentX 1253) presents per 2 s (last 3): 54 58 59 device removals: 0 crashes: 0 peak commit: 16597 MB ``` ``` xcl-smoke v1 commit: 5f49085f9a29e3bcc3df19e81525f7625ecf5859 gpu: NVIDIA GeForce RTX 2070 SUPER title: retail game seconds: 60 exit: 0x0 frames shown: 1441 (PresentX 1441) presents per 2 s (last 3): 60 60 61 device removals: 0 crashes: 0 peak commit: 16091 MB ``` **Not tested** - The regression runs skip startup shader preparation (`XCL_PREPARE=0`): shaders are built when the title first uses them, on `main` and on this PR alike. - **Other titles:** a title that does not rewrite its mirrored buffers every frame, where this should save the copies. None was available. - **Writes the write-watch does not see:** GPU writes into the source, and a title that resets the write-watch on its own memory. In both cases a draw would use stale data. - **Other hardware:** AMD and Intel GPUs, wave64. **AI use** - Claude Code with Claude Opus 5.5: wrote the code, the test, the commit message and this description, and ran the tests and the runs. - Claude Code (Claude Opus 5.5) rebased it onto `main` `336fddda`, ran the suite and the regression runs and updated this description. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
bmjask commented 2026-11-25 20:16:31 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by bmjask on 2026-11-25T20:16:31Z.

Review: COMMENTED


P2: the optimization is bypassed for a valid non-sparse UMA configuration with mirrored buffers but no title textures. refresh_once returns at title_textures.rs:722-727 before buffer mirror ranges are added/reset at :731-747. list_x.rs:3547-3565 then calls GetWriteWatch without RESET, so every page ever written stays dirty and is recopied on every draw. The new test calls the look helper directly and bypasses this return. Please run refresh when a mirror exists and add an end-to-end zero-texture/non-sparse coverage case.

<!-- greyfinch-sync:ivall/xcl:review:6064333987 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2478#pullrequestreview-6064333987). Originally posted by [bmjask](https://github.com/bmjask) on 2026-11-25T20:16:31Z. **Review:** COMMENTED --- P2: the optimization is bypassed for a valid non-sparse UMA configuration with mirrored buffers but no title textures. refresh_once returns at title_textures.rs:722-727 before buffer mirror ranges are added/reset at :731-747. list_x.rs:3547-3565 then calls GetWriteWatch without RESET, so every page ever written stays dirty and is recopied on every draw. The new test calls the look helper directly and bypasses this return. Please run refresh when a mirror exists and add an end-to-end zero-texture/non-sparse coverage case.
emirduran707 commented 2026-11-25 21:05:15 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by emirduran707 on 2026-11-25T20:24:15Z.


Independent AMD RDNA4 (native wave64) test report on exact head 2bdfb908c671fc488b7846ebbca198951ffb0114 (clean detached checkout, no local changes).

Tested

  • AMD Radeon RX 9060 XT 16 GB (RDNA4, native wave64, driver 32.0.31044.16), Ryzen 5 5600, 32 GB RAM, Windows 11 Pro 26300, Rust 1.100.0 (stable-x86_64-pc-windows-msvc), DXC 1.9.2602.17; tests debug, smoke release.
  • cargo build --workspace && cargo test --workspace --no-fail-fast -- --test-threads=4: 1275 passed, 2 failed, 46 ignored; 8 SKIPPED (6 in lower_dxil::tests::{f16,f32}_programs_on_the_gpu refused by per-lane form; heap_window_out_of_memory_falls_back_to_the_switch_form; pso_measurement_compiles_an_exact_synthetic_record). All native wave64 GPU tests ran and passed.
    • Both PR tests passed: hle::d3d12x::list_x::tests::the_mirror_sync_copies_around_a_page_the_title_made_unreadable and the_mirror_sync_copies_only_the_pages_the_title_wrote.
    • The 2 failures (gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_1 seed 722 and fuzz_validate_and_gpu_3 seed 1599) are pre-existing on unmodified main on this GPU.

Regression run (60 s retail-title smoke, XCL_NETWORK=0, release)

xcl-smoke v1
commit: 2bdfb908c671fc488b7846ebbca198951ffb0114
gpu: AMD Radeon RX 9060 XT
title: 21222967
seconds: 60
exit: 0x0
frames shown: 1614 (PresentX 1614)
presents per 2 s (last 3): 60 60 61
device removals: 0
crashes: 0
peak commit: 13922 MB

(Matched main 68a284a baseline on the same machine today: 1573 frames, 14420 MB peak, 0 device removals, 0 crashes.)

Not tested

  • D3D12 debug layer; Intel GPUs.

AI use

  • Antigravity with Gemini 4 Neon ran the build, test suite, and smoke run and drafted this report.
<!-- greyfinch-sync:ivall/xcl:comment:7173619951 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2478#issuecomment-7173619951). Originally posted by [emirduran707](https://github.com/emirduran707) on 2026-11-25T20:24:15Z. --- Independent AMD RDNA4 (native wave64) test report on exact head `2bdfb908c671fc488b7846ebbca198951ffb0114` (clean detached checkout, no local changes). **Tested** - AMD Radeon RX 9060 XT 16 GB (RDNA4, native wave64, driver 32.0.31044.16), Ryzen 5 5600, 32 GB RAM, Windows 11 Pro 26300, Rust 1.100.0 (`stable-x86_64-pc-windows-msvc`), DXC 1.9.2602.17; tests debug, smoke release. - `cargo build --workspace && cargo test --workspace --no-fail-fast -- --test-threads=4`: **1275 passed, 2 failed, 46 ignored; 8 SKIPPED** (6 in `lower_dxil::tests::{f16,f32}_programs_on_the_gpu` refused by per-lane form; `heap_window_out_of_memory_falls_back_to_the_switch_form`; `pso_measurement_compiles_an_exact_synthetic_record`). All native wave64 GPU tests ran and passed. - Both PR tests passed: `hle::d3d12x::list_x::tests::the_mirror_sync_copies_around_a_page_the_title_made_unreadable` and `the_mirror_sync_copies_only_the_pages_the_title_wrote`. - The 2 failures (`gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_1` seed 722 and `fuzz_validate_and_gpu_3` seed 1599) are pre-existing on unmodified `main` on this GPU. **Regression run** (60 s retail-title smoke, `XCL_NETWORK=0`, release) ``` xcl-smoke v1 commit: 2bdfb908c671fc488b7846ebbca198951ffb0114 gpu: AMD Radeon RX 9060 XT title: 21222967 seconds: 60 exit: 0x0 frames shown: 1614 (PresentX 1614) presents per 2 s (last 3): 60 60 61 device removals: 0 crashes: 0 peak commit: 13922 MB ``` (Matched `main` `68a284a` baseline on the same machine today: 1573 frames, 14420 MB peak, 0 device removals, 0 crashes.) **Not tested** - D3D12 debug layer; Intel GPUs. **AI use** - Antigravity with Gemini 4 Neon ran the build, test suite, and smoke run and drafted this report.
SlopTart commented 2026-11-25 21:05:19 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by SlopTart on 2026-11-25T20:37:12Z.


gpu_ suite (cold cache): 164 passed / 3 failed, no crashes. The three are the known baseline on this lane (seed-1003 fuzz, mad/mac contraction, and the promoted-UAV-clear driver gap, PR #2490); none caused by this PR. Note gpu_depth_buffer_created_for_unordered_access_is_placed is green on main now, #2466 did its job on this lane.
Targeted run of the two mirror-sync tests (the_mirror_sync_copies_only_the_pages_the_title_wrote, the_mirror_sync_copies_around_a_page_the_title_made_unreadable): 2 passed. Same lane this feature's earlier tests were verified on (#2437).

<!-- greyfinch-sync:ivall/xcl:comment:7173938358 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2478#issuecomment-7173938358). Originally posted by [SlopTart](https://github.com/SlopTart) on 2026-11-25T20:37:12Z. --- `gpu_` suite (cold cache): 164 passed / 3 failed, no crashes. The three are the known baseline on this lane (seed-1003 fuzz, mad/mac contraction, and the promoted-UAV-clear driver gap, PR #2490); none caused by this PR. Note `gpu_depth_buffer_created_for_unordered_access_is_placed` is green on main now, #2466 did its job on this lane. Targeted run of the two mirror-sync tests (`the_mirror_sync_copies_only_the_pages_the_title_wrote`, `the_mirror_sync_copies_around_a_page_the_title_made_unreadable`): 2 passed. Same lane this feature's earlier tests were verified on (#2437).
DavidM1911 commented 2026-11-25 21:05:19 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by DavidM1911 on 2026-11-25T20:37:56Z.


Verification on RTX 3060 Ti (Windows 11), branch merged with current main:

  • cargo test -p xcl --lib: 1038 passed, 1 failed in one parallel run; the failing test passes on a single-threaded rerun (1039/0). Intermittent single-test flake / 0xc0000005 abort under parallel scheduling — tracked in #1978; clean on single-threaded rerun.

Thanks!

<!-- greyfinch-sync:ivall/xcl:comment:7173956355 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2478#issuecomment-7173956355). Originally posted by [DavidM1911](https://github.com/DavidM1911) on 2026-11-25T20:37:56Z. --- Verification on RTX 3060 Ti (Windows 11), branch merged with current `main`: - `cargo test -p xcl --lib`: 1038 passed, 1 failed in one parallel run; the failing test passes on a single-threaded rerun (1039/0). Intermittent single-test flake / 0xc0000005 abort under parallel scheduling — tracked in #1978; clean on single-threaded rerun. Thanks!
KOLESNiii commented 2026-11-25 21:05:21 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by KOLESNiii on 2026-11-25T20:45:57Z.


@bmjask thanks, you're right. With no sparse window and no title texture, refresh_once returned before the look, so mirror sources were never reset and every draw copied every page ever written. Fixed in a6ec51e (squashed into the PR's commit):

  • title_textures::look_needed: the look also runs when a mirror exists (list_x::mirror_sources_gen() != 0).
  • a_look_runs_for_buffer_mirrors_alone covers that condition and fails with the old early return.
  • the_look_before_a_submit_lets_the_mirror_sync_skip_unwritten_pages goes end to end through refresh, on write-watched title memory from kernelx (reserve_watched): unchanged pages are skipped after a look, and a page written before the look is copied.
    • It doesn't cover the zero-texture, non-sparse case on my machine: the test process always has sparse windows here, so it passes with and without the fix. The predicate test is what covers that case. I don't see a way to force a non-sparse UMA in the shared test process without a test-only switch in gpu::uma; tell me if you want one.

cargo test --workspace -- --test-threads=4 on a6ec51e: 1279 passed, 0 failed, 46 ignored, 25 SKIPPED (RTX 2070 SUPER). The regression run for a6ec51e is still to come; the machine was short of commit memory for the one I tried.

Written with Claude Code (Claude Opus 5.5).

<!-- greyfinch-sync:ivall/xcl:comment:7174156528 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2478#issuecomment-7174156528). Originally posted by [KOLESNiii](https://github.com/KOLESNiii) on 2026-11-25T20:45:57Z. --- @bmjask thanks, you're right. With no sparse window and no title texture, `refresh_once` returned before the look, so mirror sources were never reset and every draw copied every page ever written. Fixed in `a6ec51e` (squashed into the PR's commit): - `title_textures::look_needed`: the look also runs when a mirror exists (`list_x::mirror_sources_gen() != 0`). - `a_look_runs_for_buffer_mirrors_alone` covers that condition and fails with the old early return. - `the_look_before_a_submit_lets_the_mirror_sync_skip_unwritten_pages` goes end to end through `refresh`, on write-watched title memory from kernelx (`reserve_watched`): unchanged pages are skipped after a look, and a page written before the look is copied. - It doesn't cover the zero-texture, non-sparse case on my machine: the test process always has sparse windows here, so it passes with and without the fix. The predicate test is what covers that case. I don't see a way to force a non-sparse UMA in the shared test process without a test-only switch in `gpu::uma`; tell me if you want one. `cargo test --workspace -- --test-threads=4` on `a6ec51e`: 1279 passed, 0 failed, 46 ignored, 25 SKIPPED (RTX 2070 SUPER). The regression run for `a6ec51e` is still to come; the machine was short of commit memory for the one I tried. *Written with Claude Code (Claude Opus 5.5).*
Oliwettoo commented 2026-11-25 23:09:11 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Oliwettoo on 2026-11-25T22:33:49Z.


Heads-up for whichever of these merges second: #1995 and #2478 (stacked on #2437) both rewrite the per-draw mirror sync in list_x.rs, and git merge-tree reports a conflict between their heads. Beyond the text conflict:

  • #1995 makes MIRRORS (title_start, cpu_src_start, len, mirror), so a mirror of a GPU-view address copies from its CPU backing.
  • #2478's page tracking (mirror_sources, the GetWriteWatch in written_pages, MIRROR_STALE) works on the title address.

Combined as they are, a GPU-view mirror's GetWriteWatch fails, so the draw copies the whole range every time. That stays correct, but it loses #2478's saving for exactly the buffers #1995 adds. Switching the write-watch and stale-page lookups to cpu_src_start when resolving would keep both. (Read from the diffs a6ec51e / bdfb2fb, not run.)

<!-- greyfinch-sync:ivall/xcl:comment:7176518026 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2478#issuecomment-7176518026). Originally posted by [Oliwettoo](https://github.com/Oliwettoo) on 2026-11-25T22:33:49Z. --- Heads-up for whichever of these merges second: #1995 and #2478 (stacked on #2437) both rewrite the per-draw mirror sync in `list_x.rs`, and `git merge-tree` reports a conflict between their heads. Beyond the text conflict: - #1995 makes `MIRRORS` `(title_start, cpu_src_start, len, mirror)`, so a mirror of a GPU-view address copies from its CPU backing. - #2478's page tracking (`mirror_sources`, the `GetWriteWatch` in `written_pages`, `MIRROR_STALE`) works on the title address. Combined as they are, a GPU-view mirror's `GetWriteWatch` fails, so the draw copies the whole range every time. That stays correct, but it loses #2478's saving for exactly the buffers #1995 adds. Switching the write-watch and stale-page lookups to `cpu_src_start` when resolving would keep both. (Read from the diffs a6ec51e / bdfb2fb, not run.)
KOLESNiii commented 2026-11-25 23:09:21 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by KOLESNiii on 2026-11-25T22:58:29Z.


Thanks, confirmed from the diffs: merged as is, a GPU-view mirror falls back to a full copy per draw (still correct). Whoever rebases second should move the GetWriteWatch range, the MIRROR_STALE key and mirror_sources() to cpu_src_start together. Moving only the copy source would make the stale-page lookup miss, and pages taken off the write-watch by a look would never be copied. I'll do that in #2478's rebase if #1995 lands first.

<!-- greyfinch-sync:ivall/xcl:comment:7177000692 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2478#issuecomment-7177000692). Originally posted by [KOLESNiii](https://github.com/KOLESNiii) on 2026-11-25T22:58:29Z. --- Thanks, confirmed from the diffs: merged as is, a GPU-view mirror falls back to a full copy per draw (still correct). Whoever rebases second should move the `GetWriteWatch` range, the `MIRROR_STALE` key and `mirror_sources()` to `cpu_src_start` together. Moving only the copy source would make the stale-page lookup miss, and pages taken off the write-watch by a look would never be copied. I'll do that in #2478's rebase if #1995 lands first.
DavidM1911 commented 2026-11-26 02:08:24 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by DavidM1911 on 2026-11-26T01:50:01Z.


Re-verification on RTX 3060 Ti (Windows 11), new head merged with current main:

  • cargo test -p xcl --lib: all passed, 0 failed, 27 ignored. The earlier merge conflict is resolved.

Thanks!

— Devin

<!-- greyfinch-sync:ivall/xcl:comment:7180182403 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2478#issuecomment-7180182403). Originally posted by [DavidM1911](https://github.com/DavidM1911) on 2026-11-26T01:50:01Z. --- Re-verification on RTX 3060 Ti (Windows 11), new head merged with current `main`: - `cargo test -p xcl --lib`: all passed, 0 failed, 27 ignored. The earlier merge conflict is resolved. Thanks! — Devin
luckyteagirl commented 2026-11-26 07:35:16 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by luckyteagirl on 2026-11-26T07:35:16Z.

Review: COMMENTED


list_x.rs:3756–3758: written_pages clears a stale bit for an entire 4 KiB page, but copy_written copies only the current draw's byte range (:3791–3801,3819). After refresh resets write-watch and records that page in MIRROR_STALE, two draws can use disjoint vertex ranges on it: draw A clears the page bit and copies only A; with no new title write, draw B sees neither a write-watch page nor a stale bit and uses old mirror bytes for B. Main's unconditional per-draw copy would update B, so this is a correctness regression from the page optimization even for ordinary CPU-written vertices.

Could the stale page be cleared only after its mirrored bytes have all been refreshed (for example by copying the dirty page's full intersection with the mirror allocation), and could the existing look/submit fixture assert two disjoint draws on one page? This is an exact-head source interleaving at 77e48ea4ba7dd7492d14b237655279f8f083f0dc; I have not run the proposed GPU fixture or a title. AI-assisted review with Codex.

<!-- greyfinch-sync:ivall/xcl:review:6070120637 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2478#pullrequestreview-6070120637). Originally posted by [luckyteagirl](https://github.com/luckyteagirl) on 2026-11-26T07:35:16Z. **Review:** COMMENTED --- `list_x.rs:3756–3758`: `written_pages` clears a stale bit for an entire 4 KiB page, but `copy_written` copies only the current draw's byte range (`:3791–3801,3819`). After `refresh` resets write-watch and records that page in `MIRROR_STALE`, two draws can use disjoint vertex ranges on it: draw A clears the page bit and copies only A; with no new title write, draw B sees neither a write-watch page nor a stale bit and uses old mirror bytes for B. Main's unconditional per-draw copy would update B, so this is a correctness regression from the page optimization even for ordinary CPU-written vertices. Could the stale page be cleared only after its mirrored bytes have all been refreshed (for example by copying the dirty page's full intersection with the mirror allocation), and could the existing look/submit fixture assert two disjoint draws on one page? This is an exact-head source interleaving at `77e48ea4ba7dd7492d14b237655279f8f083f0dc`; I have not run the proposed GPU fixture or a title. AI-assisted review with Codex.
KOLESNiii commented 2026-11-26 11:05:07 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by KOLESNiii on 2026-11-26T10:24:26Z.


@luckyteagirl thanks, you're right. Once written_pages cleared a page's stale bit, copy_written copied only the draw's bytes of it, so a second draw on another part of the page read old mirror bytes. Fixed in 1e5ab11 (squashed into the PR's commit):

  • written_pages also returns the mirror's source range. copy_written copies each page it found written or stale as far as the page lies in that range, not only the draw's part. That is the whole-page copy you suggested. The full-range fallback (source not write-watched, or a look overlapped the draw) still copies the draw's range only.
  • the_look_before_a_submit_lets_the_mirror_sync_skip_unwritten_pages now writes two bytes in different halves of one page, runs the look (refresh), and makes two draws over those halves with no write in between. It fails without the fix ("each draw on the page reads the title's bytes") and passes with it.

cargo test --workspace -- --test-threads=4 on 1e5ab11: 1429 passed, 0 failed, 46 ignored, 25 SKIPPED (RTX 2070 SUPER). The regression run in the description is now of 1e5ab11. As before, it made no mirrors, so it doesn't reach the changed path.

Written with Claude Code (Claude Opus 5.5).

<!-- greyfinch-sync:ivall/xcl:comment:7189323775 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2478#issuecomment-7189323775). Originally posted by [KOLESNiii](https://github.com/KOLESNiii) on 2026-11-26T10:24:26Z. --- @luckyteagirl thanks, you're right. Once `written_pages` cleared a page's stale bit, `copy_written` copied only the draw's bytes of it, so a second draw on another part of the page read old mirror bytes. Fixed in `1e5ab11` (squashed into the PR's commit): - `written_pages` also returns the mirror's source range. `copy_written` copies each page it found written or stale as far as the page lies in that range, not only the draw's part. That is the whole-page copy you suggested. The full-range fallback (source not write-watched, or a look overlapped the draw) still copies the draw's range only. - `the_look_before_a_submit_lets_the_mirror_sync_skip_unwritten_pages` now writes two bytes in different halves of one page, runs the look (`refresh`), and makes two draws over those halves with no write in between. It fails without the fix ("each draw on the page reads the title's bytes") and passes with it. `cargo test --workspace -- --test-threads=4` on `1e5ab11`: 1429 passed, 0 failed, 46 ignored, 25 SKIPPED (RTX 2070 SUPER). The regression run in the description is now of `1e5ab11`. As before, it made no mirrors, so it doesn't reach the changed path. *Written with Claude Code (Claude Opus 5.5).*
KOLESNiii commented 2026-11-28 17:38:28 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by KOLESNiii on 2026-11-28T17:38:28Z.


Closed in favour of #2533

<!-- greyfinch-sync:ivall/xcl:comment:7243172403 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2478#issuecomment-7243172403). Originally posted by [KOLESNiii](https://github.com/KOLESNiii) on 2026-11-28T17:38:28Z. --- Closed in favour of #2533

Pull request closed

Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
xcl-dev/xcl!2468
No description provided.