Repository navigation
Conversation
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 |
|
merge-check AI-written and posted by Foniass without a human check of each point. |
bmjask
left a comment
There was a problem hiding this comment.
Review of ea2aead7: 4 finding(s). 4 are inline.
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.
| c.Format = windows::Win32::Graphics::Dxgi::Common::DXGI_FORMAT(super::device_x::pc_shader_view_format(rf, c.Format.0 as u32) as i32); | ||
| } else if view_dim_to_image_type(c.ViewDimension.0).is_some() { | ||
| let mapped = super::device_x::pc_uav_linear_format(super::device_x::pc_target_format(c.Format.0 as u32)); | ||
| let fmt = if mapped == 0 || !super::device_x::pc_typed_uav_supported(this, mapped as i32) { |
There was a problem hiding this comment.
The null image UAV fallback relies on pc_typed_uav_supported, which returns true when CheckFeatureSupport fails. A console-only format that pc_view_format/pc_target_format don't map (outside 116-120/86/115/67) gets E_INVALIDARG from the query, is reported as supported, and reaches CreateUnorderedAccessView unchanged, which removes the device. Typeless formats (e.g. R8G8B8A8_TYPELESS=27) can do the same on drivers that report TYPED_UNORDERED_ACCESS_VIEW or fail the query, since a typed view in a typeless format is always invalid. A failed query should count as unsupported.
| } else if view_dim_to_image_type(c.ViewDimension.0).is_some() { | ||
| let mapped = super::device_x::pc_uav_linear_format(super::device_x::pc_target_format(c.Format.0 as u32)); | ||
| let fmt = if mapped == 0 || !super::device_x::pc_typed_uav_supported(this, mapped as i32) { | ||
| windows::Win32::Graphics::Dxgi::Common::DXGI_FORMAT_R32_FLOAT.0 as u32 |
There was a problem hiding this comment.
When the null UAV format falls back to R32_FLOAT, the console's PlaneSlice is kept. A null Texture2D/Array UAV with PlaneSlice=1 and a depth/stencil format becomes R32_FLOAT with plane 1, which is out of range for a one-plane format, so the debug layer reports it and the device can be removed. The SRV branch has the same issue when a non-stencil format keeps PlaneSlice != 0.
| && view_dim_to_image_type(c.ViewDimension.0).is_some() | ||
| { | ||
| c.Format = windows::Win32::Graphics::Dxgi::Common::DXGI_FORMAT_R32_FLOAT; | ||
| if res.is_null() && view_dim_to_image_type(c.ViewDimension.0).is_some() { |
There was a problem hiding this comment.
The null SRV sanitizer only rewrites depth-family typeless and depth formats. Color and BC typeless formats fall through f => f, so a null Texture2D SRV with R8G8B8A8_TYPELESS (27), R16G16B16A16_TYPELESS (9) or BC1_TYPELESS (70) still reaches CreateShaderResourceView typeless. D3D12 rejects that with the same 0x887A0001 removal this PR is meant to stop.
| let rf = ID3D12Resource::from_raw_borrowed(&res).map_or(0, |r| r.GetDesc().Format.0 as u32); | ||
| c.Format = windows::Win32::Graphics::Dxgi::Common::DXGI_FORMAT(super::device_x::pc_shader_view_format(rf, c.Format.0 as u32) as i32); | ||
| let f = if res.is_null() { | ||
| match super::device_x::pc_target_format(c.Format.0 as u32) { |
There was a problem hiding this comment.
The null RTV path only applies pc_target_format plus UNKNOWN->RGBA8, so depth, typeless and non-renderable formats pass through. A null RTV with D24_UNORM_S8_UINT (45), console D16S8 (118, which pc_target_format maps to 45) or R8G8B8A8_TYPELESS (27) reaches CreateRenderTargetView with a format that can't be an RTV, and the device is removed. The SRV path in this PR does sanitize depth formats; the RTV path doesn't.
Sanitize null-resource (
pResource == NULL) SRV, image UAV, and RTV formats incrates/xcl/src/hle/d3d12x/real.rsso console depth/stencil, sRGB, promoted target, and host-unsupported formats never triggerDXGI_ERROR_INVALID_CALL(0x887A0001) device removal on PC D3D12.What is in it
crates/xcl/src/hle/d3d12x/real.rs:dev_create_srv_inner: whenres.is_null()for an image SRV dimension, map depth and depth-typeless formats (D16_UNORM_S8_UINT->D24_UNORM_S8_UINT->R24_UNORM_X8_TYPELESS,D32_FLOAT/R32_TYPELESS->R32_FLOAT,D16_UNORM/R16_TYPELESS->R16_UNORM,D32_FLOAT_S8X24_UINT/R32G8X24_TYPELESS->R32_FLOAT_X8X24_TYPELESS) in addition toUNKNOWN->R32_FLOAT, and setPlaneSlice = 1for nullTexture2D/Texture2DArraystencil SRVs (X24_TYPELESS_G8_UINT,X32_TYPELESS_G8X24_UINT).dev_create_uav_x: whenres.is_null()for an image UAV dimension, map throughpc_target_formatandpc_uav_linear_formatand fall back toDXGI_FORMAT_R32_FLOATwhen the result isUNKNOWNor lacks hostTYPED_UNORDERED_ACCESS_VIEWsupport (pc_typed_uav_supported), leaving null buffer UAVs untouched.dev_create_rtv: whenres.is_null(), map throughpc_target_format(promotingB5G5R5A1_UNORM/B4G4R4A4_UNORM->R8G8B8A8_UNORMandR9G9B9E5_SHAREDEXP->R11G11B10_FLOAT) and mapUNKNOWNtoR8G8B8A8_UNORM.null_view_format_tests::null_srv_uav_and_rtv_sanitize_console_and_incompatible_formatscovering 11 null SRV cases, 11 null image UAV cases, and 4 null RTV cases and asserting zero D3D12 debug-layer errors and no device removal.Tested
cargo test -p xcl --lib -- hle::d3d12x::real::null_view_format_tests::):fmt=118, mapped toD24_UNORM_S8_UINT) with D3D12 debug-layer[id=28] ID3D12Device::CreateShaderResourceView: The format (0x2d, D24_UNORM_S8_UINT) cannot be used with a ShaderResource viewand[id=232] ID3D12Device::RemoveDevice (DXGI_ERROR_INVALID_CALL).1 passed; 0 failed(0.18s, zero debug-layer errors across all 26 null SRV/UAV/RTV cases).rustc 1.99.0, RTX 5070 Ti driver32.0.16.1074, DXC1.9.2609.5):cargo test --workspace -j 2 -- --test-threads=4 --skip test_title_runs_and_game_folder_is_untouched --skip uma_driver::tests::2600 passed; 0 failed; 49 ignored(301.6s).SKIPPED:1(1no heap windows).Regression run
Baseline (
mainancestorf0e8fdd5c3942ddd399d5ee11384c8595c5aacff) and this PR (ea2aead7aadaa1505eb83c4a92a1832ee51e8baa), 150 s on RTX 5070 Ti:Not tested
*_TYPELESSformats on null SRVs or null RTVs.test_title_runs_and_game_folder_is_untouchedanduma_driver::tests::were skipped in the workspace test run.AI use