GPU: copy textures from GPU-backed buffer shadows #3338
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!3338
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-3338"
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 19:03 UTC · original
fuzeofficlal:fix/gpu-copy-texture-from-gpu-buffer→main· +955 −15 · 4 files · 1 commits · openSummary
CopyTextureRegion(buffer to texture) previously always allocated a temporary upload buffer and filled it from CPU title memory at submission preparation time (HostList::defer_fill). Whenever a title wrote texel data into a buffer on the GPU—through a compute/graphics shader UAV orClearUnorderedAccessViewUint/Float—and copied that buffer into a texture in the same command list or submission,CopyTextureRegionuploaded stale pre-GPU CPU memory instead of the GPU-written bytes.Changes
shadow.rs: Addshadow::existing(address, len)to look up an already-created hostShadowcopy (inBUFFERSorLOOSE) without allocating shadows for pure CPU upload buffers.resource.rs: Addresource::buffer_unordered(this)to identify buffers created withD3D12_RESOURCE_FLAG_ALLOW_UNORDERED_ACCESS.list.rs: Incopy_texture_region(buffer -> texture):shadow::find(when UAV-capable, covering out-of-order multi-threaded command list recording) orshadow::existing(for buffers inside an already-shadowed heap or window).shadow.refresh(also pinningArc<Shadow>until list reset), issue a UAV barrier so prior GPU writes are visible, and copy directly fromshadow.bufferatshadow.offset(data)when 512-byte aligned, or stage through adefault_buffer(CopyBufferRegion+COPY_DEST -> COPY_SOURCE) when the shadow offset is not 512-byte aligned.CopyBufferRegionordering.draw.rs: Track buffer copies promoted toCOPY_SOURCEinState::copy_sources(cleared onreset/cut) soclear_unorderedtransitions them fromCOPY_SOURCE -> UNORDERED_ACCESSwhen needed, and returns cleared buffer copies toCOMMONafterward without breaking prior implicit read promotions (e.g., root SRV / vertex buffer reads on the same buffer).Testing
Added 7 end-to-end D3D12 tests in
crates/victory-gpu/src/list.rs(list::tests::copy_texture_from_gpu_buffer::*) covering compute shader UAV writes at non-zero footprint offsets,ClearUnorderedAccessViewUintbefore and afterCopyTextureRegion, out-of-order multi-list recording within one submission, non-512-byte-aligned shadow offsets, mixed CPU+GPU writes withsource_boxand destination(x, y, z), root SRV +CopyTextureRegionstate compatibility on the same buffer, and pure CPU upload buffer ordering without shadow allocation. All 7 tests fail before the fix (5 GPU-write cases fail with stale CPU bytes) and pass on both hardware D3D12 and WARP withVICTORY_D3D12_DEBUG=1and zero D3D12 debug errors, along with fullvictory-gputest suites, workspaceclippy(default and--all-features), formatting checks, andxtask policy.@Dukestar69 on GitHub · 2026-11-26 19:08 UTC · original · approved these changes
LGTM — verified on RTX 5090 (Windows / D3D12) against
origin/main(63bcca4).cargo test -p victory-gpu --lib list:: -- --test-threads=1: 11 passed, 0 failed (all 7copy_texture_from_gpu_buffer::*tests passed).cargo test -p victory-gpu --lib draw:: -- --test-threads=1: 20 passed, 0 failed.cargo test -p victory-gpu --lib resource:: -- --test-threads=1: 18 passed, 0 failed.cargo clippy -p victory-gpu --all-targets -- -D warnings: clean.cargo xtask policy: 191 files ok.Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).
@oni-swr on GitHub · 2026-11-26 19:16 UTC · original
WARP/CPU verification of head
5d0b0dfd(claim: #1633)Environment: Windows 11, WARP only (
VICTORY_WARP=1,VICTORY_D3D12_WARP=1),dxil.dllfrom Windows SDK 10.0.26100.0 (VICTORY_DXIL), no physical GPU, no game files.-j 4,--locked, separate target dir. Control:origin/main@63bcca43. Merge:git merge-treeagainst currentorigin/mainis clean (head is 1 commit ahead, 0 behind).63bcca435d0b0dfdcargo test -p victory-gpucargo clippy -p victory-gpu --all-targets -- -D warningsxtask policyThe 7 added tests (
copy_texture_region_*) all pass on WARP. They do not run on control: with the PR'sdraw.rs/resource.rs/shadow.rsreverted to main, the test module fails to compile (buffer_unordered,shadow::existing,note_copy_sourcemissing), so they depend on the fix. I did not review the design beyond that. Synthetic/unit tests only.AI disclosure: run by Claude Code (Claude Sonnet 5.5), coordinated by Antigravity.
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.