D3D12.X: fix default_dsv MSAA/1D dimensions and DXGI_FORMAT_UNKNOWN on typeless depth buffers #3280

Closed
Kalmarv wants to merge 1 commit from upstream-pr/3280 into main
Kalmarv commented 2026-11-29 03:41:48 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Kalmarv on 2026-11-29T03:41:48Z.


Fix dev_create_dsv_x and default_dsv for MSAA / 1D depth resources and explicit DSV descriptions using DXGI_FORMAT_UNKNOWN (or D16_UNORM on D16_UNORM_S8_UINT -> R24G8_TYPELESS) over depth buffers that device_x::pc_resource_desc rewrote to typeless formats.

Previously:

  1. default_dsv only emitted D3D12_DSV_DIMENSION_TEXTURE2D / TEXTURE2DARRAY. Calling CreateDepthStencilView(res, NULL, cpu) on a multisampled (SampleDesc.Count > 1) or 1D depth buffer whose format pc_resource_desc made typeless (19/39/44/53) passed a mismatched TEXTURE2D view dimension to D3D12, triggering a device removal (0x887A0005 / DXGI_ERROR_DEVICE_REMOVED) on WARP and D3D12 debug-layer errors.
  2. When CreateDepthStencilView received a non-NULL D3D12_DEPTH_STENCIL_VIEW_DESC with Format = DXGI_FORMAT_UNKNOWN (inheriting the resource format, e.g. to set D3D12_DSV_FLAG_READ_ONLY_DEPTH or a specific mip/slice) on a depth buffer rewritten to typeless, dev_create_dsv_x forwarded DXGI_FORMAT_UNKNOWN directly to PC D3D12, which rejects unknown formats on typeless resources. Likewise, a D16_UNORM (55) DSV over a console D16_UNORM_S8_UINT (118) buffer rewritten to R24G8_TYPELESS (44) was rejected as format-incompatible.

What is in it

  • crates/xcl/src/hle/d3d12x/real.rs:
    • Add typeless_depth_format (19 -> 20, 39 -> 40, 44 -> 45, 53 -> 55) and pc_dsv(rd, desc) (mirroring pc_srv) to translate console DSV formats, resolve DXGI_FORMAT_UNKNOWN on typeless depth buffers, map D16_UNORM on R24G8_TYPELESS to D24_UNORM_S8_UINT, and reuse the single GetDesc() query in dev_create_dsv_x.
    • Update default_dsv to select TEXTURE1D / TEXTURE1DARRAY for 1D resources and TEXTURE2DMS / TEXTURE2DMSARRAY when SampleDesc.Count > 1.
    • Add unit test default_dsv_handles_msaa_and_1d_depth_resources and child-process-isolated WARP + D3D12 debug-layer test dev_create_dsv_x_msaa_and_unknown_format_on_typeless_depth_succeeds_on_warp.

Tested

  • Hardware / toolchain: NVIDIA GeForce RTX 5070 Ti (driver 32.0.16.1074), AMD Ryzen 9 9950X, Windows 11 Pro (build 26200), rustc 1.99.0 (b940084d7 2026-09-28), DXC 1.9 (XCL_DXC_DIR), debug for tests and release for xcl-smoke.
  • Targeted tests (cargo test -p xcl --lib -- hle::d3d12x::real::dsv_tests:: --nocapture): both new tests failed before the fix (the WARP test hit 0x887A0005 DXGI_ERROR_DEVICE_REMOVED after the NULL/unknown-format MSAA DSV calls); after the fix, 2 passed, 0 failed (0.09s, 0 D3D12 debug-layer errors, GetDeviceRemovedReason() == S_OK, 0 skips).
  • Full workspace (cargo test --workspace -j 2 -- --test-threads=4 --skip test_title_runs_and_game_folder_is_untouched --skip uma_driver::tests::): 2601 passed, 0 failed, 49 ignored.
  • SKIPPED GPU tests on this wave32 adapter (26 total across --nocapture workspace baseline): 21 no wave64 (RTX 5070 Ti is wave32), 3 wave32 per-lane #1426 f16/cvt-f16 refusals, 2 no heap windows (opt-in XCL_HEAP_WINDOWS=1).
  • Retail title (ea3b5e4d) 150 s regression run below (0 device removals, 0 crashes, 1916 frames vs 1695 on main, 30536 MB peak commit vs 31546 MB on main).

Regression run

xcl-smoke v1
commit: f0e8fdd5c3942ddd399d5ee11384c8595c5aacff
gpu: NVIDIA GeForce RTX 5070 Ti
title: ea3b5e4d
seconds: 150
exit: 0x0
frames shown: 1695 (PresentX 1695)
presents per 2 s (last 3): 0 0 0
device removals: 0
crashes: 0
peak commit: 31546 MB
xcl-smoke v1
commit: 035b2b290ed1853cae4ae74f14b46babd027bc32
gpu: NVIDIA GeForce RTX 5070 Ti
title: ea3b5e4d
seconds: 150
exit: 0x0
frames shown: 1916 (PresentX 1916)
presents per 2 s (last 3): 31 52 12
device removals: 0
crashes: 0
peak commit: 30536 MB

Not tested

  • AMD RDNA / wave64 GPUs and retail titles creating NULL-desc MSAA depth stencil views (ea3b5e4d smoke is a regression check; MSAA NULL/unknown-format and D16_UNORM-on-R24G8_TYPELESS DSV creation is verified on WARP under the D3D12 debug layer).
  • uma_driver::tests:: (skipped locally due to pre-existing 0x7C10003 exit on NVIDIA) and test_title_runs_and_game_folder_is_untouched.

AI use

  • Antigravity (Gemini) used for root-cause verification, implementation, test authoring, and local verification; all diffs, tests, and smoke outputs reviewed and run locally.
<!-- greyfinch-sync:ivall/xcl:issue:5547263512 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3280). Originally posted by [Kalmarv](https://github.com/Kalmarv) on 2026-11-29T03:41:48Z. --- Fix `dev_create_dsv_x` and `default_dsv` for MSAA / 1D depth resources and explicit DSV descriptions using `DXGI_FORMAT_UNKNOWN` (or `D16_UNORM` on `D16_UNORM_S8_UINT` -> `R24G8_TYPELESS`) over depth buffers that `device_x::pc_resource_desc` rewrote to typeless formats. Previously: 1. `default_dsv` only emitted `D3D12_DSV_DIMENSION_TEXTURE2D` / `TEXTURE2DARRAY`. Calling `CreateDepthStencilView(res, NULL, cpu)` on a multisampled (`SampleDesc.Count > 1`) or 1D depth buffer whose format `pc_resource_desc` made typeless (`19`/`39`/`44`/`53`) passed a mismatched `TEXTURE2D` view dimension to D3D12, triggering a device removal (`0x887A0005` / `DXGI_ERROR_DEVICE_REMOVED`) on WARP and D3D12 debug-layer errors. 2. When `CreateDepthStencilView` received a non-NULL `D3D12_DEPTH_STENCIL_VIEW_DESC` with `Format = DXGI_FORMAT_UNKNOWN` (inheriting the resource format, e.g. to set `D3D12_DSV_FLAG_READ_ONLY_DEPTH` or a specific mip/slice) on a depth buffer rewritten to typeless, `dev_create_dsv_x` forwarded `DXGI_FORMAT_UNKNOWN` directly to PC D3D12, which rejects unknown formats on typeless resources. Likewise, a `D16_UNORM` (`55`) DSV over a console `D16_UNORM_S8_UINT` (`118`) buffer rewritten to `R24G8_TYPELESS` (`44`) was rejected as format-incompatible. **What is in it** - `crates/xcl/src/hle/d3d12x/real.rs`: - Add `typeless_depth_format` (`19 -> 20`, `39 -> 40`, `44 -> 45`, `53 -> 55`) and `pc_dsv(rd, desc)` (mirroring `pc_srv`) to translate console DSV formats, resolve `DXGI_FORMAT_UNKNOWN` on typeless depth buffers, map `D16_UNORM` on `R24G8_TYPELESS` to `D24_UNORM_S8_UINT`, and reuse the single `GetDesc()` query in `dev_create_dsv_x`. - Update `default_dsv` to select `TEXTURE1D` / `TEXTURE1DARRAY` for 1D resources and `TEXTURE2DMS` / `TEXTURE2DMSARRAY` when `SampleDesc.Count > 1`. - Add unit test `default_dsv_handles_msaa_and_1d_depth_resources` and child-process-isolated WARP + D3D12 debug-layer test `dev_create_dsv_x_msaa_and_unknown_format_on_typeless_depth_succeeds_on_warp`. **Tested** - Hardware / toolchain: NVIDIA GeForce RTX 5070 Ti (driver 32.0.16.1074), AMD Ryzen 9 9950X, Windows 11 Pro (build 26200), `rustc 1.99.0 (b940084d7 2026-09-28)`, DXC 1.9 (`XCL_DXC_DIR`), debug for tests and release for `xcl-smoke`. - Targeted tests (`cargo test -p xcl --lib -- hle::d3d12x::real::dsv_tests:: --nocapture`): both new tests failed before the fix (the WARP test hit `0x887A0005` `DXGI_ERROR_DEVICE_REMOVED` after the NULL/unknown-format MSAA DSV calls); after the fix, `2 passed, 0 failed` (`0.09s`, `0` D3D12 debug-layer errors, `GetDeviceRemovedReason() == S_OK`, `0` skips). - Full workspace (`cargo test --workspace -j 2 -- --test-threads=4 --skip test_title_runs_and_game_folder_is_untouched --skip uma_driver::tests::`): 2601 passed, 0 failed, 49 ignored. - `SKIPPED` GPU tests on this wave32 adapter (26 total across `--nocapture` workspace baseline): 21 `no wave64` (RTX 5070 Ti is wave32), 3 wave32 per-lane `#1426` f16/cvt-f16 refusals, 2 `no heap windows` (opt-in `XCL_HEAP_WINDOWS=1`). - Retail title (`ea3b5e4d`) 150 s regression run below (`0` device removals, `0` crashes, `1916` frames vs `1695` on `main`, `30536 MB` peak commit vs `31546 MB` on `main`). **Regression run** ``` xcl-smoke v1 commit: f0e8fdd5c3942ddd399d5ee11384c8595c5aacff gpu: NVIDIA GeForce RTX 5070 Ti title: ea3b5e4d seconds: 150 exit: 0x0 frames shown: 1695 (PresentX 1695) presents per 2 s (last 3): 0 0 0 device removals: 0 crashes: 0 peak commit: 31546 MB ``` ``` xcl-smoke v1 commit: 035b2b290ed1853cae4ae74f14b46babd027bc32 gpu: NVIDIA GeForce RTX 5070 Ti title: ea3b5e4d seconds: 150 exit: 0x0 frames shown: 1916 (PresentX 1916) presents per 2 s (last 3): 31 52 12 device removals: 0 crashes: 0 peak commit: 30536 MB ``` **Not tested** - AMD RDNA / wave64 GPUs and retail titles creating NULL-desc MSAA depth stencil views (`ea3b5e4d` smoke is a regression check; MSAA NULL/unknown-format and `D16_UNORM`-on-`R24G8_TYPELESS` DSV creation is verified on WARP under the D3D12 debug layer). - `uma_driver::tests::` (skipped locally due to pre-existing `0x7C10003` exit on NVIDIA) and `test_title_runs_and_game_folder_is_untouched`. **AI use** - Antigravity (Gemini) used for root-cause verification, implementation, test authoring, and local verification; all diffs, tests, and smoke outputs reviewed and run locally.
Lum7nt commented 2026-11-29 04:59:00 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Lum7nt on 2026-11-29T04:59:00Z.


Native Windows 11 + NVIDIA RTX 3060 verification of PR #3280

Tested PR #3280 head 035b2b290ed1853cae4ae74f14b46babd027bc32 on native Windows 11 on NVIDIA RTX 3060 (12 GB, native wave32).

Environment

  • GPU: NVIDIA GeForce RTX 3060 (12 GB / 12,115 MiB VRAM), driver 32.0.15.8142 (WDDM 3.2)
  • CPU / RAM / OS: Intel Core i5-10400 CPU @ 2.90GHz (6C / 12T), 32 GB RAM, Windows 11 Build 22631 (NT 10.0.22631.0)
  • Toolchain: rustc 1.100.0 (0ef1bc386 2026-11-09) x86_64-pc-windows-msvc, Windows SDK DXC 1.8.2502.11 / dxil 1.8.2502.11

Test Results

  1. Targeted DSV Tests (hle::d3d12x::real::dsv_tests):
cargo test -p xcl --lib -- hle::d3d12x::real::dsv_tests:: --nocapture
  • default_dsv_handles_msaa_and_1d_depth_resources — PASS
  • dev_create_dsv_x_msaa_and_unknown_format_on_typeless_depth_succeeds_on_warp — PASS (verified under isolated process with D3D12 debug layer enabled; GetDeviceRemovedReason() == S_OK, 0 debug layer errors)
    Result: 2 passed; 0 failed; 0 ignored; 0 skipped (0.09s).
  1. D3D12 Resource Creation Test Suite Integration:
cargo test -p xcl --test d3d12_create_placed_resource
cargo test -p xcl --test d3d12_create_committed_resource
cargo test -p xcl --test d3d12_create_reserved_resource
  • d3d12_create_placed_resource — 3 passed; 0 failed; 0 ignored; 0 skipped (0.51s)
  • d3d12_create_committed_resource — 2 passed; 0 failed; 0 ignored; 0 skipped (0.46s)
  • d3d12_create_reserved_resource — 3 passed; 0 failed; 0 ignored; 0 skipped (0.45s)
    All run on the physical NVIDIA RTX 3060 adapter with zero driver errors or validation faults.

Observations

  • Verified that default_dsv selects TEXTURE2DMS / TEXTURE2DMSARRAY when SampleDesc.Count > 1 and TEXTURE1D / TEXTURE1DARRAY when Dimension == 2, preventing dimension-mismatch rejections (E_INVALIDARG / device removal) when titles create default DSVs on typeless depth buffers.
  • pc_dsv correctly maps DXGI_FORMAT_UNKNOWN on typeless depth allocations (19 -> 20, 39 -> 40, 44 -> 45, 53 -> 55) and handles D16_UNORM (55) over R24G8_TYPELESS (44) by translating to D24_UNORM_S8_UINT, avoiding invalid format incompatibilities on native D3D12 devices.

AI disclosure: Testing executed independently on physical hardware; report drafted with agent assistance.

<!-- greyfinch-sync:ivall/xcl:comment:7250977122 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3280#issuecomment-7250977122). Originally posted by [Lum7nt](https://github.com/Lum7nt) on 2026-11-29T04:59:00Z. --- ### Native Windows 11 + NVIDIA RTX 3060 verification of PR #3280 Tested PR #3280 head `035b2b290ed1853cae4ae74f14b46babd027bc32` on native Windows 11 on NVIDIA RTX 3060 (12 GB, native wave32). ### Environment - **GPU:** NVIDIA GeForce RTX 3060 (12 GB / 12,115 MiB VRAM), driver `32.0.15.8142` (WDDM 3.2) - **CPU / RAM / OS:** Intel Core i5-10400 CPU @ 2.90GHz (6C / 12T), 32 GB RAM, Windows 11 Build 22631 (NT 10.0.22631.0) - **Toolchain:** `rustc 1.100.0 (0ef1bc386 2026-11-09)` x86_64-pc-windows-msvc, Windows SDK DXC `1.8.2502.11` / dxil `1.8.2502.11` ### Test Results 1. **Targeted DSV Tests (`hle::d3d12x::real::dsv_tests`):** ```powershell cargo test -p xcl --lib -- hle::d3d12x::real::dsv_tests:: --nocapture ``` - `default_dsv_handles_msaa_and_1d_depth_resources` — **PASS** - `dev_create_dsv_x_msaa_and_unknown_format_on_typeless_depth_succeeds_on_warp` — **PASS** (verified under isolated process with D3D12 debug layer enabled; `GetDeviceRemovedReason() == S_OK`, 0 debug layer errors) **Result:** **2 passed; 0 failed; 0 ignored; 0 skipped** (0.09s). 2. **D3D12 Resource Creation Test Suite Integration:** ```powershell cargo test -p xcl --test d3d12_create_placed_resource cargo test -p xcl --test d3d12_create_committed_resource cargo test -p xcl --test d3d12_create_reserved_resource ``` - `d3d12_create_placed_resource` — **3 passed; 0 failed; 0 ignored; 0 skipped** (0.51s) - `d3d12_create_committed_resource` — **2 passed; 0 failed; 0 ignored; 0 skipped** (0.46s) - `d3d12_create_reserved_resource` — **3 passed; 0 failed; 0 ignored; 0 skipped** (0.45s) All run on the physical NVIDIA RTX 3060 adapter with zero driver errors or validation faults. ### Observations - Verified that `default_dsv` selects `TEXTURE2DMS` / `TEXTURE2DMSARRAY` when `SampleDesc.Count > 1` and `TEXTURE1D` / `TEXTURE1DARRAY` when `Dimension == 2`, preventing dimension-mismatch rejections (`E_INVALIDARG` / device removal) when titles create default DSVs on typeless depth buffers. - `pc_dsv` correctly maps `DXGI_FORMAT_UNKNOWN` on typeless depth allocations (`19 -> 20`, `39 -> 40`, `44 -> 45`, `53 -> 55`) and handles `D16_UNORM` (`55`) over `R24G8_TYPELESS` (`44`) by translating to `D24_UNORM_S8_UINT`, avoiding invalid format incompatibilities on native D3D12 devices. *AI disclosure: Testing executed independently on physical hardware; report drafted with agent assistance.*
andrewDoing commented 2026-11-29 05:09:20 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by andrewDoing on 2026-11-29T05:09:20Z.


On 035b2b290ed1853cae4ae74f14b46babd027bc32, the corrected default and explicit DSVs produced the same depth samples as fully typed native reference views on RTX 5070 (616.92), in three fresh-process runs.

I created two 64×64, three-slice, 4× MSAA D24S8 textures through the console committed-resource hook and checked both native resources were R24G8_TYPELESS. For the first resource, dev_create_dsv_x received a null descriptor for the full view, then a TEXTURE2DMSARRAY descriptor with UNKNOWN format selecting only slice 1. On the reference resource I used native D24_UNORM_S8_UINT descriptors that explicitly selected all three slices and then slice 1. Each resource was cleared to 0.25 through its full view, then to 0.75 through its middle-slice view.

After transitioning the resources to shader-read state, a compute shader loaded all four samples at (7,13) on each slice. All 12 XCL samples matched the native reference exactly on every run: the outer slices held 0.25000003 and the middle slice held 0.75. The queue fence completed and the device remained healthy.

The null-descriptor MSAA dimension correction overlaps #1087. The explicit UNKNOWN-format middle-slice control additionally exercises this PR's format resolution and preservation of its slice bounds. This was a synthetic GPU test. I did not run Minecraft or a retail title, or measure the 1D or stencil paths.

AI-assisted fixture and verification.

<!-- greyfinch-sync:ivall/xcl:comment:7251083310 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3280#issuecomment-7251083310). Originally posted by [andrewDoing](https://github.com/andrewDoing) on 2026-11-29T05:09:20Z. --- On `035b2b290ed1853cae4ae74f14b46babd027bc32`, the corrected default and explicit DSVs produced the same depth samples as fully typed native reference views on RTX 5070 (616.92), in three fresh-process runs. I created two 64×64, three-slice, 4× MSAA D24S8 textures through the console committed-resource hook and checked both native resources were R24G8_TYPELESS. For the first resource, `dev_create_dsv_x` received a null descriptor for the full view, then a TEXTURE2DMSARRAY descriptor with UNKNOWN format selecting only slice 1. On the reference resource I used native D24_UNORM_S8_UINT descriptors that explicitly selected all three slices and then slice 1. Each resource was cleared to 0.25 through its full view, then to 0.75 through its middle-slice view. After transitioning the resources to shader-read state, a compute shader loaded all four samples at (7,13) on each slice. All 12 XCL samples matched the native reference exactly on every run: the outer slices held 0.25000003 and the middle slice held 0.75. The queue fence completed and the device remained healthy. The null-descriptor MSAA dimension correction overlaps [#1087](https://github.com/xcl-dev/xcl/pull/1087). The explicit UNKNOWN-format middle-slice control additionally exercises this PR's format resolution and preservation of its slice bounds. This was a synthetic GPU test. I did not run Minecraft or a retail title, or measure the 1D or stencil paths. AI-assisted fixture and verification.
Foniass commented 2026-11-29 14:56:45 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Foniass on 2026-11-29T14:56:45Z.


merge-check
base: fa204595a488c60c6c5f905244f0172072c9c2a9
head: 035b2b290ed1853cae4ae74f14b46babd027bc32
merge: clean
build: cargo build --workspace -> ok
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> the first run's lib binary aborted early with STATUS_ACCESS_VIOLATION (in gpu::dxil / gpu::agility tests, nothing near the PR; cause not found); lib rerun: 2467 passed, 4 failed, 29 ignored; SKIPPED: 38; a second lib rerun ended with the known UMA mixed-window exit 0x7C10003 (what #3187 fixes); failing: gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_0..3 (driver E_OUTOFMEMORY at seeds 70/545/1019/1507; they fail on base on this machine too)
review: no bug found in the diff. It overlaps the open #1087 (the same MSAA default-DSV fix). A D16 view on an R24G8 buffer becomes D24S8; the code comment says so, the PR text does not. The smoke title may not reach the MSAA or 1D paths.
performance: 60 s smoke on the merged tree: 1679 frames (99.9 % of main), peak commit 16844 MB (99.3 %), no removal, no crash
verdict: not yet: settle the overlap with #1087 first (close one); the code itself looks safe
hardware / tool and model: RTX 5070 Ti (driver 32.0.16.2114), Ryzen 7 7800X3D, Windows 11 26300 / Claude Code with Claude Opus 5.5

Merge-check run and written with Claude Code (Claude Opus 5.5): a test merge onto the base above, the full suite, and a 60 s scripts/smoke.ps1 run of a retail title against main on the same machine. The 4 fuzz_validate_and_gpu_* failures happen on main on this machine too.

<!-- greyfinch-sync:ivall/xcl:comment:7257697971 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3280#issuecomment-7257697971). Originally posted by [Foniass](https://github.com/Foniass) on 2026-11-29T14:56:45Z. --- ```text merge-check base: fa204595a488c60c6c5f905244f0172072c9c2a9 head: 035b2b290ed1853cae4ae74f14b46babd027bc32 merge: clean build: cargo build --workspace -> ok tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> the first run's lib binary aborted early with STATUS_ACCESS_VIOLATION (in gpu::dxil / gpu::agility tests, nothing near the PR; cause not found); lib rerun: 2467 passed, 4 failed, 29 ignored; SKIPPED: 38; a second lib rerun ended with the known UMA mixed-window exit 0x7C10003 (what #3187 fixes); failing: gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_0..3 (driver E_OUTOFMEMORY at seeds 70/545/1019/1507; they fail on base on this machine too) review: no bug found in the diff. It overlaps the open #1087 (the same MSAA default-DSV fix). A D16 view on an R24G8 buffer becomes D24S8; the code comment says so, the PR text does not. The smoke title may not reach the MSAA or 1D paths. performance: 60 s smoke on the merged tree: 1679 frames (99.9 % of main), peak commit 16844 MB (99.3 %), no removal, no crash verdict: not yet: settle the overlap with #1087 first (close one); the code itself looks safe hardware / tool and model: RTX 5070 Ti (driver 32.0.16.2114), Ryzen 7 7800X3D, Windows 11 26300 / Claude Code with Claude Opus 5.5 ``` Merge-check run and written with Claude Code (Claude Opus 5.5): a test merge onto the base above, the full suite, and a 60 s `scripts/smoke.ps1` run of a retail title against main on the same machine. The 4 `fuzz_validate_and_gpu_*` failures happen on main on this machine too.
bmjask commented 2026-12-01 20:43:27 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by bmjask on 2026-12-01T20:43:27Z.

Review: COMMENTED


Review of 035b2b29: 2 finding(s). 1 are inline. These are on lines outside the diff:

crates/xcl/src/hle/d3d12x/real.rs:3204: The 1D fix only covers DSVs. pc_srv's default-view (None) branch ignores rd.Dimension, so CreateShaderResourceView(res, NULL) on a 1D typeless depth buffer (D32_FLOAT with ALLOW_DEPTH_STENCIL becomes R32_TYPELESS) still sends ViewDimension=TEXTURE2D for a TEXTURE1D resource. That's the same mismatch and device removal the PR describes.


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.

<!-- greyfinch-sync:ivall/xcl:review:6139815090 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3280#pullrequestreview-6139815090). Originally posted by [bmjask](https://github.com/bmjask) on 2026-12-01T20:43:27Z. **Review:** COMMENTED --- Review of `035b2b29`: 2 finding(s). 1 are inline. These are on lines outside the diff: **`crates/xcl/src/hle/d3d12x/real.rs:3204`**: The 1D fix only covers DSVs. `pc_srv`'s default-view (None) branch ignores `rd.Dimension`, so `CreateShaderResourceView(res, NULL)` on a 1D typeless depth buffer (D32_FLOAT with ALLOW_DEPTH_STENCIL becomes R32_TYPELESS) still sends ViewDimension=TEXTURE2D for a TEXTURE1D resource. That's the same mismatch and device removal the PR describes. --- _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._
bmjask commented 2026-12-01 20:43:28 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by bmjask on 2026-12-01T20:43:28Z.

Code review location: crates/xcl/src/hle/d3d12x/real.rs; line 3148

@@ -3126,23 +3119,72 @@ unsafe extern "system" fn dev_create_dsv_x(this: *mut c_void, res: *mut c_void,
     super::depth_uav::note_dsv(cpu as usize, res as usize, flags);
 }
 
+/// The typed depth format for a depth buffer that `device_x::pc_resource_desc` made typeless.
+fn typeless_depth_format(fmt: i32) -> Option<i32> {
+    match fmt {
+        19 => Some(20), // R32G8X24_TYPELESS -> D32_FLOAT_S8X24_UINT
+        39 => Some(40), // R32_TYPELESS -> D32_FLOAT
+        44 => Some(45), // R24G8_TYPELESS -> D24_UNORM_S8_UINT
+        53 => Some(55), // R16_TYPELESS -> D16_UNORM
+        _ => None,
+    }
+}
+
+/// Resolve a console DSV description (or NULL for the resource's default view) for PC D3D12:
+/// translates console target formats, resolves `DXGI_FORMAT_UNKNOWN` (and `D16_UNORM` on a
+/// `D16_UNORM_S8_UINT` -> `R24G8_TYPELESS` buffer) against the resource's PC format, and builds
+/// an explicit default DSV matching MSAA / 1D / 2D / array dimensions when the resource is typeless.
+fn pc_dsv(rd: Option<&D3D12_RESOURCE_DESC>, desc: Option<&D3D12_DEPTH_STENCIL_VIEW_DESC>) -> Option<D3D12_DEPTH_STENCIL_VIEW_DESC> {
+    use windows::Win32::Graphics::Dxgi::Common::DXGI_FORMAT;
+    match desc {
+        Some(d) => {
+            let mut c = *d;
+            let mut fmt = super::device_x::pc_target_format(c.Format.0 as u32) as i32;
+            if let Some(r) = rd {
+                if fmt == 0 {
+                    if let Some(df) = typeless_depth_format(r.Format.0) {
+                        fmt = df;
+                    }
+                } else if r.Format.0 == 44 && fmt == 55 {

This turns a D16_UNORM (55) DSV over an R24G8_TYPELESS buffer into D24_UNORM_S8_UINT (45), but PSOs still get DSVFormat 55. The PSO paths (pc_topology_type ~10086, translated_mesh_stream ~9835, the stand-in stream ~9940) go through device_x::pc_view_format, which only maps 118-120. A title that renders through a D16_UNORM view of a D16_UNORM_S8_UINT (118) buffer with a D16_UNORM PSO, which is consistent on the console, now binds a D24S8 DSV against a D16 PSO. The debug layer reports that as a format mismatch, and on hardware it's undefined (wrong depth test/writes, possibly device removal on strict drivers). Before this PR, creating the view failed instead. The WARP test never binds a PSO, so it can't catch this.

<!-- greyfinch-sync:ivall/xcl:review-comment:4760713616 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3280#discussion_r4760713616). Originally posted by [bmjask](https://github.com/bmjask) on 2026-12-01T20:43:28Z. **Code review location:** `crates/xcl/src/hle/d3d12x/real.rs`; line 3148 ~~~~diff @@ -3126,23 +3119,72 @@ unsafe extern "system" fn dev_create_dsv_x(this: *mut c_void, res: *mut c_void, super::depth_uav::note_dsv(cpu as usize, res as usize, flags); } +/// The typed depth format for a depth buffer that `device_x::pc_resource_desc` made typeless. +fn typeless_depth_format(fmt: i32) -> Option<i32> { + match fmt { + 19 => Some(20), // R32G8X24_TYPELESS -> D32_FLOAT_S8X24_UINT + 39 => Some(40), // R32_TYPELESS -> D32_FLOAT + 44 => Some(45), // R24G8_TYPELESS -> D24_UNORM_S8_UINT + 53 => Some(55), // R16_TYPELESS -> D16_UNORM + _ => None, + } +} + +/// Resolve a console DSV description (or NULL for the resource's default view) for PC D3D12: +/// translates console target formats, resolves `DXGI_FORMAT_UNKNOWN` (and `D16_UNORM` on a +/// `D16_UNORM_S8_UINT` -> `R24G8_TYPELESS` buffer) against the resource's PC format, and builds +/// an explicit default DSV matching MSAA / 1D / 2D / array dimensions when the resource is typeless. +fn pc_dsv(rd: Option<&D3D12_RESOURCE_DESC>, desc: Option<&D3D12_DEPTH_STENCIL_VIEW_DESC>) -> Option<D3D12_DEPTH_STENCIL_VIEW_DESC> { + use windows::Win32::Graphics::Dxgi::Common::DXGI_FORMAT; + match desc { + Some(d) => { + let mut c = *d; + let mut fmt = super::device_x::pc_target_format(c.Format.0 as u32) as i32; + if let Some(r) = rd { + if fmt == 0 { + if let Some(df) = typeless_depth_format(r.Format.0) { + fmt = df; + } + } else if r.Format.0 == 44 && fmt == 55 { ~~~~ --- This turns a D16_UNORM (55) DSV over an R24G8_TYPELESS buffer into D24_UNORM_S8_UINT (45), but PSOs still get DSVFormat 55. The PSO paths (pc_topology_type ~10086, translated_mesh_stream ~9835, the stand-in stream ~9940) go through `device_x::pc_view_format`, which only maps 118-120. A title that renders through a D16_UNORM view of a D16_UNORM_S8_UINT (118) buffer with a D16_UNORM PSO, which is consistent on the console, now binds a D24S8 DSV against a D16 PSO. The debug layer reports that as a format mismatch, and on hardware it's undefined (wrong depth test/writes, possibly device removal on strict drivers). Before this PR, creating the view failed instead. The WARP test never binds a PSO, so it can't catch this.
Kalmarv commented 2026-12-02 20:51:56 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Kalmarv on 2026-12-02T20:51:56Z.


Superseded by #3731, which consolidates #3319 and #3280 on crates/xcl/src/hle/d3d12x/real.rs (dropping the #1087 MSAA overlap and addressing all review findings from both PRs).

AI use: Antigravity (Gemini 4 Neon) consolidated these PRs and posted this closing note.

<!-- greyfinch-sync:ivall/xcl:comment:7358439821 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3280#issuecomment-7358439821). Originally posted by [Kalmarv](https://github.com/Kalmarv) on 2026-12-02T20:51:56Z. --- Superseded by #3731, which consolidates #3319 and #3280 on `crates/xcl/src/hle/d3d12x/real.rs` (dropping the #1087 MSAA overlap and addressing all review findings from both PRs). AI use: Antigravity (Gemini 4 Neon) consolidated these PRs and posted this closing note.

Pull request closed

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!3280
No description provided.