D3D12.X: use null PC buffer UAV for shifted UMA buffers #3297
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/3297"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from ivall/xcl. Originally posted by Kalmarv on 2026-11-29T06:23:00Z.
When a console buffer was placed at a 64 KiB-aligned UMA backing address below its console address (
buffer_delta(res) != 0),dev_create_srv_xalready substituted a null PC buffer SRV (buf_delta_null) because PC D3D12FirstElementcannot express the sub-buffer byte delta, whilebuffer_viewwrote the exact UMA V# into the console descriptor slot.dev_create_uav_xdid not have the matchingbuf_delta_nullguard:buffer_delta != 0buffer (or counter buffer) toCreateUnorderedAccessViewon PC created a PC UAV referencing the shifted PC resource (at the wrong element offset, or failing PC validation when the buffer size + delta did not align withStructureByteStride/NumElements), and published the non-zero resource pointer into the console slot.null_uav_descfell through forD3D12_UAV_DIMENSION_BUFFER(1) toD3D12_UAV_DIMENSION_TEXTURE2D, which did not preserve buffer dimension for null buffer UAVs.What is in it
crates/xcl/src/hle/d3d12x/real.rs:D3D12_UAV_DIMENSION_BUFFER(1) arm tonull_uav_descreturning a valid null buffer UAV descriptor (DXGI_FORMAT_R32_UINT,D3D12_UAV_DIMENSION_BUFFER).dev_create_srv_x'sbuf_delta_nullhandling indev_create_uav_xwhenViewDimension == D3D12_UAV_DIMENSION_BUFFERand eitherresorcounterhasbuffer_delta(...) != 0: create a valid null PC buffer UAV inslot.pc_uavand publish0(whilebuffer_viewcontinues to write the exact UMA V# into the console descriptor slot).uav_buffer_delta_tests(null_uav_desc_preserves_buffer_dimensionanddev_create_uav_x_buffer_delta_uses_null_pc_uav_and_writes_uma_vsharp).Tested
32.0.16.1074),rustc 1.99.0 (b940084d7 2026-09-28), DXC 1.9 (1.9.2609).null_uav_descreturnedTEXTURE2D;dev_create_uav_xpublished the non-zero PC resource pointer instead of0).cargo test -p xcl --lib -- hle::d3d12x::real::uav_buffer_delta_tests::): 2 passed, 0 failed (0.17s, D3D12 debug layer enabled, 0 debug-layer errors, exact UMA V# verified).cargo test --workspace -j 2 -- --test-threads=4 --skip test_title_runs_and_game_folder_is_untouched --skip uma_driver::tests::withXCL_DXC_DIRset to DXC 1.9): 2601 passed, 0 failed, 49 ignored, 9 filtered (160.8s).SKIPPEDlines in workspace run (26 total): 21no wave64(RTX 5070 Ti is wave32), 3 wave32 per-lane#1426(V_MUL_F16,V_PK_MUL_F16,V_CVT_F16_F32), 2no heap windows(defaultXCL_HEAP_WINDOWSoff).cargo build --release -p xcl -j 4) succeeded and passed the paired 150 s title smoke below.Regression run
main (
f0e8fdd5c3942ddd399d5ee11384c8595c5aacff):PR (
5cd9be1c178887bc370f589c57b21eb7918860e5):Not tested
uma_driver::tests::andtest_title_runs_and_game_folder_is_untouched(filtered out of the workspace test run).ClearUnorderedAccessViewUint/ClearUnorderedAccessViewFloaton a buffer with a non-zerobuffer_delta(tracked separately from view creation).AI use
Imported from ivall/xcl. Originally posted by andrewDoing on 2026-11-29T06:41:10Z.
Verified the translated guest buffer-store path on
5cd9be1cwith an RTX 5070 (driver 616.92). In two fresh processes, the 64 lane-specific DWORDs landed at their expected addresses and all 960 surrounding or interleaved canary DWORDs kept their original address-tagged values. Both runs passed with the D3D12 debug layer enabled, once at defaults and once withXCL_DIRECT_DXIL=1.The fixture allocated a 64 KiB-aligned block of committed coherent UMA and used the production
place_at_title_addresshelper to place a 2 KiB guest buffer 256 bytes into it. The recorded delta was 256. Guestdev_create_uav_xcreated a structured view with first element 1, stride 24 and 64 records; the PC UAV resource name was zero. The test fed the guest slot's four actual V# words into a translated indexedBUFFER_STORE_DWORDand checked the first 4 KiB after fence completion. Lane i wrote at aligned block + 256 + 24 + 24*i. This checks both the placement delta and the first-element offset, including untouched bytes before the guest buffer and between records.The dispatch used the shader test runner with the coherent window bound and the fixture supplying the four SGPRs. Guest descriptor-table loading, shifted counter resources, and the native Uint/Float clear entry points remain separate coverage questions.
AI disclosure: OpenAI Codex built and ran the fixture and drafted this report.
Imported from ivall/xcl. Originally posted by Foniass on 2026-11-29T14:58:50Z.
Review (head
5cd9be1c, diff read, not a merge-check):ClearUnorderedAccessView. With this PR that clear goes to the PC with the slot's null view and the title's real resource (list_x::clear_uav→uav_clear_resourcepassesresthrough), which is an undefined clear. Before, it landeddeltabytes low.Width = delta + bytes. The new test fails before the fix only because it builds a layout that cannot happen there.Suggested verdict: not yet.
(Review written with Claude Code, Claude Opus 5.5; both points were traced in the code.)
Imported from ivall/xcl. Originally posted by bmjask on 2026-12-01T21:42:13Z.
Code review location:
crates/xcl/src/hle/d3d12x/real.rs; line 3724Once a shifted buffer's slot gets the null PC UAV,
ClearUnorderedAccessViewUint/Floatinlist_x::clear_uav, and the CLEAR_UAV_MARKER replay in console_list.rs (~967), still pass that null descriptor to the PC together with the real resource. Clearing a UAV of a buffer placed atva & 0xFFFF != 0(common for counters and indirect args) now sends a descriptor that doesn't match pResource. The debug layer reports an error, the buffer isn't zeroed, or a strict driver removes the device. Before this PR the clear went through a real view. These clears are listed under Not tested.Imported from ivall/xcl. Originally posted by bmjask on 2026-12-01T21:42:13Z.
Review: COMMENTED
Review of
5cd9be1c: 2 finding(s). 1 are inline. These are on lines outside the diff:crates/xcl/src/hle/d3d12x/real.rs:3730:buf_delta_nullalso applies whencpuisn't a console heap slot (thereturn pc_uav(cpu)path), so a plain PC descriptor becomes null and no UMA V# is written anywhere to fall back on.dev_create_srv_xreturnsf(this, res, desc, cpu)for non-console slots before its buf_delta_null check, so this doesn't mirror the SRV fix. A delta-buffer UAV at a non-console handle (XCL-internal heap, PC-handle ClearUAV viaUavClearHandles::Pc, descriptor copies) silently reads, writes or clears nothing.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.
Imported from ivall/xcl. Originally posted by Kalmarv on 2026-12-02T19:39:01Z.
Closing: conflicts in
real.rs, overlaps #3547 (#1607 D267), and review flagged undefinedClearUnorderedAccessViewbehaviour.Pull request closed