GPU: round fallback footprint size up to alignment #3183

Open
reeledMarek wants to merge 1 commit from upstream-pr/3185 into main
reeledMarek commented 2026-11-26 11:28:25 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by reeledMarek on 2026-11-26T11:28:25Z.


Summary

  • In crates/victory-gpu/src/resource.rs, footprint()'s fallback path (used for buffers and textures without a console layout) computed alignment = desc.alignment.max(minimum) (where minimum is 4 MiB for MSAA resources and 64 KiB otherwise) but rounded size up to KIB_64 instead of alignment.
  • This returned size < alignment for buffers requesting alignment > 64 KiB (e.g., 4 MiB) and for MSAA fallback textures, violating D3D12's GetResourceAllocationInfo contract and disagreeing with the console-layout branch above (t.size.checked_next_multiple_of(alignment)?).
  • Round size up to alignment via bytes.checked_next_multiple_of(alignment)?.

Testing

  • Added footprint_fallback_rounds_size_to_alignment in crates/victory-gpu/src/resource.rs covering both a 4 MiB-aligned buffer and an MSAA fallback texture (fails on main, passes with the fix).
  • Verified cargo test -p xtask --locked passes.
<!-- greyfinch-sync:Marvisak/VIctory:issue:6625677351 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3185). Originally posted by [reeledMarek](https://github.com/reeledMarek) on 2026-11-26T11:28:25Z. --- ## Summary - In `crates/victory-gpu/src/resource.rs`, `footprint()`'s fallback path (used for buffers and textures without a console layout) computed `alignment = desc.alignment.max(minimum)` (where `minimum` is `4 MiB` for MSAA resources and `64 KiB` otherwise) but rounded `size` up to `KIB_64` instead of `alignment`. - This returned `size < alignment` for buffers requesting `alignment > 64 KiB` (e.g., `4 MiB`) and for MSAA fallback textures, violating D3D12's `GetResourceAllocationInfo` contract and disagreeing with the console-layout branch above (`t.size.checked_next_multiple_of(alignment)?`). - Round `size` up to `alignment` via `bytes.checked_next_multiple_of(alignment)?`. ## Testing - Added `footprint_fallback_rounds_size_to_alignment` in `crates/victory-gpu/src/resource.rs` covering both a 4 MiB-aligned buffer and an MSAA fallback texture (fails on `main`, passes with the fix). - Verified `cargo test -p xtask --locked` passes.
oni-swr commented 2026-11-26 12:05:58 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by oni-swr on 2026-11-26T11:42:10Z.


WARP verification of #3185 at 6b5e0c00a24f3e50bc578830c8c6468606d2cb8f (software adapter only, no physical GPU; claimed in #1633).

Environment: Windows 11 Pro 10.0.26200; WARP D3D10Warp.dll 10.0.26100.9818; Windows SDK 10.0.26100.0 dxil.dll 1.8.2502.11 / dxc.exe 1.8.2502.11 (VICTORY_DXIL set to it); rustc via rust-toolchain.toml (1.98.1); VICTORY_D3D12_WARP=1; CARGO_TARGET_DIR outside the repo.

Commands (head and merge-base 63bcca43, which is current main):

  • cargo test -p victory-gpu --lib --locked -j 4 -- --test-threads=1
  • cargo test -p victory-gpu --lib --locked -j 4 footprint_fallback -- --test-threads=1
victory-gpu lib
main (63bcca43) 231 passed, 0 failed, 1 ignored
head (6b5e0c00) 232 passed, 0 failed, 1 ignored

resource::tests::footprint_fallback_rounds_size_to_alignment passes on head.

Revert check: with only the fix reverted (checked_next_multiple_of(alignment) back to KIB_64), the new test fails: left: Some(AllocationInfo { size: 65536, alignment: 4194304 }), right: size: 4194304. So the test catches the bug.

Defects: none found. In the fallback path alignment is max(desc.alignment, 64 KiB or 4 MiB), so it is non-zero and checked as a power of two before the rounding; overflow still returns None. The texture-layout branch already rounded to its alignment, so the change makes the fallback consistent with it. The tests are pure size arithmetic, so WARP only supplies the surrounding crate tests.

AI use: Claude Code (Claude Sonnet 5.5), coordinated by Claude Code (Claude Opus 5.5). No game files, dumps, shader names or hashes were used.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7191059809 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3185#issuecomment-7191059809). Originally posted by [oni-swr](https://github.com/oni-swr) on 2026-11-26T11:42:10Z. --- **WARP verification of #3185 at `6b5e0c00a24f3e50bc578830c8c6468606d2cb8f`** (software adapter only, no physical GPU; claimed in #1633). **Environment:** Windows 11 Pro 10.0.26200; WARP `D3D10Warp.dll` 10.0.26100.9818; Windows SDK 10.0.26100.0 `dxil.dll` 1.8.2502.11 / `dxc.exe` 1.8.2502.11 (`VICTORY_DXIL` set to it); rustc via `rust-toolchain.toml` (1.98.1); `VICTORY_D3D12_WARP=1`; `CARGO_TARGET_DIR` outside the repo. **Commands** (head and merge-base `63bcca43`, which is current `main`): - `cargo test -p victory-gpu --lib --locked -j 4 -- --test-threads=1` - `cargo test -p victory-gpu --lib --locked -j 4 footprint_fallback -- --test-threads=1` | | victory-gpu lib | |---|---| | main (`63bcca43`) | 231 passed, 0 failed, 1 ignored | | head (`6b5e0c00`) | 232 passed, 0 failed, 1 ignored | `resource::tests::footprint_fallback_rounds_size_to_alignment` passes on head. **Revert check:** with only the fix reverted (`checked_next_multiple_of(alignment)` back to `KIB_64`), the new test fails: `left: Some(AllocationInfo { size: 65536, alignment: 4194304 })`, `right: size: 4194304`. So the test catches the bug. **Defects:** none found. In the fallback path `alignment` is `max(desc.alignment, 64 KiB or 4 MiB)`, so it is non-zero and checked as a power of two before the rounding; overflow still returns `None`. The texture-layout branch already rounded to its alignment, so the change makes the fallback consistent with it. The tests are pure size arithmetic, so WARP only supplies the surrounding crate tests. AI use: Claude Code (Claude Sonnet 5.5), coordinated by Claude Code (Claude Opus 5.5). No game files, dumps, shader names or hashes were used.
cloph-dsp commented 2026-11-26 12:05:59 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by cloph-dsp on 2026-11-26T11:44:27Z.


Independent local verification of head 6b5e0c0 on Windows 11, Rust 1.100.0/MSVC:

  • cargo test --locked -p victory-gpu --lib resource::tests::footprint_fallback_rounds_size_to_alignment -- --exact — 1 passed, 0 failed.
  • git diff --check origin/main HEAD — clean.

Pure arithmetic on a synthetic ResourceDesc; no D3D12 device or game assets used. Worktree-local CARGO_TARGET_DIR. AI-assisted (Hy4 flash).

<!-- greyfinch-sync:Marvisak/VIctory:comment:7191106607 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3185#issuecomment-7191106607). Originally posted by [cloph-dsp](https://github.com/cloph-dsp) on 2026-11-26T11:44:27Z. --- Independent local verification of head `6b5e0c0` on Windows 11, Rust 1.100.0/MSVC: - `cargo test --locked -p victory-gpu --lib resource::tests::footprint_fallback_rounds_size_to_alignment -- --exact` — 1 passed, 0 failed. - `git diff --check origin/main HEAD` — clean. Pure arithmetic on a synthetic `ResourceDesc`; no D3D12 device or game assets used. Worktree-local `CARGO_TARGET_DIR`. AI-assisted (Hy4 flash).
Dukestar69 commented 2026-11-26 13:04:14 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Dukestar69 on 2026-11-26T12:08:51Z.

Review: APPROVED


Verified on RTX 5090 against origin/main (63bcca4):

  • cargo test -p victory-gpu --lib resource:: -- --test-threads=1: 19/19 passed (including footprint_fallback_rounds_size_to_alignment).
  • cargo clippy -p victory-gpu --all-targets -- -D warnings: clean.
  • cargo xtask policy: 191 files ok.

Cleanly rounds fallback footprint sizes up to alignment.

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

<!-- greyfinch-sync:Marvisak/VIctory:review:6073877872 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3185#pullrequestreview-6073877872). Originally posted by [Dukestar69](https://github.com/Dukestar69) on 2026-11-26T12:08:51Z. **Review:** APPROVED --- Verified on RTX 5090 against `origin/main` (`63bcca4`): - `cargo test -p victory-gpu --lib resource:: -- --test-threads=1`: 19/19 passed (including `footprint_fallback_rounds_size_to_alignment`). - `cargo clippy -p victory-gpu --all-targets -- -D warnings`: clean. - `cargo xtask policy`: 191 files ok. Cleanly rounds fallback footprint sizes up to alignment. Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).
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/3185:upstream-pr/3185'
git switch 'upstream-pr/3185'

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