Repository navigation
Conversation
…submitted lock
- 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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
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 GPU: keep clippy green without the diagnostics feature #491)(AI-assisted; synthetic unit tests only, no game data.)