Skip to content

D3D12.X: fix null UAV fallback and MSAA/typeless companion SRVs - #2511

Open
ChalanaGimhanaX wants to merge 1 commit into
xcl-dev:mainfrom
ChalanaGimhanaX:d3d12x/uav-null-desc-and-companion-srv
Open

ChalanaGimhanaX wants to merge 1 commit into
xcl-dev:mainfrom
ChalanaGimhanaX:d3d12x/uav-null-desc-and-companion-srv

Conversation

@ChalanaGimhanaX

Copy link
Copy Markdown
Contributor

Fix invalid null UAV fallback dimensions in dev_create_uav_checked_x and invalid MSAA / *_TYPELESS companion SRV descriptors in uav_companion_srv, preventing DXGI_ERROR_INVALID_CALL (0x887A0001) device removals when console titles create image UAVs on unsupported formats, MSAA textures, or non-depth typeless textures.

Part of #2461 and #1833.

What is in it

  • crates/xcl/src/hle/d3d12x/real.rs:
    • dev_create_uav_checked_x: reuse null_uav_desc(desc.as_ref(), Some(&rd)) instead of D3D12_UNORDERED_ACCESS_VIEW_DESC { ..Default::default() } when pc_typed_uav_supported returns false, avoiding zero ArraySize / WSize on Texture1DArray, Texture2DArray, and Texture3D null UAV fallbacks.
    • null_uav_desc: ignore ViewDimension == UNKNOWN (0) so it falls back to rd, and map MSAA 2DArray (7) to Texture2DArray with ArraySize = 1.
    • uav_companion_srv + concrete_srv_format: accept MSAA dimensions (6 / 7) from resource_dim_to_view when desc == None, emit D3D12_SRV_DIMENSION_TEXTURE2DMS / D3D12_SRV_DIMENSION_TEXTURE2DMSARRAY when rd.SampleDesc.Count > 1 (preventing CREATESHADERRESOURCEVIEW_INVALIDDESC and ID3D12Device::RemoveDevice), and normalize any remaining *_TYPELESS or depth-only format to a concrete same-family SRV format (preventing CREATESHADERRESOURCEVIEW_INVALIDFORMAT).
    • uav_companion_srv_tests: added unit test uav_companion_srv_msaa_typeless_and_null_uav_dimensions and D3D12 debug-layer test gpu_uav_null_fallback_and_msaa_typeless_companion_srv_debug_layer.

Tested

  • Hardware / toolchain: NVIDIA GeForce RTX 3060 12 GB (driver 32.0.16.1714), Intel Core i5-10400F, Windows 11 Pro Build 26200, rustc 1.100.0 (0ef1bc386 2026-11-09), DXC 1.8.2502.11, release build.
  • Failing-first check (before the fix):
    • uav_companion_srv_msaa_typeless_and_null_uav_dimensions failed (MSAA 2D default companion SRV returned None).
    • gpu_uav_null_fallback_and_msaa_typeless_companion_srv_debug_layer failed under D3D12SDKLayers.dll with ID3D12Device::CreateShaderResourceView: The base resource was created as a multisample resource. You must specify D3D12_SRV_DIMENSION_TEXTURE2DMSARRAY or D3D12_SRV_DIMENSION_TEXTURE2DMS. followed by ID3D12Device::RemoveDevice (DXGI_ERROR_INVALID_CALL).
  • After the fix (ba93ea4):
    • cargo test --release -p xcl --lib hle::d3d12x::real::uav_companion_srv_tests:: -- --test-threads=1 --nocapture on RTX 3060: 4 passed, 0 failed, 0 skipped (0 D3D12 debug-layer errors).
    • Same targeted test suite on WARP (XCL_ADAPTER=warp): 4 passed, 0 failed, 0 skipped (0 D3D12 debug-layer errors).
    • cargo build --release --workspace + cargo test --release --workspace --no-fail-fast -- --test-threads=4 --nocapture: 1425 passed, 0 failed, 46 ignored across 37 test binaries.
    • SKIPPED lines (26): 21 no wave64 (RTX 3060 is 32-lane), 3 per-lane refused f16/f32 forms (#1426), 1 pso_measurement_compiles_an_exact_synthetic_record (Windows Developer Mode required), 1 heap_window_out_of_memory_falls_back_to_the_switch_form (no heap windows).
    • cargo test --release -p xcl --test e2e -- --test-threads=1: 4 passed, 0 failed.

Regression run

main (6d051da):

xcl-smoke v1
commit: 6d051da51ba3fe7ba7d4ef542da71f544646e3ba
gpu: NVIDIA GeForce RTX 3060
title: 37fe04ab
seconds: 60
exit: 0x0
frames shown: 1473 (PresentX 1473)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14348 MB

this PR (ba93ea4):

xcl-smoke v1
commit: ba93ea4418e3b8440fc563ad3b270e4f328cd166
gpu: NVIDIA GeForce RTX 3060
title: 37fe04ab
seconds: 60
exit: 0x0
frames shown: 1390 (PresentX 1390)
presents per 2 s (last 3): 58 60 49
device removals: 0
crashes: 0
peak commit: 9823 MB

Not tested

  • AMD / Intel GPUs, Linux / Wine, and retail gameplay beyond the 60-second menu smoke run.

AI use

  • Antigravity (Gemini 4 Neon) implemented the real.rs null UAV fallback and MSAA/typeless companion SRV fixes and tests, ran the failing-first check, targeted GPU/WARP tests, full workspace test suite, e2e tests, and smoke run, and drafted this PR description.

@SlopTart

SlopTart commented Nov 25, 2026 •

Copy link
Copy Markdown

gpu_ suite (cold cache): 165 passed / 3 failed, no crashes. The three are the known baseline on this lane (seed-1003 fuzz, mad/mac contraction, promoted-UAV-clear driver gap, PR #2490); none caused by this PR.
Targeted run of the new companion-SRV tests (uav_companion_srv_msaa_typeless_and_null_uav_dimensions and helpers): 4 passed. The gpu_uav_null_fallback_and_msaa_typeless_companion_srv_debug_layer e2e entry ran to completion (ok) inside the suite run, no SKIPPED lines in this log, and gpu_uav_companion_srv_and_null_image_views is ok as well.

@DavidM1911

Copy link
Copy Markdown
Contributor

Verification on RTX 3060 Ti (Windows 11), branch merged with current main:

Thanks!

@emirduran707

Copy link
Copy Markdown
Contributor

Independent AMD RDNA4 (native wave64) test report on exact head ba93ea4418e3b8440fc563ad3b270e4f328cd166 (clean detached checkout, no local changes).

Tested

  • AMD Radeon RX 9060 XT 16 GB (RDNA4, native wave64, driver 32.0.31044.16), Ryzen 5 5600, 32 GB RAM, Windows 11 Pro 26300, Rust 1.100.0 (stable-x86_64-pc-windows-msvc), DXC 1.9.2602.17; tests debug, smoke release.
  • cargo build --workspace && cargo test --workspace --no-fail-fast -- --test-threads=4: 1423 passed, 2 failed, 46 ignored; 8 SKIPPED (6 in lower_dxil::tests::{f16,f32}_programs_on_the_gpu refused by per-lane form; heap_window_out_of_memory_falls_back_to_the_switch_form; pso_measurement_compiles_an_exact_synthetic_record). All native wave64 GPU tests ran and passed.
    • Both PR tests passed: hle::d3d12x::real::uav_companion_srv_tests::uav_companion_srv_msaa_typeless_and_null_uav_dimensions and gpu_uav_null_fallback_and_msaa_typeless_companion_srv_debug_layer.
    • The 2 failures (gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_1 seed 722 and fuzz_validate_and_gpu_3 seed 1599) are pre-existing on unmodified main on this GPU.

Regression run (60 s retail-title smoke, XCL_NETWORK=0, release)

xcl-smoke v1
commit: ba93ea4418e3b8440fc563ad3b270e4f328cd166
gpu: AMD Radeon RX 9060 XT
title: 21222967
seconds: 60
exit: 0x0
frames shown: 1581 (PresentX 1581)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14437 MB

(Matched main 68a284a baseline on the same machine today: 1573 frames, 14420 MB peak, 0 device removals, 0 crashes.)

Not tested

  • D3D12 debug layer (not installed on this host); Intel GPUs.

AI use

  • Antigravity with Gemini 4 Neon ran the build, test suite, and smoke run and drafted this report.

@DarkPanda69

Copy link
Copy Markdown

On a machine without the D3D12 debug layer, gpu_uav_null_fallback_and_msaa_typeless_companion_srv_debug_layer shows as passed with no SKIPPED line in a normal test run, so it is easy to count it as coverage when it tested nothing.

Head ba93ea4 applied on main 6d12f58, RX 9070 XT, Windows 11 Pro 26200, no d3d12SDKLayers.dll installed:

  • cargo test -p xcl --lib -- gpu_uav_null_fallback_and_msaa_typeless_companion_srv_debug_layer --nocapture prints SKIPPED ...: no D3D12 debug layer (...) and then ... ok.
  • The same run without --nocapture (and the whole-suite runs CONTRIBUTING.md asks for) prints only ... ok, with no SKIPPED line.

The cause is the forwarding loop in the parent test:

for line in stderr.lines().filter(|l| l.starts_with("SKIPPED ")) {
    eprintln!("{line}");
}

libtest captures eprintln! output of a passing test, so the child's SKIPPED line is dropped. runner::skip_test writes with writeln!(std::io::stderr(), ...), which is not captured, and that is why other skips do show up. Writing the forwarded line the same way would keep it visible:

use std::io::Write;
let _ = writeln!(std::io::stderr(), "{line}");

I have not built or run that change.

AI use: Claude Code (Claude Opus 5.5) found this while testing the PR on this machine and wrote this comment.

@luckyteagirl luckyteagirl 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.

Could the companion SRV and the console T# use the same normalized descriptor? For a 4x MSAA texture with an explicit TEXTURE2D UAV descriptor, the new code publishes a TEXTURE2DMS SRV, but dev_create_uav_x still builds the T# from the original UAV dimension and labels it non-MSAA. With a default UAV descriptor, the T# gets the MSAA type but hardcodes one mip, which encodes LAST_LEVEL=0 instead of 2 for four samples.

The existing srv_tsharp_from_desc helper can build the metadata from the normalized native SRV and the actual sample count. A focused fixture could check the published SRV dimension and decoded T# type and sample count for both descriptor forms. Exact-head source review of ba93ea4418e3b8440fc563ad3b270e4f328cd166. No GPU run. AI-assisted review with Codex.

rootw0rm pushed a commit to rootw0rm/xcl that referenced this pull request Nov 26, 2026
…cl-dev#2511)

(cherry picked from commit 56085f55cfaad3c006146e812b154893d2140681)
@ClosetPie107

Copy link
Copy Markdown

Independent test report under Wine/Proton (not native Windows) for head ba93ea44.

Setup

  • AMD Radeon RX 9070 (RDNA4, RADV GFX1201, Mesa 26.3.1), Ryzen 5 9600X, CachyOS Linux 7.3.5
  • Proton Experimental experimental-11.0-20261112, vkd3d-proton master ec207194 with a local patch dropping the lpVtbl checks in d3d12_command_allocator_from_iface / d3d12_command_list_from_iface, DXC 1.9.2609.5, Rust 1.96.0, x86_64-pc-windows-gnu
  • Head merged onto main 83b00818, test commit 44f6b2fc

Tests (debug, --test-threads=1)

  • hle::d3d12x::real::: 65 passed, 0 failed (main: 63 passed, 0 failed). uav_companion_srv_msaa_typeless_and_null_uav_dimensions runs; gpu_uav_null_fallback_and_msaa_typeless_companion_srv_debug_layer returns early here because vkd3d-proton has no D3D12 debug layer (0x887A002D), so its checks did not run (with XCL_REQUIRE_GPU=wave64 it fails for that reason).
  • cargo test --workspace --no-fail-fast -- --test-threads=4, lib binary: 1322 passed, 9 failed, 27 ignored (main the same run: 1320 passed, 9 failed, 27 ignored). The failures are the same as main's.

Retail title, 300 s (release, from a copy of the same warm-cache snapshot; XCL_DIRECT_DXIL=1 XCL_PREPARE=1 XCL_PSO_PRELOAD=1 XCL_PSO_WAIT_MS=50 XCL_TEXTURE_LEVEL_PAGES=1 XCL_COHERENT_MB=1024 VKD3D_CONFIG=ignore_shared_fence, A pressed every 10 s)

  • 1 run: exit 0, no crash, no device removal, 1,882 presents. main, 4 runs: all clean, 1,892–2,122. This title never removed the device here on main either, so the run does not show the fix, only that nothing broke.

Not tested

  • Native Windows, NVIDIA/Intel
  • The debug-layer test (no debug layer under vkd3d-proton)

AI use

  • Claude Code (Claude Opus 5.5) wrote the test scripts, ran the tests and runs on this machine and wrote this report.

@Kalmarv

Kalmarv commented Nov 28, 2026 •

Copy link
Copy Markdown
Contributor

merge-check
base: 5f0bfdb
head: ba93ea4
merge: clean (trial merge b836d310468e0dad0ce020be428fa94ebb34c95c, local, not pushed; git diff --check clean)
build: cargo build --workspace -> ok
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 (XCL_DXC_DIR = DXC 1.9.2609) -> 2597 passed, 0 failed, 49 ignored; SKIPPED: 26 (21 no wave64 on this 32-lane GPU, 3 per-lane f16/f32 forms refused (#1426 semantics), 2 no heap windows); failing: none. Both new tests ran and passed, including gpu_uav_null_fallback_and_msaa_typeless_companion_srv_debug_layer under the D3D12 debug layer. A first run with the Windows SDK's DXC 1.7 also failed gpu::recomp::link_tests::{gpu_linked_memory_accessors, linked_programs_keep_their_declarations} (DXC 1.7: "attribute WaveSize only valid on entry point function"). This PR doesn't touch that code, and both pass with DXC 1.9.
review: none blocking; whole diff read (real.rs: null_uav_desc ignores ViewDimension 0 and maps 7 to a Texture2DArray null UAV; the unsupported-typed-UAV fallback now uses null_uav_desc, so null Texture1DArray / Texture2DArray / Texture3D UAVs get ArraySize / WSize 1 instead of 0; MSAA companion SRVs become TEXTURE2DMS / TEXTURE2DMSARRAY; concrete_srv_format after pc_srv). Notes, none blocking:

  1. A UAV desc of Texture2D (4) / Texture2DArray (5) on an MSAA resource now gets a TEXTURE2DMS(ARRAY) companion SRV, but the T# written for that slot still comes from view_shape(.., dim 4/5, ..), i.e. a non-MSAA image type. A shader reading that slot through the T# would then use a non-MS access on an MS descriptor. Before this PR the same call created an invalid SRV (device removed), so this is still a step forward; it is just not exercised by any test.
  2. concrete_srv_format picks FLOAT / UNORM for typeless resources (R32_TYPELESS -> R32_FLOAT, R8G8B8A8_TYPELESS -> R8G8B8A8_UNORM ...). A shader that reads UINT data through that companion SRV gets converted values. This only applies where the view's format was UNKNOWN or the desc was NULL on a typeless resource, which was an invalid descriptor before.
    performance: no per-frame cost: view-creation paths only (one extra match per companion SRV). Title runs (below): no difference in exits, crashes or removals.
    title run (fast-world harness, same safe cache snapshot type for both, base vs. merged PR, release builds, run as the same firewalled exe):
  • base 5f0bfdbc: exit 0x0, crashes 0, device removals 0, no system display events; world entry at 116.5 s, peak commit 29,463 MB, 69 WARN lines.
  • PR merge b836d310: exit 0x0, crashes 0, device removals 0, no system display events; world entry at 102.6 s, peak commit 28,765 MB, 71 WARN lines (same UAV/SRV warnings as base, no new kinds).
  • Both runs ~267 s, each from its own fresh snapshot of the same warm cache. That cache doesn't match this main's translator identity, so both spent the run compiling pipelines (up to ~114 s for one) and showed no frames in the steady window: frame rate not compared. The runs only show that the PR adds no crash, removal or new warning on the way into the world.
    verdict: safe to merge
    hardware / tool and model: NVIDIA GeForce RTX 5070 Ti 16 GB (driver 610.74, wave32 only), AMD Ryzen 9 9950X, Windows 11 build 26200; rustc 1.99.0, debug test profile, DXC 1.9.2609 via XCL_DXC_DIR; title runs from release builds. Claude Code, Claude Opus 5.5: merge, build, suite, title runs and full-diff review; this report.

@github-actions github-actions Bot added area:d3d12 D3D12.X runtime, command lists, resources, sparse memory gpu:both Code affects both AMD and NVIDIA GPUs (scope tag; see needs:*-test for remaining checks) needs-1st-check Passes gates; needs first independent merge-check (#3041) needs:amd-test Needs a test report or merge-check on an AMD GPU needs:nvidia-test Needs a test report or merge-check on an NVIDIA GPU labels Nov 28, 2026
@throny

throny commented Nov 28, 2026

Copy link
Copy Markdown
Collaborator

merge-check claim
head: ba93ea4

@github-actions github-actions Bot added needs-2nd-check Has 1 safe merge-check; needs second independent check (#3041) and removed needs-1st-check Passes gates; needs first independent merge-check (#3041) needs:nvidia-test Needs a test report or merge-check on an NVIDIA GPU labels Nov 28, 2026
@throny

throny commented Nov 29, 2026

Copy link
Copy Markdown
Collaborator

merge-check
base: 851bf7f
head: ba93ea4
merge: clean
build: cargo build --workspace -> ok
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 2598 passed, 0 failed, 49 ignored (27 SKIPPED lines). Base alone at 851bf7f: 2596 passed, 0 failed, 49 ignored. The merge with main (which split the function this touches) is clean.
review: the view-dimension rules for the null UAV and for multisampled resources are right. One point from the thread is still open and I can follow it in the code: when the title's view is a plain 2D UAV of a multisampled resource, the console texture descriptor is still built from the UAV's (non-multisampled) shape while the companion SRV is now a multisampled view, so the shader reads it with the wrong texture type; main's existing helper that builds the descriptor from the resource description would give the matching one. Also unanswered: the forwarded SKIPPED line is printed through a call the test harness captures, so on a machine without the debug layer the test passes silently. Minor: the number type picked for a typeless format is a guess and not consistent between formats.
performance: one format lookup per UAV creation. No translator source.
verdict: not yet: make the descriptor match the multisampled companion view, and let the skip show.
hardware / tool and model: RTX 4080 16 GB (621.40), i9-12900K, Windows 11 26300, Rust 1.100.0, debug. Claude Code; merge, build and suite run by Claude Fable 5.2, diff review by Claude Opus 5.5 (every hunk read; nothing run on the GPU beyond the suite).

@github-actions github-actions Bot added checks-disagree Merge-checks disagree (safe vs not yet); needs maintainer/3rd look and removed needs-2nd-check Has 1 safe merge-check; needs second independent check (#3041) labels Nov 29, 2026
@thehollowedone

Copy link
Copy Markdown
Contributor

Following the blocking merge check, here is a narrow candidate for the console-descriptor mismatch on head ba93ea44. The companion SRV selects TEXTURE2DMS or TEXTURE2DMSARRAY, but the final T# is still built from the original UAV shape with LAST_LEVEL=0. The existing srv_tsharp_from_desc helper uses the resolved SRV and the resource's sample count.

Candidate descriptor diff
diff --git a/crates/xcl/src/hle/d3d12x/real.rs b/crates/xcl/src/hle/d3d12x/real.rs
@@
         g(this, srv_res, &srv, slot.pc_srv);
         super::console_heap::publish(&slot, false);
+        if !deny_srv && matches!(
+            srv.ViewDimension,
+            D3D12_SRV_DIMENSION_TEXTURE2DMS | D3D12_SRV_DIMENSION_TEXTURE2DMSARRAY
+        ) {
+            if let Some(t) = srv_tsharp_from_desc(slot.index, &rd, Some(&srv)) {
+                return super::console_heap::write(&slot, &t);
+            }
+        }
     }

This leaves the existing UAV T# path in place for ordinary views and the null companion case. Please extend the tests to decode the published T# for explicit and default 4× 2D and 2D-array views: the type should match the companion SRV, LAST_LEVEL=2, MAX_MIP=0, and the array slice count should be preserved. The separate captured SKIPPED fix is already posted.

This candidate was checked against the source, but not applied, compiled, or run on a GPU. AI use: Codex (GPT-6.2 Sol) traced the call path and drafted the diff; Codex (GPT-6.2 Astra) independently checked the encoder and test gap.

@futurepro62

futurepro62 commented Dec 1, 2026 •

Copy link
Copy Markdown

merge-check
base: d0832e6
head: ba93ea4
merge: clean
build: cargo build --workspace -> ok
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> NVIDIA: 2888 passed, 4 failed, 51 ignored, 24 SKIPPED lines (base alone: 2890 passed, 0 failed, 51 ignored). All 4 failures are in hle::d3d12x::title_textures::tests, which this PR does not touch. One assertion failed (placed_title_textures_share_vram_and_preserve_pixels: "superseded unaligned extra_pages must be reclaimed immediately"), and the other three (stream_recheck_*) then failed on the lock it poisoned. Run alone 3 times on this merge and 3 times on the base, hle::d3d12x::title_textures gave 65 passed, 0 failed every time, so it is intermittent under the full parallel suite, not this PR. AMD Radeon iGPU (XCL_ADAPTER=radeon): the lib test binary stops with exit 0x80004005, as on the base alone (#3488), and the remaining failures are the same set with and without this PR. Radeon, cargo test -p xcl --lib hle::d3d12x::real -- --test-threads=4: 172 passed, 0 failed (base: 170 passed, 0 failed). Both new tests passed with --nocapture and printed no SKIPPED line, so gpu_uav_null_fallback_and_msaa_typeless_companion_srv_debug_layer really ran under the debug layer. Its child makes its device with create_device(None), though, which is the default adapter (the RTX here) even with XCL_ADAPTER=radeon, so that test ran on NVIDIA only.
review: whole diff read on the merge result. The null-UAV and MSAA companion-SRV dimension rules are right, and concrete_srv_format is a sound map. I agree with throny's open point, and it is still in the merged code. In dev_create_uav_x (merged real.rs ~3811-3845), the console T# is built from the title's UAV view dimension: view_shape(..., dim = desc.ViewDimension, ...), then xcl_image_for_view(..., ty, ...). A plain 2D (4) or 2D-array (5) UAV of a multisampled resource therefore gets a D2 / D2Array T#, with LAST_LEVEL from mips rather than log2(samples). The same slot's PC companion SRV (uav_companion_srv, msaa at ~3644) is now TEXTURE2DMS / TEXTURE2DMSARRAY. A translated shader reading the slot then follows the T#'s type over an MS view. With no UAV desc the two agree (resource_dim_to_view gives 6/7), so only an explicit 2D UAV desc on an MSAA resource is affected. srv_tsharp_from_desc(slot.index, &rd, Some(&srv)) (~1910), already on main, builds the matching MS T# from the companion SRV (D2Msaa, LAST_LEVEL = log2(samples)). Using it when msaa is true would close this. throny's second point also holds but is minor: the parent test forwards the child's SKIPPED lines with eprintln!, which libtest captures for a passing test, so a machine without the debug layer passes silently.
performance: none at run time beyond view creation (one more match per UAV creation).
verdict: not yet: for an explicit 2D / 2D-array UAV of a multisampled resource, write the T# from the multisampled companion SRV (e.g. srv_tsharp_from_desc) so its type matches the MS view; optionally print the forwarded SKIPPED lines outside libtest's capture
hardware / tool and model: RTX 5070 Ti 16 GB + AMD Radeon iGPU, Ryzen 7 9800X3D, Windows 11 26300, debug test profile. Claude Code, Claude Opus 5.5: merge, build, both suites, solo reruns and full-diff review of the merge result.

@thehollowedone

Copy link
Copy Markdown
Contributor

Follow-up to my candidate correction, tested against PR head ba93ea4 merged locally onto current main (d0832e6). The MSAA companion SRV is created, but the console T# at its UAV slot still describes the original UAV view. On a four-sample resource, its LAST_LEVEL is 0 instead of 2. This is a descriptor mismatch; I have not established a visible title symptom.

I added a GPU regression comparing the entire console T# with the T# for the companion SRV actually published. It covers default and explicit UAVs for Texture2DMS and Texture2DMSArray. The debug-layer test failed on the unchanged PR merge (0 passed, 1 failed; slot 3's T# differed). With the small correction below, cargo test --locked -p xcl --lib hle::d3d12x::real::uav_companion_srv_tests:: -- --nocapture --test-threads=1 passed 4/4, 0 failed, 0 ignored, no skips on Windows 11 build 26300, RTX 3080 Ti (621.40), Ryzen 7 9800X3D, Rust 1.99.1 MSVC. The same focused module passed 4/4 with XCL_ADAPTER=warp; the debug-layer child explicitly selected the DXGI WARP adapter in that run. Setting XCL_ADAPTER=warp alone does not redirect this test's direct create_device(None) call, so the test change below makes that selection explicit.

Tested candidate correction and regression
diff --git a/crates/xcl/src/hle/d3d12x/real.rs b/crates/xcl/src/hle/d3d12x/real.rs
@@ -3839,6 +3839,11 @@ unsafe extern "system" fn dev_create_uav_x(this: *mut c_void, res: *mut c_void,
         g(this, srv_res, &srv, slot.pc_srv);
         super::console_heap::publish(&slot, false, srv_res as usize);
+        if !deny_srv && matches!(srv.ViewDimension, D3D12_SRV_DIMENSION_TEXTURE2DMS | D3D12_SRV_DIMENSION_TEXTURE2DMSARRAY) {
+            if let Some(t) = srv_tsharp_from_desc(slot.index, &rd, Some(&srv)) {
+                return super::console_heap::write(&slot, &t);
+            }
+        }
     }
@@ -14939,7 +14944,14 @@ void main() {
-            let Ok(dev) = crate::gpu::agility::create_device(None, D3D_FEATURE_LEVEL_11_0) else {
+            let warp = if std::env::var("XCL_ADAPTER").as_deref() == Ok("warp") {
+                use windows::Win32::Graphics::Dxgi::{CreateDXGIFactory1, IDXGIAdapter, IDXGIFactory4};
+                let factory = CreateDXGIFactory1::<IDXGIFactory4>().expect("DXGI factory");
+                Some(factory.EnumWarpAdapter::<IDXGIAdapter>().expect("WARP adapter").cast::<windows::core::IUnknown>().expect("WARP IUnknown"))
+            } else {
+                None
+            };
+            let Ok(dev) = crate::gpu::agility::create_device(warp.as_ref(), D3D_FEATURE_LEVEL_11_0) else {
@@ -15040,9 +15052,34 @@ void main() {
             dev_create_uav_x(dev.as_raw(), ms2da.as_raw(), std::ptr::null_mut(), &u_ms2da, slot_cpu(4));
+            let u_ms2d = D3D12_UNORDERED_ACCESS_VIEW_DESC {
+                Format: DXGI_FORMAT_R8G8B8A8_UNORM,
+                ViewDimension: D3D12_UAV_DIMENSION_TEXTURE2D,
+                ..Default::default()
+            };
+            dev_create_uav_x(dev.as_raw(), ms2d.as_raw(), std::ptr::null_mut(), &u_ms2d, slot_cpu(7));
+            dev_create_uav_x(dev.as_raw(), ms2da.as_raw(), std::ptr::null_mut(), std::ptr::null(), slot_cpu(8));
             let errs2 = take_errors(&iq);
             assert!(errs2.is_empty(), "MSAA companion SRV debug errors: {errs2:#?}");
 
+            // The console T# must describe the SRV actually published for each MSAA UAV.
+            for (k, resource, uav) in [
+                (3, &ms2d, None),
+                (4, &ms2da, Some(&u_ms2da)),
+                (7, &ms2d, Some(&u_ms2d)),
+                (8, &ms2da, None),
+            ] {
+                let rd = resource.GetDesc();
+                let slot = super::super::console_heap::slot(slot_cpu(k)).expect("console UAV slot");
+                let srv = uav_companion_srv(Some(&rd), uav, false).expect("MSAA companion SRV");
+                let expected = srv_tsharp_from_desc(slot.index, &rd, Some(&srv)).expect("MSAA T#");
+                let mut actual = [0u32; 8];
+                std::ptr::copy_nonoverlapping(slot.at as *const u32, actual.as_mut_ptr(), 8);
+                assert_eq!(actual, expected, "console T# differs from the published MSAA companion SRV at slot {k}");
+                assert_eq!((actual[3] >> 16) & 0xf, 2, "four samples require LAST_LEVEL=2");
+                assert_eq!((actual[5] >> 4) & 0xf, 0, "MSAA views have MAX_MIP=0");
+            }

This validates the descriptor correction, not the full PR for merge. The full workspace suite and paired retail smoke were not run on this uncommitted candidate. AI use: OpenAI Codex (GPT-6.2 Sol) prepared the regression, correction, and report and ran the focused tests.

@Foniass

Foniass commented Dec 1, 2026

Copy link
Copy Markdown
Contributor

Triage (#1607) – head ba93ea4

No open or merged PR makes the same change. #3319 sanitizes formats of null-resource SRVs/RTVs in other functions and does not touch uav_companion_srv. #2518 (same issue #2461) changes console_list.rs only. #1914 (merged) added the companion SRVs this fixes.
No problems found in the diff. Note that concrete_srv_format picks UNORM/FLOAT for typeless families, so an integer-typed view on a typeless resource reads as float in the companion SRV.
Recommendation: keep open.

AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human.

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 checks-disagree Merge-checks disagree (safe vs not yet); needs maintainer/3rd look gpu:both Code affects both AMD and NVIDIA GPUs (scope tag; see needs:*-test for remaining checks) needs:amd-test Needs a test report or merge-check on an AMD GPU

Projects

None yet

Development

Successfully merging this pull request may close these issues.