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

Open
RVZO6 wants to merge 1 commit from upstream-pr/3057 into main
RVZO6 commented 2026-11-26 05:43:04 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by RVZO6 on 2026-11-26T05:43:04Z.


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)

<!-- greyfinch-sync:Marvisak/VIctory:issue:6620361830 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3057). Originally posted by [RVZO6](https://github.com/RVZO6) on 2026-11-26T05:43:04Z. --- ### 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)
fuzeofficlal commented 2026-11-26 06:03:34 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by fuzeofficlal on 2026-11-26T05:55:32Z.

Review: APPROVED


Reviewed head 10c9fdf2 line-by-line (CI green):

  • Matches element() (118..=120 => (3, 1)) and pc_format() (118..=120 => 20..=22) in resource.rs: plane 0 maps to DXGI_FORMAT_R16_TYPELESS (53, 2 B/texel) and plane 1 maps to DXGI_FORMAT_R8_TYPELESS (60, 1 B/texel), both with 512-byte row pitch alignment.
  • d16_s8_depth_stencil_footprints_follow_the_pc_plane_order verifies offsets, formats, dimensions, row counts, row sizes, total size (24_072), and out-of-range subresource (8) across all three formats (118..=120).

Clean and well-tested.

<!-- greyfinch-sync:Marvisak/VIctory:review:6069202109 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3057#pullrequestreview-6069202109). Originally posted by [fuzeofficlal](https://github.com/fuzeofficlal) on 2026-11-26T05:55:32Z. **Review:** APPROVED --- Reviewed head `10c9fdf2` line-by-line (CI green): - Matches `element()` (`118..=120 => (3, 1)`) and `pc_format()` (`118..=120 => 20..=22`) in `resource.rs`: plane 0 maps to `DXGI_FORMAT_R16_TYPELESS` (`53`, 2 B/texel) and plane 1 maps to `DXGI_FORMAT_R8_TYPELESS` (`60`, 1 B/texel), both with 512-byte row pitch alignment. - `d16_s8_depth_stencil_footprints_follow_the_pc_plane_order` verifies offsets, formats, dimensions, row counts, row sizes, total size (`24_072`), and out-of-range subresource (`8`) across all three formats (`118..=120`). Clean and well-tested.
kotekompotek commented 2026-11-26 06:03:34 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by kotekompotek on 2026-11-26T06:00:06Z.

Review: APPROVED


Verified: 118..=120 (D16_UNORM_S8_UINT family) is the missing two-plane depth-stencil case — plane 0 was falling through to the console format and plane 1 returned None. The match now maps them to R16_TYPELESS/R8_TYPELESS at 512-byte pitch like the D24/D32 family, and the test pins the PC plane order (all depth subresources then all stencil), exact offsets, and the count boundary for all three formats.

<!-- greyfinch-sync:Marvisak/VIctory:review:6069238909 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3057#pullrequestreview-6069238909). Originally posted by [kotekompotek](https://github.com/kotekompotek) on 2026-11-26T06:00:06Z. **Review:** APPROVED --- Verified: 118..=120 (D16_UNORM_S8_UINT family) is the missing two-plane depth-stencil case — plane 0 was falling through to the console format and plane 1 returned None. The match now maps them to R16_TYPELESS/R8_TYPELESS at 512-byte pitch like the D24/D32 family, and the test pins the PC plane order (all depth subresources then all stencil), exact offsets, and the count boundary for all three formats.
Dukestar69 commented 2026-11-26 07:01:31 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Dukestar69 on 2026-11-26T06:30:23Z.

Review: APPROVED


Tested locally merged onto origin/main (63bcca4) on Windows 11 x64 (NVIDIA GeForce RTX 5090):

  • Diff review: Handling console D16_UNORM_S8_UINT formats (118..=120) as two 512-byte-aligned planes (R16_TYPELESS = 53 for plane 0, R8_TYPELESS = 60 for plane 1) in resource::subresource cleanly extends GetCopyableFootprints to 16-bit depth + 8-bit stencil textures.
  • cargo test -p victory-gpu resource::tests -- --test-threads=1: 19 passed, 0 failed (including d16_s8_depth_stencil_footprints_follow_the_pc_plane_order).
  • cargo clippy -p victory-gpu --all-targets -- -D warnings: clean.
  • cargo xtask policy: 191 files ok.

Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).

<!-- greyfinch-sync:Marvisak/VIctory:review:6069517992 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3057#pullrequestreview-6069517992). Originally posted by [Dukestar69](https://github.com/Dukestar69) on 2026-11-26T06:30:23Z. **Review:** APPROVED --- Tested locally merged onto `origin/main` (`63bcca4`) on Windows 11 x64 (NVIDIA GeForce RTX 5090): - Diff review: Handling console `D16_UNORM_S8_UINT` formats (`118..=120`) as two 512-byte-aligned planes (`R16_TYPELESS` = 53 for plane 0, `R8_TYPELESS` = 60 for plane 1) in `resource::subresource` cleanly extends `GetCopyableFootprints` to 16-bit depth + 8-bit stencil textures. - `cargo test -p victory-gpu resource::tests -- --test-threads=1`: 19 passed, 0 failed (including `d16_s8_depth_stencil_footprints_follow_the_pc_plane_order`). - `cargo clippy -p victory-gpu --all-targets -- -D warnings`: clean. - `cargo xtask policy`: 191 files ok. Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).
Marvisak commented 2026-11-26 07:01:45 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-26T06:16:48Z.


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

<!-- greyfinch-sync:Marvisak/VIctory:comment:7184272158 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3057#issuecomment-7184272158). Originally posted by [Marvisak](https://github.com/Marvisak) on 2026-11-26T06:16:48Z. --- <!-- 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 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/3057:upstream-pr/3057'
git switch 'upstream-pr/3057'

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