D3D12.X: fix default_dsv MSAA/1D dimensions and DXGI_FORMAT_UNKNOWN on typeless depth buffers #3280
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/3280"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from ivall/xcl. Originally posted by Kalmarv on 2026-11-29T03:41:48Z.
Fix
dev_create_dsv_xanddefault_dsvfor MSAA / 1D depth resources and explicit DSV descriptions usingDXGI_FORMAT_UNKNOWN(orD16_UNORMonD16_UNORM_S8_UINT->R24G8_TYPELESS) over depth buffers thatdevice_x::pc_resource_descrewrote to typeless formats.Previously:
default_dsvonly emittedD3D12_DSV_DIMENSION_TEXTURE2D/TEXTURE2DARRAY. CallingCreateDepthStencilView(res, NULL, cpu)on a multisampled (SampleDesc.Count > 1) or 1D depth buffer whose formatpc_resource_descmade typeless (19/39/44/53) passed a mismatchedTEXTURE2Dview dimension to D3D12, triggering a device removal (0x887A0005/DXGI_ERROR_DEVICE_REMOVED) on WARP and D3D12 debug-layer errors.CreateDepthStencilViewreceived a non-NULLD3D12_DEPTH_STENCIL_VIEW_DESCwithFormat = DXGI_FORMAT_UNKNOWN(inheriting the resource format, e.g. to setD3D12_DSV_FLAG_READ_ONLY_DEPTHor a specific mip/slice) on a depth buffer rewritten to typeless,dev_create_dsv_xforwardedDXGI_FORMAT_UNKNOWNdirectly to PC D3D12, which rejects unknown formats on typeless resources. Likewise, aD16_UNORM(55) DSV over a consoleD16_UNORM_S8_UINT(118) buffer rewritten toR24G8_TYPELESS(44) was rejected as format-incompatible.What is in it
crates/xcl/src/hle/d3d12x/real.rs:typeless_depth_format(19 -> 20,39 -> 40,44 -> 45,53 -> 55) andpc_dsv(rd, desc)(mirroringpc_srv) to translate console DSV formats, resolveDXGI_FORMAT_UNKNOWNon typeless depth buffers, mapD16_UNORMonR24G8_TYPELESStoD24_UNORM_S8_UINT, and reuse the singleGetDesc()query indev_create_dsv_x.default_dsvto selectTEXTURE1D/TEXTURE1DARRAYfor 1D resources andTEXTURE2DMS/TEXTURE2DMSARRAYwhenSampleDesc.Count > 1.default_dsv_handles_msaa_and_1d_depth_resourcesand child-process-isolated WARP + D3D12 debug-layer testdev_create_dsv_x_msaa_and_unknown_format_on_typeless_depth_succeeds_on_warp.Tested
rustc 1.99.0 (b940084d7 2026-09-28), DXC 1.9 (XCL_DXC_DIR), debug for tests and release forxcl-smoke.cargo test -p xcl --lib -- hle::d3d12x::real::dsv_tests:: --nocapture): both new tests failed before the fix (the WARP test hit0x887A0005DXGI_ERROR_DEVICE_REMOVEDafter the NULL/unknown-format MSAA DSV calls); after the fix,2 passed, 0 failed(0.09s,0D3D12 debug-layer errors,GetDeviceRemovedReason() == S_OK,0skips).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.SKIPPEDGPU tests on this wave32 adapter (26 total across--nocaptureworkspace baseline): 21no wave64(RTX 5070 Ti is wave32), 3 wave32 per-lane#1426f16/cvt-f16 refusals, 2no heap windows(opt-inXCL_HEAP_WINDOWS=1).ea3b5e4d) 150 s regression run below (0device removals,0crashes,1916frames vs1695onmain,30536 MBpeak commit vs31546 MBonmain).Regression run
Not tested
ea3b5e4dsmoke is a regression check; MSAA NULL/unknown-format andD16_UNORM-on-R24G8_TYPELESSDSV creation is verified on WARP under the D3D12 debug layer).uma_driver::tests::(skipped locally due to pre-existing0x7C10003exit on NVIDIA) andtest_title_runs_and_game_folder_is_untouched.AI use
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
035b2b290ed1853cae4ae74f14b46babd027bc32on native Windows 11 on NVIDIA RTX 3060 (12 GB, native wave32).Environment
32.0.15.8142(WDDM 3.2)rustc 1.100.0 (0ef1bc386 2026-11-09)x86_64-pc-windows-msvc, Windows SDK DXC1.8.2502.11/ dxil1.8.2502.11Test Results
hle::d3d12x::real::dsv_tests):default_dsv_handles_msaa_and_1d_depth_resources— PASSdev_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).
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
default_dsvselectsTEXTURE2DMS/TEXTURE2DMSARRAYwhenSampleDesc.Count > 1andTEXTURE1D/TEXTURE1DARRAYwhenDimension == 2, preventing dimension-mismatch rejections (E_INVALIDARG/ device removal) when titles create default DSVs on typeless depth buffers.pc_dsvcorrectly mapsDXGI_FORMAT_UNKNOWNon typeless depth allocations (19 -> 20,39 -> 40,44 -> 45,53 -> 55) and handlesD16_UNORM(55) overR24G8_TYPELESS(44) by translating toD24_UNORM_S8_UINT, avoiding invalid format incompatibilities on native D3D12 devices.AI disclosure: Testing executed independently on physical hardware; report drafted with agent assistance.
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_xreceived 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.
Imported from ivall/xcl. Originally posted by Foniass on 2026-11-29T14:56:45Z.
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.ps1run of a retail title against main on the same machine. The 4fuzz_validate_and_gpu_*failures happen on main on this machine too.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 ignoresrd.Dimension, soCreateShaderResourceView(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.
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 3148This 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.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.
Pull request closed