GPU: a typed depth format in a shader resource view is made in the readable colour format #2292
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2294"
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 Marvisak/VIctory. Originally posted by denkencar-sketch on 2026-11-25T10:05:20Z.
Summary
The host refuses a depth format for a shader resource view, but the view of a typeless depth texture took the title's format. A typed depth format in a shader resource view is now made in the matching readable colour format (depth 20/40/45/55 map to 21/41/46/56).
fits()is only used for SRV/UAV, and a depth texture cannot carry a UAV. The branch has a second, comment-only commit that keeps two doc comments with their items.Testing
Test
depth_formats_in_shader_resource_views_are_made_readablefails onmainand passes with this change.cargo test --workspace --lockedpasses apart from known flakes:modules::dstorage::tests::a_page_list_filled_after_its_request_startsfails now and then onmaintoo, and so does a parallel-run flake invictory-gpu's lib tests (watch::anddescriptor::host::tests, 2 of 40 runs on pristinemain).Not tried: a run in the game, or the D3D12 debug layer rejecting a D32_FLOAT SRV.
AI-assisted.
Imported from Marvisak/VIctory. Originally posted by catminou4 on 2026-11-25T10:19:12Z.
Review: COMMENTED
Typed depth formats in shader resource views made readable (DEPTH_READABLE mapping). Static review only: victory-gpu/victory-hle are Windows-only (D3D12/windows-sys); not compiled or tested on this macOS arm64 host. rustc 1.98.1.
Imported from Marvisak/VIctory. Originally posted by steven-seagull27 on 2026-11-25T10:48:26Z.
I checked the D3D12 depth-SRV question on
298a0067againstmain940d32f6. On an RTX 5080 (621.40) and built-in Microsoft WARP (10.0.26100.10068), all four SRV formats selected by the PR were accepted by the D3D12 debug layer and returned the expected depth samples. Windows 11 build 26300.10075, separate hardware and WARP processes.The probe created a real 4×4 typeless depth resource in each family, passed its typed depth format through the runtime's
fits, and used the selected format to create a shader resource view. Two depth clears wrote 0.75 to the left half and 0.25 to the right. A compute shader loaded every texel through that SRV into a readback buffer. The D32 variants returned exact floats. D16 returned about 0.7499962 and 0.2500038, within one UNORM step.On pristine
main,fitsretained all four typed depth formats. Both adapters reported shader loads unsupported for those four selections. In a separate creation-only baseline check, both debug layers explicitly rejected the first selection,D32_FLOAT_S8X24_UINT, with message 28 (CREATESHADERRESOURCEVIEW_INVALIDFORMAT) before any dispatch. Using the explicit readable SRV formats as a positive control onmaingave 64/64 correct samples per adapter. This covers the depth plane and descriptor creation with synthetic data. The game and stencil-plane reads were outside this test.Reproduction on Windows. I put the opt-in readback in a single source-only commit on this PR head. This version creates the title’s SRV through the production descriptor path. It compiles its shader at test time. From the PR branch at
298a0067, with Windows Graphics Tools installed, run in PowerShell:I ran these Cargo invocations on the published commit. Each process printed its real adapter name and four
16/16readbacks, for 64/64 on the RTX and 64/64 on WARP.Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T14:52:00Z.
Automated triage for the maintainers.
Merge candidate (worth a look). Rebased onto current
main. Infits(crates/victory-gpu/src/descriptor/host.rs), a shader resource view described in a typed depth format is made in the matching readable format (DEPTH_READABLE: D32_FLOAT_S8X24_UINT -> R32_FLOAT_X8X24_TYPELESS, D32_FLOAT -> R32_FLOAT, D24_UNORM_S8_UINT -> R24_UNORM_X8_TYPELESS, D16_UNORM -> R16_UNORM). I checked these against the public DXGI format list: D3D12 does not allow depth formats in an SRV, and these are the documented readable equivalents. UAVs are left alone. The new testdepth_formats_in_shader_resource_views_are_made_readablecovers it. CIcheckpasses and it merges cleanly.On your reply: the two updated expectations in
placed_uav_textures_create_real_host_uavs(R32_TYPELESS + D32_FLOATandR16_TYPELESS + D16_UNORMnow make real views instead of the null fallback) follow from this change.Generated by Claude Code
Imported from Marvisak/VIctory. Originally posted by denkencar-sketch on 2026-11-25T23:25:22Z.
Rebased onto current \main\ (\
842b0cb) and updated the two \R32_TYPELESS + D32_FLOAT\ / \R16_TYPELESS + D16_UNORM\ expectations in \placed_uav_textures_create_real_host_uavs\ (added by #1273) now that those SRVs create real readable host views without D3D12 errors. \descriptor::host::tests\ (16/16) and \clippy\ pass.Imported from Marvisak/VIctory. Originally posted by fuzeofficlal on 2026-11-26T19:44:47Z.
Review: APPROVED
Reviewed and verified
3968b02a51f462dc2a5f757312709aeeef6ec1cfmerged ontoorigin/main(63bcca43c6a00a758510398fa43096ce7e4f7df0) on Windows 11 x64 (RTX 5090 + Microsoft WARP,--features diagnosticswithVICTORY_D3D12_DEBUG=1, Rust 1.98.1 MSVC).Code Audit
fits(crates/victory-gpu/src/descriptor/host.rs:1339, 1380-1390), rewriting typed depth SRV formats viaDEPTH_READABLE(20 -> 21,40 -> 41,45 -> 46,55 -> 56) only when!unorderedproduces the valid D3D12 readable colour formats for typeless depth textures while keeping depth UAVs rejected and stencil SRVs (22,47) untouched.srv_desc(L950-952) runsresource::pc_formatbeforehand, console 16-bit depth/stencil (118) maps118 -> 20 -> 21(DXGI_FORMAT_R32_FLOAT_X8X24_TYPELESS) through the same path, andDENY_SHADER_RESOURCEdepth textures remain refused atL1357.placed_uav_textures_create_real_host_uavs(L2481-2482) align cleanly with the new behavior.Local Verification
cargo xtask policy— pass (191 files ok).cargo clippy --locked -p victory-gpu --all-targets -- -D warnings(default and--all-features) — 0 warnings.cargo test --locked -p victory-gpu --features diagnostics --libfordepth_formats_in_shader_resource_views_are_made_readableandplaced_uav_textures_create_real_host_uavs(RTX 5090 and WARP) — passed.CreateShaderResourceViewprobe through productionmake_viewunderVICTORY_D3D12_DEBUG=1: tested all 5 title depth formats (20,40,45,55, and console118) with both explicit depth format andDXGI_FORMAT_UNKNOWN (0), stencil SRVs (22and47withPlaneSlice = 1), and negative controls (unordered = trueUAV andDENY_SHADER_RESOURCEdepth texture) — all passed on both RTX 5090 and WARP withGetDeviceRemovedReason() == Ok(())and 0ID3D12InfoQueuemessages.Looks good to merge.
Imported from Marvisak/VIctory. Originally posted by Dukestar69 on 2026-11-26T22:10:28Z.
Review: APPROVED
LGTM — verified on RTX 5090 (Windows / D3D12) against
origin/main(63bcca4).D32_FLOAT_S8X24_UINT,D32_FLOAT,D24_UNORM_S8_UINT,D16_UNORM) to their readable SRV color formats infits()avoids falling back to null descriptors when shaders sample depth textures.cargo test -p victory-gpu --lib descriptor::host::tests:: -- --skip dynamic_slots_are_held_until_released --test-threads=1: 15 passed, 0 failed (includingdepth_formats_in_shader_resource_views_are_made_readable).cargo clippy -p victory-gpu --all-targets -- -D warnings: clean.cargo xtask policy: 191 files ok.Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.