GPU: target dumps refuse a footprint the host could not give #3388
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!3388
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-3388"
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?
@neonbyte1 on GitHub · 2026-11-26 21:23 UTC · original
neonbyte1:fix/capture-invalid-format→main· +266 −8 · 1 files · 2 commits · openWhat is wrong
A diagnostics run with
VICTORY_DUMP_TARGETS=1/VICTORY_DUMP_WRITERSaborted GTA VI (RTX 5090, Wine + vkd3d-proton) withmemory allocation of 103079215080 bytes failed, right aftervkd3d_get_format: Invalid format -1. It happened while dumping the fourth target written by one compute pass.dump_one/read_backtrusted whateverGetCopyableFootprintsleft in the footprint. For a subresource it can't describe, vkd3d-proton fills the layout with0xFFbytes (memset(layouts, 0xff, …),total = ~0), so the footprint readsFormat = Width = Height = Depth = RowPitch = 0xFFFFFFFF. Then:f.Width * f.Heightwraps to 1 inu32, so the dump takes the "tiny target" path;Vec<String>whose size hint isf.Height: 24 bytes ×0xFFFFFFFF= 103,079,215,080 bytes, the failed allocation;CopyTextureRegion, which is theInvalid format -1line.capture.rsis the same onmain, so any capture of such a target aborts there too.What changes
footprint_fits(desc, footprint)(pure): the footprint's format has a known element size, its extent equals the resource's block-aligned mip-0 extent, the depth matches, the texel count is under a cap, and the row pitch holds a row. All with checked arithmetic.read_backalso asks for the row count and row size, recomputes the bytes it needs, and refuses a short or implausible total (over 1 GiB) before it sizes any buffer.dump_onechecks again before mapping, tests "tiny" inu64, andto_rgbarefuses extents over 128 Mi texels.R32_TYPELESS→R32_FLOAT,R24G8_TYPELESS→D24_UNORM_S8,R16_TYPELESS→R16_FLOAT, BGRA typeless → sRGB), and planar depth uses the plane footprint's own format.R32G32B32_FLOATis added.#601 also touches
dump_one(one line, slice bounds for mips) but fixes a different bug; whichever lands second needs a trivial rebase.Tested
footprint_fits(including the all-0xFFfootprint), plus the existingcapture::tests(8/8) andr32_tests(6/6), under Wine.-D warningsforx86_64-pc-windows-msvc, default and--all-features; formatting clean.AI-assisted (Claude); measured on my machine, no game data shared.
@Dukestar69 on GitHub · 2026-11-26 21:27 UTC · original · reviewed
Tested on Windows against
origin/main(63bcca4).cargo test -p victory-gpu --lib --features diagnostics capture:: -- --test-threads=1: 14 passed, 0 failed (footprints_of_failed_copies_are_refused,an_implausible_extent_is_not_allocated_for,typeless_formats_read_as_the_value_they_hold).cargo clippy -p victory-gpu --all-targets --features diagnostics -- -D warnings:Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).
@neonbyte1 on GitHub · 2026-11-26 21:33 UTC · original
In game, on the same build and capture settings that aborted before (
VICTORY_DUMP_TARGETS=1,VICTORY_DUMP_WRITERS=<21 hashes>,VICTORY_CAPTURE_WORLD=0,60,300), with this commit applied:memory allocation of 103079215080 bytes failed).target not read back: the host gives no copyable footprint. All are one resource,format=86(B5G5R5A1_UNORM), where vkd3d-proton returns the all-0xFFfootprint (width=height=depth=pitch=4294967295). That's the case this PR refuses instead of sizing a buffer from it.AI-assisted (Claude); measured on my machine, no game data shared.
@fuzeofficlal on GitHub · 2026-11-26 21:51 UTC · original · requested changes
The footprint validation (
footprint_fits),read_backbounds checks, and typeless format decoding look solid — all 14capture::unit tests and a live 10-format D3D12read_backmatrix (R8G8B8A8_UNORM64x64 and 1x1,R16G16B16A16_FLOAT,R32_TYPELESS,D24_UNORM_S8_UINT,R24G8_TYPELESS,D32_FLOAT_S8X24_UINT,B5G5R5A1_UNORM,BC7_UNORM, andTEXTURE3D16x16x4) pass on both RTX 5090 and WARP withVICTORY_D3D12_DEBUG=1and zero debug layer errors.One blocking lint failure needs fixing before merge:
Blocking:
clippy --features diagnostics --all-targets -- -D warningsfails oncapture.rs:1143crates/victory-gpu/src/capture.rs:1143Changing this line to
const { assert!(MAX_READBACK >= 2560 * 1440); }clearscargo clippy --locked -p victory-gpu --features diagnostics --all-targets -- -D warnings.Additional hardening notes (non-blocking)
crates/victory-gpu/src/capture.rs:629:dump_onecreatesstd::slice::from_raw_parts(data.cast::<u8>(), pitch * f.Height as usize), which exceeds thetotal-byte readback buffer whenever the final row is shorter thanRowPitchor the format is block-compressed (observed on both RTX 5090 and WARP: e.g.,R8G8B8A8_UNORM1x1 allocates4bytes vs256;D24_UNORM_S8_UINT64x64 allocates32,512vs32,768;BC7_UNORM64x64 allocates4,096vs16,384). Sizing the mapped slice to the actual readback buffer length (buffer.GetDesc().Width as usize) avoids creating an out-of-bounds slice.crates/victory-gpu/src/capture.rs:140, 199: Checkingrows == 0 || row == 0explicitly (rather than relying onrows.saturating_sub(1)inexpected) andd.SampleDesc.Count == 1infootprint_fitsmakespub(crate) fn read_backsafe even if called without the caller's MSAA filter (capture.rs:351, 376).@neonbyte1 on GitHub · 2026-11-26 22:14 UTC · original
Pushed a follow-up commit
27a3b6d3("GPU: dumps map their rows, not theirpitch, and refuse no rows at all") on top of
ecb0e7ec; the reviewed commitis unchanged. Thanks for the live matrix — the buffer-vs-pitch numbers are
exactly what item 2 needed.
1. Blocking lint (
capture.rs:1143). Fixed: the assertion is now a constblock,
(one per line, as
rustfmtwants it). Why my earlier check missed it: I rancargo clippy -p victory-gpu [--all-features] -- -D warningswithout--all-targets, so the#[cfg(test)]module was never compiled and no lintin it could fire — not a toolchain difference; the pinned toolchain
(
rust-toolchain.toml, 1.98.1) is the one I was already using, and thereviewer's command reproduces on it. Now run, all clean with
-D warnings:cargo clippy --locked -p victory-gpu --features diagnostics --all-targets --target x86_64-pc-windows-msvc(the reviewer's exact command),
--all-features,cargo clippy --locked --workspace --all-targetsand--all-features.2. The mapped slice in
dump_one. It is now sized to the read-backbuffer's own bytes,
buffer.GetDesc().Width(bounded byMAX_READBACK), andthe span within it is
row_bytes(pitch, rows, last_row)— a new pure function(
pitch * (rows - 1) + row, every row pitched but the last). Everything thatreads the mapping stays inside it:
to_rgba's widest index is the last row'sown size, and the "tiny target" window uses the same row size instead of
width * texel. Block-compressed footprints are refused as undecoded (asbefore —
to_rgbanever decoded them, and their height is texels, not rows ofblocks), so a BC height no longer sizes a slice.
The new test
tests::a_mapping_spans_its_rows_and_not_its_pitchpins thenumbers from your matrix: 1×1
R8G8B8A8_UNORM→ 4 (not 256),D24_UNORM_S8_UINT64×64 → 32,512 (not 32,768),
BC7_UNORM64×64 → 4,096 (not 16,384), plus2560×1440
R8_UNORMand the empty cases (no rows, no row, row > pitch).On #601: this stays minimal and complementary — the only change to
dump_oneis the length of the mapped slice and the row window inside it; nothing else
in that function moves, so the two changes should not conflict textually or
semantically (both bound the same slice).
3.
read_back/footprint_fits.read_backnow refuses a footprint thatnames no rows, or no bytes in a row, by name (the same
row_bytes, sorows.saturating_sub(1)no longer carries the check), andfootprint_fitsrequires
d.SampleDesc.Count == 1, so a caller that did not pre-filtermulti-sampled resources is safe too. Both cases are in the tests: the
multi-sampled description is refused in
tests::footprints_of_failed_copies_are_refused, and the zero-row/zero-row-size/row-longer-than-pitch cases in
tests::a_mapping_spans_its_rows_and_not_its_pitch.Checks. CPU-only (no device):
capture::tests9/9 andcapture::r32_tests6/6 under Wine in a headless gamescope. Clippy as listed above, all three
feature configs plus the two workspace forms,
-D warnings, clean.Formatting of the changed lines is clean for both commits.
AI-assisted (Claude); no game data shared.
@fuzeofficlal on GitHub · 2026-11-26 22:44 UTC · original · approved these changes
Verified the updated head (
27a3b6d3) merged cleanly ontomain(63bcca43) — all items from the previous review are resolved.Verification
cargo xtask policy: 191 files ok.cargo clippy --locked -p victory-gpu --all-targets -- -D warnings(both default and--features diagnostics): 0 warnings; theconst { assert!(MAX_READBACK >= 2560 * 1440); }block (crates/victory-gpu/src/capture.rs:1194-1196) resolves the diagnostics clippy failure.capture::tests::(9/9) passed on both a discrete NVIDIA RTX 5090 and WARP with--features diagnosticsandVICTORY_D3D12_DEBUG=1.VICTORY_D3D12_DEBUG=1(1x1R8G8B8A8_UNORM,64x64R8G8B8A8_UNORM/R8G8B8A8_TYPELESS/R32_TYPELESS/R24G8_TYPELESS/BC7_UNORM,16x16R32_FLOAT/R32_UINT/R32G32B32_FLOAT/R32G32B32A32_FLOAT,32x32R16G16B16A16_FLOAT, and4xMSAAR8G8B8A8_UNORM): all 12 cases passed with 0 Debug Layer errors, confirming exactspanbounds indump_one(capture.rs:651-672),row_byteshandling (capture.rs:137-140), BC block skipping, and clean MSAA refusal inread_back(capture.rs:171).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.