Skip to content

GPU: a depth texture used before it got a twin is copied to the twin in the list - #2276

Open
denkencar-sketch wants to merge 1 commit into
Marvisak:mainfrom
denkencar-sketch:fix/twin-001
Open

denkencar-sketch wants to merge 1 commit into
Marvisak:mainfrom
denkencar-sketch:fix/twin-001

Conversation

@denkencar-sketch

Copy link
Copy Markdown
Contributor

Summary

The list's first use of a depth texture's twin counted as the list's first use of the texture, so the prelude copied the depth side to the twin before the draws that wrote it. A twin made after a depth use in the list now gets the copy in the list. It copies once more than needed when the earlier use only read.

Testing

Test a_twin_made_after_a_depth_use_in_the_list_gets_the_copy fails on main and passes with this change. cargo test --workspace --locked passes apart from the 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 catminou4 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A depth texture used before it got a twin is copied to the twin inside the list, not before it. 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. Timing fix in host list execution; ties to the #2226 aliasing work.

@DenRakEiw DenRakEiw left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verified locally merged onto origin/main (940d32f, Windows 11 x64, NVIDIA GeForce RTX 5090, Rust 1.98.1 MSVC):

  • cargo test -p victory-gpu --lib a_twin_made_after_a_depth_use_in_the_list_gets_the_copy — passed on RTX 5090
  • cargo clippy -p victory-gpu --all-targets — 0 warnings
  • cargo xtask policy — ok (183 files ok)

Clean fix copying depth contents to a late-created twin within the same command list. Looks good.

AI-assisted (Gemini 4 Neon).

@andrewpozdnakov7-jpg

Copy link
Copy Markdown
Contributor

I ran an end-to-end WARP check on your exact 14e872b head. Test-only commit d9ef195.

The fixture submits a clear to 0.125, then records a second clear to 0.375 before the writable twin exists. It creates and routes the twin in that second list, submits the list and reads the twin texture into a mapped buffer.

  • Same fixture on 940d32f: the first row reads the previous clear, 0.125.
  • On 14e872b: all 16 pixels read 0.375. Both focused tests passed. Full forced-WARP GPU suite gave 148 passed, 2 ignored, with strict GPU Clippy in both feature modes and repository policy passing.

Please retain the Git author if you cherry-pick the fixture. If you fold it into another commit, please add:

Co-authored-by: andrewpozdnakov7-jpg andrewpozdnakov7-jpg@users.noreply.github.com

AI-assisted. Synthetic tests only.

Marvisak commented Nov 25, 2026 •

Copy link
Copy Markdown
Owner

Automated triage for the maintainers.

Merge candidate. It is rebased onto current main (one commit, d16e981), and the host.rs conflict is gone. In HostList::twin_use (crates/victory-gpu/src/host.rs), a depth texture that this list already used before its twin existed is now in the list's states but not yet in twins. Such a texture is now recorded as first used and written on its depth side, so the depth-to-twin copy is recorded in the list (twin::Use::again) and not left to the prelude, which would run before the draws that wrote it. I checked that states and twins are keyed by the same Arc::as_ptr, and that taking states while holding twins doesn't reverse the lock order anywhere (prelude takes and drops twins first). The cost is one extra copy when the earlier use only read, which the PR states. A WARP readback fixture in the comments shows stale depth on main and the right value with this change.

CI: passing (check). Recommending a look, not approving.


Generated by Claude Code

…in the list

The list's first use of the twin counted as the list's first use of the
texture, so the prelude copied the depth side before the draws that wrote
it.
github-actions Bot added a commit to KevinPratap/VIctory that referenced this pull request Nov 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants