Skip to content

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

Open
fuzeofficlal wants to merge 1 commit into
Marvisak:mainfrom
fuzeofficlal:fix/gpu-depth-twin-d16-and-msaa
Open

fuzeofficlal wants to merge 1 commit into
Marvisak:mainfrom
fuzeofficlal:fix/gpu-depth-twin-d16-and-msaa

Conversation

@fuzeofficlal

Copy link
Copy Markdown
Contributor

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 DenRakEiw left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 catminou4 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Copy Markdown

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 Nov 25, 2026 •

Copy link
Copy Markdown
Owner

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

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.
@fuzeofficlal
fuzeofficlal force-pushed the fix/gpu-depth-twin-d16-and-msaa branch from cdd11bd to ec7d678 Compare November 25, 2026 22:01
github-actions Bot added a commit to KevinPratap/VIctory that referenced this pull request Nov 26, 2026
BastienRodz added a commit to BastienRodz/VIctory that referenced this pull request Nov 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants