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

Merged
emirduran707 merged 1 commit from upstream-pr/1265 into main 2026-11-24 15:58:13 +00:00
emirduran707 commented 2026-11-24 13:59:12 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by emirduran707 on 2026-11-24T13:59:12Z.


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

<!-- greyfinch-sync:ivall/xcl:issue:6583463909 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1265). Originally posted by [emirduran707](https://github.com/emirduran707) on 2026-11-24T13:59:12Z. --- `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)
thehollowedone commented 2026-11-24 14:06:51 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by thehollowedone on 2026-11-24T14:03:39Z.


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.

<!-- greyfinch-sync:ivall/xcl:comment:7133774069 --> Imported from [ivall/xcl](https://github.com/ivall/xcl/pull/1265#issuecomment-7133774069). Originally posted by [thehollowedone](https://github.com/thehollowedone) on 2026-11-24T14:03:39Z. --- 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.
DavidM1911 commented 2026-11-24 14:06:52 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by DavidM1911 on 2026-11-24T14:05:34Z.


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!

<!-- greyfinch-sync:ivall/xcl:comment:7133827049 --> Imported from [ivall/xcl](https://github.com/ivall/xcl/pull/1265#issuecomment-7133827049). Originally posted by [DavidM1911](https://github.com/DavidM1911) on 2026-11-24T14:05:34Z. --- 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!
upstream-sync closed this pull request 2026-11-24 16:06:07 +00:00
DavidM1911 commented 2026-11-26 05:05:35 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by DavidM1911 on 2026-11-26T04:40:52Z.


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

<!-- greyfinch-sync:ivall/xcl:comment:7182808041 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1265#issuecomment-7182808041). Originally posted by [DavidM1911](https://github.com/DavidM1911) on 2026-11-26T04:40:52Z. --- 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
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
xcl-dev/xcl!1255
No description provided.