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

Open
github-bot wants to merge 1 commit from github-bot/gh-2276 into main AGit
Owner

@⁠denkencar-sketch on GitHub · 2026-11-25 09:29 UTC · original
denkencar-sketch:fix/twin-001 → main · +42 −3 · 1 files · 1 commits · open

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.

**@⁠denkencar-sketch** on GitHub · 2026-11-25 09:29 UTC · [original](https://github.com/Marvisak/VIctory/pull/2276) `denkencar-sketch:fix/twin-001` → `main` · +42 −3 · 1 files · 1 commits · open ## 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.
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-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 05:00:44 +00:00
Author
Owner

@⁠andrewpozdnakov7-jpg on GitHub · 2026-11-25 11:20 UTC · original

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 [email protected]

AI-assisted. Synthetic tests only.

**@⁠andrewpozdnakov7-jpg** on GitHub · 2026-11-25 11:20 UTC · [original](https://github.com/Marvisak/VIctory/pull/2276#issuecomment-7160913114) I ran an end-to-end WARP check on your exact `14e872b` head. [Test-only commit `d9ef195`](https://github.com/andrewpozdnakov7-jpg/VIctory/commit/d9ef195ac1278acbe71d3b305825590b65690a66). 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 <[email protected]> AI-assisted. Synthetic tests only.
Author
Owner

@⁠Marvisak on GitHub · 2026-11-25 13:32 UTC · original · edited 2026-11-26 01:22 UTC

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

**@⁠Marvisak** on GitHub · 2026-11-25 13:32 UTC · [original](https://github.com/Marvisak/VIctory/pull/2276#issuecomment-7163934549) · edited 2026-11-26 01:22 UTC <!-- victory-triage v1 head=d16e98180262be2ce89299a1d42c46f6639b1fa3 verdict=merge-candidate at=2026-11-26T01:22:24Z --> 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](https://claude.ai/code)_
Author
Owner

@⁠catminou4 on GitHub · 2026-11-25 09:35 UTC · original · reviewed

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.

**@⁠catminou4** on GitHub · 2026-11-25 09:35 UTC · [original](https://github.com/Marvisak/VIctory/pull/2276#pullrequestreview-6055075532) · **reviewed** 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.
Author
Owner

@⁠DenRakEiw on GitHub · 2026-11-25 09:42 UTC · original · approved these changes

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).

**@⁠DenRakEiw** on GitHub · 2026-11-25 09:42 UTC · [original](https://github.com/Marvisak/VIctory/pull/2276#pullrequestreview-6055168537) · **approved these changes** 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).
Author
Owner

@⁠fuzeofficlal on GitHub · 2026-11-26 19:27 UTC · original · approved these changes

Reviewed and verified d16e98180262be2ce89299a1d42c46f6639b1fa3 merged onto origin/main (63bcca43c6a00a758510398fa43096ce7e4f7df0) on Windows 11 x64 (RTX 5090 + Microsoft WARP, Rust 1.98.1 MSVC).

Code & Lock-Order Audit

  • In HostList::twin_use (crates/victory-gpu/src/host.rs:1907-1926), when twins has a vacant entry for a depth texture whose Arc::as_ptr key is already present in self.states, seeding twin::Use::new(depth, crate::twin::DEPTH, true) and immediately calling .again(side, writes) guarantees the depth-to-twin copy is emitted in-list (after the earlier depth commands) rather than in the prelude (before them).
  • Audited every .twins.lock() and .states.lock() acquisition in crates/victory-gpu/src/host.rs (prelude, transition, twin_use, twin_copy, reset): every site that touches both locks takes twins before states (or drops twins first), so there is no lock-order inversion risk, and reset() clears both maps.

Local Verification

  • cargo xtask policy — pass.
  • cargo clippy --locked -p victory-gpu --all-targets -- -D warnings (default and --all-features) — 0 warnings.
  • cargo test --locked -p victory-gpu --lib a_twin_made_after_a_depth_use_in_the_list_gets_the_copy and twin::tests:: (RTX 5090 and WARP) — all passed.
  • Additional end-to-end GPU readback probe: submission 1 clears a D32_FLOAT depth texture to 0.125 with no twin; submission 2 clears the same texture to 0.625, creates a writable twin mid-list, transitions to UAV via twin_use, and copies twin.planes[0] to a readback buffer — every pixel read back 0.625 (not stale 0.125) with zero debug-layer errors on both RTX 5090 and WARP.

Looks good to merge.

**@⁠fuzeofficlal** on GitHub · 2026-11-26 19:27 UTC · [original](https://github.com/Marvisak/VIctory/pull/2276#pullrequestreview-6079533048) · **approved these changes** Reviewed and verified `d16e98180262be2ce89299a1d42c46f6639b1fa3` merged onto `origin/main` (`63bcca43c6a00a758510398fa43096ce7e4f7df0`) on Windows 11 x64 (RTX 5090 + Microsoft WARP, Rust 1.98.1 MSVC). ### Code & Lock-Order Audit - In `HostList::twin_use` (`crates/victory-gpu/src/host.rs:1907-1926`), when `twins` has a vacant entry for a depth texture whose `Arc::as_ptr` key is already present in `self.states`, seeding `twin::Use::new(depth, crate::twin::DEPTH, true)` and immediately calling `.again(side, writes)` guarantees the depth-to-twin copy is emitted in-list (after the earlier depth commands) rather than in the prelude (before them). - Audited every `.twins.lock()` and `.states.lock()` acquisition in `crates/victory-gpu/src/host.rs` (`prelude`, `transition`, `twin_use`, `twin_copy`, `reset`): every site that touches both locks takes `twins` before `states` (or drops `twins` first), so there is no lock-order inversion risk, and `reset()` clears both maps. ### Local Verification - `cargo xtask policy` — pass. - `cargo clippy --locked -p victory-gpu --all-targets -- -D warnings` (default and `--all-features`) — 0 warnings. - `cargo test --locked -p victory-gpu --lib a_twin_made_after_a_depth_use_in_the_list_gets_the_copy` and `twin::tests::` (RTX 5090 and WARP) — all passed. - Additional end-to-end GPU readback probe: submission 1 clears a `D32_FLOAT` depth texture to `0.125` with no twin; submission 2 clears the same texture to `0.625`, creates a writable twin mid-list, transitions to UAV via `twin_use`, and copies `twin.planes[0]` to a readback buffer — every pixel read back `0.625` (not stale `0.125`) with zero debug-layer errors on both RTX 5090 and WARP. Looks good to merge.
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/2276/head:github-bot/gh-2276'
git switch 'github-bot/gh-2276'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-2276'
git switch 'github-bot/gh-2276'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-2276'
git switch 'github-bot/gh-2276'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-2276'
git switch 'main'
git merge --squash 'github-bot/gh-2276'
git switch 'main'
git merge --ff-only 'github-bot/gh-2276'
git switch 'main'
git merge 'github-bot/gh-2276'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No reviewers
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.

Dependencies

No dependencies set

Reference
github/Marvisak--VIctory!2276
No description provided.