GPU: a texture sampled before an in-list title memory copy is uploaded again after it #2295

Open
denkencar-sketch wants to merge 1 commit from upstream-pr/2297 into main
denkencar-sketch commented 2026-11-25 10:05:28 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by denkencar-sketch on 2026-11-25T10:05:28Z.


Summary

The list's per-texture first-use set was kept across defer_copy and defer, so a later draw skipped the upload of a texture sampled before an in-list title memory copy and read the pre-copy pixels. A title memory copy now makes textures due again. Cost: every later sampled texture is copied again after each title-memory write step; not measured.

Testing

Test a_title_memory_copy_makes_textures_due_again fails on main and passes with this change. cargo test --workspace --locked passes apart from known flakes: modules::dstorage::tests::a_page_list_filled_after_its_request_starts fails now and then on main too, and so does a parallel-run flake in victory-gpu's lib tests (watch:: and descriptor::host:: tests, 2 of 40 runs on pristine main).

Not tried: a run in the game.

AI-assisted.

<!-- greyfinch-sync:Marvisak/VIctory:issue:6601983021 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2297). Originally posted by [denkencar-sketch](https://github.com/denkencar-sketch) on 2026-11-25T10:05:28Z. --- ## Summary The list's per-texture first-use set was kept across `defer_copy` and `defer`, so a later draw skipped the upload of a texture sampled before an in-list title memory copy and read the pre-copy pixels. A title memory copy now makes textures due again. Cost: every later sampled texture is copied again after each title-memory write step; not measured. ## Testing Test `a_title_memory_copy_makes_textures_due_again` fails on `main` and passes with this change. `cargo test --workspace --locked` passes apart from known flakes: `modules::dstorage::tests::a_page_list_filled_after_its_request_starts` fails now and then on `main` too, and so does a parallel-run flake in `victory-gpu`'s lib tests (`watch::` and `descriptor::host::` tests, 2 of 40 runs on pristine `main`). Not tried: a run in the game. AI-assisted.
catminou4 commented 2026-11-25 11:04:39 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by catminou4 on 2026-11-25T10:19:14Z.

Review: COMMENTED


A texture sampled before an in-list title memory copy is uploaded again after it (first_use invalidation). Static review only: victory-gpu/victory-hle are Windows-only (D3D12/windows-sys); not compiled or tested on this macOS arm64 host. rustc 1.98.1. Test included (host-gated).

<!-- greyfinch-sync:Marvisak/VIctory:review:6055712832 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2297#pullrequestreview-6055712832). Originally posted by [catminou4](https://github.com/catminou4) on 2026-11-25T10:19:14Z. **Review:** COMMENTED --- A texture sampled before an in-list title memory copy is uploaded again after it (first_use invalidation). Static review only: victory-gpu/victory-hle are Windows-only (D3D12/windows-sys); not compiled or tested on this macOS arm64 host. rustc 1.98.1. Test included (host-gated).
welisonzika14-jpg commented 2026-11-25 12:03:57 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by welisonzika14-jpg on 2026-11-25T12:00:26Z.


First run on NVIDIA hardware here, as far as I can see (the reviews above are static or WARP). RTX 5070 (Blackwell, driver 621.24), Ryzen 7 5700X, Windows 11, Rust 1.98.1 MSVC, no game files. Head a5c7e71 merged onto main 940d32f, cargo test -p victory-gpu -p victory-shader --lib --no-fail-fast.

The PR's test host::tests::a_title_memory_copy_makes_textures_due_again passes on this card. The rest is the same as main on this card: the 5 known NVIDIA failures from #1744 (2 view heap cap tests in victory-gpu, 3 in victory-shader), nothing new.

One run, unit tests only, title not run.

Written with AI help (Claude/Kiro); the numbers are from runs on my machine.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7161794228 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2297#issuecomment-7161794228). Originally posted by [welisonzika14-jpg](https://github.com/welisonzika14-jpg) on 2026-11-25T12:00:26Z. --- First run on NVIDIA hardware here, as far as I can see (the reviews above are static or WARP). RTX 5070 (Blackwell, driver 621.24), Ryzen 7 5700X, Windows 11, Rust 1.98.1 MSVC, no game files. Head `a5c7e71` merged onto `main` `940d32f`, `cargo test -p victory-gpu -p victory-shader --lib --no-fail-fast`. The PR's test `host::tests::a_title_memory_copy_makes_textures_due_again` passes on this card. The rest is the same as `main` on this card: the 5 known NVIDIA failures from #1744 (2 view heap cap tests in `victory-gpu`, 3 in `victory-shader`), nothing new. One run, unit tests only, title not run. Written with AI help (Claude/Kiro); the numbers are from runs on my machine.
Marvisak commented 2026-11-25 16:09:30 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T15:25:42Z.


Automated triage for the maintainers.

Verdict: needs work. The rebase is clean, but I don't think the change makes a later draw see the copied pixels. texture::upload sends a texture again after the copy because first_use is true again, and it pushes a second Step::Texture for it. HostList::run_deferred skips Step::Texture ("brought up to date before the submission's lists were made"). The submit path in host.rs collects every list's texture steps into bindless::uploads, which removes duplicates by staging buffer. That upload list runs before all of the submission's lists, so it also runs before this list's Step::Copy. The documented shortcut in texture::upload ("a title copy into texture memory recorded in the same submission shows from the next one on") still holds.

Clearing deferred.textures also clears the odd keys that texture::alias_copy uses, so alias copies get recorded again after every copy or deferred step. That is extra cost with no test.

The new test checks only that first_use returns true again, not that a draw reads the post-copy texels. To fix the bug described, the upload would have to be ordered after the copy, for example by a per-step upload or by splitting the submission at the copy. A test that samples the texture after an in-list copy would show it.

CI: passing (check).


Generated by Claude Code

<!-- greyfinch-sync:Marvisak/VIctory:comment:7166826223 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2297#issuecomment-7166826223). Originally posted by [Marvisak](https://github.com/Marvisak) on 2026-11-25T15:25:42Z. --- <!-- victory-triage v1 head=085b3c3681a67bba27c593b104a3e54920e8a145 verdict=needs-work at=2026-11-26T03:23:16Z --> Automated triage for the maintainers. **Verdict: needs work.** The rebase is clean, but I don't think the change makes a later draw see the copied pixels. `texture::upload` sends a texture again after the copy because `first_use` is true again, and it pushes a second `Step::Texture` for it. `HostList::run_deferred` skips `Step::Texture` ("brought up to date before the submission's lists were made"). The submit path in `host.rs` collects every list's texture steps into `bindless::uploads`, which removes duplicates by staging buffer. That upload list runs before all of the submission's lists, so it also runs before this list's `Step::Copy`. The documented shortcut in `texture::upload` ("a title copy into texture memory recorded in the same submission shows from the next one on") still holds. Clearing `deferred.textures` also clears the odd keys that `texture::alias_copy` uses, so alias copies get recorded again after every copy or deferred step. That is extra cost with no test. The new test checks only that `first_use` returns true again, not that a draw reads the post-copy texels. To fix the bug described, the upload would have to be ordered after the copy, for example by a per-step upload or by splitting the submission at the copy. A test that samples the texture after an in-list copy would show it. CI: passing (`check`). --- _Generated by [Claude Code](https://claude.ai/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/2297:upstream-pr/2297'
git switch 'upstream-pr/2297'

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/2297'
git switch 'upstream-pr/2297'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/2297'
git switch 'upstream-pr/2297'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/2297'
git switch 'main'
git merge --squash 'upstream-pr/2297'
git switch 'main'
git merge --ff-only 'upstream-pr/2297'
git switch 'main'
git merge 'upstream-pr/2297'
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
Marvisak/VIctory!2295
No description provided.