You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
GPU: avoid illegal COPY_SOURCE self-transition in Host::present - #2545
In queue::present and Host::present, if the presented texture was already in D3D12_RESOURCE_STATE_COPY_SOURCE (0x800), Host::present emitted illegal COPY_SOURCE -> COPY_SOURCE before/after resource barriers.
queue::present obtained an un-owned &'static ID3D12Resource via host_resource() and mutated HostTexture::state via host_transition() outside Host::submitted, racing with concurrent submissions and risking use-after-free if the resource was released during presentation.
Fix
Pass an owned &Arc<HostTexture> from queue::present (via resource::host_copy) into Host::present.
Record the source texture transition through p.copy.move_texture(copy, COPY_SOURCE) so p.copy.prelude() swaps copy.state atomically under Host::submitted and skips emitting any barrier when copy is already in COPY_SOURCE.
Gate now test-only resource::host_transition with #[cfg(all(windows, test))].
Testing
Added move_texture_to_copy_source_skips_prelude_when_already_copy_source in crates/victory-gpu/src/host.rs.
Verified cargo test -p xtask --locked passes asset policy.
Status check (2026-11-25, no game data): gh pr view 2545 --json mergeable,mergeStateStatus reports mergeable=CONFLICTING, mergeStateStatus=DIRTY against main — this PR cannot merge as-is and needs a rebase. No formal review and no comments were present at check time. Other PRs checked in the same pass are not in that state: #2543 is MERGEABLE (status UNSTABLE, CI pending) and #2542 is transient UNKNOWN. Flagging only because the conflict is real, not because CI is red. AI-assisted (Hy4 flash); GPU/driver N/A (status check only); no game data.
Needs rebase. This PR no longer merges cleanly into main: main has moved since the last triage, and the branch now conflicts in crates/victory-gpu/src/host.rs and crates/victory-gpu/src/queue.rs. It will be reviewed again once it is rebased onto current main.
reeledMarek
changed the title
GPU: avoid illegal COPY_SOURCE self-transition and keep HostTexture alive in Host::present
GPU: avoid illegal COPY_SOURCE self-transition in Host::present
Nov 25, 2026
Updated to address the triage feedback and CI failure:
Moved move_texture_to_copy_source_skips_prelude_when_already_copy_source into its own mod present_tests with proper imports and added list.close() before list.reset().
Confirming both questions:
Yes, after present, the texture remains in COPY_SOURCE with copy.state updated by p.copy's prelude (so later draws/copies transition cleanly from COPY_SOURCE without an extra barrier).
Yes, clearing p.copy.states right after self.execute(&[&p.copy]) is safe because Host::execute waits for the submission fence to finish before returning.
Also corrected the PR note about host_resource returning an owned clone.
Closing as superseded by #1997 (0736f8b): Host::present now skips the COPY_SOURCE -> COPY_SOURCE self-transition and queue.rs keeps owned ID3D12Resource handles alive across host.present.
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
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
queue::presentandHost::present, if the presented texture was already inD3D12_RESOURCE_STATE_COPY_SOURCE(0x800),Host::presentemitted illegalCOPY_SOURCE -> COPY_SOURCEbefore/after resource barriers.queue::presentobtained an un-owned&'static ID3D12Resourceviahost_resource()and mutatedHostTexture::stateviahost_transition()outsideHost::submitted, racing with concurrent submissions and risking use-after-free if the resource was released during presentation.Fix
&Arc<HostTexture>fromqueue::present(viaresource::host_copy) intoHost::present.p.copy.move_texture(copy, COPY_SOURCE)sop.copy.prelude()swapscopy.stateatomically underHost::submittedand skips emitting any barrier whencopyis already inCOPY_SOURCE.resource::host_transitionwith#[cfg(all(windows, test))].Testing
move_texture_to_copy_source_skips_prelude_when_already_copy_sourceincrates/victory-gpu/src/host.rs.cargo test -p xtask --lockedpasses asset policy.