Repository navigation
Conversation
clear_unordered took a dynamic slot of the bound view heap on every call and held it until the list was reset, so a list that clears the same view many times (a per-frame clear inside a loop of passes, say) took one slot per clear from the capped heap; when the pool runs out, later draws and dispatches that need dynamic slots are dropped. The list's draw state now keeps the slot it made per view (view heap, view, host resource) and clears of that view reuse it. The cache lives with the slots: it goes when the list is reset (or released) and at a cut of the list, where root views are made again too. The host resource in the key is one the list keeps, so its address names no other while the slot is held. The view is now made before a slot is taken, so a view the host cannot make takes none. The clear itself moves into State::clear_view (taking the resolved view, returning whether it was recorded), which clear_unordered calls after it looks the title's CPU handle up; the test drives it directly. Test (WARP): eight clears of a view take one slot, another view one more, a further clear of the first none; the views hold their last clears; the slots come back at reset. HostHeap::dynamic_free (tests only) counts the free slots. Split from Marvisak#2619 at the maintainer's triage. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
kotekompotek
left a comment
There was a problem hiding this comment.
Sound: keying clear slots by (heap, view, host resource) and releasing them with the list's dynamic pool gives each cleared view exactly one slot per list — the resource in the key is what makes reuse safe since the list holds it. Clearing on reset matches root_slots' lifetime model. LGTM.
AwsAli05
left a comment
There was a problem hiding this comment.
The focused clear-slot test at e7169ee passed on Windows with WARP and the D3D12 debug layer requested. The test covers repeated clears, final texel values, and slot release on reset.
The patch also clears the lookup cache at a list cut while retaining the slots for the earlier segment. That is an important lifetime boundary for the world-rendering path. A useful follow-up would be to clear the same UAV on both sides of a cut, submit both segments, and verify the clear result and that the old segment's slot stays held until reset.
AI-assisted review and test.
|
Reviewed and verified
Looks clean and ready to merge. |
…held A view cleared on both sides of a cut (a wait that moves the recording on to a new host list), both segments submitted in order: the first segment's clears share one slot, the cut gives none back, the second segment takes one slot of its own (its view heap is bound afresh) and shares it for its next clear, and both stay held until the list is reset, when both come back. A read in each segment sees the last clear recorded before it in that segment. Suggested in review of Marvisak#2871. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Thanks, all three of you. @fuzeofficlal, the RTX 5090 run with the debug layer is very useful, since we can only test on WARP here. @AwsAli05, I've added the test you suggested in d3f9b11:
Results at d3f9b11 on AI-assisted |
|
VERIFY-2871: verified Review: no defects found.
Results (
AI-assisted (Claude Code). |
|
Automated triage for the maintainers. Merge candidate. Repeated unordered-access clears of one view in one list now share a single dynamic slot via CI: passing. Generated by Claude Code |
Dukestar69
left a comment
There was a problem hiding this comment.
Verified on RTX 5090 against origin/main (63bcca4):
cargo test -p victory-gpu --lib draw:: -- --test-threads=1: 22/22 passed (includingclears_of_one_view_in_a_list_share_a_dynamic_slotanda_clear_after_a_cut_takes_a_new_slot_and_the_old_one_stays_held).cargo test -p victory-gpu --lib descriptor:: -- --test-threads=1 --skip dynamic_slots_are_held_until_released: 21/21 passed.cargo clippy -p victory-gpu --all-targets -- -D warnings: clean.cargo xtask policy: 191 files ok.
Cleanly reuses a single dynamic slot for repeated clears of the same view in a command list and allocates a fresh slot after a cut.
Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).
fuzeofficlal
left a comment
There was a problem hiding this comment.
The slot-sharing idea and cut/reset handling are clean, and both new tests (clears_of_one_view_in_a_list_share_a_dynamic_slot and a_clear_after_a_cut_takes_a_new_slot_and_the_old_one_stays_held) plus all 22 draw::tests pass on RTX 5090 and WARP under VICTORY_D3D12_DEBUG=1.
However, reordering make_view(view, at) before visible.make_at(slot, view) in State::clear_view (crates/victory-gpu/src/draw.rs) introduces a descriptor-identity bug on cache misses that did not exist on main:
-
Unaligned buffer UAVs (
shadow::for_view→shadow::exact/Arena) can clear the wrong slice silently.- On
main,visible.make_at(slot, &view)ran first, pinningown: Option<Arc<Shadow>>insidevisible.kept[slot], so the subsequentmake_view(&view, at)upgraded the exact same liveWeak<Shadow>inshadow::EXACTand wrote matching(chunk, FirstElement)to both descriptors. - Here,
make_view(view, at)runs first, andmake_view(crates/victory-gpu/src/descriptor/host.rs:1461) doesmake(view, at).flatten().map(|k| k.0), droppingk.1: Option<Arc<Shadow>>immediately. If no other heap slot currently holds thatexactshadow,Shadow::drop(shadow.rs:694-698) immediately callsarena().give_back(slice)and kills theWeakinEXACTwhileatstill points to the freed Arena offset. - If another recording thread or heap sync allocates from
ARENAbeforevisible.make_at(slot, view)runs, that unrelated viewv2takesv1's freed offset (e.g. offset0) andvisible.make_at(slot, view)allocates a different offset (e.g.256, or even another Arena chunk). - Reproducing that sequence with
ClearUnorderedAccessViewUint(visible.gpu(slot), at, &resource, ...)on both RTX 5090 and WARP underVICTORY_D3D12_DEBUG=1leavesv1uncleared ([0, 0, 0, 0]) and silently overwritesv2's Arena slice withv1's clear values — with zero D3D12 Debug Layer messages because both slices share the same Arena chunk buffer. (Ifvisible.make_atspills into a new chunk, the GPU and CPU descriptors also disagree on theID3D12Resourceandclear_slotscaches the staleresource.as_raw().) - Even single-threaded, every unaligned cache miss allocates and immediately drops an
Arenaslice andMARKSrange inmake_view, only to allocate them again invisible.make_at.
- On
-
Concurrent texture eviction/recreation mismatch.
- Between
make_view(view, at)andvisible.make_at(slot, view), a concurrent host texture eviction/recreation can causevisible.make_atto populateslotwith a differentID3D12Resource(or a null view) than theresourcewritten intoatand stored inclear_slots.
- Between
Suggested fix:
On a cache miss, build the view once while retaining Kept (both the ID3D12Resource and Option<Arc<Shadow>>), and copy the already-created non-shader-visible descriptor from at into visible.cpu(slot) via CopyDescriptorsSimple (storing kept and the slot's stride/mark/address metadata on visible). That guarantees bit-for-bit identical GPU and CPU descriptors referencing the same resource and Arena slice, closes both race windows, and avoids creating the UAV twice.
Split out of #2619 at the maintainer's triage: this changes
clear_unorderedfor every unordered access clear, the title's own included, so it gets its own review. #2619 and #2620 will be rebased on top of it.What changes
clear_unorderedtook a fresh dynamic slot of the bound view heap on every call and held it until the list was reset. A list that clears the same view many times (a per-pass clear in a loop of passes, or a stand-in after each dispatch of its program) took one slot per clear from the capped heap. When the pool runs out, the draws and dispatches that need dynamic slots after it are dropped.State::clear_view(the resolved view in, whether it was recorded out).clear_unorderedcalls it after it looks up the title's CPU handle, and the test drives it directly. GPU: an opt-in constant stands in for one view a named program writes (VICTORY_AMBIENT) #2619 builds on the same function.Nothing else changes: the clear's barriers, the heap binding and the Clear call are as before.
Tests
The title was not used in these tests.
draw::tests::clears_of_one_view_in_a_list_share_a_dynamic_slot(WARP): eight clears of one view take one slot, a clear of a second view one more, and a further clear of the first none. A compute pass then reads both views, and each holds its last clear (0x55 and 0x77 at four texels). The slots come back at reset, and a new recording takes one afresh.HostHeap::dynamic_free(tests only) counts the free slots.mainf3578e3:cargo clippy -p victory-gpu --all-targets --locked -- -D warningsand the same with--all-features: both clean.VICTORY_D3D12_WARP=1 cargo test -p victory-gpu --features diagnostics --lib --locked: 244 passed, 0 failed, 1 ignored (an existing benchmark).Note for later: if a change lands that lends each list a run of dynamic slots at once (rather than one slot at a time), this test's count of the heap's free slots has to count out of the list's run instead. We hit that in our play build and fixed the test that way; the slot sharing itself was unaffected.
🤖 Generated with Claude Code