GPU: sanitize resource barrier bind flags and UAV targets #43
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/Belobug--VIctory-Belobug-AMD!43
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-43"
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?
@vicennpacheco on GitHub · 2026-11-25 12:42 UTC · original
vicennpacheco:fix/uav-barrier-bind-flags→main· +200 −22 · 1 files · 2 commits · openSummary
Addresses
ResourceBarrierbind-flag validation errors (id=523: Missing resource bind flags, causingID3D12GraphicsCommandList::Closeto fail withE_INVALIDARG/0x80070057), as reported in #13.Changes (
crates/victory-gpu/src/list.rs)host_barrier,kind == 2): if the named host resource lacksD3D12_RESOURCE_FLAG_ALLOW_UNORDERED_ACCESS(for example, a depth texture whose console copy allowed UAVs), emit a globalUAV_BARRIER(null resource) instead of naming the texture directly, and zero any console barrier flags.host_barrier,kind == 0): sanitize bothbeforeandwantedthroughlegal_stateand drop no-op transitions (before == after).clear_rtv: route theRENDER_TARGETtransition throughensure_state(matchingclear_dsv) instead of passing rawState(RENDER_TARGET).list::tests::uav_barrier_on_non_uav_texture_falls_back_to_globalverifying that a depth texture falls back to a global UAV barrier, a UAV-capable texture keeps its pointer, and both record and close cleanly on a live D3D12 command list.(Note: tested without game files, so linking #13 rather than auto-closing it.)
Verification
Tested on Windows 11, AMD Radeon Vega 8 iGPU (Ryzen 7 5825U, GCN 5 /
gfx90c, PCI1002:15E7, AMD driver31.0.21921.13001), Rust1.98.1(x86_64-pc-windows-msvc), without game files:cargo test -p victory-gpu --lib -- list::tests: 6 passed, 0 failed (both default andVICTORY_D3D12_DEBUG=1, no debug-layer errors)cargo test -p victory-gpu --lib: 110 passed, 0 failed, 4 ignored(AI-assisted investigation and patch.)
@enriquebruno12 on GitHub · 2026-11-25 14:49 UTC · original
Independently tested on Windows on my RX 9070 XT system. The depth texture used a global UAV barrier, the UAV-capable texture retained its resource pointer, and the D3D12 command list closed successfully. The test also passed in a diagnostics build with VICTORY_D3D12_DEBUG=1 and a live device required. No game files were used.
@vicennpacheco on GitHub · 2026-11-25 16:39 UTC · original
Good call — extracted
transition_barrier_forand addedlist::tests::transition_barrier_skips_noop_after_legal_statecovering the cases wherelegal_statecollapsesbefore == aftertoNone(e.g.UAV -> COMMON,UAV -> RT, and(UAV | DEPTH_WRITE) -> DEPTH_WRITEon a depth texture) as well as recording/closing a sanitized legal transition on a live D3D12 command list. Verified on Vega 8 (default andVICTORY_D3D12_DEBUG=1: 7 passed, 0 failed).@adrianmjim on GitHub · 2026-11-25 17:23 UTC · original
Tried on an RX 7900 XT (RDNA3, driver 32.0.32029.2010), Windows 11 build 26300, without the debug layer (only
Close()'s HRESULT is checked). I used a test that records barriers the way the title does, through the list'sbarrierentry point, on host textures that lack a use the console allows.What fails on
main(Close returns0x80070057), so this is not NVIDIA-only:ALLOW_UNORDERED_ACCESS(a depth texture with console UAV; BGRX8 also loses UAV on this card);BEGIN_ONLY/END_ONLY), on a texture or global;BEGIN_ONLY.Transitions, split transitions, and UAV/aliasing barriers without flags all close.
With this PR every UAV case closes, but the aliasing case still fails: the kind-1 arm (
list.rs:521on01aadd1) passes the console's flags through with..*b. One line fixes it, since the host splits only transitions:With #43 and that line on
71652a2,cargo test -p victory-gpu --libgives 112 passed, 0 failed, 4 ignored here.The kind-0 change makes no difference in the real path, as far as I can tell (checked at
667389f;a3788bemoves it intotransition_barrier_forwithout changing it).HostList::transition(host.rs:2013on01aadd1) already runswantedthroughlegal_statebefore it stores or compares it, and it returnsNonewhen the state does not change. Sobeforeis always a state that was legalised earlier, and the newbefore == aftercheck can never fire.legal_foronly clears bits, so applying it twice gives the same value. The code is the same at4cbe9d7, the tree used in #13. The new test callstransition_barrier_fordirectly with rawbeforestates such asUAV | DEPTH_WRITE, buthost_barrieronly ever passes thebeforethattransitionreturns, which is already legal. So the black-to-visible change reported in #13 on the RTX 4060 Ti probably comes from something else in that run (a fresh cache, another difference), which may be worth finding. A more likely trigger on NVIDIA is the UAV case above:resource::host_texturedrops UAV from formats the host refuses (resource.rs:1310, BGRA8 on NVIDIA). WARP and this AMD card keep it, which would fit "WARP passes". That part is a guess; I have no NVIDIA card.Two smaller notes:
clear_rtvthroughensure_statealso callsresource::note_written(list.rs:598), so a clear now moves the texture's written clock. That is probably right, but the description does not mention it.main, transitions to some state combinations also fail Close here: UAV together with read states (0x8c8), and bits0x4000,0x8000,0x10000-0x400000. I don't know if the title ever asks for these.No game data used; not run in the game.
@gut0to on GitHub · 2026-11-25 14:57 UTC · original
On
crates/victory-gpu/src/list.rsline 532 (outdated):Could a regression also cover the transition branch where legal_state makes the before and requested states equal, and verify that no barrier is emitted? The new test covers the UAV fallback, but not this separate transition/no-op behavior. AI-assisted review.
@gut0to on GitHub · 2026-11-25 14:57 UTC · original · reviewed
AI-assisted review: I checked the new transition sanitization path and the tests added in this diff.
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.