Skip to content

D3D12.X: a memory window with no GPU buffer gives no GPU address - #3658

Open
Prime1997 wants to merge 1 commit into
xcl-dev:mainfrom
Prime1997:contrib/up-window-without-buffer
Open

Prime1997 wants to merge 1 commit into
xcl-dev:mainfrom
Prime1997:contrib/up-window-without-buffer

Conversation

@Prime1997

@Prime1997 Prime1997 commented Dec 2, 2026 •

Copy link
Copy Markdown
Collaborator

Requested by Prime

On an RTX 3060 Ti, open-world runs of a game title lost the device (0x887a0005) after 3 to 5.5 minutes in about half of them. With XCL_DRED both faults were GPU page faults at address 0x0, which DRED placed at "window 10 + 0x0": the memory window table had an entry whose buffer address was 0, so uma_va_of of an address in that window returned the offset alone as the GPU address, and uma_window_buffer(_gpu) a null buffer. uma_window_va now returns None for such a window, and the buffer lookups return none for a null buffer. Callers then fall back (most bind window 0's address instead) or skip, rather than handing the GPU address 0.

Related: #3052 guards the two-pass stage's window view against the same null window. This change fixes the lookup itself, so it also covers that site.

What is in it

  • crates/xcl/src/hle/d3d12x/real.rs: uma_window_va filters a 0 buffer address; uma_window_buffer / uma_window_buffer_gpu return none for a null buffer.

Tested

  • RTX 3060 Ti 8 GB, Windows 11, release build: the change has been in our test builds since 1 Dec (no measured before/after on its own).
  • This branch (on main 1c8b551): cargo check -p xcl --lib --tests --target x86_64-pc-windows-gnu passes. The test suite was not run on this exact branch.

Regression run

  • Not run yet: testers welcome.

Not tested

  • The suite and scripts/smoke.ps1 on this branch; AMD.
  • No unit test: it needs a window table with a null buffer, which the UMA setup does not create on purpose.

AI use

  • Claude Code wrote the change and this description.

🤖 Generated with Claude Code

@Prime1997 Prime1997 self-assigned this Dec 2, 2026
@github-actions github-actions Bot added area:d3d12 D3D12.X runtime, command lists, resources, sparse memory gpu:nvidia Code is specific to NVIDIA / wave32 GPUs (scope tag; see needs:nvidia-test) labels Dec 2, 2026
@Prime1997
Prime1997 force-pushed the contrib/up-window-without-buffer branch from 55e89dc to 9552842 Compare December 2, 2026 04:58
World runs of a game title on an RTX 3060 Ti lost the device (0x887a0005) after 3 to 5.5
minutes in about half of them. With XCL_DRED both faults were GPU page faults at
address 0x0, which DRED placed at "window 10 + 0x0": the window table had an entry
whose buffer address was 0, so uma_va_of of an address in that window gave its
offset alone as the GPU address, and uma_window_buffer(_gpu) a null buffer.
uma_window_va now gives None for such a window and the buffer lookups none for a
null buffer, so callers fall back (most bind window 0's address in its place) or
skip instead of handing the GPU address 0. This also covers the two-pass stage's
window view that xcl-dev#3052 guards.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Foniass

Foniass commented Dec 2, 2026

Copy link
Copy Markdown
Collaborator

Review (head 7d656c9, diff read, not a merge-check; checks red):

  • The lookups changed here never reach "window 10", so this cannot be the fix for that fault. log_device_removed (real.rs ~12489) labels a fault address with the first entry of uma_window_vas() within 4 GiB below it. A fault at 0x0 therefore matches the first window whose address is 0. In the 16-window layout with one coherent window (sparse 0-2, coherent 3, views 4-9), windows 10-15 are WindowKind::None and stay (0, 0) by construction (real.rs ~710). Uma::window gives them length 0 (uma.rs ~738), so window_of never returns them (uma.rs ~775), and uma_va_of, uma_window_buffer_gpu and pc_va_in never look them up. The only callers that pass an index ask for windows 0-3 (bind.rs ~3108, ~5317). The label "window 10" also shows that windows 0-9 all had addresses, so nothing this PR filters was 0 in that run. By reading, the PR changes nothing on the reported path. The same DRED fault is the evidence for D3D12.X: a vertex or index buffer view at address 0 is a null view #3657 (vertex or index buffer views at address 0), which fits it better.
  • Binds on XCL's ABI now fail when window 0 has no buffer and memory is not shadowed. first_window(uma_window_va(0), ..) (bind.rs ~3083, ~5291) now receives None instead of Some(0). When sparse::init could not make the reserved buffers (sparse.rs ~3408), every bind_abi and every two-pass stage is now refused with "unified memory is not open on the GPU", and the draw or dispatch is skipped (bind.rs ~3837). Main kept drawing in that case on purpose: binds_refuse_shadowed_memory_without_window_0 (bind.rs ~7964) says "unshadowed memory with none keeps going as before". That test still passes only because it calls first_window directly. The first == 0 && shadowed branch is now dead, and the shadowed case gets the wrong error message.
  • pc_va sends the title's CPU address to the GPU for a window with no buffer. In pc_va_in (list_x.rs ~5745), a non-view window whose lookup now gives None takes the None => va arm. That passes the raw title address on as a GPU address, which the comment above it says hangs the device. Main sent the offset alone instead. Neither of these is a null view.
  • No test. pc_va_in and first_window already take the window address as a parameter. A test that feeds them a window without a buffer would have shown the two behaviour changes above. The description says no window table with a null buffer exists "on purpose", which agrees with the first point.
  • PR description check is red. It refuses the PR because it has no xcl-smoke block for the head commit and none for main. The description also says the test suite was not run on this branch.

Fine: every caller handles the new None without unwrapping it. The only unwrap is in a GPU test (gpu/recomp/tests.rs ~5527). bind.rs ~5317 and list_x.rs ~5232 already filtered 0 on main, and uma_window_buffer has no callers. This PR overlaps the open #3052 at the two-pass site.

AI review: Claude Code (Claude Opus 5.5), posted by Foniass without a human check of each point.

@Foniass

Foniass commented Dec 2, 2026

Copy link
Copy Markdown
Collaborator

Test report (not a merge-check: PR description red)
base: 1c8b551
head: 7d656c9
merge: clean
build: cargo build --workspace -> ok
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 2909 passed, 0 failed, 51 ignored; SKIPPED: 28 (20 no wave64, 2 no d3d12SDKLayers.dll, 1 no D3D12 debug layer, 1 no heap windows, 1 cannot disable the driver cache, 3 others; the same set as on main); failing: none
review: read by one reviewer at this same head; the review is at #3658 (comment) and its findings stand. Most serious: the changed lookups never reach the empty "window 10", so it can't fix the fault it cites, and binds now fail when window 0 has no buffer.
performance: 60 s smoke of a retail title, main 1c8b551 vs this merge (7d656c9): 1652 -> 1675 frames shown (101 %; last presents per 2 s: 60 60 60), peak commit 18228 -> 17821 MB, 0 device removals, 0 crashes.
assessment: merges, builds and passes the whole suite on current main, and the smoke run is clean; the blocking point is in the review: the changed lookups never reach the empty "window 10", so it can't fix the fault it cites, and binds now fail when window 0 has no buffer
hardware / tool and model: RTX 5070 Ti (driver 621.14), Ryzen 7 7800X3D, Windows 11 26300 / Claude Code with Claude Opus 5.5

AI-written and posted by Foniass without a human check of each point.

@bmjask bmjask left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review of 7d656c9a: 3 finding(s) (2 high, 1 medium), most severe first.

  1. High crates/xcl/src/hle/d3d12x/bind.rs:5305: see below.
  2. High crates/xcl/src/hle/d3d12x/bind.rs:5076: see below.
  3. Medium crates/xcl/src/hle/d3d12x/list_x.rs:5751: see below.

On lines outside the diff:

  1. High crates/xcl/src/hle/d3d12x/bind.rs:5305: va = |p| uma_va_of(p).unwrap_or(first) silently binds window 0's base as the io and res blocks now that uma_va_of returns None for a window with no buffer. The same pattern is at bind.rs:3099 and console_list.rs:884. So the shader reads and writes the wrong memory instead of the bind failing. If the arena puts io_at or res_at in a window with no buffer, the GPU address used to be the bare offset (a fault). Now views[0] and views[1] are window 0's base: the shader reads window 0's first bytes as its io block (table address, limits, loop budget) and writes its results there, corrupting title memory, and may loop or read out of bounds. A None for io_at/res_at should return Err.

  2. High crates/xcl/src/hle/d3d12x/bind.rs:5076: uma_window_va(0) now returns None instead of Some(0), so first_window refuses unshadowed memory whose window 0 has no buffer, the case its test documents as 'keeps going as before'. With bufs[0] = (0,0) and memory unshadowed, bind_abi and prepare_two_pass_stage used to go on with first = 0. Now every bind on XCL's ABI fails with "unified memory is not open on the GPU" and every draw and dispatch on that path is dropped. The 'no buffer in window 0' message is never logged, and binds_refuse_shadowed_memory_without_window_0 still passes while testing an input (Some(0)) that can no longer occur.

  3. Medium crates/xcl/src/hle/d3d12x/list_x.rs:5751: pc_va_in still hands the GPU an invalid address for a window that isn't a GPU view and has no buffer: None => va returns the raw console address (before the PR it returned the offset alone). If sparse::init failed for a sparse or VRAM window (bufs[k] stays (0,0), not is_view_window), IASetIndexBuffer/IASetVertexBuffers at a title address in it get pc_va = va. gpu_va then sees u.contains(va) and returns it, so a console address is bound as a PC GPU address, giving the page fault or device removal this PR targets. Returning 0 (null view) there, as the view-window branch does, would fix it.


These findings come from an AI-assisted review (Claude Code) and focus on correctness. Each is a candidate; please check it before acting on it.

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

Labels

area:d3d12 D3D12.X runtime, command lists, resources, sparse memory gpu:nvidia Code is specific to NVIDIA / wave32 GPUs (scope tag; see needs:nvidia-test)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants