GPU: flush before depth-twin copies and coalesce duplicate transitions in ResourceBarrier #3129
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!3129
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-3129"
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?
@fuzeofficlal on GitHub · 2026-11-26 09:20 UTC · original
fuzeofficlal:fix/gpu-barrier-coalesce-and-twin-order→main· +600 −21 · 1 files · 1 commits · openRoot cause
crates/victory-gpu/src/list.rs::barriercollects every translated host barrier from a title'sResourceBarrierbatch into a localVec<Barrier>and submits the entire slice once at the end of the call. That causes two D3D12 barrier correctness bugs:RESOURCE_BARRIER_BEFORE_AFTER_MISMATCH):HostList::statesimmediately while staying buffered in the localVec<Barrier>.HostList::transitionon a depth texture with an initialized writable twin (crate::twin::route->Twin::copy),Twin::copyrecords its own barriers (starting from the already-updated tracked state) andCopyTextureRegioncalls directly ontolist.listbefore the buffered barrier is flushed.DEPTH_WRITE -> PIXEL_SHADER_RESOURCEis recorded afterPIXEL_SHADER_RESOURCE -> COPY_SOURCE, failing D3D12 validation at both recording time andExecuteCommandLists, and leaving the real GPU resource state diverged fromHostTexture::statefor subsequent submissions.ResourceBarriercall (D3D12 Debug Layer ID #1008RESOURCE_BARRIER_DUPLICATE_SUBRESOURCE_TRANSITIONS):ALL_SUBRESOURCES(0xffff_ffff), a singleResourceBarrierbatch naming multiple subresources of one texture, a round-trip (A -> B -> A), two aliased placed title textures sharing oneHostTexture, or transitions separated by a UAV/aliasing barrier emits multiple transitions for the same hostID3D12Resourcein onelist.list.ResourceBarriercall.Before-fix reproduction
Running the new synthetic tests on
origin/main(63bcca43) withVICTORY_D3D12_DEBUG=1 --features diagnosticsfails on both RTX 5090 and WARP:barrier_flushes_pending_transitions_before_depth_twin_copyfails with two D3D12id=527errors:Before state (0x10: D3D12_RESOURCE_STATE_DEPTH_WRITE) ... does not match with the state (0x800: D3D12_RESOURCE_STATE_COPY_SOURCE)Before state (0x80: D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE) ... does not match with the state (0x10: D3D12_RESOURCE_STATE_DEPTH_WRITE)barrier_coalesces_duplicate_transitions_and_splits_across_uavandbarrier_coalesces_aliased_title_textures_sharing_one_host_textureemit D3D12id=1008(Called on the same subresource(s) of Resource(...) in separate Barrier Descs ... (subresource : 4294967295)).Change
Scoped cleanly to
crates/victory-gpu/src/list.rs:emit_barriers) before callingHostList::transitionon a texture whoseHostTexturehas an initialized writable twin, keeping earlier transitions and ordering barriers strictly ahead oftwin::routecopies.ID3D12Resourceinpush_host_barrier(A -> B+B -> C=>A -> C;A -> B+B -> Aremoved), and flush earlier barriers before pushing the new transition whenever a UAV or aliasing barrier sits between two transitions of the same resource.host::tests::ISSUEDunder#[cfg(test)]and add 4 synthetic regression tests covering batch coalescing/splitting, depth-twin flush ordering across consecutive submissions, and aliased placed textures.Verification
VICTORY_D3D12_DEBUG=1 cargo test -p victory-gpu --features diagnostics --locked -- list::tests::on RTX 5090: 8 passed, 0 failed (0 D3D12 debug errors/warnings)VICTORY_D3D12_WARP=1 VICTORY_D3D12_DEBUG=1 cargo test -p victory-gpu --features diagnostics --locked -- list::tests::on WARP: 8 passed, 0 failed (0 D3D12 debug errors/warnings)VICTORY_D3D12_WARP=1 cargo test -p victory-gpu --features diagnostics --lockedon WARP: 250 passed, 0 failed, 1 ignoredcargo test -p victory-gpu --locked -- list::tests::/twin::tests::/indirect::tests::on RTX 5090: all passedcargo clippy --workspace --all-targets --locked -- -D warnings: cleancargo clippy --workspace --all-targets --all-features --locked -- -D warnings: cleancargo test -p xtask --locked policy::tests::repository_passes_policy: passed@Dukestar69 on GitHub · 2026-11-26 12:32 UTC · original · approved these changes
Verified on RTX 5090 against
origin/main(63bcca4):cargo test -p victory-gpu --lib list:: -- --test-threads=1: passed.cargo test -p victory-gpu --lib draw:: -- --test-threads=1: 20/20 passed;twin::: 2/2 passed.cargo clippy -p victory-gpu --all-targets -- -D warnings: clean.cargo xtask policy: 191 files ok.Cleanly flushes pending barriers before depth-twin copies and coalesces duplicate transitions in
ResourceBarrier.Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).
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.