D3D12.X: default SRVs of multisampled depth buffers are Texture2DMS views #1265

Manually merged
github merged 1 commit from gh-pr/1265/head into gh-pr/1265/base 2026-11-26 04:48:53 +00:00
Owner

@⁠emirduran707 on GitHub · 2026-11-24 13:59 UTC · original
emirduran707:d3d12x-default-srv-msaa-depth → main · +59 −13 · 1 files · 1 commits · merged 2026-11-24 15:58 UTC

CreateShaderResourceView with a NULL description on a console depth buffer built a TEXTURE2D (or TEXTURE2DARRAY) view with a full mip range, whatever the buffer's sample count. Every console depth buffer is typeless on the PC (pc_resource_desc), so pc_srv makes the view itself. For a multisampled depth buffer that is an invalid view of an MSAA resource. resource_dim_to_view also returned the single-sampled dimension, so the console T# was a D2 image instead of D2Msaa. Microsoft's documentation of CreateShaderResourceView: with a NULL description the view "inherits the resource format and dimension", and for a multisampled 2D texture that is TEXTURE2DMS.

With more than one sample, the NULL-description view is now TEXTURE2DMS, or TEXTURE2DMSARRAY over every slice, and resource_dim_to_view gives the MSAA dimensions (6 / 7). Single-sampled resources get the same views as before. #1087 does the same for the default DSV of these buffers.

What is in it

  • crates/xcl/src/hle/d3d12x/real.rs: pc_srv and resource_dim_to_view; test a_default_view_of_a_depth_buffer_matches_its_sample_count_and_array_size (no device). It covers R24G8_TYPELESS at 1 and 4 samples, with 1 and 3 slices.

Tested

  • AMD Radeon RX 9060 XT (driver 32.0.31044.16), Ryzen 5 5600, Windows 11 Pro 26300, Rust 1.100.0; tests debug, smoke release
  • cargo test --workspace -- --test-threads=4 on 615cb20: 742 passed, 0 failed, 41 ignored; no SKIPPED GPU tests
  • the new test without the change: 4 samples, 1 slices left: D3D12_SRV_DIMENSION(4), right: D3D12_SRV_DIMENSION(6); with it it passes

Regression run

main:

xcl-smoke v1
commit: 47efa2ecea0a12934719ae69b81930cf02a4b1c3
gpu: AMD Radeon RX 9060 XT
title: retail-title
seconds: 60
exit: 0x0
frames shown: 1541 (PresentX 1541)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 19650 MB

this PR:

xcl-smoke v1
commit: 615cb20f39c516bf40c49add0736cec27500c951
gpu: AMD Radeon RX 9060 XT
title: retail-title
seconds: 60
exit: 0x0
frames shown: 1488 (PresentX 1488)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 19611 MB

Not tested

  • A title that makes a default view of a multisampled depth buffer; the smoke title's run is a regression check only.
  • dev_create_uav_x with a NULL description also uses resource_dim_to_view: for a multisampled resource it no longer builds the TEXTURE2D SRV it made before (invalid too). No test covers that path.
  • The T#'s sample count for MSAA views (last_level is 0) is as before; title-made TEXTURE2DMS views already get the same T#.
  • NVIDIA and Intel GPUs.

AI use

  • Claude Code with Claude Opus 5.5: found the problem, wrote the change, the test and this description; I reviewed the diff and ran the tests and smoke runs above.

🤖 Generated with Claude Code

**@⁠emirduran707** on GitHub · 2026-11-24 13:59 UTC · [original](https://github.com/xcl-dev/xcl/pull/1265) `emirduran707:d3d12x-default-srv-msaa-depth` → `main` · +59 −13 · 1 files · 1 commits · merged 2026-11-24 15:58 UTC `CreateShaderResourceView` with a NULL description on a console depth buffer built a `TEXTURE2D` (or `TEXTURE2DARRAY`) view with a full mip range, whatever the buffer's sample count. Every console depth buffer is typeless on the PC (`pc_resource_desc`), so `pc_srv` makes the view itself. For a multisampled depth buffer that is an invalid view of an MSAA resource. `resource_dim_to_view` also returned the single-sampled dimension, so the console T# was a D2 image instead of D2Msaa. Microsoft's documentation of `CreateShaderResourceView`: with a NULL description the view "inherits the resource format and dimension", and for a multisampled 2D texture that is `TEXTURE2DMS`. With more than one sample, the NULL-description view is now `TEXTURE2DMS`, or `TEXTURE2DMSARRAY` over every slice, and `resource_dim_to_view` gives the MSAA dimensions (6 / 7). Single-sampled resources get the same views as before. #1087 does the same for the default DSV of these buffers. **What is in it** - `crates/xcl/src/hle/d3d12x/real.rs`: `pc_srv` and `resource_dim_to_view`; test `a_default_view_of_a_depth_buffer_matches_its_sample_count_and_array_size` (no device). It covers R24G8_TYPELESS at 1 and 4 samples, with 1 and 3 slices. **Tested** - AMD Radeon RX 9060 XT (driver 32.0.31044.16), Ryzen 5 5600, Windows 11 Pro 26300, Rust 1.100.0; tests debug, smoke release - `cargo test --workspace -- --test-threads=4` on 615cb20: 742 passed, 0 failed, 41 ignored; no SKIPPED GPU tests - the new test without the change: `4 samples, 1 slices` `left: D3D12_SRV_DIMENSION(4)`, `right: D3D12_SRV_DIMENSION(6)`; with it it passes **Regression run** main: ``` xcl-smoke v1 commit: 47efa2ecea0a12934719ae69b81930cf02a4b1c3 gpu: AMD Radeon RX 9060 XT title: retail-title seconds: 60 exit: 0x0 frames shown: 1541 (PresentX 1541) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 19650 MB ``` this PR: ``` xcl-smoke v1 commit: 615cb20f39c516bf40c49add0736cec27500c951 gpu: AMD Radeon RX 9060 XT title: retail-title seconds: 60 exit: 0x0 frames shown: 1488 (PresentX 1488) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 19611 MB ``` **Not tested** - A title that makes a default view of a multisampled depth buffer; the smoke title's run is a regression check only. - `dev_create_uav_x` with a NULL description also uses `resource_dim_to_view`: for a multisampled resource it no longer builds the TEXTURE2D SRV it made before (invalid too). No test covers that path. - The T#'s sample count for MSAA views (`last_level` is 0) is as before; title-made TEXTURE2DMS views already get the same T#. - NVIDIA and Intel GPUs. **AI use** - Claude Code with Claude Opus 5.5: found the problem, wrote the change, the test and this description; I reviewed the diff and ran the tests and smoke runs above. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
pc_resource_desc makes every console depth buffer typeless, so a
CreateShaderResourceView with a NULL description of one goes through
pc_srv, which builds the view itself. It always built TEXTURE2D (or
TEXTURE2DARRAY) with MipLevels u32::MAX, whatever the resource's sample
count: for a multisampled depth buffer that is an invalid view (a NULL
description inherits the resource's dimension, and a multisampled 2D
texture has only the TEXTURE2DMS / TEXTURE2DMSARRAY ones). The console T#
written next to it then said D2 / D2Array instead of D2Msaa /
D2MsaaArray, and resource_dim_to_view, which gives that dimension for
any NULL-description SRV or UAV of a 2D texture, ignored the sample
count the same way.

pc_srv now picks TEXTURE2DMS or TEXTURE2DMSARRAY (all slices) when
SampleDesc.Count > 1 (the approach #1087 takes for the default DSV), and
resource_dim_to_view returns 6 / 7 (view_shape: D2Msaa / D2MsaaArray)
for a multisampled 2D texture. Single-sampled resources are unchanged.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:48:51 +00:00
github manually merged commit 615cb20f39 into gh-pr/1265/base 2026-11-26 04:48:53 +00:00
Author
Owner

@⁠thehollowedone on GitHub · 2026-11-24 14:03 UTC · original

Independent D3D12 debug-layer check on 615cb20 and its parent 930e8b4. Windows 11 build 26300, RTX 3080 Ti / 621.35, Rust 1.99.1 MSVC, debug.

I passed XCL’s synthesized default depth SRVs to native CreateShaderResourceView for both R24G8_TYPELESS and R32_TYPELESS, at 1× and 4× samples with one or three slices. The PR produced zero D3D12 errors across all eight cases in two fresh processes. On the parent, the two single-sample R24 controls passed. The first 4× R24 view (one slice) produced two debug-layer errors, and creating the next test resource returned DXGI_ERROR_DEVICE_REMOVED, ending that baseline run.

The three focused SRV tests passed on the PR. This covers native descriptor creation with synthetic resources. Shader sampling and retail behavior were outside this run. AI-assisted. Codex (GPT-6, exact variant unavailable) wrote and ran the scratch fixture and drafted this report.

**@⁠thehollowedone** on GitHub · 2026-11-24 14:03 UTC · [original](https://github.com/xcl-dev/xcl/pull/1265#issuecomment-7133774069) Independent D3D12 debug-layer check on [`615cb20`](https://github.com/ivall/xcl/commit/615cb20f39c516bf40c49add0736cec27500c951) and its parent [`930e8b4`](https://github.com/ivall/xcl/commit/930e8b49c1c2ec683d22c724a398b39111cd0e56). Windows 11 build 26300, RTX 3080 Ti / 621.35, Rust 1.99.1 MSVC, debug. I passed XCL’s synthesized default depth SRVs to native `CreateShaderResourceView` for both `R24G8_TYPELESS` and `R32_TYPELESS`, at 1× and 4× samples with one or three slices. The PR produced zero D3D12 errors across all eight cases in two fresh processes. On the parent, the two single-sample R24 controls passed. The first 4× R24 view (one slice) produced two debug-layer errors, and creating the next test resource returned `DXGI_ERROR_DEVICE_REMOVED`, ending that baseline run. The three focused SRV tests passed on the PR. This covers native descriptor creation with synthetic resources. Shader sampling and retail behavior were outside this run. AI-assisted. Codex (GPT-6, exact variant unavailable) wrote and ran the scratch fixture and drafted this report.
Author
Owner

@⁠DavidM1911 on GitHub · 2026-11-24 14:05 UTC · original

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

  • cargo test -p xcl a_default_view_of_a_depth_buffer_matches_its_sample_count_and_array_size: 1 passed; lib srv filter: 3 passed, 0 failed.

Thanks!

**@⁠DavidM1911** on GitHub · 2026-11-24 14:05 UTC · [original](https://github.com/xcl-dev/xcl/pull/1265#issuecomment-7133827049) Verification on RTX 3060 Ti (Windows 11), branch merged with current `main`: - cargo test -p xcl a_default_view_of_a_depth_buffer_matches_its_sample_count_and_array_size: 1 passed; lib srv filter: 3 passed, 0 failed. Thanks!
Author
Owner

@⁠DavidM1911 on GitHub · 2026-11-26 04:40 UTC · original

Re-verification on RTX 3060 Ti (Windows 11), new head merged with current main:

  • cargo test -p xcl --lib: all passed, 0 failed, 27 ignored. The earlier merge conflict is resolved.

Thanks!

— Devin

**@⁠DavidM1911** on GitHub · 2026-11-26 04:40 UTC · [original](https://github.com/xcl-dev/xcl/pull/1265#issuecomment-7182808041) Re-verification on RTX 3060 Ti (Windows 11), new head merged with current `main`: - `cargo test -p xcl --lib`: all passed, 0 failed, 27 ignored. The earlier merge conflict is resolved. Thanks! — Devin
This discussion has been locked. Commenting is limited to contributors.
No description provided.