GPU: round fallback footprint size up to alignment #3185

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

@⁠reeledMarek on GitHub · 2026-11-26 11:28 UTC · original
reeledMarek:fix/gpu-footprint-fallback-alignment → main · +30 −1 · 1 files · 1 commits · open

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.
**@⁠reeledMarek** on GitHub · 2026-11-26 11:28 UTC · [original](https://github.com/Marvisak/VIctory/pull/3185) `reeledMarek:fix/gpu-footprint-fallback-alignment` → `main` · +30 −1 · 1 files · 1 commits · open ## 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.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 11:33:14 +00:00
Author
Owner

@⁠oni-swr on GitHub · 2026-11-26 11:42 UTC · original

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.

**@⁠oni-swr** on GitHub · 2026-11-26 11:42 UTC · [original](https://github.com/Marvisak/VIctory/pull/3185#issuecomment-7191059809) **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.
Author
Owner

@⁠cloph-dsp on GitHub · 2026-11-26 11:44 UTC · original

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).

**@⁠cloph-dsp** on GitHub · 2026-11-26 11:44 UTC · [original](https://github.com/Marvisak/VIctory/pull/3185#issuecomment-7191106607) 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).
Author
Owner

@⁠Dukestar69 on GitHub · 2026-11-26 12:08 UTC · original · approved these changes

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).

**@⁠Dukestar69** on GitHub · 2026-11-26 12:08 UTC · [original](https://github.com/Marvisak/VIctory/pull/3185#pullrequestreview-6073877872) · **approved these changes** 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 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/3185/head:github-bot/gh-3185'
git switch 'github-bot/gh-3185'

Merge

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