D3D12.X: XCL_GPU_TEXTURE_TOUCH logs CPU accesses to textures the GPU owns #2685

Closed
joeypercia wants to merge 1 commit from upstream-pr/2695 into main
joeypercia commented 2026-11-26 06:43:48 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by joeypercia on 2026-11-26T06:43:48Z.


XCL_GPU_TEXTURE_TOUCH=1 logs which of the textures the GPU owns the title's CPU reads or writes at their console address. These are render targets, depth buffers and UAV textures, which vram::place puts in video memory. On the PC nothing copies them to or from the title's memory, so a title that reads one on the CPU reads stale bytes. This tells whether the newer retail title does that and for which textures, before #2663 wires a read-back into the title. Off by default; nothing changes without the switch.

Part of #2663.

What is in it (one commit)

  • crates/xcl/src/hle/d3d12x/gpu_touch.rs:
    • When such a texture is placed, the committed pages wholly inside its console memory get PAGE_GUARD. A vectored handler notes the first access to each page, which the OS has already unguarded, and lets the access go on.
    • A background thread logs each texture's first access: read or write, offset, texture size and format, and the code address via modules::describe_address. Then every 2 s, while they change, it logs the counts: textures, guarded pages, touched pages, writes. The handler itself doesn't log or allocate.
  • crates/xcl/src/hle/d3d12x/device_x.rs: the vram::place path calls gpu_touch::placed with the console size and description.
  • The diagnostic keeps the exact set of pages it guarded (ARMED), and its handler handles a guard exception on one of those pages and only those. That holds even after a newer texture replaced the page's texture, and a page someone else had guarded already is left to them (luckyteagirl's first review).
  • crates/xcl/src/hle/kernelx.rs: VirtualFree (decommit, and release of the whole allocation) and MapTitlePhysicalPages drop the pages they free or map anew from that set (gpu_touch::freed, gpu_touch::forget). With an empty set that's one read lock. Without this, a decommitted page committed again and guarded by another owner would have had its exception taken here (luckyteagirl's second review).
  • crates/xcl/src/hle/kernelx/lazy.rs: a lazily committed page reports its first access too (same behaviour otherwise).
  • Test the_first_cpu_access_to_a_gpu_texture_is_noted:
    • Memory outside the texture isn't watched.
    • A read and a write of its pages both go on with the right bytes and are both noted.
    • The second access of a page isn't noted again.
    • The first access is kept with its address.
    • A lazy-page commit inside the texture counts, and one outside doesn't.
    • A newer texture over the middle page: the old texture's untouched pages are still handled (an access goes on, not noted), and a page guarded by someone else isn't armed. Without the set (handling only pages a texture owns), the test process ends with an unhandled 0x80000001.
  • Test a_decommitted_page_is_left_to_its_next_owner:
    • a guarded page is decommitted through kernelx::VirtualFree, committed again, and guarded by another owner with a handler after this one;
    • that handler gets its guard exception;
    • the page left committed stays armed;
    • a release through kernelx disarms the rest.
      Without the VirtualFree hook it fails ("a decommitted page stays armed").

Tested

  • NVIDIA GeForce RTX 4070 Ti (driver 621.40), and the AMD Radeon iGPU of a Ryzen 7 7800X3D (RDNA2) with XCL_ADAPTER=Radeon. Windows 11 Pro 26200, Rust 1.100.0 MSVC, DXC 1.8.2502.11. Debug builds for the tests, release for the runs.
  • cargo build --workspace, then cargo test --workspace --no-fail-fast -- --test-threads=4 on 11ef28f2:
    • RTX 4070 Ti: 1436 passed, 0 failed, 47 ignored.
    • RDNA2: 1435 passed, 1 failed, 47 ignored. The failure is gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_1, which fails the same way on main on this iGPU (#2115).
    • The new test ran on both adapters (... ok), not skipped.
  • In the newer retail title, with the switch on (on nvidia-dev c044dc6d, the build that gets furthest on this card): 720 textures the GPU owns, 13,344 pages guarded, 0 touched by the CPU. That covers the menus and the world load up to the device removal at 123 s (#2403). The removal came at the same time as in the runs before it without the switch (122–168 s). Details are on #2663.

Regression run

RTX 4070 Ti (driver 621.40), release builds, 60 s each, scripts/smoke.ps1 -Game <folder> -Title retail-title on the newer retail title, with the same settings. The switch is off in both, so this checks that nothing changes without it. Both ran with the NVIDIA shader-heap profile (#2590, 1 GiB) installed on this machine since 2026-11-25. main b49be183 (this PR's base) and this PR's head (no uncommitted changes):

main:

xcl-smoke v1
commit: b49be1836844fe0b0cdb3211dce3cb7fb4e21ac7
gpu: NVIDIA GeForce RTX 4070 Ti
title: retail-title
seconds: 60
exit: 0x0
frames shown: 1587 (PresentX 1587)
presents per 2 s (last 3): 60 58 48
device removals: 0
crashes: 0
peak commit: 15772 MB

PR:

xcl-smoke v1
commit: 11ef28f21184f165bf8246abdff89cb789b5eda1
gpu: NVIDIA GeForce RTX 4070 Ti
title: retail-title
seconds: 60
exit: 0x0
frames shown: 1520 (PresentX 1521)
presents per 2 s (last 3): 37 51 56
device removals: 0
crashes: 0
peak commit: 16178 MB

Not tested

  • A run that reaches the world, which is where the title is expected to read such a texture (#2663).
  • A kernel call that reads or writes a guarded page fails with STATUS_GUARD_PAGE_VIOLATION instead of faulting, so with the switch on a title could see such a call fail. That's why this is a diagnostic, off by default. The retail run above showed no such failure, but I didn't check for one specifically.
  • Textures placed before the title commits their memory and that aren't lazy pages: their pages can't be guarded, and they're not counted as guarded.
  • A decommit or release of title memory that doesn't go through kernelx (such as XCL's own frees of title ranges): its pages stay in the set until touched.

AI use

  • Claude Code with Claude Opus 5.5 wrote the code, the test and this description, and ran the tests and the runs on the hardware above.
<!-- greyfinch-sync:ivall/xcl:issue:5505337023 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2695). Originally posted by [joeypercia](https://github.com/joeypercia) on 2026-11-26T06:43:48Z. --- `XCL_GPU_TEXTURE_TOUCH=1` logs which of the textures the GPU owns the title's CPU reads or writes at their console address. These are render targets, depth buffers and UAV textures, which `vram::place` puts in video memory. On the PC nothing copies them to or from the title's memory, so a title that reads one on the CPU reads stale bytes. This tells whether the newer retail title does that and for which textures, before #2663 wires a read-back into the title. Off by default; nothing changes without the switch. Part of #2663. **What is in it** (one commit) - `crates/xcl/src/hle/d3d12x/gpu_touch.rs`: - When such a texture is placed, the committed pages wholly inside its console memory get `PAGE_GUARD`. A vectored handler notes the first access to each page, which the OS has already unguarded, and lets the access go on. - A background thread logs each texture's first access: read or write, offset, texture size and format, and the code address via `modules::describe_address`. Then every 2 s, while they change, it logs the counts: textures, guarded pages, touched pages, writes. The handler itself doesn't log or allocate. - `crates/xcl/src/hle/d3d12x/device_x.rs`: the `vram::place` path calls `gpu_touch::placed` with the console size and description. - The diagnostic keeps the exact set of pages it guarded (`ARMED`), and its handler handles a guard exception on one of those pages and only those. That holds even after a newer texture replaced the page's texture, and a page someone else had guarded already is left to them (luckyteagirl's first review). - `crates/xcl/src/hle/kernelx.rs`: `VirtualFree` (decommit, and release of the whole allocation) and `MapTitlePhysicalPages` drop the pages they free or map anew from that set (`gpu_touch::freed`, `gpu_touch::forget`). With an empty set that's one read lock. Without this, a decommitted page committed again and guarded by another owner would have had its exception taken here (luckyteagirl's second review). - `crates/xcl/src/hle/kernelx/lazy.rs`: a lazily committed page reports its first access too (same behaviour otherwise). - Test `the_first_cpu_access_to_a_gpu_texture_is_noted`: - Memory outside the texture isn't watched. - A read and a write of its pages both go on with the right bytes and are both noted. - The second access of a page isn't noted again. - The first access is kept with its address. - A lazy-page commit inside the texture counts, and one outside doesn't. - A newer texture over the middle page: the old texture's untouched pages are still handled (an access goes on, not noted), and a page guarded by someone else isn't armed. Without the set (handling only pages a texture owns), the test process ends with an unhandled `0x80000001`. - Test `a_decommitted_page_is_left_to_its_next_owner`: - a guarded page is decommitted through `kernelx::VirtualFree`, committed again, and guarded by another owner with a handler after this one; - that handler gets its guard exception; - the page left committed stays armed; - a release through kernelx disarms the rest. Without the `VirtualFree` hook it fails ("a decommitted page stays armed"). **Tested** - NVIDIA GeForce RTX 4070 Ti (driver 621.40), and the AMD Radeon iGPU of a Ryzen 7 7800X3D (RDNA2) with `XCL_ADAPTER=Radeon`. Windows 11 Pro 26200, Rust 1.100.0 MSVC, DXC 1.8.2502.11. Debug builds for the tests, release for the runs. - `cargo build --workspace`, then `cargo test --workspace --no-fail-fast -- --test-threads=4` on `11ef28f2`: - RTX 4070 Ti: **1436 passed, 0 failed, 47 ignored**. - RDNA2: **1435 passed, 1 failed, 47 ignored**. The failure is `gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_1`, which fails the same way on `main` on this iGPU (#2115). - The new test ran on both adapters (`... ok`), not skipped. - In the newer retail title, with the switch on (on `nvidia-dev` `c044dc6d`, the build that gets furthest on this card): 720 textures the GPU owns, 13,344 pages guarded, 0 touched by the CPU. That covers the menus and the world load up to the device removal at 123 s (#2403). The removal came at the same time as in the runs before it without the switch (122–168 s). Details are on #2663. **Regression run** RTX 4070 Ti (driver 621.40), release builds, 60 s each, `scripts/smoke.ps1 -Game <folder> -Title retail-title` on the newer retail title, with the same settings. The switch is off in both, so this checks that nothing changes without it. Both ran with the NVIDIA shader-heap profile (#2590, 1 GiB) installed on this machine since 2026-11-25. `main` `b49be183` (this PR's base) and this PR's head (no uncommitted changes): main: ``` xcl-smoke v1 commit: b49be1836844fe0b0cdb3211dce3cb7fb4e21ac7 gpu: NVIDIA GeForce RTX 4070 Ti title: retail-title seconds: 60 exit: 0x0 frames shown: 1587 (PresentX 1587) presents per 2 s (last 3): 60 58 48 device removals: 0 crashes: 0 peak commit: 15772 MB ``` PR: ``` xcl-smoke v1 commit: 11ef28f21184f165bf8246abdff89cb789b5eda1 gpu: NVIDIA GeForce RTX 4070 Ti title: retail-title seconds: 60 exit: 0x0 frames shown: 1520 (PresentX 1521) presents per 2 s (last 3): 37 51 56 device removals: 0 crashes: 0 peak commit: 16178 MB ``` **Not tested** - A run that reaches the world, which is where the title is expected to read such a texture (#2663). - A kernel call that reads or writes a guarded page fails with `STATUS_GUARD_PAGE_VIOLATION` instead of faulting, so with the switch on a title could see such a call fail. That's why this is a diagnostic, off by default. The retail run above showed no such failure, but I didn't check for one specifically. - Textures placed before the title commits their memory and that aren't lazy pages: their pages can't be guarded, and they're not counted as guarded. - A decommit or release of title memory that doesn't go through `kernelx` (such as XCL's own frees of title ranges): its pages stay in the set until touched. **AI use** - Claude Code with Claude Opus 5.5 wrote the code, the test and this description, and ran the tests and the runs on the hardware above.
luckyteagirl commented 2026-11-26 06:51:36 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by luckyteagirl on 2026-11-26T06:51:36Z.

Review: COMMENTED


placed() removes an older TEXTURES entry when a newer texture overlaps any part of its range, but it does not retire guards this diagnostic installed on the old range outside the overlap. For example, replacing the middle of a three-page texture removes its entire owner record while the outer pages can remain PAGE_GUARD. A later ordinary CPU access on an outer page raises a guard exception; texture_at() returns None, and this handler returns EXCEPTION_CONTINUE_SEARCH, so the diagnostic can pass an exception it created to the rest of the process. Microsoft describes PAGE_GUARD as a one-shot exception. Could the replacement path retain ownership for still-armed pages or disarm only the obsolete pages this diagnostic actually guarded, without clearing preexisting guards owned elsewhere? A child-process fixture with a partially overlapping placement and an access to an untouched old page would cover this lifecycle.

Exact-head source review of 638f0b5b6a7c8972f063f45ad5dbb5187d044f40; I did not enable the diagnostic or run a title. AI-assisted review with Codex.

<!-- greyfinch-sync:ivall/xcl:review:6069701528 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2695#pullrequestreview-6069701528). Originally posted by [luckyteagirl](https://github.com/luckyteagirl) on 2026-11-26T06:51:36Z. **Review:** COMMENTED --- `placed()` removes an older `TEXTURES` entry when a newer texture overlaps *any* part of its range, but it does not retire guards this diagnostic installed on the old range outside the overlap. For example, replacing the middle of a three-page texture removes its entire owner record while the outer pages can remain `PAGE_GUARD`. A later ordinary CPU access on an outer page raises a guard exception; `texture_at()` returns `None`, and this handler returns `EXCEPTION_CONTINUE_SEARCH`, so the diagnostic can pass an exception it created to the rest of the process. [Microsoft describes `PAGE_GUARD` as a one-shot exception](https://learn.microsoft.com/en-us/windows/win32/memory/creating-guard-pages). Could the replacement path retain ownership for still-armed pages or disarm only the obsolete pages this diagnostic actually guarded, without clearing preexisting guards owned elsewhere? A child-process fixture with a partially overlapping placement and an access to an untouched old page would cover this lifecycle. Exact-head source review of `638f0b5b6a7c8972f063f45ad5dbb5187d044f40`; I did not enable the diagnostic or run a title. AI-assisted review with Codex.
luckyteagirl commented 2026-11-26 07:50:30 +00:00 (Migrated from github.com)

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

Review: COMMENTED


gpu_touch.rs:98–102,161: ARMED remembers only a virtual address and removes it on a guard exception (or failed protection). If an untouched page is decommitted, Windows drops its protection but XCL retains that address. After the page is recommitted and another owner sets its own PAGE_GUARD, this handler sees the stale ARMED entry and consumes the other owner's exception, contrary to the comment that preexisting guards are left alone. This is distinct from the earlier partial-overlap issue.

I added a test-only fixture at exact head 14a3b803ef5c5fc2f246304b5fa503bdcc9a2c4a: guard one committed page with XCL, MEM_DECOMMIT/recommit the same VA, verify its protection is plain PAGE_READWRITE, install a separate guard and a later VEH, then read the page. The read succeeds, but the later VEH never sees its guard exception. Focused cargo test --locked -p xcl --lib -j 1 hle::d3d12x::gpu_touch::tests::a_recommitted_page_keeps_its_new_guard_owner -- --exact --test-threads=1 --nocapture fails as expected (0 passed/1 failed, 1,337 filtered). Could the diagnostic retire ownership when a guarded allocation is decommitted/released, or validate current ownership before consuming the exception, with this address-reuse lifecycle in a regression test? This is a CPU-only modified-fixture result, not a GPU/title run. AI-assisted review with Codex.

<!-- greyfinch-sync:ivall/xcl:review:6070270310 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2695#pullrequestreview-6070270310). Originally posted by [luckyteagirl](https://github.com/luckyteagirl) on 2026-11-26T07:50:30Z. **Review:** COMMENTED --- `gpu_touch.rs:98–102,161`: `ARMED` remembers only a virtual address and removes it on a guard exception (or failed protection). If an untouched page is decommitted, Windows drops its protection but XCL retains that address. After the page is recommitted and another owner sets its own `PAGE_GUARD`, this handler sees the stale `ARMED` entry and consumes the other owner's exception, contrary to the comment that preexisting guards are left alone. This is distinct from the earlier partial-overlap issue. I added a test-only fixture at exact head `14a3b803ef5c5fc2f246304b5fa503bdcc9a2c4a`: guard one committed page with XCL, `MEM_DECOMMIT`/recommit the same VA, verify its protection is plain `PAGE_READWRITE`, install a separate guard and a later VEH, then read the page. The read succeeds, but the later VEH never sees its guard exception. Focused `cargo test --locked -p xcl --lib -j 1 hle::d3d12x::gpu_touch::tests::a_recommitted_page_keeps_its_new_guard_owner -- --exact --test-threads=1 --nocapture` fails as expected (0 passed/1 failed, 1,337 filtered). Could the diagnostic retire ownership when a guarded allocation is decommitted/released, or validate current ownership before consuming the exception, with this address-reuse lifecycle in a regression test? This is a CPU-only modified-fixture result, not a GPU/title run. AI-assisted review with Codex.
sage-sage commented 2026-11-26 08:04:35 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by sage-sage on 2026-11-26T07:05:48Z.


Test report: passes on NVIDIA. Exact head 638f0b5b (its base is current main b49be18, so head = merged).

Tested

  • RTX 4080 SUPER (driver 621.40), Ryzen 5 7600X, Windows 11 26H2 build 26300.10075, rustc 1.100.0 MSVC, DXC 1.9.2602.17 (Windows SDK 10.0.26100), debug build
  • cargo test --workspace -- --test-threads=4: 1436 passed, 0 failed, 47 ignored; the_first_cpu_access_to_a_gpu_texture_is_noted passes
  • SKIPPED (29 lines, the same as on main on this machine): 21 wave64 tests (NVIDIA is wave32 only), 3 per-lane wave32 f16/f32 forms (refused), 3 D3D12 debug layer (d3d12SDKLayers.dll not installed), 1 no heap windows, 1 pso_measurement_compiles_an_exact_synthetic_record (Developer Mode off)

Not tested

  • No game, so not XCL_GPU_TEXTURE_TOUCH on a title.

Claude Code (Claude Opus 5.5) ran the tests and wrote this report.

<!-- greyfinch-sync:ivall/xcl:comment:7185091589 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2695#issuecomment-7185091589). Originally posted by [sage-sage](https://github.com/sage-sage) on 2026-11-26T07:05:48Z. --- **Test report: passes on NVIDIA.** Exact head `638f0b5b` (its base is current `main` `b49be18`, so head = merged). **Tested** - RTX 4080 SUPER (driver 621.40), Ryzen 5 7600X, Windows 11 26H2 build 26300.10075, rustc 1.100.0 MSVC, DXC 1.9.2602.17 (Windows SDK 10.0.26100), debug build - `cargo test --workspace -- --test-threads=4`: 1436 passed, 0 failed, 47 ignored; `the_first_cpu_access_to_a_gpu_texture_is_noted` passes - SKIPPED (29 lines, the same as on `main` on this machine): 21 wave64 tests (NVIDIA is wave32 only), 3 per-lane wave32 f16/f32 forms (refused), 3 D3D12 debug layer (`d3d12SDKLayers.dll` not installed), 1 `no heap windows`, 1 `pso_measurement_compiles_an_exact_synthetic_record` (Developer Mode off) **Not tested** - No game, so not `XCL_GPU_TEXTURE_TOUCH` on a title. Claude Code (Claude Opus 5.5) ran the tests and wrote this report.
Aniseto commented 2026-11-26 08:04:37 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Aniseto on 2026-11-26T07:23:00Z.


Ran the GPU-texture CPU-access test at 14a3b80:

Environment: Windows 11 Pro build 26200 x64, NVIDIA GeForce RTX 5070 Ti (Blackwell, 32-lane waves only, 16 GB) driver 32.0.16.2124, Intel Core i5-12400F, 64 GB RAM, rustc 1.100.0 (0ef1bc386 2026-11-09) MSVC 14.44.35207, DXC 1.9.2609.5, debug build.

XCL_ADAPTER=nvidia cargo test -p xcl --lib gpu_touch -- --test-threads=1 --nocapture
1 passed; 0 failed; 0 ignored; 1336 filtered out      (exit 0)

the_first_cpu_access_to_a_gpu_texture_is_noted passes at the current head. This is a Win32 guard-page test, so it does not exercise the RTX 5070 Ti's rendering path; it exercises the CPU-access tracking on this host.

What this adds: the existing NVIDIA report in the thread is on an RTX 4080 SUPER at the earlier head 638f0b5. This is a second host (RTX 5070 Ti, driver 32.0.16.2124) at the current head 14a3b80.

Not tested: a retail title with XCL_GPU_TEXTURE_TOUCH=1, the background logger's live output, the whole workspace suite, a paired 60 s smoke run, AMD and Intel GPUs, Wine, release profile, title data.

AI-assisted (OpenCode), model: DeepSeek V4.1 Flash Free - checked out the PR's head commit in a detached worktree, built it, ran the tests, wrote this report; the worktree was not modified; no game data was used.

Update (26/11, head moved to 11ef28f): 79 new lines in gpu_touch.rs/kernelx.rs, including a second test. Re-ran the same filter at 11ef28f:

XCL_ADAPTER=nvidia cargo test -p xcl --lib gpu_touch -- --test-threads=1 --nocapture
2 passed; 0 failed; 0 ignored; 1336 filtered out      (exit 0)

Both the_first_cpu_access_to_a_gpu_texture_is_noted and a_decommitted_page_is_left_to_its_next_owner pass here. Still a Win32 guard-page test, not a GPU rendering path.

<!-- greyfinch-sync:ivall/xcl:comment:7185395661 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2695#issuecomment-7185395661). Originally posted by [Aniseto](https://github.com/Aniseto) on 2026-11-26T07:23:00Z. --- Ran the GPU-texture CPU-access test at `14a3b80`: Environment: Windows 11 Pro build 26200 x64, NVIDIA GeForce RTX 5070 Ti (Blackwell, 32-lane waves only, 16 GB) driver 32.0.16.2124, Intel Core i5-12400F, 64 GB RAM, rustc 1.100.0 (0ef1bc386 2026-11-09) MSVC 14.44.35207, DXC 1.9.2609.5, debug build. ``` XCL_ADAPTER=nvidia cargo test -p xcl --lib gpu_touch -- --test-threads=1 --nocapture 1 passed; 0 failed; 0 ignored; 1336 filtered out (exit 0) ``` `the_first_cpu_access_to_a_gpu_texture_is_noted` passes at the current head. This is a Win32 guard-page test, so it does not exercise the RTX 5070 Ti's rendering path; it exercises the CPU-access tracking on this host. What this adds: the existing NVIDIA report in the thread is on an RTX 4080 SUPER at the earlier head `638f0b5`. This is a second host (RTX 5070 Ti, driver 32.0.16.2124) at the current head `14a3b80`. Not tested: a retail title with `XCL_GPU_TEXTURE_TOUCH=1`, the background logger's live output, the whole workspace suite, a paired 60 s smoke run, AMD and Intel GPUs, Wine, release profile, title data. AI-assisted (OpenCode), model: **DeepSeek V4.1 Flash Free** - checked out the PR's head commit in a detached worktree, built it, ran the tests, wrote this report; the worktree was not modified; no game data was used. Update (26/11, head moved to `11ef28f`): 79 new lines in `gpu_touch.rs`/`kernelx.rs`, including a second test. Re-ran the same filter at `11ef28f`: ``` XCL_ADAPTER=nvidia cargo test -p xcl --lib gpu_touch -- --test-threads=1 --nocapture 2 passed; 0 failed; 0 ignored; 1336 filtered out (exit 0) ``` Both `the_first_cpu_access_to_a_gpu_texture_is_noted` and `a_decommitted_page_is_left_to_its_next_owner` pass here. Still a Win32 guard-page test, not a GPU rendering path.
joeypercia commented 2026-11-26 08:04:44 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by joeypercia on 2026-11-26T07:53:55Z.


Thanks, @luckyteagirl, that's right too. A page's guard goes when it's decommitted, but the diagnostic kept counting the page as its own. Now kernelx::VirtualFree (decommit and release; a release covers the whole allocation) and MapTitlePhysicalPages drop the pages they free or map anew from the diagnostic's list (gpu_touch::forget). That costs nothing while the list is empty, which it is unless the switch is on.

The new test a_decommitted_page_is_left_to_its_next_owner follows your fixture:

  • a guarded page is decommitted through kernelx, committed again, and guarded by another owner with a handler after this one;
  • that handler gets its guard exception;
  • the page left committed stays armed;
  • a release through kernelx disarms the rest.

Without the VirtualFree hook the test fails ("a decommitted page stays armed"). It's in 11ef28f2.

Not covered: a decommit or release of title memory that doesn't go through kernelx, such as XCL's own frees of title ranges. The title's own frees all do. (Claude Code, Claude Opus 5.5)

<!-- greyfinch-sync:ivall/xcl:comment:7185956093 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2695#issuecomment-7185956093). Originally posted by [joeypercia](https://github.com/joeypercia) on 2026-11-26T07:53:55Z. --- Thanks, @luckyteagirl, that's right too. A page's guard goes when it's decommitted, but the diagnostic kept counting the page as its own. Now `kernelx::VirtualFree` (decommit and release; a release covers the whole allocation) and `MapTitlePhysicalPages` drop the pages they free or map anew from the diagnostic's list (`gpu_touch::forget`). That costs nothing while the list is empty, which it is unless the switch is on. The new test `a_decommitted_page_is_left_to_its_next_owner` follows your fixture: - a guarded page is decommitted through kernelx, committed again, and guarded by another owner with a handler after this one; - that handler gets its guard exception; - the page left committed stays armed; - a release through kernelx disarms the rest. Without the `VirtualFree` hook the test fails ("a decommitted page stays armed"). It's in `11ef28f2`. Not covered: a decommit or release of title memory that doesn't go through `kernelx`, such as XCL's own frees of title ranges. The title's own frees all do. (Claude Code, Claude Opus 5.5)
Decodere commented 2026-11-26 15:03:42 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Decodere on 2026-11-26T14:18:16Z.


Independent RTX 4060 (8 GB) / Windows 11 release verification of PR #2695 at 11ef28f21184f165bf8246abdff89cb789b5eda1 (exact parent origin/main b49be1836844fe0b0cdb3211dce3cb7fb4e21ac7). Measurements and targeted test results only; not a full source review.

Setup

  • GPU: NVIDIA GeForce RTX 4060 (8 GB / 7956 MiB reported by D3D12), driver 32.0.16.2114 (NVIDIA 621.14, WDDM 3.2)
  • CPU / RAM / OS: Intel Core i5-11400F (6 cores / 12 threads), 32 GB RAM (31.9 GiB usable), Windows 11 Home 26200
  • Toolchain / caches: rustc 1.100.0 (0ef1bc386 2026-11-09), DXC 1.9.2609.5, release builds, warm DXIL/pipeline caches, quiet machine (zero concurrent builds/tests during timed runs)
  • Workload: Retail workload title: 29640639 via scripts/smoke.ps1 (XCL_NETWORK=0 XCL_ACTIVITY=1, no input)

Targeted Win11 / RTX 4060 release unit tests (11ef28f2)

  • cargo test --release -p xcl --lib hle::d3d12x::gpu_touch:: -- --test-threads=1 --nocapture: 2 passed, 0 failed, 0 ignored (0.02 s, 0 skipped, exit 0), covering both the_first_cpu_access_to_a_gpu_texture_is_noted and a_decommitted_page_is_left_to_its_next_owner.
  • cargo test --release -p xcl --lib hle::kernelx:: -- --test-threads=4: 42 passed, 0 failed, 1 ignored (0.51 s, scatter_timing ignored, 0 skipped, exit 0).
  • cargo test --release -p xcl --lib hle::d3d12x::device_x:: -- --test-threads=4: 14 passed, 0 failed, 0 ignored (0.25 s, 0 skipped, exit 0).

Live XCL_GPU_TEXTURE_TOUCH=1 retail sanity run (20 s, 11ef28f2)

  • With XCL_GPU_TEXTURE_TOUCH=1 enabled on retail workload title: 29640639, XCL armed PAGE_GUARD across 153 GPU-owned textures (13,344 pages guarded) and ran cleanly to exit (exit: 0x0, 277 frames shown, 0 device removals, 0 crashes):
[    5.608][ 9724][INFO ] GPU texture touch: 16 textures the GPU owns (4896 pages guarded), 0 of them touched by the CPU: 0 pages, 0 by writes
[   15.744][ 9724][INFO ] GPU texture touch: 72 textures the GPU owns (13344 pages guarded), 0 of them touched by the CPU: 0 pages, 0 by writes
[   19.745][ 9724][INFO ] GPU texture touch: 153 textures the GPU owns (13344 pages guarded), 0 of them touched by the CPU: 0 pages, 0 by writes
  • Quiet 60 s default-off retail smoke ran cleanly (exit: 0x0, 1542 frames shown, 60 60 60 steady-state presents per 2 s, 0 device removals, 0 crashes, 14001 MB peak commit vs parent b49be183's 14018 MB / 1518 frames).

Paired 60 s default-off RTX 4060 smoke (b49be183 vs 11ef28f2)

Parent origin/main (b49be183):

xcl-smoke v1
commit: b49be1836844fe0b0cdb3211dce3cb7fb4e21ac7
gpu: NVIDIA GeForce RTX 4060
title: 29640639
seconds: 60
exit: 0x0
frames shown: 1518 (PresentX 1518)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14018 MB

PR #2695 head (11ef28f2, default off):

xcl-smoke v1
commit: 11ef28f21184f165bf8246abdff89cb789b5eda1
gpu: NVIDIA GeForce RTX 4060
title: 29640639
seconds: 60
exit: 0x0
frames shown: 1542 (PresentX 1542)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14001 MB

PR #2695 head (11ef28f2, 20 s sanity check with XCL_GPU_TEXTURE_TOUCH=1):

xcl-smoke v1
commit: 11ef28f21184f165bf8246abdff89cb789b5eda1
gpu: NVIDIA GeForce RTX 4060
title: 29640639
seconds: 20
exit: 0x0
frames shown: 277 (PresentX 278)
presents per 2 s (last 3): 49 31 20
device removals: 0
crashes: 0
peak commit: 9890 MB

Limits of coverage

  • Full workspace test suite was not re-run on 11ef28f2 (only targeted gpu_touch::, kernelx::, and device_x:: release tests plus paired default-off 60 s smoke and 20 s XCL_GPU_TEXTURE_TOUCH=1 smoke).
  • During the 20 s XCL_GPU_TEXTURE_TOUCH=1 menu/intro run, the title made 0 CPU accesses to the 153 guarded GPU-owned textures (0 pages); VEH trap capture and post-decommit ARMED cleanup are covered by the_first_cpu_access_to_a_gpu_texture_is_noted and a_decommitted_page_is_left_to_its_next_owner.
  • Native Windows 11 (26200) / discrete RTX 4060 only; no Wine/Linux run on this host.

AI use

Ran the targeted release unit tests, paired quiet smokes, and log checks with assistance from Google Antigravity (Gemini 4 Neon); all test counts, verbatim log lines, and smoke blocks were taken directly from cargo test, xcl.log, and scripts/smoke.ps1 outputs.

<!-- greyfinch-sync:ivall/xcl:comment:7194596546 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2695#issuecomment-7194596546). Originally posted by [Decodere](https://github.com/Decodere) on 2026-11-26T14:18:16Z. --- **Independent RTX 4060 (8 GB) / Windows 11 release verification of PR #2695 at `11ef28f21184f165bf8246abdff89cb789b5eda1`** (exact parent `origin/main` `b49be1836844fe0b0cdb3211dce3cb7fb4e21ac7`). Measurements and targeted test results only; not a full source review. ### Setup - **GPU:** NVIDIA GeForce RTX 4060 (8 GB / `7956 MiB` reported by D3D12), driver `32.0.16.2114` (NVIDIA `621.14`, WDDM 3.2) - **CPU / RAM / OS:** Intel Core i5-11400F (6 cores / 12 threads), 32 GB RAM (`31.9 GiB` usable), Windows 11 Home `26200` - **Toolchain / caches:** `rustc 1.100.0 (0ef1bc386 2026-11-09)`, DXC `1.9.2609.5`, release builds, warm DXIL/pipeline caches, quiet machine (zero concurrent builds/tests during timed runs) - **Workload:** Retail workload `title: 29640639` via `scripts/smoke.ps1` (`XCL_NETWORK=0 XCL_ACTIVITY=1`, no input) ### Targeted Win11 / RTX 4060 release unit tests (`11ef28f2`) - `cargo test --release -p xcl --lib hle::d3d12x::gpu_touch:: -- --test-threads=1 --nocapture`: **2 passed, 0 failed, 0 ignored** (`0.02 s`, `0` skipped, exit `0`), covering both `the_first_cpu_access_to_a_gpu_texture_is_noted` and `a_decommitted_page_is_left_to_its_next_owner`. - `cargo test --release -p xcl --lib hle::kernelx:: -- --test-threads=4`: **42 passed, 0 failed, 1 ignored** (`0.51 s`, `scatter_timing` ignored, `0` skipped, exit `0`). - `cargo test --release -p xcl --lib hle::d3d12x::device_x:: -- --test-threads=4`: **14 passed, 0 failed, 0 ignored** (`0.25 s`, `0` skipped, exit `0`). ### Live `XCL_GPU_TEXTURE_TOUCH=1` retail sanity run (20 s, `11ef28f2`) - With `XCL_GPU_TEXTURE_TOUCH=1` enabled on retail workload `title: 29640639`, XCL armed `PAGE_GUARD` across `153` GPU-owned textures (`13,344` pages guarded) and ran cleanly to exit (`exit: 0x0`, `277` frames shown, `0` device removals, `0` crashes): ```text [ 5.608][ 9724][INFO ] GPU texture touch: 16 textures the GPU owns (4896 pages guarded), 0 of them touched by the CPU: 0 pages, 0 by writes [ 15.744][ 9724][INFO ] GPU texture touch: 72 textures the GPU owns (13344 pages guarded), 0 of them touched by the CPU: 0 pages, 0 by writes [ 19.745][ 9724][INFO ] GPU texture touch: 153 textures the GPU owns (13344 pages guarded), 0 of them touched by the CPU: 0 pages, 0 by writes ``` - Quiet 60 s default-off retail smoke ran cleanly (`exit: 0x0`, `1542` frames shown, `60 60 60` steady-state presents per 2 s, `0` device removals, `0` crashes, `14001 MB` peak commit vs parent `b49be183`'s `14018 MB` / `1518` frames). ### Paired 60 s default-off RTX 4060 smoke (`b49be183` vs `11ef28f2`) Parent `origin/main` (`b49be183`): ``` xcl-smoke v1 commit: b49be1836844fe0b0cdb3211dce3cb7fb4e21ac7 gpu: NVIDIA GeForce RTX 4060 title: 29640639 seconds: 60 exit: 0x0 frames shown: 1518 (PresentX 1518) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 14018 MB ``` PR #2695 head (`11ef28f2`, default off): ``` xcl-smoke v1 commit: 11ef28f21184f165bf8246abdff89cb789b5eda1 gpu: NVIDIA GeForce RTX 4060 title: 29640639 seconds: 60 exit: 0x0 frames shown: 1542 (PresentX 1542) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 14001 MB ``` PR #2695 head (`11ef28f2`, 20 s sanity check with `XCL_GPU_TEXTURE_TOUCH=1`): ``` xcl-smoke v1 commit: 11ef28f21184f165bf8246abdff89cb789b5eda1 gpu: NVIDIA GeForce RTX 4060 title: 29640639 seconds: 20 exit: 0x0 frames shown: 277 (PresentX 278) presents per 2 s (last 3): 49 31 20 device removals: 0 crashes: 0 peak commit: 9890 MB ``` ### Limits of coverage - Full workspace test suite was not re-run on `11ef28f2` (only targeted `gpu_touch::`, `kernelx::`, and `device_x::` release tests plus paired default-off 60 s smoke and 20 s `XCL_GPU_TEXTURE_TOUCH=1` smoke). - During the 20 s `XCL_GPU_TEXTURE_TOUCH=1` menu/intro run, the title made `0` CPU accesses to the `153` guarded GPU-owned textures (`0 pages`); VEH trap capture and post-decommit `ARMED` cleanup are covered by `the_first_cpu_access_to_a_gpu_texture_is_noted` and `a_decommitted_page_is_left_to_its_next_owner`. - Native Windows 11 (`26200`) / discrete RTX 4060 only; no Wine/Linux run on this host. ### AI use Ran the targeted release unit tests, paired quiet smokes, and log checks with assistance from Google Antigravity (Gemini 4 Neon); all test counts, verbatim log lines, and smoke blocks were taken directly from `cargo test`, `xcl.log`, and `scripts/smoke.ps1` outputs.
luckyteagirl commented 2026-11-27 05:25:52 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by luckyteagirl on 2026-11-27T05:25:52Z.

Review: COMMENTED


On current head 11ef28f21184f165bf8246abdff89cb789b5eda1, kernelx::VirtualFree calls gpu_touch::freed before the free is validated or succeeds. For a normal guarded allocation, VirtualFree(base, PAGE, MEM_RELEASE) must fail because Win32 requires zero size with MEM_RELEASE. freed nevertheless removes the whole allocation from ARMED; the OS leaves PAGE_GUARD in place, so the next access produces a guard exception this handler no longer recognizes and forwards. A separate native Win32 probe confirmed the failed call returns error 87 while the page remains committed and guarded. Could the hook retain diagnostic ownership on a failed free, and add a rejected-release case before the successful release in the new lifecycle fixture? The range may need capturing before a successful release, while it remains queryable. This is exact-head source/API review plus a native probe; I did not run an XCL title.

AI use: Two OpenAI Codex GPT-6.2 Sol agents independently traced the failure and handler paths; OpenAI Codex (GPT-6.2 Astra) checked the Win32 contract and wrote this review.

<!-- greyfinch-sync:ivall/xcl:review:6083850759 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2695#pullrequestreview-6083850759). Originally posted by [luckyteagirl](https://github.com/luckyteagirl) on 2026-11-27T05:25:52Z. **Review:** COMMENTED --- On current head `11ef28f21184f165bf8246abdff89cb789b5eda1`, `kernelx::VirtualFree` calls `gpu_touch::freed` **before** the free is validated or succeeds. For a normal guarded allocation, `VirtualFree(base, PAGE, MEM_RELEASE)` must fail because [Win32 requires zero size with `MEM_RELEASE`](https://learn.microsoft.com/en-us/windows/win32/api/memoryapi/nf-memoryapi-virtualfree). `freed` nevertheless removes the whole allocation from `ARMED`; the OS leaves `PAGE_GUARD` in place, so the next access produces a guard exception this handler no longer recognizes and forwards. A separate native Win32 probe confirmed the failed call returns error 87 while the page remains committed and guarded. Could the hook retain diagnostic ownership on a failed free, and add a rejected-release case before the successful release in the new lifecycle fixture? The range may need capturing before a successful release, while it remains queryable. This is exact-head source/API review plus a native probe; I did not run an XCL title. AI use: Two OpenAI Codex GPT-6.2 Sol agents independently traced the failure and handler paths; OpenAI Codex (GPT-6.2 Astra) checked the Win32 contract and wrote this review.
joeypercia commented 2026-11-28 21:03:46 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by joeypercia on 2026-11-28T21:03:46Z.


Closing: this is a diagnostic only, and @luckyteagirl's review found three lifecycle bugs in it (partial overlaps, recommitted pages, a rejected VirtualFree) that can let it leave behind or swallow guard exceptions it did not create. Fixing them is not worth it for a diagnostic; thanks for the careful review and the fixtures.

<!-- greyfinch-sync:ivall/xcl:comment:7245743841 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2695#issuecomment-7245743841). Originally posted by [joeypercia](https://github.com/joeypercia) on 2026-11-28T21:03:46Z. --- Closing: this is a diagnostic only, and @luckyteagirl's review found three lifecycle bugs in it (partial overlaps, recommitted pages, a rejected VirtualFree) that can let it leave behind or swallow guard exceptions it did not create. Fixing them is not worth it for a diagnostic; thanks for the careful review and the fixtures.

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!2685
No description provided.