GPU: no copy of a host texture onto itself #2905
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!2905
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-2905"
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?
@0xkn0wh3r3 on GitHub · 2026-11-25 23:32 UTC · original
0xkn0wh3r3:gpu/no-copy-of-a-texture-onto-itself→main· +179 −3 · 1 files · 3 commits · openWhat
Two title textures over one memory share one host texture (decision 0007). This PR stops recording a copy of that host texture onto itself:
CopyResourcebetween two such textures: the two transitions and the copy are left out.CopyTextureRegionbetween the same subresource of each: also left out.Uploads of a CPU-written source still happen before the check. A skipped copy doesn't mark the destination host-written, since nothing was written: the texture still shows title memory, so later CPU writes keep being uploaded. A copy to another place inside the same subresource is also left out, with a one-time warning: the host can't do that in one copy, and so far no title has been seen doing it.
Why
Main recorded
COPY_DESTand thenCOPY_SOURCEtransitions on the same host texture, thenCopyResource(t, t). That left the texture in the copy-source state as the copy's destination, and the debug layer reports:In the title's terms the copy moves memory onto itself, which changes nothing. The fork logged this 37 times in one run, on a 2560x1440 depth texture.
Where it comes from
From the avatarmanz/VIctory-7900XTX fork, commit
51d3f4d, only its list.rs part (that commit's comment credits triippywhale6e502b3b, a commit I couldn't see). I rewrote it against main'scopy_resourceandcopy_texture_regionand added a test. The same commit's efficiency-mode opt-out duplicates #2569, so it's left out.Tested (Windows 11, RTX 5070 Ti)
list::tests::a_copy_between_textures_over_one_memory_is_left_out: two textures at one address share one host copy. A whole copy and an in-place subresource copy between them are left out, while copies between two memories are still recorded. The test also asserts the debug layer reported nothing. WithVICTORY_D3D12_DEBUG=1 --features diagnosticsit passes on this branch. The same calls on main fail with the debug-layer error quoted above.cargo test -p victory-gpu: 230 passed. The only 2 failures (dynamic_slots_are_held_until_released,lists_share_a_table_and_copies_keep_their_views) are this NVIDIA card's descriptor-heap cap and fail on main too (#2121).cargo clippy -p victory-gpu --all-targets -- -D warnings, with and without--features diagnostics: clean.Not tested
COPY_DEST. Fixing that needs per-subresource states (#594). This PR doesn't change it.@andrewpozdnakov7-jpg on GitHub · 2026-11-26 02:13 UTC · original
I verified that
0ac5f55addresses the displaced-region note. There is a related case for identity copies on a CPU-written texture. An identity copy records no GPU write, but callinghost_writesfor it prevents later CPU updates from being uploaded.67474ec is one commit directly on
0ac5f55966798c4c4c6a0ac87ecba4c8c3776a0b. It keeps the upload and the skip diagnostic, and leaves the host-written flag untouched for skipped copies.The same synthetic Windows/WARP test reads an RGBA8 pixel through the guest command list, submits an identity copy between distinct guest objects that share one host texture, writes new bytes from the CPU, and reads the pixel again. For both
CopyResourceand in-placeCopyTextureRegion, the second pixel stays at[23,23,23,23]before the change and reaches[42,42,42,42]after it. Six paired runs. The existing alias-copy test and full GPU diagnostics passed (248 passed, 1 ignored), plus strict Clippy and asset policy. Clean composition with main63bcca4.If you take the patch or test, please preserve its Git author. If you fold it into another commit, please add:
Co-authored-by: andrewpozdnakov7-jpg [email protected]
@0xkn0wh3r3 on GitHub · 2026-11-26 02:16 UTC · original
@andrewpozdnakov7-jpg thanks, you're right: a skipped identity copy writes nothing, so marking the texture host-written stopped later CPU writes from being uploaded.
Fixed in
73a2895(my own change, not your commit): neither a skippedCopyResourcenor a skippedCopyTextureRegioncallshost_writesany more. The upload of a CPU-written source before the check and the skip counter stay.The test now submits its lists. After the skipped copies, the shared host texture is not marked host-written; after copies between two different memories, both textures are. With the old
host_writescalls put back, the test fails.Tested on Windows 11 with an RTX 5070 Ti:
VICTORY_D3D12_DEBUG=1 --features diagnosticscargo test -p victory-gpu: 230 passed; the only 2 failures are this card's descriptor-heap cap (#2121), which fail on main toodiagnostics@Marvisak on GitHub · 2026-11-26 02:19 UTC · original
Automated triage for the maintainers.
Merge candidate (a recommendation to look, not an approval). In
list.rs,copy_resourceandcopy_texture_regionnow skip a copy when both title textures resolve to the same host texture (same_texture). Onmainthis recordedCopyResource(t, t)with the texture left in COPY_SOURCE, which the debug layer reports as an error. The fix in73a2895is in: a skipped copy no longer callshost_writes, so later CPU writes keep being uploaded, and the test checks that. The one real behaviour cost is the documented shortcut: a copy to a different place inside the same subresource is dropped with a one-time warning. CIcheckwas still running at review time.Generated by Claude Code
@pickles976 on GitHub · 2026-11-26 02:44 UTC · original
Independent Wine/vkd3d-proton 3.2.0 check on NVIDIA RTX 4060 Laptop GPU (590.48.1, vendor masking disabled), exact head
73a28957:list::tests::a_copy_between_textures_over_one_memory_is_left_out1/1 passed against the actual adapter. It covered aliasing two title textures to one host resource, skipped whole-resource and same-subresource copies without falsely marking host-written, and still recorded distinct-memory copies. This is an offscreen fixture result, not a title/debug-layer check; cross-subresource shared-host transitions remain outside this fix. Local log:.compat-runtime/logs/verify-pr2905-wine-rtx4060-alias-self-copy.log.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.