Twin copies: a whole copy into a held twin goes subresource by subresource (follow-up to #3792) #4040

Open
Mikey970 wants to merge 1 commit from upstream-pr/4040 into main
Mikey970 commented 2026-11-30 15:05:03 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by Mikey970 on 2026-11-30T15:05:03Z.


Fixes #

What it changes

Follow-up to #3792 (merged): a gap found in review after the merge (note on #3792). #3792 left out a whole CopyResource into a placed twin whose host copy is laid out differently from the source's, for example a twin made of held levels only (it begins at a later level). That avoided the refused copy, but the twin kept stale contents. The layout check also compared the twin with the destination's host texture (to), not with from, the source the copy actually reads.

Now in copy_resource (list.rs):

  • The twin's host copy is compared with the source's (from). When they are laid out alike, it is one CopyResource as before.
  • When they differ, each title subresource both ends hold at the same size gets its own CopyTextureRegion. Each subresource is mapped with host_target at both ends, covering every level, array slice and plane (resource::whole_copy_pairs, built on held_pairs).
  • The copy is left out only when no subresource is held alike (twin_copy_left_out, why whole copy, no level held alike).

How it was tested

  • GPU and profile: unit tests only, on WARP (VICTORY_WARP=1); not yet measured in-game. IN-GAME-ON-MAIN: pending.
  • New test a_whole_copy_into_a_held_twin_takes_the_levels_both_hold: a twin that begins at level 3 of 11 takes title levels 3–10 of each slice from a full source at their own indices; a held source gives only what it holds; nothing held at one end gives no copy.
  • Existing a_copy_into_a_held_copy_takes_its_own_level and a_placed_copy_target_keeps_the_stencil_plane still pass.
  • For shader changes, the wave sizes tested: n/a
  • cargo test passed for the crates it touches: yes, the targeted victory-gpu tests above. Clippy on victory-gpu --all-targets adds no warnings. The CI check failure (unwind_copy in victory-loader) is pre-existing on main. On main c71899d9 the victory-gpu lib tests do not compile: two card_pass calls in host.rs tests lack the new capture argument. I passed [0; 3] locally to run the tests above; that change is not part of this PR.

Checked for overlap

  • I searched the open pull requests for the same issue and for the files this touches. Related: #3792, #3062, #3976
    • #3062 fits the title's own whole copy between dst and src host copies, not the copy into placed twins.
    • #3976 routes region copies into twins of another format family through a buffer; it does not touch the whole-copy twin path.

🤖 Generated with Claude Code

<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:issue:5567860811 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/4040). Originally posted by [Mikey970](https://github.com/Mikey970) on 2026-11-30T15:05:03Z. --- Fixes # ## What it changes Follow-up to #3792 (merged): a gap found in review after the merge ([note on #3792](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/3792#issuecomment-7281850788)). #3792 left out a whole `CopyResource` into a placed twin whose host copy is laid out differently from the source's, for example a twin made of held levels only (it begins at a later level). That avoided the refused copy, but the twin kept stale contents. The layout check also compared the twin with the destination's host texture (`to`), not with `from`, the source the copy actually reads. Now in `copy_resource` (`list.rs`): - The twin's host copy is compared with the source's (`from`). When they are laid out alike, it is one `CopyResource` as before. - When they differ, each title subresource both ends hold at the same size gets its own `CopyTextureRegion`. Each subresource is mapped with `host_target` at both ends, covering every level, array slice and plane (`resource::whole_copy_pairs`, built on `held_pairs`). - The copy is left out only when no subresource is held alike (`twin_copy_left_out`, why `whole copy, no level held alike`). ## How it was tested - GPU and profile: unit tests only, on WARP (`VICTORY_WARP=1`); not yet measured in-game. IN-GAME-ON-MAIN: pending. - New test `a_whole_copy_into_a_held_twin_takes_the_levels_both_hold`: a twin that begins at level 3 of 11 takes title levels 3–10 of each slice from a full source at their own indices; a held source gives only what it holds; nothing held at one end gives no copy. - Existing `a_copy_into_a_held_copy_takes_its_own_level` and `a_placed_copy_target_keeps_the_stencil_plane` still pass. - For shader changes, the wave sizes tested: n/a - `cargo test` passed for the crates it touches: yes, the targeted `victory-gpu` tests above. Clippy on `victory-gpu --all-targets` adds no warnings. The CI `check` failure (`unwind_copy` in `victory-loader`) is pre-existing on `main`. On `main` c71899d9 the `victory-gpu` lib tests do not compile: two `card_pass` calls in `host.rs` tests lack the new `capture` argument. I passed `[0; 3]` locally to run the tests above; that change is not part of this PR. ## Checked for overlap - [x] I searched the open pull requests for the same issue and for the files this touches. Related: #3792, #3062, #3976 - #3062 fits the title's own whole copy between `dst` and `src` host copies, not the copy into placed twins. - #3976 routes region copies into twins of another format family through a buffer; it does not touch the whole-copy twin path. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/4040:upstream-pr/4040'
git switch 'upstream-pr/4040'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/4040'
git switch 'upstream-pr/4040'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/4040'
git switch 'upstream-pr/4040'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/4040'
git switch 'main'
git merge --squash 'upstream-pr/4040'
git switch 'main'
git merge --ff-only 'upstream-pr/4040'
git switch 'main'
git merge 'upstream-pr/4040'
git push origin 'main'
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
trustno1-coder/VIctory-NVIDIA!4040
No description provided.