Repository navigation
D3D12.X: XCL_GPU_TEXTURE_TOUCH logs CPU accesses to textures the GPU owns - #2695
joeypercia wants to merge 1 commit into
Conversation
luckyteagirl
left a comment
There was a problem hiding this comment.
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.
638f0b5 to
14a3b80
Compare
|
Test report: passes on NVIDIA. Exact head Tested
Not tested
Claude Code (Claude Opus 5.5) ran the tests and wrote this report. |
|
Ran the GPU-texture CPU-access test at 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.
What this adds: the existing NVIDIA report in the thread is on an RTX 4080 SUPER at the earlier head Not tested: a retail title with 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 Both |
luckyteagirl
left a comment
There was a problem hiding this comment.
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.
…owns Render targets, depth buffers and UAV textures live in video memory on the PC, and nothing copies them to or from the title's memory. A title that reads one on the CPU reads stale bytes (xcl-dev#2663). This finds which textures that is: their committed pages get PAGE_GUARD when they are placed, a lazily committed page is noted when it is first touched, and each texture's first access is logged with the title's code address. Part of xcl-dev#2663. Assisted-by: Claude Code (Claude Opus 5.5)
|
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 The new test
Without the Not covered: a decommit or release of title memory that doesn't go through |
14a3b80 to
11ef28f
Compare
|
Independent RTX 4060 (8 GB) / Windows 11 release verification of PR #2695 at Setup
Targeted Win11 / RTX 4060 release unit tests (
|
luckyteagirl
left a comment
There was a problem hiding this comment.
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.
XCL_GPU_TEXTURE_TOUCH=1logs 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, whichvram::placeputs 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:PAGE_GUARD. A vectored handler notes the first access to each page, which the OS has already unguarded, and lets the access go on.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: thevram::placepath callsgpu_touch::placedwith the console size and description.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) andMapTitlePhysicalPagesdrop 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).the_first_cpu_access_to_a_gpu_texture_is_noted:0x80000001.a_decommitted_page_is_left_to_its_next_owner:kernelx::VirtualFree, committed again, and guarded by another owner with a handler after this one;Without the
VirtualFreehook it fails ("a decommitted page stays armed").Tested
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, thencargo test --workspace --no-fail-fast -- --test-threads=4on11ef28f2:gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_1, which fails the same way onmainon this iGPU (DXIL fuzz tests: fuzz_validate_and_gpu_1 fails on AMD (seed 722 and others, RDNA2-4), so the default suite is red there #2115).... ok), not skipped.nvidia-devc044dc6d, 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 (NVIDIA: the device is removed when the pipelines in use need more than 512 MB of shader code (0x887a0005) #2403). The removal came at the same time as in the runs before it without the switch (122–168 s). Details are on D3D12.X: textures the GPU writes never reach title memory; a title reading them on the CPU gets stale data #2663.Regression run
RTX 4070 Ti (driver 621.40), release builds, 60 s each,
scripts/smoke.ps1 -Game <folder> -Title retail-titleon 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.mainb49be183(this PR's base) and this PR's head (no uncommitted changes):main:
PR:
Not tested
STATUS_GUARD_PAGE_VIOLATIONinstead 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.kernelx(such as XCL's own frees of title ranges): its pages stay in the set until touched.AI use