GPU: honor BaseOffset in GetCopyableFootprints #3285

Open
andrewpozdnakov7-jpg wants to merge 1 commit from upstream-pr/3287 into main
andrewpozdnakov7-jpg commented 2026-11-26 15:59:53 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by andrewpozdnakov7-jpg on 2026-11-26T15:59:53Z.


Refs #386.

GetCopyableFootprints adds BaseOffset to each subresource's relative layout. The shim aligned the absolute position instead. A 10×6 RGBA8 texture with two mips at base 1 returned offsets 512 and 2048 on main. Native D3D12 returned 1 and 1537. Microsoft API documentation

Keep subresource alignment relative to the base and add the base exactly as supplied. This addresses the base-offset result from #386 and credits the earlier patch in #409.

Verification

  • The new regression fails on main 63bcca4 at base 1 and passes with the patch. It checks bases 0, 1, 255, 512 and 513 against native D3D12 on app-local WARP 1.0.22 / Agility 1.620.2. The total is 2,068 bytes at each base.
  • All 19 resource tests passed. Full GPU lib run passed 247 tests with 1 ignored. Strict GPU Clippy passed with and without all features, and policy passed.
  • Synthetic layout queries only.

AI-assisted with Codex.

<!-- greyfinch-sync:Marvisak/VIctory:issue:6630462807 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3287). Originally posted by [andrewpozdnakov7-jpg](https://github.com/andrewpozdnakov7-jpg) on 2026-11-26T15:59:53Z. --- Refs #386. `GetCopyableFootprints` adds `BaseOffset` to each subresource's relative layout. The shim aligned the absolute position instead. A 10×6 RGBA8 texture with two mips at base 1 returned offsets 512 and 2048 on main. Native D3D12 returned 1 and 1537. [Microsoft API documentation](https://learn.microsoft.com/en-us/windows/win32/api/d3d12/nf-d3d12-id3d12device-getcopyablefootprints) Keep subresource alignment relative to the base and add the base exactly as supplied. This addresses the base-offset result from #386 and credits the earlier patch in #409. ## Verification - The new regression fails on main `63bcca4` at base 1 and passes with the patch. It checks bases 0, 1, 255, 512 and 513 against native D3D12 on app-local WARP 1.0.22 / Agility 1.620.2. The total is 2,068 bytes at each base. - All 19 resource tests passed. Full GPU lib run passed 247 tests with 1 ignored. Strict GPU Clippy passed with and without all features, and policy passed. - Synthetic layout queries only. AI-assisted with Codex.
Dukestar69 commented 2026-11-26 16:09:38 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Dukestar69 on 2026-11-26T16:09:38Z.

Review: APPROVED


Reviewed the diff and verified locally on Windows 11 x64 (RTX 5090):

  • Computing footprint.offset = base + (end - base).next_multiple_of(PLACEMENT) aligns subresources relative to base and matches native ID3D12Device::GetCopyableFootprints across both aligned and unaligned base offsets.
  • cargo test -p victory-gpu --lib resource:: -- --test-threads=1 (RTX 5090): 19 passed, 0 failed (including copyable_footprints_add_the_exact_base_offset).
  • 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:6077296994 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3287#pullrequestreview-6077296994). Originally posted by [Dukestar69](https://github.com/Dukestar69) on 2026-11-26T16:09:38Z. **Review:** APPROVED --- Reviewed the diff and verified locally on Windows 11 x64 (RTX 5090): - Computing `footprint.offset = base + (end - base).next_multiple_of(PLACEMENT)` aligns subresources relative to `base` and matches native `ID3D12Device::GetCopyableFootprints` across both aligned and unaligned `base` offsets. - `cargo test -p victory-gpu --lib resource:: -- --test-threads=1` (RTX 5090): 19 passed, 0 failed (including `copyable_footprints_add_the_exact_base_offset`). - `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).
andrewpozdnakov7-jpg commented 2026-11-26 17:01:29 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by andrewpozdnakov7-jpg on 2026-11-26T17:01:29Z.


I checked this exact b06f7d7 with #2193 at a3c16a3. They merge cleanly. The cross-PR regression 8e690a1 creates a 10x6 RGBA8 texture with automatic mips and two array slices. It takes the guest GetDesc result and queries three footprints that cross the slice boundary, then compares dimensions, pitch, row counts, row sizes, offsets and total bytes against native D3D12.

The same test failed three times on this PR alone at GetDesc (0 instead of 4 mips). It failed three times on #2193 alone at the first unaligned base. The integration passed three runs at bases 0, 1 and 513, with row counts [1, 6, 3] and 2,580 bytes each time. On verified app-local Agility 1.620.2/WARP 1.0.22, resource tests passed 22/22 and GPU diagnostics 251/0/1, including runtime identity. Strict GPU Clippy passed in both configurations. Policy passed.

The maintainers can land both fixes independently. The regression is available once both are present. Please retain its Git author on cherry-pick, or add Co-authored-by: andrewpozdnakov7-jpg <[email protected]> if folding it into another commit. AI-assisted with Codex.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7198392234 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3287#issuecomment-7198392234). Originally posted by [andrewpozdnakov7-jpg](https://github.com/andrewpozdnakov7-jpg) on 2026-11-26T17:01:29Z. --- I checked this exact `b06f7d7` with #2193 at `a3c16a3`. They merge cleanly. The [cross-PR regression `8e690a1`](https://github.com/andrewpozdnakov7-jpg/VIctory/commit/8e690a11a9c35dd92b5b99262b4a034ca81d1632) creates a 10x6 RGBA8 texture with automatic mips and two array slices. It takes the guest `GetDesc` result and queries three footprints that cross the slice boundary, then compares dimensions, pitch, row counts, row sizes, offsets and total bytes against native D3D12. The same test failed three times on this PR alone at `GetDesc` (0 instead of 4 mips). It failed three times on #2193 alone at the first unaligned base. The integration passed three runs at bases 0, 1 and 513, with row counts [1, 6, 3] and 2,580 bytes each time. On verified app-local Agility 1.620.2/WARP 1.0.22, resource tests passed 22/22 and GPU diagnostics 251/0/1, including runtime identity. Strict GPU Clippy passed in both configurations. Policy passed. The maintainers can land both fixes independently. The regression is available once both are present. Please retain its Git author on cherry-pick, or add `Co-authored-by: andrewpozdnakov7-jpg <[email protected]>` if folding it into another commit. AI-assisted with Codex.
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/3287:upstream-pr/3287'
git switch 'upstream-pr/3287'

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