GPU/descriptor: validate buffer extent/view in own_bytes and require 16-byte alignment for raw views #803
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/fxceless--victory-fork!803
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-803"
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?
@AscilCH on GitHub · 2026-11-25 08:19 UTC · original
AscilCH:fix/gpu-descriptor-own-bytes-bounds-and-raw-align→main· +187 −32 · 1 files · 1 commits · openSummary
Fix two
own_bytes()/own_bytes_if()bugs introduced ina26859f(crates/victory-gpu/src/descriptor/host.rs):Validate buffer extent and view validity before calling
shadow::exact().own_bytes_if()previously checked onlyelement > 0 && count > 0andoffset % element != 0, without checking(first + count) * element <= len(the title buffer's actual extent) orbuffer_view_ok.exactcopies viashadow::exact(), after whichbuffer_srv()/buffer_uav()ranbuffer_view_okagainst the newly allocatedexactbuffer's width instead of the title buffer'slen, completely bypassing the bounds check.lenandDXGI_FORMATintoown_bytes()/own_bytes_if()and requirelen > 0,(first + count) * element <= len, andbuffer_view_ok(including structured-to-raw conversion viaraw_window) before allocating anexactcopy.Enforce D3D12's 16-byte alignment requirement for RAW buffer SRVs/UAVs in
own_bytes().own_bytes_if()previously checked onlyoffset.is_multiple_of(element)(4 bytes forR32_TYPELESSRAWviews), ignoringbuffer_view_ok's 16-byte raw alignment check (first.is_multiple_of(4)).None, shiftedFirstElementbyoffset / 4, failedbuffer_view_ok, and were left NULL.offset.is_multiple_of(4) && (first + offset / 4).is_multiple_of(4)for raw views to stay on the whole buffer copy, routing misaligned raw views toshadow::exact()starting atFirstElement = 0.Verification
cargo test -p victory-gpu --locked -- descriptor:::30 passed; 0 failed; 0 ignored, including newout_of_bounds_and_invalid_views_do_not_allocate_exact_copiesandraw_views_off_16_byte_alignment_get_exact_copies.cargo clippy -p victory-gpu --all-targets --all-features --locked: 0 warnings incrates/victory-gpu/src/descriptor/host.rs(only pre-existing9376fd6warnings indraw.rsandindirect.rs).cargo xtask policy:171 files ok.(AI-assisted; synthetic unit tests only, no game data.)
@MamaLeVrai on GitHub · 2026-11-25 09:54 UTC · original
Test report on real hardware: AMD RX 6950 XT (RDNA2), Windows 11, Rust 1.98.1, with a GPU present. I merged this PR's head
ba5600dintomain9376fd6in a throwaway tree (no conflict).cargo clippy --workspace --all-targets --locked -- -D warningsfails, with the same two errors asmainitself on this machine (function placed_filler_twins is never used,field depth_written is never read,victory-gpu): this PR adds none and removes none.cargo test --workspace --locked: 542 passed, 0 failed, 10 ignored, two runs (mainalone: 540 passed). The title was not run, so this says nothing about in-game effect. No game data.AI-assisted (Claude Code); no game data.
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.