GPU: handle depth/stencil copy footprints #504

Manually merged
github merged 1 commit from gh-pr/504/head into gh-pr/504/base 2026-11-26 04:06:25 +00:00
Owner

@⁠broccolize on GitHub · 2026-11-24 04:16 UTC · original
broccolize:gpu/depth-stencil-copy-footprints → main · +67 −12 · 1 files · 1 commits · merged 2026-11-25 00:11 UTC

GetCopyableFootprints now returns separate depth and stencil layouts with 512-byte row alignment. The regression test covers both DXGI depth/stencil format families across two mips and two array slices.

The regression failed on main and passes with this change. A local harness matched 528 native D3D12 queries per adapter on the GTX 1650, Intel UHD Graphics, and WARP.

On Windows with Rust 1.98.1 (GNU), the GPU suite passed 44 tests by default and 46 with diagnostics. Both runs had zero failures and one ignored benchmark. The asset policy and git diff --check passed.

AI-assisted with Codex. All checks used synthetic inputs.

**@⁠broccolize** on GitHub · 2026-11-24 04:16 UTC · [original](https://github.com/Marvisak/VIctory/pull/504) `broccolize:gpu/depth-stencil-copy-footprints` → `main` · +67 −12 · 1 files · 1 commits · merged 2026-11-25 00:11 UTC `GetCopyableFootprints` now returns separate depth and stencil layouts with 512-byte row alignment. The regression test covers both DXGI depth/stencil format families across two mips and two array slices. The regression failed on `main` and passes with this change. A local harness matched 528 native D3D12 queries per adapter on the GTX 1650, Intel UHD Graphics, and WARP. On Windows with Rust 1.98.1 (GNU), the GPU suite passed 44 tests by default and 46 with diagnostics. Both runs had zero failures and one ignored benchmark. The asset policy and `git diff --check` passed. AI-assisted with Codex. All checks used synthetic inputs.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:06:24 +00:00
github manually merged commit b956320125 into gh-pr/504/base 2026-11-26 04:06:25 +00:00
Author
Owner

@⁠fromthemoonx on GitHub · 2026-11-24 04:40 UTC · original

Tested b956320 (on main d2a4bae) on another adapter, with a wider native comparison.

Environment: Windows 11 Pro build 26300, AMD Ryzen 7 5700X, 16 GB, NVIDIA GeForce RTX 3060 12 GB (driver 610.88), Rust 1.98.1 x86_64-pc-windows-msvc (MSVC rather than GNU), debug.

Native comparison (a throwaway test in resource.rs, not pushed): the same description went to copyable_footprints and to the RTX 3060 device's own GetCopyableFootprints, comparing offset, format, width, height, depth, row pitch, row count, row size and total for every record.

  • Formats: 19–22 and 44–47, plus 28, 40, 41, 55 and 71 as non-planar controls
  • Sizes: 1×1, 16×8, 17×9, 64×64, 100×37, 257×3, 1920×1080
  • Mips 1–3, array sizes 1–3, flags 0 and ALLOW_DEPTH_STENCIL (depth formats)
  • Bases 0, 512 and 1024, and every first with count running to the last subresource
queries records mismatched queries
this PR 29,484 160,860 0
main (same harness) 29,484 160,860 24,192

On main the mismatches are the depth/stencil formats, as the description says: plane 0 reports the view format with a 256-byte pitch, and plane 1 comes back with the all-ones values (e.g. f19 1×1: native R32_TYPELESS, pitch 512, then R8_TYPELESS at offset 512; total 513 against u64::MAX).

Other checks

  • cargo test --locked -p victory-gpu --lib: 44 passed, 0 failed, 1 ignored, including depth_stencil_footprints_follow_the_pc_plane_order
  • cargo test --locked --workspace: 265 passed, 0 failed, 4 ignored
  • cargo xtask policy: 151 files ok; git diff --check: clean
  • clippy and cargo fmt --check report only what main already has (host.rs:267 safety comment, and a format! in host_texture), nothing in the changed lines

Not tested: copies through these footprints on the GPU (layout calculation only); no game data used.

AI-assisted (Claude Code) ran the checks and drafted this comment.

**@⁠fromthemoonx** on GitHub · 2026-11-24 04:40 UTC · [original](https://github.com/Marvisak/VIctory/pull/504#issuecomment-7122239733) Tested `b956320` (on `main` `d2a4bae`) on another adapter, with a wider native comparison. **Environment:** Windows 11 Pro build 26300, AMD Ryzen 7 5700X, 16 GB, NVIDIA GeForce RTX 3060 12 GB (driver 610.88), Rust 1.98.1 `x86_64-pc-windows-msvc` (MSVC rather than GNU), debug. **Native comparison** (a throwaway test in `resource.rs`, not pushed): the same description went to `copyable_footprints` and to the RTX 3060 device's own `GetCopyableFootprints`, comparing offset, format, width, height, depth, row pitch, row count, row size and total for every record. - Formats: 19–22 and 44–47, plus 28, 40, 41, 55 and 71 as non-planar controls - Sizes: 1×1, 16×8, 17×9, 64×64, 100×37, 257×3, 1920×1080 - Mips 1–3, array sizes 1–3, flags 0 and `ALLOW_DEPTH_STENCIL` (depth formats) - Bases 0, 512 and 1024, and every `first` with `count` running to the last subresource | | queries | records | mismatched queries | |---|---|---|---| | this PR | 29,484 | 160,860 | **0** | | `main` (same harness) | 29,484 | 160,860 | 24,192 | On `main` the mismatches are the depth/stencil formats, as the description says: plane 0 reports the view format with a 256-byte pitch, and plane 1 comes back with the all-ones values (e.g. f19 1×1: native `R32_TYPELESS`, pitch 512, then `R8_TYPELESS` at offset 512; total 513 against `u64::MAX`). **Other checks** - `cargo test --locked -p victory-gpu --lib`: 44 passed, 0 failed, 1 ignored, including `depth_stencil_footprints_follow_the_pc_plane_order` - `cargo test --locked --workspace`: 265 passed, 0 failed, 4 ignored - `cargo xtask policy`: 151 files ok; `git diff --check`: clean - clippy and `cargo fmt --check` report only what `main` already has (`host.rs:267` safety comment, and a `format!` in `host_texture`), nothing in the changed lines **Not tested:** copies through these footprints on the GPU (layout calculation only); no game data used. AI-assisted (Claude Code) ran the checks and drafted this comment.
Author
Owner

@⁠Dathinel on GitHub · 2026-11-24 06:31 UTC · original

I checked how #409 and #504 interact when a depth/stencil query starts at an unaligned base. On an RTX 3050 Laptop GPU, for a 16×8 D24_UNORM_S8_UINT texture with two mips and two array slices, GetCopyableFootprints(first=3, count=2, base=513) crosses from the last depth subresource into stencil:

Revision Offsets Plane formats Row pitches Total bytes
Native D3D12 513, 2561 R32_TYPELESS, R8_TYPELESS 512, 512 5648
#409 (340499c) 513, unknown D24_UNORM_S8_UINT, unknown 256, unknown unknown
#504 (b956320) 1024, 3072 R32_TYPELESS, R8_TYPELESS 512, 512 6159

I resolved the resource.rs conflict locally against d2a4bae by taking #504’s format and row-pitch selection per plane, applying #409’s block dimensions to that format, and keeping #409’s placement relative to the caller’s base. The result matched all 38 native records and all seven totals across RGBA8 and D24/S8 with bases 0, 1 and 513.

A regression test with those two expected rows and the total runs without a GPU. It failed on each PR for the reason above. All four filtered footprint tests passed on the combined tree, including both PRs’ original regressions. This covered layout queries only. The placement and plane fixes are from the authors of #409 and #504. AI-assisted, using synthetic descriptions.

Both changes remain attributable to their respective PRs. For the next rebase, here is the single-file resolution and CPU regression. It is an experimental merge of the two GitHub test merges. Run cargo test --frozen -p victory-gpu --lib resource::tests::depth_stencil_footprints_preserve_an_unaligned_base_across_planes -- --exact on that commit.

**@⁠Dathinel** on GitHub · 2026-11-24 06:31 UTC · [original](https://github.com/Marvisak/VIctory/pull/504#issuecomment-7124028522) I checked how #409 and #504 interact when a depth/stencil query starts at an unaligned base. On an RTX 3050 Laptop GPU, for a 16×8 D24_UNORM_S8_UINT texture with two mips and two array slices, `GetCopyableFootprints(first=3, count=2, base=513)` crosses from the last depth subresource into stencil: | Revision | Offsets | Plane formats | Row pitches | Total bytes | |---|---|---|---|---:| | Native D3D12 | 513, 2561 | R32_TYPELESS, R8_TYPELESS | 512, 512 | 5648 | | #409 (`340499c`) | 513, unknown | D24_UNORM_S8_UINT, unknown | 256, unknown | unknown | | #504 (`b956320`) | 1024, 3072 | R32_TYPELESS, R8_TYPELESS | 512, 512 | 6159 | I resolved the `resource.rs` conflict locally against `d2a4bae` by taking #504’s format and row-pitch selection per plane, applying #409’s block dimensions to that format, and keeping #409’s placement relative to the caller’s base. The result matched all 38 native records and all seven totals across RGBA8 and D24/S8 with bases 0, 1 and 513. A regression test with those two expected rows and the total runs without a GPU. It failed on each PR for the reason above. All four filtered footprint tests passed on the combined tree, including both PRs’ original regressions. This covered layout queries only. The placement and plane fixes are from the authors of #409 and #504. AI-assisted, using synthetic descriptions. Both changes remain attributable to their respective PRs. For the next rebase, here is the [single-file resolution and CPU regression](https://github.com/Dathinel/VIctory/commit/3f1d688d347f99c0e14489f3e40c3bdc197a017f). It is an experimental merge of the two GitHub test merges. Run `cargo test --frozen -p victory-gpu --lib resource::tests::depth_stencil_footprints_preserve_an_unaligned_base_across_planes -- --exact` on that commit.
Author
Owner

@⁠fromthemoonx on GitHub · 2026-11-24 06:40 UTC · original

A correction to my run above, and @⁠Dathinel's combined resolution on the RTX 3060.

My "0 mismatches" used bases 0, 512 and 1024 only, all 512-aligned. I re-ran the same harness (same formats, sizes, mips, arrays, flags and first/count ranges) with unaligned bases 1, 256 and 513 against native GetCopyableFootprints:

revision aligned bases (0/512/1024) unaligned bases (1/256/513)
main d2a4bae 24,192 of 29,484 queries mismatch 29,484 of 29,484 mismatch
this PR b956320 0 of 29,484 29,484 of 29,484 mismatch
Dathinel's 3f1d688 (#409 + this PR) 0 of 29,484 0 of 29,484

With an unaligned base, native places the first subresource at the base itself (e.g. f19 1×1, base 1: native offsets 1 and 513, total 513), while main and this PR round it up to 512 (offsets 512 and 1024, total 1024). That happens for every format, so it's older than this PR and is #409's part, as Dathinel says. On 3f1d688, cargo test --locked -p victory-gpu --lib gives 46 passed, 0 failed, 1 ignored, including both PRs' regressions and depth_stencil_footprints_preserve_an_unaligned_base_across_planes.

So on NVIDIA desktop too, that resolution matches native for both the plane layout and the base placement.

Layout queries only; no game data used. AI-assisted (Claude Code).

**@⁠fromthemoonx** on GitHub · 2026-11-24 06:40 UTC · [original](https://github.com/Marvisak/VIctory/pull/504#issuecomment-7124175303) A correction to my run above, and @⁠Dathinel's combined resolution on the RTX 3060. My "0 mismatches" used bases 0, 512 and 1024 only, all 512-aligned. I re-ran the same harness (same formats, sizes, mips, arrays, flags and `first`/`count` ranges) with **unaligned bases 1, 256 and 513** against native `GetCopyableFootprints`: | revision | aligned bases (0/512/1024) | unaligned bases (1/256/513) | |---|---|---| | `main` `d2a4bae` | 24,192 of 29,484 queries mismatch | 29,484 of 29,484 mismatch | | this PR `b956320` | 0 of 29,484 | 29,484 of 29,484 mismatch | | Dathinel's `3f1d688` (#409 + this PR) | **0** of 29,484 | **0** of 29,484 | With an unaligned base, native places the first subresource at the base itself (e.g. f19 1×1, base 1: native offsets 1 and 513, total 513), while `main` and this PR round it up to 512 (offsets 512 and 1024, total 1024). That happens for every format, so it's older than this PR and is #409's part, as Dathinel says. On `3f1d688`, `cargo test --locked -p victory-gpu --lib` gives 46 passed, 0 failed, 1 ignored, including both PRs' regressions and `depth_stencil_footprints_preserve_an_unaligned_base_across_planes`. So on NVIDIA desktop too, that resolution matches native for both the plane layout and the base placement. Layout queries only; no game data used. AI-assisted (Claude Code).
Author
Owner

@⁠broccolize on GitHub · 2026-11-24 07:29 UTC · original

Thanks @⁠Dathinel for the combined patch and @⁠fromthemoonx for checking both aligned and unaligned bases against native D3D12.

Which PR should land first, #409 or #504? If #409 lands first, I can rebase this PR using the tested resolution.

**@⁠broccolize** on GitHub · 2026-11-24 07:29 UTC · [original](https://github.com/Marvisak/VIctory/pull/504#issuecomment-7125056134) Thanks @⁠Dathinel for the combined patch and @⁠fromthemoonx for checking both aligned and unaligned bases against native D3D12. Which PR should land first, #409 or #504? If #409 lands first, I can rebase this PR using the tested resolution.
Author
Owner

@⁠Dathinel on GitHub · 2026-11-24 07:53 UTC · original

I'd land #409 first, then rebase #504 on it as you suggest. #409 fixes placement relative to the caller's base and the packed-format row sizes reported in #386. #504 can then add plane-specific formats and pitches on top, keeping both sets of regressions.

I checked both orders against main@c2e7254. Applying the corresponding resource.rs resolution produced the same Git tree either way. All four footprint tests passed on that combined tree, including the unaligned cross-plane case. When rebasing, the tested resolution is a reference for the conflicting hunk. You can check the result with cargo test --locked -p victory-gpu --lib footprints. Thanks for taking the rebase. AI-assisted.

**@⁠Dathinel** on GitHub · 2026-11-24 07:53 UTC · [original](https://github.com/Marvisak/VIctory/pull/504#issuecomment-7125485353) I'd land **#409 first**, then rebase #504 on it as you suggest. #409 fixes placement relative to the caller's base and the packed-format row sizes reported in #386. #504 can then add plane-specific formats and pitches on top, keeping both sets of regressions. I checked both orders against `main@c2e7254`. Applying the corresponding `resource.rs` resolution produced the **same Git tree** either way. All four footprint tests passed on that combined tree, including the unaligned cross-plane case. When rebasing, the [tested resolution](https://github.com/Dathinel/VIctory/commit/3f1d688d347f99c0e14489f3e40c3bdc197a017f) is a reference for the conflicting hunk. You can check the result with `cargo test --locked -p victory-gpu --lib footprints`. Thanks for taking the rebase. AI-assisted.
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!504
No description provided.