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

Open
fuzeofficlal wants to merge 1 commit from upstream-pr/2173 into main
fuzeofficlal commented 2026-11-25 06:59:46 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by fuzeofficlal on 2026-11-25T06:59:46Z.


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.
<!-- greyfinch-sync:Marvisak/VIctory:issue:6599077901 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2173). Originally posted by [fuzeofficlal](https://github.com/fuzeofficlal) on 2026-11-25T06:59:46Z. --- ### 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.
DenRakEiw commented 2026-11-25 08:06:09 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by DenRakEiw on 2026-11-25T07:03:11Z.

Review: APPROVED


Verified locally merged onto origin/main (940d32f, Windows 11 x64, NVIDIA GeForce RTX 5090, Rust 1.98.1 MSVC):

  • cargo test -p victory-gpu --lib a_typed_depth_texture_shares_its_bytes_with_its_twin — passed on RTX 5090
  • cargo clippy -p victory-gpu --all-targets — 0 warnings
  • cargo xtask policy — ok (183 files ok)

Clean handling of typed D16/D32 and multisample depth twins with end-to-end GPU test coverage. Looks good.

AI-assisted (Gemini 4 Neon).

<!-- greyfinch-sync:Marvisak/VIctory:review:6053207826 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2173#pullrequestreview-6053207826). Originally posted by [DenRakEiw](https://github.com/DenRakEiw) on 2026-11-25T07:03:11Z. **Review:** APPROVED --- Verified locally merged onto `origin/main` (`940d32f`, Windows 11 x64, NVIDIA GeForce RTX 5090, Rust 1.98.1 MSVC): - `cargo test -p victory-gpu --lib a_typed_depth_texture_shares_its_bytes_with_its_twin` — passed on RTX 5090 - `cargo clippy -p victory-gpu --all-targets` — 0 warnings - `cargo xtask policy` — ok (`183 files ok`) Clean handling of typed D16/D32 and multisample depth twins with end-to-end GPU test coverage. Looks good. AI-assisted (Gemini 4 Neon).
catminou4 commented 2026-11-25 08:06:09 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by catminou4 on 2026-11-25T07:17:35Z.

Review: COMMENTED


Static review only: victory-gpu is Windows-only (D3D12/windows_sys) — nothing compiles or runs on macOS; source review of the diff.

Typed D16/D32 + multisample depth twins handled — depth-format coverage; pairs with #2125's D16 integer loads and #2173's twins.

<!-- greyfinch-sync:Marvisak/VIctory:review:6053350716 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2173#pullrequestreview-6053350716). Originally posted by [catminou4](https://github.com/catminou4) on 2026-11-25T07:17:35Z. **Review:** COMMENTED --- Static review only: victory-gpu is Windows-only (D3D12/windows_sys) — nothing compiles or runs on macOS; source review of the diff. Typed D16/D32 + multisample depth twins handled — depth-format coverage; pairs with #2125's D16 integer loads and #2173's twins.
MamaLeVrai commented 2026-11-25 08:06:44 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by MamaLeVrai on 2026-11-25T07:58:03Z.


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.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7156452904 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2173#issuecomment-7156452904). Originally posted by [MamaLeVrai](https://github.com/MamaLeVrai) on 2026-11-25T07:58:03Z. --- 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.
Marvisak commented 2026-11-25 13:02:52 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T12:37:41Z.


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

<!-- greyfinch-sync:Marvisak/VIctory:comment:7162634731 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2173#issuecomment-7162634731). Originally posted by [Marvisak](https://github.com/Marvisak) on 2026-11-25T12:37:41Z. --- <!-- 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 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/2173:upstream-pr/2173'
git switch 'upstream-pr/2173'

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/2173'
git switch 'upstream-pr/2173'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/2173'
git switch 'upstream-pr/2173'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/2173'
git switch 'main'
git merge --squash 'upstream-pr/2173'
git switch 'main'
git merge --ff-only 'upstream-pr/2173'
git switch 'main'
git merge 'upstream-pr/2173'
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!2171
No description provided.