GPU: a typed depth format in a shader resource view is made in the readable colour format #2294

Open
github-bot wants to merge 2 commits from github-bot/gh-2294 into main AGit
Owner

@⁠denkencar-sketch on GitHub · 2026-11-25 10:05 UTC · original
denkencar-sketch:fix/dhost-004 → main · +44 −3 · 1 files · 2 commits · open

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_readable fails on main and passes with this change. cargo test --workspace --locked passes apart from known flakes: modules::dstorage::tests::a_page_list_filled_after_its_request_starts fails now and then on main too, and so does a parallel-run flake in victory-gpu's lib tests (watch:: and descriptor::host:: tests, 2 of 40 runs on pristine main).

Not tried: a run in the game, or the D3D12 debug layer rejecting a D32_FLOAT SRV.

AI-assisted.

**@⁠denkencar-sketch** on GitHub · 2026-11-25 10:05 UTC · [original](https://github.com/Marvisak/VIctory/pull/2294) `denkencar-sketch:fix/dhost-004` → `main` · +44 −3 · 1 files · 2 commits · open ## 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_readable` fails on `main` and passes with this change. `cargo test --workspace --locked` passes apart from known flakes: `modules::dstorage::tests::a_page_list_filled_after_its_request_starts` fails now and then on `main` too, and so does a parallel-run flake in `victory-gpu`'s lib tests (`watch::` and `descriptor::host::` tests, 2 of 40 runs on pristine `main`). Not tried: a run in the game, or the D3D12 debug layer rejecting a D32_FLOAT SRV. AI-assisted.
The host refuses a depth format for a shader resource view; the view of a
typeless depth texture took the title's.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 05:01:18 +00:00
Author
Owner

@⁠steven-seagull27 on GitHub · 2026-11-25 10:48 UTC · original · edited 2026-11-25 10:55 UTC

I checked the D3D12 depth-SRV question on 298a0067 against main 940d32f6. 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.

Guest depth format SRV format selected by the PR RTX 5080 samples correct WARP samples correct
D32_FLOAT_S8X24_UINT R32_FLOAT_X8X24_TYPELESS 16/16 16/16
D32_FLOAT R32_FLOAT 16/16 16/16
D24_UNORM_S8_UINT R24_UNORM_X8_TYPELESS 16/16 16/16
D16_UNORM R16_UNORM 16/16 16/16

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, fits retained 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 on main gave 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:

git fetch https://github.com/steven-seagull27/VIctory.git refs/heads/codex/pr2294-depth-srv-readback
git cherry-pick 53a1725153001bacaa2e91d3988eac5017f7a787
$env:VICTORY_D3D12_DEBUG = '1'
foreach ($warp in '0', '1') {
    $env:VICTORY_D3D12_WARP = $warp
    cargo test --locked -p victory-gpu --lib --features diagnostics draw::tests::typed_depth_srvs_read_the_rendered_depth -- --exact --ignored --nocapture --test-threads=1
    if ($LASTEXITCODE -ne 0) { break }
}

I ran these Cargo invocations on the published commit. Each process printed its real adapter name and four 16/16 readbacks, for 64/64 on the RTX and 64/64 on WARP.

**@⁠steven-seagull27** on GitHub · 2026-11-25 10:48 UTC · [original](https://github.com/Marvisak/VIctory/pull/2294#issuecomment-7160198715) · edited 2026-11-25 10:55 UTC I checked the D3D12 depth-SRV question on `298a0067` against `main` `940d32f6`. 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. | Guest depth format | SRV format selected by the PR | RTX 5080 samples correct | WARP samples correct | |---|---|---:|---:| | D32_FLOAT_S8X24_UINT | R32_FLOAT_X8X24_TYPELESS | 16/16 | 16/16 | | D32_FLOAT | R32_FLOAT | 16/16 | 16/16 | | D24_UNORM_S8_UINT | R24_UNORM_X8_TYPELESS | 16/16 | 16/16 | | D16_UNORM | R16_UNORM | 16/16 | 16/16 | 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`, `fits` retained 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 on `main` gave 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](https://github.com/steven-seagull27/VIctory/commit/53a1725153001bacaa2e91d3988eac5017f7a787). 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: ```powershell git fetch https://github.com/steven-seagull27/VIctory.git refs/heads/codex/pr2294-depth-srv-readback git cherry-pick 53a1725153001bacaa2e91d3988eac5017f7a787 $env:VICTORY_D3D12_DEBUG = '1' foreach ($warp in '0', '1') { $env:VICTORY_D3D12_WARP = $warp cargo test --locked -p victory-gpu --lib --features diagnostics draw::tests::typed_depth_srvs_read_the_rendered_depth -- --exact --ignored --nocapture --test-threads=1 if ($LASTEXITCODE -ne 0) { break } } ``` I ran these Cargo invocations on the published commit. Each process printed its real adapter name and four `16/16` readbacks, for 64/64 on the RTX and 64/64 on WARP.
Author
Owner

@⁠Marvisak on GitHub · 2026-11-25 14:52 UTC · original · edited 2026-11-26 00:23 UTC

Automated triage for the maintainers.

Merge candidate (worth a look). Rebased onto current main. In fits (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 test depth_formats_in_shader_resource_views_are_made_readable covers it. CI check passes and it merges cleanly.

On your reply: the two updated expectations in placed_uav_textures_create_real_host_uavs (R32_TYPELESS + D32_FLOAT and R16_TYPELESS + D16_UNORM now make real views instead of the null fallback) follow from this change.


Generated by Claude Code

**@⁠Marvisak** on GitHub · 2026-11-25 14:52 UTC · [original](https://github.com/Marvisak/VIctory/pull/2294#issuecomment-7165937010) · edited 2026-11-26 00:23 UTC <!-- victory-triage v1 head=3968b02a51f462dc2a5f757312709aeeef6ec1cf verdict=merge-candidate at=2026-11-26T00:23:24Z --> Automated triage for the maintainers. **Merge candidate (worth a look).** Rebased onto current `main`. In `fits` (`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 test `depth_formats_in_shader_resource_views_are_made_readable` covers it. CI `check` passes and it merges cleanly. On your reply: the two updated expectations in `placed_uav_textures_create_real_host_uavs` (`R32_TYPELESS + D32_FLOAT` and `R16_TYPELESS + D16_UNORM` now make real views instead of the null fallback) follow from this change. --- _Generated by [Claude Code](https://claude.ai/code)_
Author
Owner

@⁠denkencar-sketch on GitHub · 2026-11-25 23:25 UTC · original

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.

**@⁠denkencar-sketch** on GitHub · 2026-11-25 23:25 UTC · [original](https://github.com/Marvisak/VIctory/pull/2294#issuecomment-7177538316) 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.
Author
Owner

@⁠catminou4 on GitHub · 2026-11-25 10:19 UTC · original · reviewed

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.

**@⁠catminou4** on GitHub · 2026-11-25 10:19 UTC · [original](https://github.com/Marvisak/VIctory/pull/2294#pullrequestreview-6055712358) · **reviewed** 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.
Author
Owner

@⁠fuzeofficlal on GitHub · 2026-11-26 19:44 UTC · original · approved these changes

Reviewed and verified 3968b02a51f462dc2a5f757312709aeeef6ec1cf merged onto origin/main (63bcca43c6a00a758510398fa43096ce7e4f7df0) on Windows 11 x64 (RTX 5090 + Microsoft WARP, --features diagnostics with VICTORY_D3D12_DEBUG=1, Rust 1.98.1 MSVC).

Code Audit

  • In fits (crates/victory-gpu/src/descriptor/host.rs:1339, 1380-1390), rewriting typed depth SRV formats via DEPTH_READABLE (20 -> 21, 40 -> 41, 45 -> 46, 55 -> 56) only when !unordered produces the valid D3D12 readable colour formats for typeless depth textures while keeping depth UAVs rejected and stencil SRVs (22, 47) untouched.
  • Because srv_desc (L950-952) runs resource::pc_format beforehand, console 16-bit depth/stencil (118) maps 118 -> 20 -> 21 (DXGI_FORMAT_R32_FLOAT_X8X24_TYPELESS) through the same path, and DENY_SHADER_RESOURCE depth textures remain refused at L1357.
  • The two updated expectations in 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 --lib for depth_formats_in_shader_resource_views_are_made_readable and placed_uav_textures_create_real_host_uavs (RTX 5090 and WARP) — passed.
  • Additional 14-case CreateShaderResourceView probe through production make_view under VICTORY_D3D12_DEBUG=1: tested all 5 title depth formats (20, 40, 45, 55, and console 118) with both explicit depth format and DXGI_FORMAT_UNKNOWN (0), stencil SRVs (22 and 47 with PlaneSlice = 1), and negative controls (unordered = true UAV and DENY_SHADER_RESOURCE depth texture) — all passed on both RTX 5090 and WARP with GetDeviceRemovedReason() == Ok(()) and 0 ID3D12InfoQueue messages.

Looks good to merge.

**@⁠fuzeofficlal** on GitHub · 2026-11-26 19:44 UTC · [original](https://github.com/Marvisak/VIctory/pull/2294#pullrequestreview-6079708193) · **approved these changes** Reviewed and verified `3968b02a51f462dc2a5f757312709aeeef6ec1cf` merged onto `origin/main` (`63bcca43c6a00a758510398fa43096ce7e4f7df0`) on Windows 11 x64 (RTX 5090 + Microsoft WARP, `--features diagnostics` with `VICTORY_D3D12_DEBUG=1`, Rust 1.98.1 MSVC). ### Code Audit - In `fits` (`crates/victory-gpu/src/descriptor/host.rs:1339, 1380-1390`), rewriting typed depth SRV formats via `DEPTH_READABLE` (`20 -> 21`, `40 -> 41`, `45 -> 46`, `55 -> 56`) only when `!unordered` produces the valid D3D12 readable colour formats for typeless depth textures while keeping depth UAVs rejected and stencil SRVs (`22`, `47`) untouched. - Because `srv_desc` (`L950-952`) runs `resource::pc_format` beforehand, console 16-bit depth/stencil (`118`) maps `118 -> 20 -> 21` (`DXGI_FORMAT_R32_FLOAT_X8X24_TYPELESS`) through the same path, and `DENY_SHADER_RESOURCE` depth textures remain refused at `L1357`. - The two updated expectations in `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 --lib` for `depth_formats_in_shader_resource_views_are_made_readable` and `placed_uav_textures_create_real_host_uavs` (RTX 5090 and WARP) — passed. - Additional 14-case `CreateShaderResourceView` probe through production `make_view` under `VICTORY_D3D12_DEBUG=1`: tested all 5 title depth formats (`20`, `40`, `45`, `55`, and console `118`) with both explicit depth format and `DXGI_FORMAT_UNKNOWN (0)`, stencil SRVs (`22` and `47` with `PlaneSlice = 1`), and negative controls (`unordered = true` UAV and `DENY_SHADER_RESOURCE` depth texture) — all passed on both RTX 5090 and WARP with `GetDeviceRemovedReason() == Ok(())` and 0 `ID3D12InfoQueue` messages. Looks good to merge.
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/2294/head:github-bot/gh-2294'
git switch 'github-bot/gh-2294'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-2294'
git switch 'github-bot/gh-2294'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-2294'
git switch 'github-bot/gh-2294'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-2294'
git switch 'main'
git merge --squash 'github-bot/gh-2294'
git switch 'main'
git merge --ff-only 'github-bot/gh-2294'
git switch 'main'
git merge 'github-bot/gh-2294'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No reviewers
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.

Dependencies

No dependencies set

Reference
github/Marvisak--VIctory!2294
No description provided.