Skip to content

D3D12.X: the list's ClearUnorderedAccessViewUint / Float get the PC's handles of the view - #2329

Open
imnicho wants to merge 1 commit into
xcl-dev:mainfrom
imnicho:clear-uav-handles
Open

imnicho wants to merge 1 commit into
xcl-dev:mainfrom
imnicho:clear-uav-handles

Conversation

@imnicho

@imnicho imnicho commented Nov 25, 2026

Copy link
Copy Markdown
Contributor

A title's ClearUnorderedAccessViewUint / Float (list #53 / #54) went to the PC with the two handles as the title gave them. Those are addresses of slots in a console view heap (console_heap), which the PC took for descriptor handles: a retail title's first such clear in its world hung the GPU. Now the list translates them, as the older console list (console_list) already does. Part of #675.

What is in it

  • crates/xcl/src/hle/d3d12x/list_x.rs: clear_uav_uint_x / clear_uav_float_x for XAsync: cancellation is the provider's to do #53 / Task queues: terminating cancels delayed callbacks before the termination callback #54. clear_uav_handles looks the two handles up as console slots and gives the PC the UAV's GPU handle (in the title's own shader-visible heap, or in the shared heap when the view heap is hosted there - then ensure_view_heap binds it if the title named no heap) and the UAV's CPU handle in the title's own PC heap. Handles that are no console slots go on as they are. A slot with no shader-visible UAV (a heap that is not shader visible, a sampler slot, a slot paired with a PC handle) is not cleared, with a warning for the first four. The rectangles go on unchanged.
  • crates/xcl/src/hle/d3d12x/real.rs: the two entries in the command list's slots.
  • Tests: the_command_list_hooks_clear_unordered_access_view (the two slots are XCL's - it fails without the entries); clear_uav_handles_are_those_of_the_pc_heap_behind_the_slots (the handles of a slot, of two slots, PC handles, a heap that is not shader visible, samplers); clear_unordered_access_view_takes_the_slots_of_a_console_heap on the GPU (an R32_UINT and an R32_FLOAT texture with their UAVs in a console heap's slots, both clears with the slots' addresses, the textures read back).
  • 220 lines added, none changed; 169 of them are the tests.

Tested

run this change the device is lost counted from 4 s after the world's set-up the driver's "stopped responding"
1 no 18 s after the set-up 1 frame, 5 124 draws yes
2 no 19 s 0 frames, 4 140 draws yes
3 no 14 s 0 frames, 0 draws yes
4 (XCL_GPU_PROFILE=1 XCL_DRED=1) no 51 s 733 frames, 6 896 draws yes
5 (the same) no 14 s 0 frames, 0 draws yes
6 yes 38 s 45 frames, 105 532 draws no
7 yes 28 s 35 frames, 87 664 draws no
8 yes 160 s 6 frames, 23 039 draws yes, 147 s into the world
  • Without the change XCL_DRED=1 names the same place in two runs: a list of 139 operations with 45 done, the next one ClearUnorderedAccessView (the first clear of the list; before it 17 barriers, 10 WriteBufferImmediate, 5 ResolveQueryData, 3 Dispatch, 3 ExecuteIndirect, 2 draws, 2 buffer copies and 2 texture copies), and the system log has the driver's "stopped responding" (event 4101) for each of the five runs.
  • With it the title makes two clears there, of a 20 MB buffer and of an 80x45 R32_FLOAT texture, each with a GPU handle and a CPU handle from two console heaps, and goes on (three runs of three).
  • The device is still lost in every run, later and in other ways: in runs 6 and 7 without a hang (no event in the system log, no GPU wait timed out, XCL_DRED=1 names no list; local video memory 13.7 - 13.9 GB of a 15.0 GB budget), in run 8 with one that starts 10 s after a compute pipeline of 1.0 MB of DXIL came out of the driver (70 s in it), which is not this change's subject.

Regression run

main:

xcl-smoke v1
commit: 06c9f5505f63f10c5ec49ef932d75b2c28177324
gpu: NVIDIA GeForce RTX 5080
title: 21222967
seconds: 60
exit: 0x0
frames shown: 1255 (PresentX 1256)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14084 MB

PR (this PR's head commit):

xcl-smoke v1
commit: 9606785c5e7bd97c5a2c01fd9e1462dd2f90da3b
gpu: NVIDIA GeForce RTX 5080
title: 21222967
seconds: 60
exit: 0x0
frames shown: 1338 (PresentX 1338)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14071 MB

A second round of the same two binaries: main 1169 frames, PR 1154. These 60 s end in the title's menus, before its first ClearUnorderedAccessView: the pair shows nothing else changed, not the fix.

Not tested

  • The title on this head itself: the runs are on the local tree named, with the same hooks (there with a log line for the first calls, and ensure_view_heap called for every translated clear, not only for a view in the shared heap).
  • A clear with rectangles (the title passes none) and a clear whose slots are not in the shared heap, in a title (the GPU test has that case; in the title's runs the view heap is in the shared heap).
  • AMD and Intel GPUs, native 64-lane waves, Linux / Wine; other titles.

AI use

  • Claude Code with Claude Fable 5.2: found the cause from the device-removal trace, wrote the change and its tests, ran the suite and the title runs on the machine named, and wrote this description.

🤖 Generated with Claude Code

… handles of the view

The two calls (list xcl-dev#53 / xcl-dev#54) went to the PC with the handles as the title gave
them. Those are addresses of slots in a console view heap, which the PC took
for descriptor handles: a retail title's first such clear in its world hung the
GPU (the driver stopped responding; the device-removal trace names a list of
139 operations with 45 done and the clear next).

The list now looks the two handles up as console slots and gives the PC the
UAV's GPU handle in the heap that is bound and its CPU handle, as the older
console list already does. Handles that are no console slots go on as they are.

Part of xcl-dev#675.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@thehollowedone

thehollowedone commented Nov 25, 2026 •

Copy link
Copy Markdown

Independent Windows check of 9606785. Windows 11 build 26300, Ryzen 7 9800X3D, RTX 3080 Ti / 621.35, Rust 1.99.1 MSVC and DXC 1.8.2502.11.

The clean head passed cargo build --offline --locked --workspace -j 6. cargo test --offline --locked --workspace --no-fail-fast -j 6 -- --test-threads=4 --nocapture finished with 1,268 passed, 0 failed, 46 ignored, including 26 runtime skips. The stock console-slot GPU clear test passed.

I also extended the fixture, without changing runtime code, to use separate shader-visible GPU and non-shader-visible CPU heaps as required by D3D12’s clear API. For both R32_UINT and R32_FLOAT, readback confirmed 288 texels updated and 3,808 retained their original values. Both standard and GPU-based validation passed with zero skipped tests, debug-layer warnings or errors, and a healthy device. The focused command was cargo test --offline --locked -p xcl --lib -j 6 clear_unordered_access_view_takes_the_slots_of_a_console_heap -- --test-threads=1 --nocapture.

I also ran a separate shared-heap case for D80 on the same head. With heap windows enabled and no descriptor heap initially bound, the console clear bound the shared heap and filled all 4,096 texels in each of the R32_UINT and R32_FLOAT textures with the expected value. The focused test passed with zero skips or D3D12 debug-layer warnings or errors. The device remained healthy.

Synthetic inputs only. No retail world-load run on this machine.

AI-assisted. Codex (GPT-6, exact variant unavailable) extended the temporary fixture, ran the tests and drafted this report.

@SlopTart

Copy link
Copy Markdown

Wine/vkd3d-proton lane: verified, clean.

Tested: head 9606785c merged onto current origin/main (auto-merge, clean), Linux (Arch, kernel 7.2.15), Mesa 26.2.5 RADV, Radeon RX 7900 XT (NAVI31), cargo target x86_64-pc-windows-gnu run under wine-11.0 (Proton), rustc 1.94.0, vkd3d-proton 3.1 with the XCL patch, official MS DXC (binaries 2026-09-29).

The handle-translation fix itself is on the console-list clear path, which the data-free suite lane cannot exercise; it only shows that nothing else breaks with it in.

Not tested: the retail-title clear path that hangs without this fix (no title data on this lane, counts only).

AI use: Hermes agent (local Qwen-class) ran both machines and drafted this; I checked it before posting.

@nnonno91

Copy link
Copy Markdown

Independent Radeon iGPU and RTX 5090 readback through the title-facing slots on 9606785c5e7bd97c5a2c01fd9e1462dd2f90da3b.

Tested

  • Windows 11 25H2 build 26200.9974, Ryzen 7 9800X3D, Rust 1.100.0 MSVC, unoptimized profile. AMD Radeon(TM) Graphics driver 32.0.21042.62 and RTX 5090 driver 32.0.16.1742.
  • On the unchanged head, cargo test --locked -p xcl --lib <filter> -- --nocapture --test-threads=1 with filters clear_uav_handles_are_those and the_command_list_hooks_clear gave 1 passed, 0 failed each.
  • For the GPU readback I temporarily adapted clear_unordered_access_view_takes_the_slots_of_a_console_heap to select and print the named adapter, and call XAsync: cancellation is the provider's to do #53/Task queues: terminating cancels delayed callbacks before the termination callback #54 through the wrapped list from a registered synthetic title caller. A first attempt from the unregistered test harness took the PC call path, so I registered the caller as in the existing title-list layout test before collecting the results below.
  • With the same Cargo command and the GPU fixture filter, both XCL_ADAPTER=AMD Radeon and XCL_ADAPTER=NVIDIA GeForce RTX 5090 gave 1 passed, 0 failed. Both title slots returned and all 4,096 texels of each R32_UINT and R32_FLOAT texture matched the respective clear value on both GPUs. No ignores or skips in the reported passing runs. The temporary changes were restored.

Not tested

The parent, a retail title, the shared-heap GPU path, and the full workspace suite.

AI use

OpenAI Codex (GPT-6.2 Sol) adapted the test fixture, ran the checks and wrote this report.

@luckyteagirl

Copy link
Copy Markdown
Contributor

Independent RX 6800M check of exact PR head 9606785c5e7bd97c5a2c01fd9e1462dd2f90da3b.

Environment: Windows 11 build 26200; Ryzen 9 5980HX; discrete AMD Radeon RX 6800M driver 30.0.13002.13003 alongside integrated Radeon graphics; Rust 1.99.0 MSVC; DXC/DXIL 1.9.2609.5. Isolated debug Cargo target.

Clean-head tests: The command-list hook and GPU clear_unordered_access_view tests passed 2/0/0, and clear_uav_handles_are_those_of_the_pc_heap_behind_the_slots passed 1/0/0, with no skips. The checked-in GPU fixture creates the default D3D12 device without printing its adapter, so its clean-head pass alone is not attributable to the RX 6800M.

Selected-RX GPU readback: I changed only the GPU fixture's device selection locally to use gpu::adapter::Selector::from_env_or("auto") and candidates, then ran clear_unordered_access_view_takes_the_slots_of_a_console_heap with XCL_ADAPTER=6800M. It printed ClearUnorderedAccessView test adapter: AMD Radeon RX 6800M and passed 1/0/0, no skip. The fixture clears R32_UINT and R32_FLOAT UAV textures through console-heap slot addresses and checks the resulting GPU values. I removed the selector edit and verified the exact-head worktree is clean.

Limits: Focused synthetic tests only. I did not run the full workspace suite, a paired owned-title smoke, or the retail world's first clear on this head. A separate title smoke attempt for another PR had stopped under the available-commit memory guard. This check does not establish that later device loss in the author's title runs is resolved.

AI use: OpenAI Codex (GPT-6; exact variant unavailable in this session) ran the Windows tests, made and restored the test-only selector, and drafted this report. No game data was used.

@throny

throny commented Nov 25, 2026

Copy link
Copy Markdown
Collaborator

Two contributors checked independently and found that #1291 solves the same problem (for #675) in a different way: #1607, group D80. You may want to compare them with the other author and agree on one, or say in the PR why both are needed.

This is a hint from the community triage in #1607, not a maintainer decision.

AI use: Claude Code (Claude Opus 5.5), posted by a script from the #1607 table.

@throny throny added the goal:world-load Bears on the retail title getting past world loading label Nov 25, 2026
gustavsi added a commit to gustavsi/xcl that referenced this pull request Nov 25, 2026
…#2296, xcl-dev#2297, xcl-dev#2320, xcl-dev#2323, xcl-dev#2329, xcl-dev#2333

Integrates shader heap-base addresses (xcl-dev#1803), fenced superseded texture unmaps (xcl-dev#2270), cross-queue VRAM heap reclamation fencing (xcl-dev#2275, using create_raw_fence under Wine), PcCall frame clamping and orphan PSO drop (xcl-dev#2296), PSO pointer guards (xcl-dev#2297), KickoffX idle spare list switching (xcl-dev#2320, preserving UnadoptGuard), console-list descriptor heap binding (xcl-dev#2323), ClearUnorderedAccessView PC handles (xcl-dev#2329), and dispatch_chain PSO retention (xcl-dev#2333).
gustavsi added a commit to gustavsi/xcl that referenced this pull request Nov 25, 2026
@bmjask

bmjask commented Nov 25, 2026

Copy link
Copy Markdown
Contributor

High — The clear can pass D3D12 a CPU descriptor from a shader-visible heap. clear_uav_handles checks the GPU slot’s visibility, then forwards c.pc_uav from the CPU slot’s backing heap without checking that heap’s visibility. The committed GPU test exercises exactly this case by passing the same slot from one shader-visible heap as both arguments. D3D12 explicitly requires the CPU descriptor to live in a non-shader-visible heap. A reviewer’s temporary two-heap test passed with validation enabled, which supports the normal two-heap path. Before merge, use a CPU-only descriptor for any supported same-slot clear and commit the two-heap regression test. Implementation and fixture · D3D12 handle requirements

Medium — The committed GPU test bypasses the shared-heap branch used by the game. It binds a private heap and calls clear_uav_uint_x and clear_uav_float_x directly. A separate test checks the slot numbers. An independent reviewer successfully exercised the title-facing slots on AMD and NVIDIA, but explicitly excluded the shared heap. The retail runs used a modified tree that called ensure_view_heap unconditionally. I’d add one readback test that calls slots 53 and 54 through the wrapped list, uses a shared GPU heap and a separate CPU heap, and starts with no explicitly bound view heap. That would catch a regression where the handle arithmetic is correct but the command list lacks the heap containing the descriptor.

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

Labels

goal:world-load Bears on the retail title getting past world loading

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants