GPU: rectangle draws check their bounds without 32-bit overflow #616
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/616"
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 itzzArshad on 2026-11-24T05:42:02Z.
The rectangle-list bounds check added
first + countin 32 bits, so a draw whose first vertex and count together pass 2^32 wrapped to a small end, passed the check, and had the CPU expansion read far outside the vertex buffer at submission (title memory that may not be mapped), or panicked in debug builds. The check is now done in 64 bits with a checked multiply by the stride.The expanded draw's vertex count (
count / 3 * 6) and its vertex view size (rects * 6 * stride) also overflowed 32 bits silently; such draws are now dropped with a warning instead of running with a wrapped count.Imported from Marvisak/VIctory. Originally posted by LAKSHYA-cmd-tech on 2026-11-24T05:43:03Z.
Review: APPROVED
Verified and tested on Windows 11 x64 (D3D12 WARP + Hardware).
ect_source: checked addition and multiplication in 64 bits ((u64::from(first) + u64::from(count)).checked_mul(stride)) cleanly prevents 32-bit integer wrap-around on boundary values (u32::MAX).
ectangle_bounds_do_not_wrap,
ectangle_vertices_inside_their_buffer) pass.
Imported from Marvisak/VIctory. Originally posted by geiyiliyabumo on 2026-11-24T10:50:27Z.
Independent verification & code review on Windows 11 Pro (build 26100) + AMD Radeon RX 9060 XT (RDNA4, driver
32.0.32029.2010, Rust1.98.1), merged ontomain(ffe310e):cargo xtask policy: PASS (154 files ok)cargo test -p victory-gpu --locked -- draw: 3/3 PASS (including underVICTORY_D3D12_DEBUG=1on RX 9060 XT and WARP)cargo clippy -p victory-gpu --all-targets --locked -- -D warnings: FAIL after clean auto-merge ontomain(ffe310e)Findings
clippy::items-after-test-module): Althoughgit mergesucceeds without conflict againstffe310e, it leaves#[cfg(test)] mod tests(crates/victory-gpu/src/draw.rs:1226) ahead ofviewports,scissors,blend_factor, andstencil_ref(draw.rs:1256-1274), which failsclippy --all-targets -- -D warnings. Movingmod teststo the end ofdraw.rsresolves it.draw.rsrectangles):.map(|offset| v.address + offset)still uses uncheckedu64addition on the guestv.addresspointer; switching to.and_then(|offset| v.address.checked_add(offset))avoids debug-mode overflow panics on malformed high addresses.The core
expanded_verticesandrect_sourceoverflow logic and tests look solid otherwise.AI-assisted; synthetic tests only, no game files.
Imported from Marvisak/VIctory. Originally posted by mercuryVM on 2026-11-24T11:20:37Z.
Review: APPROVED
Tested
94bc7cfon Windows 11, RTX 5070, MSVC:cargo test -p victory-gpu -- --test-threads=146 passed, including the three new rectangle tests. With--features diagnostics, 48 passed.rect_sourcedoesfirst + countand the multiply by stride in u64 withchecked_mul, so the old wrap past 2^32, which read far outside the vertex buffer, is gone. Every 32-bit narrowing (expanded_vertices,u32::try_from(rects * 6 * stride)) is now checked before use.items_after_test_moduleat draw.rs:1191, because the newmod testssits in the middle of the file. Moving it to the end keeps clippy as quiet as before. The other warning (host.rs:267) was already there.AI-assisted (Claude Code).
Imported from Marvisak/VIctory. Originally posted by MichaelSmithAI on 2026-11-24T13:32:14Z.
Melissa checked the accepted boundary through a rendered draw on RTX 4090 with Wine/vkd3d-proton 3.2. Head
e930351merged cleanly withffe310e. A guest rectangle-list draw used three vertices starting at vertex 3 in a 48-byte vertex view with an 8-byte stride. Its last vertex ended exactly at the end of the view. After expansion, all 64 pixels of the 8×8 render target read back red.All four rectangle-filtered tests passed on that integration, including both bounds tests, the fourth-corner test, and the new render readback. This checks that the revised bounds still admit a valid edge-aligned draw.
Imported from Marvisak/VIctory. Originally posted by Yaekai on 2026-11-24T16:15:06Z.
Independent test & review on Windows 11 + NVIDIA RTX 3070 (Rust 1.98.1) at head
e930351:cargo test -p victory-gpu --lib: 46 passed, 0 failed.cargo clippy -p victory-gpu -- -D warnings: 0 warnings.draw.rs+ new rectangle bounds unit tests: cleanly prevents 32-bit overflow in vertex/address calculations. Ready to merge!Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T00:30:53Z.
Automated triage for the maintainers.
Needs rebase. This PR does not merge cleanly into current
main(ac2525d). Conflicting files:crates/victory-gpu/src/draw.rs.The content has not been reviewed yet; it will be once the branch is rebased onto
main.Generated by Claude Code
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.