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

Open
github-bot wants to merge 1 commit from github-bot/gh-2511 into main AGit
Owner

@⁠ChalanaGimhanaX on GitHub · 2026-11-25 21:10 UTC · original
ChalanaGimhanaX:d3d12x/uav-null-desc-and-companion-srv → main · +307 −10 · 1 files · 1 commits · open

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.
**@⁠ChalanaGimhanaX** on GitHub · 2026-11-25 21:10 UTC · [original](https://github.com/xcl-dev/xcl/pull/2511) `ChalanaGimhanaX:d3d12x/uav-null-desc-and-companion-srv` → `main` · +307 −10 · 1 files · 1 commits · open 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.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 05:32:32 +00:00
Author
Owner

@⁠SlopTart on GitHub · 2026-11-25 21:21 UTC · original

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.

**@⁠SlopTart** on GitHub · 2026-11-25 21:21 UTC · [original](https://github.com/xcl-dev/xcl/pull/2511#issuecomment-7174977417) `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.
Author
Owner

@⁠DavidM1911 on GitHub · 2026-11-25 21:24 UTC · original

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

  • cargo test -p xcl --lib: all passed, 0 failed, ~26 ignored. (Intermittent single-test flake / 0xc0000005 abort under parallel scheduling — tracked in #1978; clean on single-threaded rerun.)

Thanks!

**@⁠DavidM1911** on GitHub · 2026-11-25 21:24 UTC · [original](https://github.com/xcl-dev/xcl/pull/2511#issuecomment-7175025776) Verification on RTX 3060 Ti (Windows 11), branch merged with current `main`: - `cargo test -p xcl --lib`: all passed, 0 failed, ~26 ignored. (Intermittent single-test flake / 0xc0000005 abort under parallel scheduling — tracked in #1978; clean on single-threaded rerun.) Thanks!
Author
Owner

@⁠emirduran707 on GitHub · 2026-11-25 21:29 UTC · original

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.
**@⁠emirduran707** on GitHub · 2026-11-25 21:29 UTC · [original](https://github.com/xcl-dev/xcl/pull/2511#issuecomment-7175143163) 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.
Author
Owner

@⁠DarkPanda69 on GitHub · 2026-11-25 22:32 UTC · original

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.

**@⁠DarkPanda69** on GitHub · 2026-11-25 22:32 UTC · [original](https://github.com/xcl-dev/xcl/pull/2511#issuecomment-7176498882) 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: ```rust 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: ```rust 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.
Author
Owner

@⁠luckyteagirl on GitHub · 2026-11-26 07:19 UTC · original · reviewed

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.

**@⁠luckyteagirl** on GitHub · 2026-11-26 07:19 UTC · [original](https://github.com/xcl-dev/xcl/pull/2511#pullrequestreview-6069956294) · **reviewed** 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.
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/2511/head:github-bot/gh-2511'
git switch 'github-bot/gh-2511'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-2511'
git switch 'github-bot/gh-2511'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-2511'
git switch 'github-bot/gh-2511'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-2511'
git switch 'main'
git merge --squash 'github-bot/gh-2511'
git switch 'main'
git merge --ff-only 'github-bot/gh-2511'
git switch 'main'
git merge 'github-bot/gh-2511'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.