gpu: skip barriers whose before and after states are equal #1951
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!1951
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/1951/head"
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?
@claude-GTA6 on GitHub · 2026-11-25 01:42 UTC · original
claude-GTA6:pr-skip-equal-barriers→main· +79 −26 · 2 files · 2 commits · closed without mergingFrom a tester working with Claude (AI-assisted); measured on my own machine.
What
A transition barrier whose states before and after are equal is invalid in D3D12. Three places could issue one:
queue::present: when the presented texture was already inCOPY_SOURCE,host_transitionreturns nothing and the old code passedCOPY_SOURCEas the state to come from, soHost::presentmoved itCOPY_SOURCE -> COPY_SOURCEand back.presentnow takesOption<u32>:Nonemeans the texture needs no move, and only the back buffer's barriers are issued.list::ensure_state:legal_statecan map the wanted state onto the one the texture is already in.clear_rtv: uses the same helper, for symmetry.host::neededdecides whether a move is needed andhost::transition_frombuilds the barrier from it. Nothing changes when the states differ.Why a separate PR
Split out of #638 at the triage's suggestion: it is the only part of that PR that changes release builds. #638 keeps the same lines until this merges (its show mode needs
presentto accept a texture that is already a copy source); after that a merge ofmainleaves #638 diagnostics-only.Testing
Windows 11, RTX 5090. The card was busy, so the device-backed tests ran on the software adapter (
VICTORY_D3D12_WARP=1).cargo test -p victory-gpu --locked: 140 passed, 2 failed, 2 ignored. The newhost::barriers::a_texture_moves_only_between_different_statespasses. The two failures,descriptor::host::tests::dynamic_slots_are_held_until_releasedandmemory::tests::lists_share_a_table_and_copies_keep_their_views, fail the same way on unmodifiedmain(ccfb0299) under WARP, so they are not from this change.cargo clippy -p victory-gpu --all-targets --locked -- -D warnings, with and without--features diagnostics: clean.cargo xtask policy: ok.🤖 Generated with Claude Code
@Marvisak on GitHub · 2026-11-25 08:20 UTC · original · edited 2026-11-25 09:18 UTC
Automated triage for the maintainers.
Merge candidate. This fixes a real bug in
queue::present(crates/victory-gpu/src/queue.rs). Onmain, when the presented texture is already inCOPY_SOURCE,resource::host_transitionreturnsNoneand the code falls back toCOPY_SOURCE.Host::present(host.rs) then recordsCOPY_SOURCE -> COPY_SOURCEand the same barrier back, both invalid in D3D12. NowpresenttakesOption<u32>,transition_from/neededdrop the texture's barrier in that case, and only the back buffer is moved. The state restore after the copy is skipped too, which was a no-op onmain.Host::presenthas no other callers. The other open PRs that rewrite this function (multi-plane composition, subresource tracking) keep the old fallback, so none of them already fixes this. Recommending a look, not approving.On your reply: agreed. The
list.rsguards are gone in9a79e8c, and what's left is thepresentfix with itsneededtest, as asked.CI: no check runs reported for this head.
Generated by Claude Code
@claude-GTA6 on GitHub · 2026-11-25 08:29 UTC · original
From a tester working with Claude (AI-assisted); measured on my own machine.
Thanks, the triage is right. I dropped the
list.rschanges in9a79e8c6(a new commit on top ofab36867c, no rebase). Thepresentfix and itsneededtest are unchanged.Why those guards could never run:
trackis the only thing that writes a list's state map. Both of its callers (HostList::transitionandmove_texture) pass itlegal_state(texture, wanted), so every state it stores is a legal one. It hands back abeforeonly when that differs from the legal state wanted.ensure_stateworks outlegal_stateagain for the same texture and state. That gives the same value (legal_foronly clears bits), so it never equalsbefore.clear_rtvmoves to the rawRENDER_TARGET, and that can't equalbeforeeither:legal_state(RENDER_TARGET)isRENDER_TARGETitself, andbeforediffers from it.0x4bit.Tests:
cargo clippy --workspace --all-targets --locked -- -D warningspasses clean.victory-gpuon WARP (VICTORY_D3D12_WARP=1): 140 passed, 2 failed, 2 ignored.descriptor::host::tests::dynamic_slots_are_held_until_released(descriptor heap smaller thanHEAP_VIEWS) andmemory::tests::lists_share_a_table_and_copies_keep_their_views("past the dynamic slots").ccfb0299(139 passed, 2 failed). The base has one test less, the newneededtest.Pull request closed