GPU: a depth texture used before it got a twin is copied to the twin in the list #2276
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!2276
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-2276"
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?
@denkencar-sketch on GitHub · 2026-11-25 09:29 UTC · original
denkencar-sketch:fix/twin-001→main· +42 −3 · 1 files · 1 commits · openSummary
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_copyfails onmainand passes with this change.cargo test --workspace --lockedpasses apart from the known flakes:modules::dstorage::tests::a_page_list_filled_after_its_request_startsfails now and then onmaintoo, and so does a parallel-run flake invictory-gpu's lib tests (watch::anddescriptor::host::tests, 2 of 40 runs on pristinemain).Not tried: a run in the game.
AI-assisted.
@andrewpozdnakov7-jpg on GitHub · 2026-11-25 11:20 UTC · original
I ran an end-to-end WARP check on your exact
14e872bhead. Test-only commitd9ef195.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.
940d32f: the first row reads the previous clear, 0.125.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.
@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 thehost.rsconflict is gone. InHostList::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'sstatesbut not yet intwins. 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 thatstatesandtwinsare keyed by the sameArc::as_ptr, and that takingstateswhile holdingtwinsdoesn't reverse the lock order anywhere (preludetakes and dropstwinsfirst). 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 onmainand the right value with this change.CI: passing (
check). Recommending a look, not approving.Generated by Claude Code
@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.
@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 5090cargo clippy -p victory-gpu --all-targets— 0 warningscargo 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).
@fuzeofficlal on GitHub · 2026-11-26 19:27 UTC · original · approved these changes
Reviewed and verified
d16e98180262be2ce89299a1d42c46f6639b1fa3merged ontoorigin/main(63bcca43c6a00a758510398fa43096ce7e4f7df0) on Windows 11 x64 (RTX 5090 + Microsoft WARP, Rust 1.98.1 MSVC).Code & Lock-Order Audit
HostList::twin_use(crates/victory-gpu/src/host.rs:1907-1926), whentwinshas a vacant entry for a depth texture whoseArc::as_ptrkey is already present inself.states, seedingtwin::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)..twins.lock()and.states.lock()acquisition incrates/victory-gpu/src/host.rs(prelude,transition,twin_use,twin_copy,reset): every site that touches both locks takestwinsbeforestates(or dropstwinsfirst), so there is no lock-order inversion risk, andreset()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_copyandtwin::tests::(RTX 5090 and WARP) — all passed.D32_FLOATdepth texture to0.125with no twin; submission 2 clears the same texture to0.625, creates a writable twin mid-list, transitions to UAV viatwin_use, and copiestwin.planes[0]to a readback buffer — every pixel read back0.625(not stale0.125) with zero debug-layer errors on both RTX 5090 and WARP.Looks good to merge.
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.