GPU: handle typed D16/D32 and multisample depth twins #2173

Open
github-bot wants to merge 1 commit from github-bot/gh-2173 into main AGit
Owner

@⁠fuzeofficlal on GitHub · 2026-11-25 06:59 UTC · original
fuzeofficlal:fix/gpu-depth-twin-d16-and-msaa → main · +143 −2 · 2 files · 1 commits · open

Problem

  • A multisample depth texture written through an unordered view got a twin created with its sample count and only ALLOW_UNORDERED_ACCESS. D3D12 rejects that (a multisample resource needs the render target or depth stencil flag), and the debug layer reports it as an error.
  • A 16- or 32-bit depth texture that denies shader reads stays typed on the host (D16_UNORM / D32_FLOAT). Its copyable footprint format then did not match the twin plane's typeless format (R16_TYPELESS / R32_TYPELESS), so the twin was refused as needing a conversion and the unordered writes were dropped.

Changes

  • twin::make returns early for multisample depth textures, logging it once, before creating anything.
  • Typed single-plane depth footprints (D16_UNORM, D32_FLOAT) are renamed to their typeless plane format, so the same bytes are copied straight through. Formats with stencil keep their per-plane footprints.
  • One test covers both: a typed D16/D32 round trip through the twin with readback of the depth texture, plus a multisample texture that gets no twin and produces no debug layer error.

Verification

  • cargo test -p victory-gpu --locked on hardware: the 2 failures already on main are unrelated. With VICTORY_D3D12_WARP=1: all pass. The new test also passes with VICTORY_D3D12_DEBUG=1, and fails without either fix.
  • clippy -D warnings (default and diagnostics), rustfmt on the changed hunks, and cargo xtask policy all pass.
**@⁠fuzeofficlal** on GitHub · 2026-11-25 06:59 UTC · [original](https://github.com/Marvisak/VIctory/pull/2173) `fuzeofficlal:fix/gpu-depth-twin-d16-and-msaa` → `main` · +143 −2 · 2 files · 1 commits · open ### Problem - A multisample depth texture written through an unordered view got a twin created with its sample count and only `ALLOW_UNORDERED_ACCESS`. D3D12 rejects that (a multisample resource needs the render target or depth stencil flag), and the debug layer reports it as an error. - A 16- or 32-bit depth texture that denies shader reads stays typed on the host (`D16_UNORM` / `D32_FLOAT`). Its copyable footprint format then did not match the twin plane's typeless format (`R16_TYPELESS` / `R32_TYPELESS`), so the twin was refused as needing a conversion and the unordered writes were dropped. ### Changes - `twin::make` returns early for multisample depth textures, logging it once, before creating anything. - Typed single-plane depth footprints (`D16_UNORM`, `D32_FLOAT`) are renamed to their typeless plane format, so the same bytes are copied straight through. Formats with stencil keep their per-plane footprints. - One test covers both: a typed D16/D32 round trip through the twin with readback of the depth texture, plus a multisample texture that gets no twin and produces no debug layer error. ### Verification - `cargo test -p victory-gpu --locked` on hardware: the 2 failures already on main are unrelated. With `VICTORY_D3D12_WARP=1`: all pass. The new test also passes with `VICTORY_D3D12_DEBUG=1`, and fails without either fix. - clippy `-D warnings` (default and `diagnostics`), rustfmt on the changed hunks, and `cargo xtask policy` all pass.
A multisample depth texture got a twin created with its sample count
and only ALLOW_UNORDERED_ACCESS, which D3D12 rejects (a multisample
resource needs the render target or depth stencil flag) and the debug
layer reports as an error. Such a texture now gets no twin: make()
logs it once and returns before creating anything.

A 16- or 32-bit depth texture that denies shader reads stays in its
typed format on the host (D16_UNORM, D32_FLOAT), so its copyable
footprint format no longer equalled the twin plane's typeless one
(R16_TYPELESS, R32_TYPELESS) and the twin was refused as needing a
conversion. The bytes are the same, so the footprint now names the
typeless format and the plane is copied straight through. Formats with
stencil keep their per-plane footprints and are unaffected.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:57:22 +00:00
Author
Owner

@⁠MamaLeVrai on GitHub · 2026-11-25 07:58 UTC · original

Test report on real hardware: AMD RX 6950 XT (RDNA2), Windows 11, Rust 1.98.1, with a GPU present, so the hardware-only shader checks run. I merged this PR's head cdd11bd2 into main 940d32f in a throwaway tree (no conflict). cargo clippy --workspace --all-targets --locked -- -D warnings: clean; the same with --all-features: clean. cargo test --workspace --locked: 702 passed, 0 failed, 10 ignored, two runs (main alone on the same machine: 701 passed, 0 failed, 10 ignored). The title was not run, so this says nothing about in-game effect. No game data.

AI-assisted (Claude Code); no game data.

**@⁠MamaLeVrai** on GitHub · 2026-11-25 07:58 UTC · [original](https://github.com/Marvisak/VIctory/pull/2173#issuecomment-7156452904) Test report on real hardware: AMD RX 6950 XT (RDNA2), Windows 11, Rust 1.98.1, with a GPU present, so the hardware-only shader checks run. I merged this PR's head `cdd11bd2` into `main` `940d32f` in a throwaway tree (no conflict). `cargo clippy --workspace --all-targets --locked -- -D warnings`: clean; the same with `--all-features`: clean. `cargo test --workspace --locked`: 702 passed, 0 failed, 10 ignored, two runs (`main` alone on the same machine: 701 passed, 0 failed, 10 ignored). The title was not run, so this says nothing about in-game effect. No game data. AI-assisted (Claude Code); no game data.
Author
Owner

@⁠Marvisak on GitHub · 2026-11-25 12:37 UTC · original · edited 2026-11-26 01:21 UTC

Automated triage for the maintainers.

Merge candidate (a recommendation to look, not an approval). The new head is a single commit on current main with the same change as before. In crates/victory-gpu/src/twin.rs, make refuses multisample depth textures with a one-time log before creating anything. For depth textures the host keeps typed, it renames the D16_UNORM/D32_FLOAT copy footprints to the plane's typeless format, so the bytes copy through without a conversion. Formats with stencil keep their per-plane footprints. The GPU test a_typed_depth_texture_shares_its_bytes_with_its_twin (draw.rs) checks both formats in both directions and checks that a multisample texture gets no twin and raises no debug-layer error.

The branch merges cleanly. CI: check passing.


Generated by Claude Code

**@⁠Marvisak** on GitHub · 2026-11-25 12:37 UTC · [original](https://github.com/Marvisak/VIctory/pull/2173#issuecomment-7162634731) · edited 2026-11-26 01:21 UTC <!-- victory-triage v1 head=ec7d67877a83123a5a49efdf796927ddbca368ed verdict=merge-candidate at=2026-11-26T01:21:51Z --> Automated triage for the maintainers. **Merge candidate** (a recommendation to look, not an approval). The new head is a single commit on current `main` with the same change as before. In `crates/victory-gpu/src/twin.rs`, `make` refuses multisample depth textures with a one-time log before creating anything. For depth textures the host keeps typed, it renames the `D16_UNORM`/`D32_FLOAT` copy footprints to the plane's typeless format, so the bytes copy through without a conversion. Formats with stencil keep their per-plane footprints. The GPU test `a_typed_depth_texture_shares_its_bytes_with_its_twin` (`draw.rs`) checks both formats in both directions and checks that a multisample texture gets no twin and raises no debug-layer error. The branch merges cleanly. CI: `check` passing. --- _Generated by [Claude Code](https://claude.ai/code)_
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/2173/head:github-bot/gh-2173'
git switch 'github-bot/gh-2173'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-2173'
git switch 'github-bot/gh-2173'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-2173'
git switch 'github-bot/gh-2173'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-2173'
git switch 'main'
git merge --squash 'github-bot/gh-2173'
git switch 'main'
git merge --ff-only 'github-bot/gh-2173'
git switch 'main'
git merge 'github-bot/gh-2173'
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!2173
No description provided.