GPU: validate CopyTextureRegion subresources, source boxes, and destination bounds #3194
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!3194
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-3194"
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?
@fuzeofficlal on GitHub · 2026-11-26 11:55 UTC · original
fuzeofficlal:fix/gpu-copy-texture-region-validation→main· +341 −14 · 1 files · 1 commits · openProblem
copy_texture_regionandread_backincrates/victory-gpu/src/list.rspreviously forwarded title locations, subresource indices, source boxes, and destination coordinates directly toID3D12GraphicsCommandList::CopyTextureRegionwithout validating D3D12's copy contract:DepthOrArraySizeis depth rather than array slice count, and multi-plane depth/stencil formats), invalidCopyLocation::kindvalues, zero-sizedPlacedFootprintextents, source boxes extending past source bounds, destination coordinates extending past destination bounds, or unaligned block-compressed (BC) coordinates/boxes causeID3D12GraphicsCommandList::Close()to fail withE_INVALIDARG(0x80070057) even on retail D3D12 (without the Debug Layer) on both hardware and WARP, abortingHostList::close().ensure_state), and markedtexture::host_writesbefore failing.Fix
copy_subresourcesusingID3D12Device::CheckFeatureSupport(D3D12_FEATURE_FORMAT_INFO, ...)for exact D3D12PlaneCountand handlingTEXTURE3D(slices = 1) vs 1D/2D array textures accurately.copy_extent_sub,copy_extent_fp, andvalidate_copy_region:next_multiple_of(block)), preserving valid BC 1x1/2x2 tail mips as well as cross-format block-compatible copies ((w / src.block) * dst.block).pSrcBox(left,right,top,bottom) and destination(DstX, DstY)coordinates, non-zeroPlacedFootprintextents, and overflow-safe source/destination bounds across(x, y, z).pSrcBox(left >= right || top >= bottom || front >= back) as legal D3D12 no-ops.read_back) before allocating upload/readback buffers, emittingensure_state, or markingtexture::host_writes, and keep the sourceID3D12Resourcehandle alive across theCopyTextureRegioncall in both B2T and T2T branches.Verification
Added
list::tests::copy_texture_region_validates_subresources_boxes_and_boundstesting 16 invalid retailE_INVALIDARGcases (T2T, B2T, T2B, BC alignment/tail bounds, 3D subresources/Z bounds, 2-plane depth/stencil OOB, wrong location kind, zero-width footprint) and 9 valid transfers (empty/inverted no-op boxes, T2T mip 1, BC 2x2/1x1 tail mips with 4x4 & 1x1 footprints, T2B readback, 3D z-slice, 2-plane stencil):origin/main): failslist.Close()withHRESULT(0x80070057)(E_INVALIDARG) on retail RTX 5090 (no Debug Layer), Debug RTX 5090, and Debug WARP.--features diagnostics+VICTORY_D3D12_DEBUG=1, and WARP--features diagnostics+VICTORY_D3D12_DEBUG=1withhost.log_messages() == None.cargo test -p victory-gpu --lib --lockedpasses on hardware default (230 passed), hardwarediagnostics + DEBUG=1(244 passed), and WARPdiagnostics + DEBUG=1(246 passed).cargo clippy --workspace --all-targets --locked -- -D warnings(default and--all-features) andxtaskpolicy checks pass cleanly.@Dukestar69 on GitHub · 2026-11-26 12:07 UTC · original · approved these changes
Verified on RTX 5090 against
origin/main(63bcca4):cargo test -p victory-gpu --lib list:: -- --test-threads=1: 5/5 passed (includingcopy_texture_region_validates_subresources_boxes_and_bounds).cargo test -p victory-gpu --lib resource:: -- --test-threads=1: 18/18 passed.cargo clippy -p victory-gpu --all-targets -- -D warnings: clean.cargo xtask policy: 191 files ok.Cleanly validates
CopyTextureRegionsubresource indices, source boxes, and destination bounds.Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).
@oni-swr on GitHub · 2026-11-26 14:24 UTC · original
WARP verification of #3194 at
4b224882(base63bcca4,origin/main). Software adapter only; synthetic tests only; no GPU, game files, dumps, shader names or hashes.Environment: Windows 11 Pro 10.0.26200; WARP
d3d10warp.dll10.0.26100.9818; Windows SDKdxil.dll10.0.19041.5609 onPATH; rustc 1.98.1.VICTORY_WARP=1 VICTORY_D3D12_WARP=1. A throwaway probe (reverted) asserted the adapter description is "Microsoft Basic Render Driver" before any device was created; it held in every run.Commands (exact head,
--features diagnostics, because that is where the WARP switch lives):Head: the new test
list::tests::copy_texture_region_validates_subresources_boxes_and_boundspasses (1 passed, 0 failed). Fullvictory-gpulib: 247 passed, 0 failed, 1 ignored.Control:
origin/main'slist.rswith only this PR's test module appended. Result: the test fails withlist.Close()E_INVALIDARG(0x80070057) at the first invalid case,t2t_oob_dst_sub.Test report only; no source changes. AI use: Claude Code (Claude Sonnet 5.5).
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.