GPU: bound texture upload and capture slices to the allocated buffer #601
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!601
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-601"
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?
@AwsAli05 on GitHub · 2026-11-24 05:21 UTC · original
AwsAli05:gpu/bound-footprint-slices→main· +69 −3 · 2 files · 7 commits · openA 10×6 RGBA8 texture with two mips places its 5×3 mip at byte 1536. Native D3D12 on WARP reports a 256-byte pitch, 20 bytes of pixels per row and a 2068-byte upload buffer. The old detile code formed a 768-byte mutable slice at offset 1536, where the mapping has only 532 bytes of resource data. The texture upload diagnostics reported the same oversized range. Both capture paths also assumed a full pitch after the last row of their readback buffers.
The upload path now caps the pitched subresource span at the end of the staging buffer. Frame captures and render-target dumps use the readback buffer’s declared byte width. Row and depth strides stay intact. The regression test checks both mips so that the final-row fix also preserves the earlier mip’s span.
Verified on Windows with Rust 1.98.1 (GNU target). An independent call to
ID3D12Device::GetCopyableFootprintson the WARP adapter confirmed the offsets and lengths above.cargo check --locked -p victory-gpuVICTORY_D3D12_WARP=1 cargo test --locked -p victory-gpu --features diagnostics -- --test-threads=1(46 passed, one benchmark ignored)cargo xtask policyTesting covered synthetic resources. Gameplay impact is unmeasured.
@geiyiliyabumo on GitHub · 2026-11-24 10:51 UTC · original
Independent verification & code review on Windows 11 Pro (build 26100) + AMD Radeon RX 9060 XT (RDNA4, driver
32.0.32029.2010, Rust1.98.1), cleanly merged ontomain(ffe310e):cargo xtask policy: PASS (154 files ok)cargo clippy -p victory-gpu --all-targets --locked -- -D warnings: PASScargo clippy -p victory-gpu --all-targets --features diagnostics --locked -- -D warnings: PASSVICTORY_D3D12_DEBUG=1 cargo test -p victory-gpu --locked: 51 passed, 0 failed, 1 ignored (including newtexture::tests::upload_slice_stops_at_the_end_of_the_buffer)VICTORY_WARP=1 VICTORY_D3D12_DEBUG=1 cargo test -p victory-gpu --locked -- texture: 4/4 PASS (1 ignored benchmark)Diff review (
capture.rs,texture.rs):GetCopyableFootprintssizes the allocation to end after the last row's active bytes rather than a fullRowPitch.capture.rs'sto_rgba/saveonly readw * pixel_byteson the last row, so boundingrowstobuffer.GetDesc().Widthis safe and exact.buffer_size.saturating_sub(footprint.Offset)infootprint_lenis slightly more defensive thanbuffer_size - footprint.Offsetif a synthetic/mock footprint ever passes an offset pastbuffer_size.AI-assisted; synthetic tests only, no game files.
@Yaekai on GitHub · 2026-11-24 16:02 UTC · original
Independent test & review on Windows 11 + NVIDIA RTX 3070 (Rust 1.98.1) at head
4899516:cargo test -p victory-gpu --lib: 44 passed, 0 failed (includingupload_slice_stops_at_the_end_of_the_buffer).cargo clippy -p victory-gpu -- -D warnings: 0 warnings.footprint_len(): usingbuffer_size.saturating_sub(footprint.Offset)instead ofbuffer_size - footprint.Offsetavoids an underflow panic if a footprint offset ever exceedsbuffer_size.Clean fix for the last-row staging/readback overread — looks ready to merge!
@AwsAli05 on GitHub · 2026-11-24 20:18 UTC · original
Thanks for the independent checks. I addressed the out-of-range offset in
839be49. The slice length now uses saturating subtraction, and staging rejects a footprint at or beyond the buffer end before forming a pointer or recording a copy. The regression checks both boundary offsets as well as the two original mips.On the branch merged with current main, the diagnostics suite passed 54 tests with one ignored benchmark. GPU Clippy passed with all targets and features.
@Marvisak on GitHub · 2026-11-25 00:30 UTC · original · edited 2026-11-26 01:23 UTC
Automated triage for the maintainers.
Still a merge candidate. The only push since the last triage is
75135d7, a merge of currentmain. The PR's own diff is unchanged: the samesubresource_lenbound for the diagnosticsnote_readrange intexture.rs::copies, the out-of-range footprint rejection instaging, and readback slices sized by the buffer'sWidthincapture.rs(save_read_back,dump_one), plus the device-backed BC4 test. The branch merges cleanly into currentmain, and CI (check) passes on this head.Generated by Claude Code
@tyr0nsur on GitHub · 2026-11-25 01:49 UTC · original
An 8×4 BC4_UNORM texture with two mips gives a useful hardware case for the rebase. I called
GetCopyableFootprintsonmain@940d32fon Windows 11 build 26300, desktop RTX 4060, NVIDIA driver 32.0.16.2114. Offsets were[0, 512], row counts[1, 1], row sizes[16, 8], and the entire upload allocation was 520 bytes.Staging::detilealready returns the correct 8 bytes for the last mip on main. Therecorddiagnostic still computes 256 bytes for that mip, so its reported read extends 248 bytes past the allocation. Using the same bound fornote_readwould bring the trace into line with the copy. Diagnostic calculation on the tested revisionOne locally added device-footprint test passed on that exact main revision with production code unchanged. The linked fixture contains the descriptor and D3D12 query. AI-assisted test and report (Codex). Reproducible BC4 fixture
@AwsAli05 on GitHub · 2026-11-25 05:05 UTC · original
Thanks for the measured BC4 case. On current main the PR applies the same bounded length to
note_readand the CPU upload. Commit9235ae1adds an 8×4 BC4 check that queries D3D12 and verifies that the last mip ends after its 8 active bytes. All three texture tests passed on an RTX 5070 Ti.@fuzeofficlal on GitHub · 2026-11-26 01:20 UTC · original
Code review and RTX 5090 + WARP verification at head
75135d7a0448merged cleanly ontomain(63bcca43c6a0):crates/victory-gpu/src/texture.rs:442-448, 697-701, 748-754, 831-834,capture.rs:220-222, 552):subresource_lenclampspitch.saturating_mul(rows).saturating_mul(depth)tototal.saturating_sub(offset), preventing out-of-bounds reads/writes on the unpadded final row of the last subresource (including 3D depth slices and compressed BC mips whereRowPitch > row_bytes), andstagingvalidatesf.Offset < totalacross all footprints before buildingStaging.capture.rs(save_read_back/dump_one) bounds mapped slices tobuffer.GetDesc().Width as usizerather thanRowPitch * Height.VICTORY_D3D12_DEBUG=1, Rust 1.98.1):cargo xtask policy:191 files ok;cargo clippy -p victory-gpu --all-targets -- -D warnings(default +--features diagnostics): 0 warningstexture:: capture::): 3/3 passed; WARP (--features diagnostics,texture:: capture::): 14/14 passed (includingsubresource_len_stays_inside_staging_totalandlast_bc4_mip_ends_after_the_active_block).LGTM.
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.