GPU/Resource: support 2-plane D16_UNORM_S8_UINT formats (118..=120) in GetCopyableFootprints #3057

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

@⁠RVZO6 on GitHub · 2026-11-26 05:43 UTC · original
RVZO6:rvzo/d16-s8-footprints → main · +55 −5 · 1 files · 1 commits · open

Problem

In crates/victory-gpu/src/resource.rs, subresource() (used by GetCopyableFootprints) only recognizes 2-plane depth-stencil formats 19..=22 (D32_FLOAT_S8X24_UINT family) and 44..=47 (D24_UNORM_S8_UINT family), omitting console 2-plane 16-bit depth + 8-bit stencil formats 118..=120 (DXGI_FORMAT_D16_UNORM_S8_UINT, R16_UNORM_X8_TYPELESS, X16_TYPELESS_G8_UINT — already treated as 2-plane [R16, R8] in twin.rs:101 and victory-formats/src/texture.rs:766).

On main:

  • Plane 0 falls through to (desc.format, 256), returning raw console format 118..=120 with element == (3, 1) (1.5x wrong row_size, 256-byte row alignment instead of 512).
  • Plane 1 (stencil subresources) returns None, causing copyable_footprints to emit NO_FOOTPRINT (u64::MAX) and total = u64::MAX.

Fix

Handle (118..=120, 0) => (53, 512) (DXGI_FORMAT_R16_TYPELESS, 2 B/texel) and (118..=120, 1) => (60, 512) (DXGI_FORMAT_R8_TYPELESS, 1 B/texel) in subresource(). Disjoint from #1543 (which adds checked arithmetic overflow guards).

Verification

  • Added resource::tests::d16_s8_depth_stencil_footprints_follow_the_pc_plane_order (2 mips × 2 slices × 2 planes across formats 118..=120).
  • Negative control before fix failed on format 118 with plane-0 (512, 118, ...) / 256-aligned offsets and plane-1 u64::MAX; passes 2/2 after fix.
  • Verified green on windows-latest MSVC + WARP SM 6.6 CI (cargo clippy --workspace --all-targets --locked -- -D warnings, --all-features, xtask policy, full workspace tests): https://github.com/RVZO6/VIctory/actions/runs/45762903919
  • Not run: the title; any hardware GPU.

AI-assisted: T3 Code (Antigravity, gemini-4-neon)

**@⁠RVZO6** on GitHub · 2026-11-26 05:43 UTC · [original](https://github.com/Marvisak/VIctory/pull/3057) `RVZO6:rvzo/d16-s8-footprints` → `main` · +55 −5 · 1 files · 1 commits · open ### Problem In `crates/victory-gpu/src/resource.rs`, `subresource()` (used by `GetCopyableFootprints`) only recognizes 2-plane depth-stencil formats `19..=22` (`D32_FLOAT_S8X24_UINT` family) and `44..=47` (`D24_UNORM_S8_UINT` family), omitting console 2-plane 16-bit depth + 8-bit stencil formats `118..=120` (`DXGI_FORMAT_D16_UNORM_S8_UINT`, `R16_UNORM_X8_TYPELESS`, `X16_TYPELESS_G8_UINT` — already treated as 2-plane `[R16, R8]` in `twin.rs:101` and `victory-formats/src/texture.rs:766`). On `main`: - Plane 0 falls through to `(desc.format, 256)`, returning raw console format `118..=120` with `element == (3, 1)` (`1.5x` wrong `row_size`, 256-byte row alignment instead of 512). - Plane 1 (stencil subresources) returns `None`, causing `copyable_footprints` to emit `NO_FOOTPRINT` (`u64::MAX`) and `total = u64::MAX`. ### Fix Handle `(118..=120, 0) => (53, 512)` (`DXGI_FORMAT_R16_TYPELESS`, 2 B/texel) and `(118..=120, 1) => (60, 512)` (`DXGI_FORMAT_R8_TYPELESS`, 1 B/texel) in `subresource()`. Disjoint from #1543 (which adds checked arithmetic overflow guards). ### Verification - Added `resource::tests::d16_s8_depth_stencil_footprints_follow_the_pc_plane_order` (2 mips × 2 slices × 2 planes across formats `118..=120`). - Negative control before fix failed on `format 118` with plane-0 `(512, 118, ...)` / `256`-aligned offsets and plane-1 `u64::MAX`; passes 2/2 after fix. - Verified green on `windows-latest` MSVC + WARP SM 6.6 CI (`cargo clippy --workspace --all-targets --locked -- -D warnings`, `--all-features`, `xtask policy`, full workspace tests): https://github.com/RVZO6/VIctory/actions/runs/45762903919 - **Not run:** the title; any hardware GPU. AI-assisted: T3 Code (Antigravity, gemini-4-neon)
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 06:27:43 +00:00
Author
Owner

@⁠Marvisak on GitHub · 2026-11-26 06:16 UTC · original

Automated triage for the maintainers.

Merge candidate. subresource() in crates/victory-gpu/src/resource.rs (behind GetCopyableFootprints) treated only formats 19..=22 and 44..=47 as two-plane depth-stencil, so the 16-bit depth + stencil formats 118..=120 got the raw format with a 256-byte pitch for plane 0 and NO_FOOTPRINT for plane 1. The PR maps them to R16_TYPELESS (53) and R8_TYPELESS (60) with 512-byte row alignment, which matches how the rest of the repo already splits these formats (twin.rs plane_formats: [R16, R8]; victory-formats texture::format: 2 bytes with stencil). I checked the new test's expected offsets, row sizes and total by hand.

These footprints follow the PC plane-copy rules by analogy with the D32S8/D24S8 cases. Nobody has confirmed them against the console runtime, but on main plane 1 has no footprint at all.

CI: check passing.


Generated by Claude Code

**@⁠Marvisak** on GitHub · 2026-11-26 06:16 UTC · [original](https://github.com/Marvisak/VIctory/pull/3057#issuecomment-7184272158) <!-- victory-triage v1 head=10c9fdf26dbb1fefa133200db05cfb2a6ee45bdc verdict=merge-candidate at=2026-11-26T06:17:30Z --> Automated triage for the maintainers. **Merge candidate.** `subresource()` in `crates/victory-gpu/src/resource.rs` (behind `GetCopyableFootprints`) treated only formats 19..=22 and 44..=47 as two-plane depth-stencil, so the 16-bit depth + stencil formats 118..=120 got the raw format with a 256-byte pitch for plane 0 and `NO_FOOTPRINT` for plane 1. The PR maps them to R16_TYPELESS (53) and R8_TYPELESS (60) with 512-byte row alignment, which matches how the rest of the repo already splits these formats (`twin.rs` `plane_formats`: `[R16, R8]`; `victory-formats` `texture::format`: 2 bytes with stencil). I checked the new test's expected offsets, row sizes and total by hand. These footprints follow the PC plane-copy rules by analogy with the D32S8/D24S8 cases. Nobody has confirmed them against the console runtime, but on `main` plane 1 has no footprint at all. CI: `check` passing. --- _Generated by [Claude Code](https://claude.ai/code)_
This pull request can be merged automatically.
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/3057/head:github-bot/gh-3057'
git switch 'github-bot/gh-3057'

Merge

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