GPU: keep Staging::detile inside the staging buffer and harden committed() #1657
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1658"
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 HailLucifer666 on 2026-11-24T20:33:31Z.
Issue:
Staging::detilebuildsfrom_raw_parts_mut(data + offset, pitch * rows * depth). Because D3D12GetCopyableFootprintsdoes not pad the final row of the final subresource toRowPitch(e.g., 4x4 RGBA8:total = 784whilepitch * rows = 1024), the slice extends past the mapped upload buffer allocation (UB / page-boundary fault).committed(at, len)computesp + lenunchecked (wraps toend < pin release and returnstrue) and checks onlyMEM_COMMIT, lettingPAGE_NOACCESS/PAGE_GUARDpages pass.Fix:
Staging.sizeunconditionally and clamp each subresource slice tosize - footprint.Offsetviasubresource_len().checked_add/saturating_addand rejectPAGE_NOACCESS | PAGE_GUARDincommitted().subresource_len_stays_inside_staging_totalandcommitted_rejects_overflow_and_noaccess_pages.Verification:
cargo clippy -p victory-gpu --all-targets --locked -- -D warnings(clean)cargo clippy -p victory-gpu --all-targets --all-features --locked -- -D warnings(clean)cargo test -p victory-gpu --locked(52 passed, 0 failed, 1 ignored)cargo test -p xtask --locked(4 passed, 0 failed)Imported from Marvisak/VIctory. Originally posted by catminou4 on 2026-11-24T22:19:50Z.
Review: COMMENTED
Static review only: victory-gpu is Windows-only (D3D12/windows_sys) — nothing compiles or runs on macOS; source review of the diff.
Staging::detile stays inside the staging buffer: the copyable-footprints helper now accounts for D3D12 omitting trailing row-pitch padding on the final row of the final subresource (pitchrowsdepth can exceed total-offset). 2 tests. Subtle API quirk handled explicitly — good.
Imported from Marvisak/VIctory. Originally posted by acetonahard-code on 2026-11-24T22:12:41Z.
Heads-up: #1191 (opened earlier today,
Closes #935) fixes the same two things intexture.rs, thedetilespan past an unpadded last row and the overflow incommitted(), as part of a larger rewrite. The two conflict.Tested on Windows 11, RTX 4070 SUPER (driver 621.14), with the repo toolchain, merged into current
main(70564ae):cargo test -p victory-gpumainmain+ this PRmain,--all-featuresmain+ this PR,--all-featurescargo clippy --all-targets -- -D warnings, with and without--all-features: clean.cargo fmt --checkwould rewrap 3 blocks this PR adds (texture.rs).mainisn't rustfmt-clean either, so take it or leave it.victory-gputests fail on currentmainon this NVIDIA card:dynamic_slots_are_held_until_released,lists_share_a_table_and_copies_keep_their_views. That's the 1,000,000-view heap cap, see #1744. They fail the same way with this PR, and no other test does.I didn't test with game data.
Tested locally with an AI-assisted script (Claude Code); I checked the results before posting.