GPU/present: transition presented texture via HostList prelude under submitted lock #564
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/fxceless--victory-fork!564
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-564"
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?
@AscilCH on GitHub · 2026-11-25 02:17 UTC · original
AscilCH:fix/gpu-present-copy-source-barrier-and-state-race→main· +115 −33 · 3 files · 1 commits · openProblem
Two bugs in the presentation state-tracking path across
crates/victory-gpu/src/queue.rsandcrates/victory-gpu/src/host.rs:COPY_SOURCE -> COPY_SOURCED3D12 barriers: When the presented texture was already inD3D12_RESOURCE_STATE_COPY_SOURCE(0x800),resource::host_transition(resource, COPY_SOURCE)returnedNone, defaultingstate = COPY_SOURCE.Host::present()then unconditionally recorded twoCOPY_SOURCE -> COPY_SOURCEbarriers (StateBefore == StateAfter, violating D3D12 barrier rules).HostTexture::staterace:queue.rsmutatedHostTexture::statetoCOPY_SOURCEbeforeHost::present()acquiredhost.submitted, and unconditionally swapped it back afterwards. A concurrentHost::submit()runninglist.prelude()in that window saw the bogusCOPY_SOURCEstate, emitted a mismatched barrier, and then had its resultingHostTexture::stateclobbered byqueue.rs. (Passing&ID3D12Resourceinstead ofArc<HostTexture>also did not retain the texture on asynclate_free_presentcopy lists.)Fix
Arc<HostTexture>(resource::host_copy) intoHost::present()and remove the unlockedhost_transitionswaps fromqueue.rs(scopingresource::host_transitionto#[cfg(all(windows, test))]).copy.settle(texture, D3D12_RESOURCE_STATE_COPY_SOURCE.0 as u32)on the present copy list socopy.prelude()transitionstexturefrom its true state toCOPY_SOURCEatomically underself.submitted, skips the barrier completely when already inCOPY_SOURCE, and retainsArc<HostTexture>untilcopy.reset().present_settle_skips_redundant_copy_source_barrier_and_tracks_state_at_prelude.Verification
cargo test -p victory-gpu --locked host::batch -- --test-threads=1: 5 passed, 0 failed (1 pre-existing ignored benchmark)cargo test -p victory-gpu --locked queue::tests -- --test-threads=1: 4 passed, 0 failedcargo xtask policy: 169 files okcargo clippy -p victory-gpu --all-targets --all-features --locked -- -D warnings: clean (default-features build onc96b4f2has only the pre-existingdead_codewarning onplaced_filler_twins, tracked in #491)(AI-assisted; synthetic unit tests only, no game data.)
- Replace unlocked `resource::host_transition` swaps around `host.present()` in `queue.rs` with passing an owned `Arc<HostTexture>` (`resource::host_copy`) into `Host::present()`. - Record `copy.settle(texture, D3D12_RESOURCE_STATE_COPY_SOURCE)` on the present copy list so `copy.prelude()` runs atomically under `self.submitted`: - Eliminates illegal `COPY_SOURCE -> COPY_SOURCE` D3D12 barriers when the presented texture is already in `COPY_SOURCE`. - Eliminates the race where a concurrent `Host::submit()` observed the unlocked `COPY_SOURCE` swap and had its resulting `HostTexture::state` overwritten on `present()`'s return. - Retains the `Arc<HostTexture>` on the present copy list until reset after GPU completion (including `late_free_present` flights). - Add synthetic D3D12 unit test verifying `settle` + `prelude` emits no no-op barrier for `COPY_SOURCE` and updates `HostTexture::state` only at prelude/submission time.View command line instructions
Manual merge helper
Use this merge commit message when completing the merge manually.
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.