GPU: preserve sub-64 KiB alignments and check bounds in allocation_info #1396
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1396"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from Marvisak/VIctory. Originally posted by fuzeofficlal on 2026-11-24T17:43:29Z.
Fixes #782.
Summary
total.alignmentto1instead ofKIB_64inplace()so 4 KiB (SW_4KB_S) and 256-byte linear texture layouts retain their alignments inGetResourceAllocationInfoandGetResourceAllocationInfo2(andcount == 0returns{ size: 0, alignment: 1 }).footprint()sizes up to their computedalignmentrather thanKIB_64so 4 MiB-aligned fallback resources never returnsize < alignment.u64offset/size arithmetic withchecked_next_multiple_of+checked_add, reject null descriptor pointers whencount > 0, fill remainingAllocationInfo1entries with error sentinels on failure, and writeoutviaout.write(total)when non-null without creating references to uninitialized return slots.Verification
resource::tests::allocation_info_preserves_sub_64k_alignments_and_boundscovering 4 KiB BC7 textures, 256-byte linear textures, mixed batches, 4 MiB fallback alignment, null/empty calls, andu64overflow boundaries, verified against nativeID3D12Device::GetResourceAllocationInfoon NVIDIA GeForce RTX 5090, AMD Radeon(TM) Graphics, and D3D12 WARP.cargo test -p victory-gpu,cargo clippy --workspace --all-features, andcargo xtask policy: passed.Imported from Marvisak/VIctory. Originally posted by dcastell1 on 2026-11-24T17:51:20Z.
Verified on native Windows (no Wine): NVIDIA GeForce RTX 5090 (driver 621.24), Windows 11 10.0.26300, Rust 1.98.1, MSVC 14.44.35207, debug build.
main@ffe310ebaseline on this box: 342 passed, 0 failed, 6 ignored.One more than the baseline; preserving sub-64 KiB alignments and checking bounds is exercised and green.
Tree restored afterwards (full diff against a clean checkout); no game data, the tests are synthetic. AI-assisted (opencode): applied the patch to a built tree, ran
cargo test --workspace, reverted it.Imported from Marvisak/VIctory. Originally posted by catminou4 on 2026-11-24T20:49:18Z.
Review: COMMENTED
Static review only: victory-gpu/victory-hle are Windows-only (D3D12/windows_sys/Win32) — nothing compiles or runs on macOS; this is source review plus the PR's own Windows tests.
allocation_info/allocation_info2: footprint now rounds to the resource's own alignment instead of always 64 KiB (sub-64 KiB alignments preserved), null descs with count>0 yield the u64::MAX sentinel instead of an empty placement, null out pointers are checked before write, and per-descriptor entries are only written when
eachis non-null. Bounds and sentinel handling look careful; Windows-only, relies on the PR's tests.Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T01:25:17Z.
Automated triage for the maintainers.
Merge candidate. The PR is now reduced to what the second look asked for.
place()incrates/victory-gpu/src/resource.rsstarts the running total at alignment 1 instead of 64 KiB, soGetResourceAllocationInfo/GetResourceAllocationInfo2report the 4 KiB or 256-byte alignment thatfootprintgives each resource (#782). The new testallocation_info_preserves_sub_64k_alignmentschecks the 4KB_S BC7 total(0x56000, 0x1000)through both 0xc8 and 0x360 againsteach[0], the 256-byte linear texture, and the offsets and maximum alignment of a mixed batch.On your reply: confirmed. The
footprint()rounding change, the null, overflow and sentinel guards, and test sections 3 to 6 are all gone, and the diff is one hunk plus the test. It merges cleanly with currentmain.CI: passing (
check).Generated by Claude Code
Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T22:01:48Z.
Automated triage for the maintainers, second look (a review against
main, with the PR built and tested).The core change is right and matters: the running total's alignment should start at 1, so that a batch of 4 KiB-aligned textures reports 4 KiB, which is what the title asks for and checks. This can be merged once it is reduced to that. Please keep the
place()change incrates/victory-gpu/src/resource.rs(alignment: 1for the running total) and the first two cases of the new test (the 4KB_S BC7 total of(0x56000, 0x1000)through 0xc8 and 0x360 equal toeach[0], and the mixed batch offsets). Please drop thefootprint()fallback rounding change, the null and overflow guards and the sentinel back-fill inallocation_info,allocation_info2andplace, and test sections 3 to 6 (including the host-adapter enumeration): the title passes neither null pointers nor sizes near 2^64, and nothing shows that the rounding change is needed.Push the change and it will be reviewed again. Thank you for the contribution.
Imported from Marvisak/VIctory. Originally posted by fuzeofficlal on 2026-11-25T22:38:01Z.
Reduced and rebased onto
main(f3578e3) in08fb746per second-look feedback:place()change (alignment: 1for the running total) and the first two test sections (4KB_S BC7(0x56000, 0x1000)through0xc8/0x360matchingeach[0], linear 256-byte texture, and mixed batch offsets/max alignment).footprint()fallback rounding change, null/overflow/sentinel guards inallocation_info/allocation_info2/place, and test sections 3–6 (including host-adapter enumeration).resource::tests(18/18 passed),cargo clippy -p victory-gpu --all-targets(default &--features diagnostics, 0 warnings), andcargo xtask policy(190 files ok).View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.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.