GPU: select the readable format and plane for depth/stencil shader views #651

Open
Raxstreams wants to merge 1 commit from upstream-pr/651 into main
Raxstreams commented 2026-11-24 06:13:52 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Raxstreams on 2026-11-24T06:13:52Z.


VIctory creates typeless host textures so a title can use the same surface for depth testing and shader reads. The descriptor path on main copies the title's plane index and accepts a depth-stencil view format as long as it belongs to the resource's DXGI family. That can pass a DSV-only format to CreateShaderResourceView, or request stencil with plane zero on a two-plane host texture.

Select the readable depth or stencil format when building the host SRV. Texture2D and Texture2DArray use plane zero for depth and plane one for stencil. The test includes the console stencil format that maps to X24_TYPELESS_G8_UINT and checks that the mip and array ranges survive the conversion.

I isolated this change while tracing a black world frame. In a separate integration run with the diagnostic lighting pass disabled, the HDR scene and bloom inputs were already black when the title's composite sampled them. The effect of this change alone on the game image is unverified. Related work in #485 covers resource states for simultaneous shader and depth reads.

Verification

  • On the previous descriptor path the regression test returned format 20 (D32_FLOAT_S8X24_UINT) where the shader requires format 21 (R32_FLOAT_X8X24_TYPELESS).
  • On Windows, with VICTORY_D3D12_DEBUG=1, cargo test --locked --offline -p victory-gpu --features diagnostics -- --test-threads=1 passed 46 tests with one ignored. The new test inspects the generated host descriptors.
  • cargo xtask policy --staged passed for the single source file.

AI-assisted contribution using Codex.

<!-- greyfinch-sync:Marvisak/VIctory:issue:6575858727 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/651). Originally posted by [Raxstreams](https://github.com/Raxstreams) on 2026-11-24T06:13:52Z. --- VIctory creates typeless host textures so a title can use the same surface for depth testing and shader reads. The descriptor path on main copies the title's plane index and accepts a depth-stencil view format as long as it belongs to the resource's DXGI family. That can pass a DSV-only format to CreateShaderResourceView, or request stencil with plane zero on a two-plane host texture. Select the readable depth or stencil format when building the host SRV. Texture2D and Texture2DArray use plane zero for depth and plane one for stencil. The test includes the console stencil format that maps to X24_TYPELESS_G8_UINT and checks that the mip and array ranges survive the conversion. I isolated this change while tracing a black world frame. In a separate integration run with the diagnostic lighting pass disabled, the HDR scene and bloom inputs were already black when the title's composite sampled them. The effect of this change alone on the game image is unverified. Related work in #485 covers resource states for simultaneous shader and depth reads. ### Verification - On the previous descriptor path the regression test returned format 20 (D32_FLOAT_S8X24_UINT) where the shader requires format 21 (R32_FLOAT_X8X24_TYPELESS). - On Windows, with VICTORY_D3D12_DEBUG=1, `cargo test --locked --offline -p victory-gpu --features diagnostics -- --test-threads=1` passed 46 tests with one ignored. The new test inspects the generated host descriptors. - `cargo xtask policy --staged` passed for the single source file. AI-assisted contribution using Codex.
LAKSHYA-cmd-tech commented 2026-11-24 06:54:13 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by LAKSHYA-cmd-tech on 2026-11-24T06:21:40Z.

Review: APPROVED


Tested on Windows 11 with Rust 1.98.1 (x86_64-pc-windows-msvc).

  • cargo test -p victory-gpu: all 44 unit tests passed cleanly (0 failed, 1 ignored benchmark).
  • depth_srv_uses_the_requested_aspect passed across all depth/stencil format pairs and mip/array plane slice conversions.
  • cargo xtask policy: 151 files ok.
  • Verified typeless depth/stencil SRV format translation and PlaneSlice selection for 2D and 2DArray shader resource views.
<!-- greyfinch-sync:Marvisak/VIctory:review:6034606878 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/651#pullrequestreview-6034606878). Originally posted by [LAKSHYA-cmd-tech](https://github.com/LAKSHYA-cmd-tech) on 2026-11-24T06:21:40Z. **Review:** APPROVED --- Tested on Windows 11 with Rust 1.98.1 (x86_64-pc-windows-msvc). - cargo test -p victory-gpu: all 44 unit tests passed cleanly (0 failed, 1 ignored benchmark). - depth_srv_uses_the_requested_aspect passed across all depth/stencil format pairs and mip/array plane slice conversions. - cargo xtask policy: 151 files ok. - Verified typeless depth/stencil SRV format translation and PlaneSlice selection for 2D and 2DArray shader resource views.
mercuryVM commented 2026-11-24 12:04:11 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by mercuryVM on 2026-11-24T11:03:26Z.

Review: APPROVED


Tested d615ee0 on Windows 11, RTX 5070, MSVC: cargo test -p victory-gpu -- --test-threads=1 44 passed, including depth_srv_uses_the_requested_aspect. Clippy's 1 warning is the existing undocumented_unsafe_blocks in host.rs.

  • Only resources with ALLOW_DEPTH_STENCIL are rewritten. The requested format is then mapped to the readable aspect: DXGI_FORMAT_UNKNOWN, the typeless format and the DSV format all become the depth SRV format on plane 0, and the stencil SRV format goes to plane 1. Anything else is left alone, so fits still rejects it. That is the D3D12 rule for two-plane depth formats.
  • Mip and array ranges come through unchanged. The test checks them for both Texture2D and Texture2DArray, including the console stencil and depth codes.
  • Not covered: TEXTURECUBE, TEXTURE2DMS and the other dimensions get the format fix but no plane assignment. That's fine for depth (plane 0 is implicit), but a stencil SRV on a cube or MS view still requests plane 0 as before. Worth a comment, or a refusal, if a title ever does that.

AI-assisted (Claude Code).

<!-- greyfinch-sync:Marvisak/VIctory:review:6038037610 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/651#pullrequestreview-6038037610). Originally posted by [mercuryVM](https://github.com/mercuryVM) on 2026-11-24T11:03:26Z. **Review:** APPROVED --- Tested d615ee0 on Windows 11, RTX 5070, MSVC: `cargo test -p victory-gpu -- --test-threads=1` 44 passed, including `depth_srv_uses_the_requested_aspect`. Clippy's 1 warning is the existing `undocumented_unsafe_blocks` in host.rs. - Only resources with `ALLOW_DEPTH_STENCIL` are rewritten. The requested format is then mapped to the readable aspect: `DXGI_FORMAT_UNKNOWN`, the typeless format and the DSV format all become the depth SRV format on plane 0, and the stencil SRV format goes to plane 1. Anything else is left alone, so `fits` still rejects it. That is the D3D12 rule for two-plane depth formats. - Mip and array ranges come through unchanged. The test checks them for both `Texture2D` and `Texture2DArray`, including the console stencil and depth codes. - Not covered: `TEXTURECUBE`, `TEXTURE2DMS` and the other dimensions get the format fix but no plane assignment. That's fine for depth (plane 0 is implicit), but a stencil SRV on a cube or MS view still requests plane 0 as before. Worth a comment, or a refusal, if a title ever does that. AI-assisted (Claude Code).
erLCoder commented 2026-11-24 14:04:38 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by erLCoder on 2026-11-24T13:10:30Z.


Depth/stencil descriptor fixture on Windows 10 22H2 build 19045.6466, GTX 1660 Ti, NVIDIA 581.42, Ryzen 5 3600, Rust 1.98.1 MSVC and Agility SDK 1.620.2. Parent d2a4bae, PR d615ee0.

cargo test --offline --locked -p victory-gpu --features diagnostics --lib depth_srv_uses_the_requested_aspect -- --nocapture --test-threads=1 — 1 passed, 0 failed, 0 ignored, 46 filtered out. This is a CPU test of selected DXGI format and plane for 2D and array descriptors. GPU depth sampling, resource transitions and image effect remain untested. Applying this revision to my separate Turing runtime stack requires conflict resolution in descriptor/host.rs.

Codex prepared the worktree, ran the test and drafted this report.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7132454200 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/651#issuecomment-7132454200). Originally posted by [erLCoder](https://github.com/erLCoder) on 2026-11-24T13:10:30Z. --- Depth/stencil descriptor fixture on Windows 10 22H2 build 19045.6466, GTX 1660 Ti, NVIDIA 581.42, Ryzen 5 3600, Rust 1.98.1 MSVC and Agility SDK 1.620.2. Parent d2a4bae, PR d615ee0. `cargo test --offline --locked -p victory-gpu --features diagnostics --lib depth_srv_uses_the_requested_aspect -- --nocapture --test-threads=1` — 1 passed, 0 failed, 0 ignored, 46 filtered out. This is a CPU test of selected DXGI format and plane for 2D and array descriptors. GPU depth sampling, resource transitions and image effect remain untested. Applying this revision to my separate Turing runtime stack requires conflict resolution in descriptor/host.rs. Codex prepared the worktree, ran the test and drafted this report.
konradbeck commented 2026-11-24 14:04:56 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by konradbeck on 2026-11-24T13:54:41Z.


Independent GPU readback on an NVIDIA RTX A4500 (driver 32.0.16.2124, Windows 11 build 26300.9974).

  • main tested at ffe310eb2098e52169f4c44db5ffdabf43a72622
  • PR head tested at d615ee0fe0f90750320575e2501726486a0454ca

I cleared synthetic 2×2 depth/stencil patterns, sampled both aspects in a compute shader, and copied the results back to the CPU. The PR matched native D3D12 exactly for both corrected view requests.

Texture Depth readback Stencil readback
D32S8 Texture2D 4/4 (0.125, 0.375, 0.625, 0.875) 4/4 (5, 17, 42, 213)
D24S8 Texture2DArray, mip 1, slice 1 4/4 (0.12500001, 0.37500003, 0.625, 0.875) 4/4 (5, 17, 42, 213)

On main, the native and valid VIctory controls also matched. For the inputs this PR fixes, the test guard recorded a DSV-only format on depth plane 1 and a stencil SRV on plane 0, then blocked those descriptors before dispatch. The D3D12 debug layer was unavailable for these runs. The PR’s existing depth_srv_uses_the_requested_aspect test also passed.

AI-assisted test fixture and write-up.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7133520870 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/651#issuecomment-7133520870). Originally posted by [konradbeck](https://github.com/konradbeck) on 2026-11-24T13:54:41Z. --- Independent GPU readback on an **NVIDIA RTX A4500** (driver `32.0.16.2124`, Windows 11 build `26300.9974`). - `main` tested at `ffe310eb2098e52169f4c44db5ffdabf43a72622` - PR head tested at `d615ee0fe0f90750320575e2501726486a0454ca` I cleared synthetic 2×2 depth/stencil patterns, sampled both aspects in a compute shader, and copied the results back to the CPU. The PR matched native D3D12 exactly for both corrected view requests. | Texture | Depth readback | Stencil readback | | --- | --- | --- | | D32S8 `Texture2D` | 4/4 (`0.125`, `0.375`, `0.625`, `0.875`) | 4/4 (`5`, `17`, `42`, `213`) | | D24S8 `Texture2DArray`, mip 1, slice 1 | 4/4 (`0.12500001`, `0.37500003`, `0.625`, `0.875`) | 4/4 (`5`, `17`, `42`, `213`) | On `main`, the native and valid VIctory controls also matched. For the inputs this PR fixes, the test guard recorded a DSV-only format on depth plane 1 and a stencil SRV on plane 0, then blocked those descriptors before dispatch. **The D3D12 debug layer was unavailable** for these runs. The PR’s existing `depth_srv_uses_the_requested_aspect` test also passed. AI-assisted test fixture and write-up.
molodayamama commented 2026-11-24 14:05:03 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by molodayamama on 2026-11-24T14:04:38Z.


Independent Windows check of d615ee0fe0f90750320575e2501726486a0454ca (Windows 10 22H2 19045, Rust 1.98.1, MSVC x64).

  • cargo test -p victory-gpu --locked --lib depth_srv_uses_the_requested_aspect -- --test-threads=1 --nocapture: 1 passed.

The synthetic descriptor fixture checks that SRV descriptions preserve the requested readable aspect on depth/stencil textures. This was a descriptor-construction check without GPU sampling.

Only source-built synthetic fixtures were used. AI-assisted verification.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7133802338 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/651#issuecomment-7133802338). Originally posted by [molodayamama](https://github.com/molodayamama) on 2026-11-24T14:04:38Z. --- Independent Windows check of `d615ee0fe0f90750320575e2501726486a0454ca` (Windows 10 22H2 19045, Rust 1.98.1, MSVC x64). - `cargo test -p victory-gpu --locked --lib depth_srv_uses_the_requested_aspect -- --test-threads=1 --nocapture`: 1 passed. The synthetic descriptor fixture checks that SRV descriptions preserve the requested readable aspect on depth/stencil textures. This was a descriptor-construction check without GPU sampling. Only source-built synthetic fixtures were used. AI-assisted verification.
Marvisak commented 2026-11-25 01:08:00 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T00:32:22Z.


Automated triage for the maintainers.

Needs rebase. This PR does not merge cleanly into current main (ac2525d). Conflicting files: crates/victory-gpu/src/descriptor/host.rs.

The content has not been reviewed yet; it will be once the branch is rebased onto main.


Generated by Claude Code

<!-- greyfinch-sync:Marvisak/VIctory:comment:7148611458 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/651#issuecomment-7148611458). Originally posted by [Marvisak](https://github.com/Marvisak) on 2026-11-25T00:32:22Z. --- <!-- victory-triage v1 head=d615ee0fe0f90750320575e2501726486a0454ca verdict=needs-rebase at=2026-11-25T00:13:20Z --> Automated triage for the maintainers. **Needs rebase.** This PR does not merge cleanly into current `main` (ac2525d). Conflicting files: `crates/victory-gpu/src/descriptor/host.rs`. The content has not been reviewed yet; it will be once the branch is rebased onto `main`. --- _Generated by [Claude Code](https://claude.ai/code)_
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/651:upstream-pr/651'
git switch 'upstream-pr/651'

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.

git switch 'main'
git merge --no-ff 'upstream-pr/651'
git switch 'upstream-pr/651'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/651'
git switch 'upstream-pr/651'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/651'
git switch 'main'
git merge --squash 'upstream-pr/651'
git switch 'main'
git merge --ff-only 'upstream-pr/651'
git switch 'main'
git merge 'upstream-pr/651'
git push origin 'main'
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
Marvisak/VIctory!651
No description provided.