GPU: preserve sub-64 KiB alignments and check bounds in allocation_info #1396
No reviewers
Labels
No labels
accessibility
area: build
area: formats
area: gpu
area: loader
area: runtime
area: shader
bug
documentation
duplicate
enhancement
good first issue
gpu: amd
gpu: intel
gpu: nvidia
help wanted
host: wine
invalid
out of scope
question
request
run report
triage: confirmed
triage: has patch
triage: merge candidate
triage: needs info
triage: needs rebase
triage: needs work
triage: proposed close
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/Marvisak--VIctory!1396
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-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?
@fuzeofficlal on GitHub · 2026-11-24 17:43 UTC · original
fuzeofficlal:fix/resource-allocation-info-alignment-782→main· +133 −1 · 1 files · 1 commits · openFixes #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.@dcastell1 on GitHub · 2026-11-24 17:51 UTC · original
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.@Marvisak on GitHub · 2026-11-25 01:25 UTC · original · edited 2026-11-26 00:25 UTC
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
@Marvisak on GitHub · 2026-11-25 22:01 UTC · original
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.
@fuzeofficlal on GitHub · 2026-11-25 22:38 UTC · original
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.