GPU: clears of one view in a list share one dynamic slot #2871

Open
github-bot wants to merge 2 commits from github-bot/gh-2871 into main AGit
Owner

@⁠r4tedx on GitHub · 2026-11-25 22:49 UTC · original
r4tedx:gpu/clear-view-one-slot → main · +212 −11 · 2 files · 2 commits · open

Split out of #2619 at the maintainer's triage: this changes clear_unordered for 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_unordered took 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.

  • The list's draw state now keeps the slot it made per (view heap, view, host resource), and later clears of that view in the same list 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 resource while the slot is held.
  • The host view is now made before a slot is taken, so a view the host cannot make takes no slot.
  • The clear itself moves into State::clear_view (the resolved view in, whether it was recorded out). clear_unordered calls it after it looks up the title's CPU handle, and the test drives it directly. #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.

  • New, 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.
  • Results on main f3578e38:
    • cargo clippy -p victory-gpu --all-targets --locked -- -D warnings and 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

**@⁠r4tedx** on GitHub · 2026-11-25 22:49 UTC · [original](https://github.com/Marvisak/VIctory/pull/2871) `r4tedx:gpu/clear-view-one-slot` → `main` · +212 −11 · 2 files · 2 commits · open Split out of #2619 at the maintainer's triage: this changes `clear_unordered` for 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_unordered` took 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. - The list's draw state now keeps the slot it made per (view heap, view, host resource), and later clears of that view in the same list 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 resource while the slot is held. - The host view is now made before a slot is taken, so a view the host cannot make takes no slot. - The clear itself moves into `State::clear_view` (the resolved view in, whether it was recorded out). `clear_unordered` calls it after it looks up the title's CPU handle, and the test drives it directly. #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. - New, `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. - Results on `main` f3578e38: - `cargo clippy -p victory-gpu --all-targets --locked -- -D warnings` and 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](https://claude.com/claude-code)
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 #2619 at the maintainer's triage.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
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 #2871.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 05:16:23 +00:00
Author
Owner

@⁠fuzeofficlal on GitHub · 2026-11-25 23:05 UTC · original

Reviewed and verified e7169ee6 on Windows 11 (RTX 5090 + VICTORY_D3D12_DEBUG=1 + WARP) against main (842b0cb):

  • Keying State::clear_slots on (heap_ptr, view.clone(), resource.as_raw() as usize) while list.keep(&resource) keeps the host ID3D12Resource alive for the lifetime of the recorded list guarantees cache misses whenever the bound heap changes, the title rewrites the descriptor slot, or the underlying host texture/shadow is replaced.
  • State::cut and State::reset both clear clear_slots in lockstep with fresh_tables/root_slots and dynamic slot release.
  • Local checks: RTX 5090 draw::tests 21/21 (including clears_of_one_view_in_a_list_share_a_dynamic_slot), descriptor::host::tests 14/14, list::tests 4/4 passed; WARP draw::tests 21/21 and list::tests 4/4 passed; VICTORY_D3D12_DEBUG=1 passed on both RTX 5090 and WARP; cargo clippy (default & diagnostics) 0 warnings; cargo xtask policy (190 files ok).

Looks clean and ready to merge.

**@⁠fuzeofficlal** on GitHub · 2026-11-25 23:05 UTC · [original](https://github.com/Marvisak/VIctory/pull/2871#issuecomment-7177126332) Reviewed and verified `e7169ee6` on Windows 11 (RTX 5090 + `VICTORY_D3D12_DEBUG=1` + WARP) against `main` (`842b0cb`): - Keying `State::clear_slots` on `(heap_ptr, view.clone(), resource.as_raw() as usize)` while `list.keep(&resource)` keeps the host `ID3D12Resource` alive for the lifetime of the recorded list guarantees cache misses whenever the bound heap changes, the title rewrites the descriptor slot, or the underlying host texture/shadow is replaced. - `State::cut` and `State::reset` both clear `clear_slots` in lockstep with `fresh_tables`/`root_slots` and dynamic slot release. - Local checks: RTX 5090 `draw::tests` 21/21 (including `clears_of_one_view_in_a_list_share_a_dynamic_slot`), `descriptor::host::tests` 14/14, `list::tests` 4/4 passed; WARP `draw::tests` 21/21 and `list::tests` 4/4 passed; `VICTORY_D3D12_DEBUG=1` passed on both RTX 5090 and WARP; `cargo clippy` (default & `diagnostics`) 0 warnings; `cargo xtask policy` (`190 files ok`). Looks clean and ready to merge.
Author
Owner

@⁠r4tedx on GitHub · 2026-11-25 23:10 UTC · original

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 d3f9b11e: draw::tests::a_clear_after_a_cut_takes_a_new_slot_and_the_old_one_stays_held (WARP). One view is cleared twice in a list, the list is cut (State::cut onto a second host list, as a wait does), and the view is cleared twice more. Both segments are submitted in order. It checks that:

  • the first segment's two clears share one slot, and 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 second clear;
  • both slots stay held after execution until the list is reset, and then both come back;
  • a read pass at the end of each segment sees that segment's last clear (0x33, then 0x44, at four texels).

Results at d3f9b11e on main f3578e38: clippy -D warnings clean with and without --all-features; VICTORY_D3D12_WARP=1 cargo test -p victory-gpu --features diagnostics --lib --locked 245 passed, 0 failed, 1 ignored. The title was not used in these tests.

AI-assisted

**@⁠r4tedx** on GitHub · 2026-11-25 23:10 UTC · [original](https://github.com/Marvisak/VIctory/pull/2871#issuecomment-7177235211) 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 d3f9b11e: `draw::tests::a_clear_after_a_cut_takes_a_new_slot_and_the_old_one_stays_held` (WARP). One view is cleared twice in a list, the list is cut (`State::cut` onto a second host list, as a wait does), and the view is cleared twice more. Both segments are submitted in order. It checks that: - the first segment's two clears share one slot, and 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 second clear; - both slots stay held after execution until the list is reset, and then both come back; - a read pass at the end of each segment sees that segment's last clear (0x33, then 0x44, at four texels). Results at d3f9b11e on `main` f3578e38: clippy `-D warnings` clean with and without `--all-features`; `VICTORY_D3D12_WARP=1 cargo test -p victory-gpu --features diagnostics --lib --locked` 245 passed, 0 failed, 1 ignored. The title was not used in these tests. AI-assisted
Author
Owner

@⁠pawrenity on GitHub · 2026-11-25 23:49 UTC · original

VERIFY-2871: verified d3f9b11e (incl. the new cut test) on NVIDIA GeForce RTX 4070, Windows 11 (default adapter, confirmed via GetAdapterLuid → EnumAdapterByLuid), base f3578e38.

Review: no defects found.

  • clear_view makes the CPU view before taking a slot, so a view the host cannot make no longer leaks a dynamic slot.
  • The slot is written (make_at) only on a cache miss. The key (heap, View, host resource) changes whenever the bound heap, the title's view or the host resource changes, and list.keep(&resource) holds the resource, so the cached descriptor still names the same view when it is reused.
  • State::reset (*self = State::default()) drops clear_slots along with dynamic, whose Drop releases the slots. State::cut clears clear_slots together with fresh_tables/root_slots and releases nothing.

Results (cargo test -p victory-gpu --locked --lib):

  • draw::tests::clears_of_one_view_in_a_list_share_a_dynamic_slot and draw::tests::a_clear_after_a_cut_takes_a_new_slot_and_the_old_one_stays_held: pass.
  • Same two plus all of draw::: 22/22 pass with --features diagnostics and VICTORY_D3D12_DEBUG=1, --test-threads=1.
  • The tests catch a missing cache. At head, with the cache lookup forced to miss (.filter(|_| false)), both fail on the slot count: "eight clears of one view, one slot" (65528 vs 65535) and "one slot before the cut" (65534 vs 65535).
  • Full lib suite at head: 228 passed, 2 failed, 1 ignored. The 2 failures are descriptor::host::tests::dynamic_slots_are_held_until_released (NumDescriptors >= HEAP_VIEWS) and memory::tests::lists_share_a_table_and_copies_keep_their_views ("past the dynamic slots"). Both also fail alone (--test-threads=1) on base f3578e38 and on current main 63bcca4 on this machine, so this PR does not cause them.
  • A trial merge onto current main 63bcca4 merges cleanly (auto-merge in draw.rs) and gives 231 passed with the same 2 failures that main already has.
  • cargo clippy -p victory-gpu --all-targets --locked -- -D warnings: clean.

AI-assisted (Claude Code).

**@⁠pawrenity** on GitHub · 2026-11-25 23:49 UTC · [original](https://github.com/Marvisak/VIctory/pull/2871#issuecomment-7178111589) VERIFY-2871: verified `d3f9b11e` (incl. the new cut test) on NVIDIA GeForce RTX 4070, Windows 11 (default adapter, confirmed via `GetAdapterLuid` → `EnumAdapterByLuid`), base `f3578e38`. Review: no defects found. - `clear_view` makes the CPU view before taking a slot, so a view the host cannot make no longer leaks a dynamic slot. - The slot is written (`make_at`) only on a cache miss. The key `(heap, View, host resource)` changes whenever the bound heap, the title's view or the host resource changes, and `list.keep(&resource)` holds the resource, so the cached descriptor still names the same view when it is reused. - `State::reset` (`*self = State::default()`) drops `clear_slots` along with `dynamic`, whose `Drop` releases the slots. `State::cut` clears `clear_slots` together with `fresh_tables`/`root_slots` and releases nothing. Results (`cargo test -p victory-gpu --locked --lib`): - `draw::tests::clears_of_one_view_in_a_list_share_a_dynamic_slot` and `draw::tests::a_clear_after_a_cut_takes_a_new_slot_and_the_old_one_stays_held`: pass. - Same two plus all of `draw::`: 22/22 pass with `--features diagnostics` and `VICTORY_D3D12_DEBUG=1`, `--test-threads=1`. - The tests catch a missing cache. At head, with the cache lookup forced to miss (`.filter(|_| false)`), both fail on the slot count: "eight clears of one view, one slot" (65528 vs 65535) and "one slot before the cut" (65534 vs 65535). - Full lib suite at head: 228 passed, 2 failed, 1 ignored. The 2 failures are `descriptor::host::tests::dynamic_slots_are_held_until_released` (`NumDescriptors >= HEAP_VIEWS`) and `memory::tests::lists_share_a_table_and_copies_keep_their_views` ("past the dynamic slots"). Both also fail alone (`--test-threads=1`) on base `f3578e38` and on current `main` `63bcca4` on this machine, so this PR does not cause them. - A trial merge onto current `main` `63bcca4` merges cleanly (auto-merge in `draw.rs`) and gives 231 passed with the same 2 failures that `main` already has. - `cargo clippy -p victory-gpu --all-targets --locked -- -D warnings`: clean. AI-assisted (Claude Code).
Author
Owner

@⁠Marvisak on GitHub · 2026-11-26 04:26 UTC · original

Automated triage for the maintainers.

Merge candidate. Repeated unordered-access clears of one view in one list now share a single dynamic slot via State::clear_slots, keyed on (view heap, View, host resource), and the host view is made before a slot is taken so a view the host cannot make no longer leaks one. The key is sound (View derives Ord, the resource is kept alive by list.keep), the cache is cleared in State::cut next to root_slots, and the tests check slot counts and the texel values each view holds after its last clear.

CI: passing.


Generated by Claude Code

**@⁠Marvisak** on GitHub · 2026-11-26 04:26 UTC · [original](https://github.com/Marvisak/VIctory/pull/2871#issuecomment-7182596400) <!-- victory-triage v1 head=d3f9b11e2e21fba764903348da2b1bf2408d033b verdict=merge-candidate at=2026-11-26T04:26:17Z --> Automated triage for the maintainers. **Merge candidate.** Repeated unordered-access clears of one view in one list now share a single dynamic slot via `State::clear_slots`, keyed on (view heap, `View`, host resource), and the host view is made before a slot is taken so a view the host cannot make no longer leaks one. The key is sound (`View` derives `Ord`, the resource is kept alive by `list.keep`), the cache is cleared in `State::cut` next to `root_slots`, and the tests check slot counts and the texel values each view holds after its last clear. CI: passing. --- _Generated by [Claude Code](https://claude.ai/code)_
Author
Owner

@⁠kotekompotek on GitHub · 2026-11-25 22:53 UTC · original · reviewed

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.

**@⁠kotekompotek** on GitHub · 2026-11-25 22:53 UTC · [original](https://github.com/Marvisak/VIctory/pull/2871#pullrequestreview-6066088618) · **reviewed** 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.
Author
Owner

@⁠AwsAli05 on GitHub · 2026-11-25 22:56 UTC · original · reviewed

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.

**@⁠AwsAli05** on GitHub · 2026-11-25 22:56 UTC · [original](https://github.com/Marvisak/VIctory/pull/2871#pullrequestreview-6066119661) · **reviewed** 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.
Author
Owner

@⁠Dukestar69 on GitHub · 2026-11-26 10:08 UTC · original · approved these changes

Verified on RTX 5090 against origin/main (63bcca4):

  • cargo test -p victory-gpu --lib draw:: -- --test-threads=1: 22/22 passed (including 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).
  • 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).

**@⁠Dukestar69** on GitHub · 2026-11-26 10:08 UTC · [original](https://github.com/Marvisak/VIctory/pull/2871#pullrequestreview-6072124447) · **approved these changes** Verified on RTX 5090 against `origin/main` (`63bcca4`): - `cargo test -p victory-gpu --lib draw:: -- --test-threads=1`: 22/22 passed (including `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`). - `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).
Author
Owner

@⁠fuzeofficlal on GitHub · 2026-11-26 10:52 UTC · original · requested changes

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:

  1. Unaligned buffer UAVs (shadow::for_view → shadow::exact / Arena) can clear the wrong slice silently.

    • On main, visible.make_at(slot, &view) ran first, pinning own: Option<Arc<Shadow>> inside visible.kept[slot], so the subsequent make_view(&view, at) upgraded the exact same live Weak<Shadow> in shadow::EXACT and wrote matching (chunk, FirstElement) to both descriptors.
    • Here, make_view(view, at) runs first, and make_view (crates/victory-gpu/src/descriptor/host.rs:1461) does make(view, at).flatten().map(|k| k.0), dropping k.1: Option<Arc<Shadow>> immediately. If no other heap slot currently holds that exact shadow, Shadow::drop (shadow.rs:694-698) immediately calls arena().give_back(slice) and kills the Weak in EXACT while at still points to the freed Arena offset.
    • If another recording thread or heap sync allocates from ARENA before visible.make_at(slot, view) runs, that unrelated view v2 takes v1's freed offset (e.g. offset 0) and visible.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 under VICTORY_D3D12_DEBUG=1 leaves v1 uncleared ([0, 0, 0, 0]) and silently overwrites v2's Arena slice with v1's clear values — with zero D3D12 Debug Layer messages because both slices share the same Arena chunk buffer. (If visible.make_at spills into a new chunk, the GPU and CPU descriptors also disagree on the ID3D12Resource and clear_slots caches the stale resource.as_raw().)
    • Even single-threaded, every unaligned cache miss allocates and immediately drops an Arena slice and MARKS range in make_view, only to allocate them again in visible.make_at.
  2. Concurrent texture eviction/recreation mismatch.

    • Between make_view(view, at) and visible.make_at(slot, view), a concurrent host texture eviction/recreation can cause visible.make_at to populate slot with a different ID3D12Resource (or a null view) than the resource written into at and stored in clear_slots.

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.

**@⁠fuzeofficlal** on GitHub · 2026-11-26 10:52 UTC · [original](https://github.com/Marvisak/VIctory/pull/2871#pullrequestreview-6072837898) · **requested changes** 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`: 1. **Unaligned buffer UAVs (`shadow::for_view` → `shadow::exact` / `Arena`) can clear the wrong slice silently.** - On `main`, `visible.make_at(slot, &view)` ran first, pinning `own: Option<Arc<Shadow>>` inside `visible.kept[slot]`, so the subsequent `make_view(&view, at)` upgraded the exact same live `Weak<Shadow>` in `shadow::EXACT` and wrote matching `(chunk, FirstElement)` to both descriptors. - Here, `make_view(view, at)` runs first, and `make_view` (`crates/victory-gpu/src/descriptor/host.rs:1461`) does `make(view, at).flatten().map(|k| k.0)`, dropping `k.1: Option<Arc<Shadow>>` immediately. If no other heap slot currently holds that `exact` shadow, `Shadow::drop` (`shadow.rs:694-698`) immediately calls `arena().give_back(slice)` and kills the `Weak` in `EXACT` while `at` still points to the freed Arena offset. - If another recording thread or heap sync allocates from `ARENA` before `visible.make_at(slot, view)` runs, that unrelated view `v2` takes `v1`'s freed offset (e.g. offset `0`) and `visible.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 under `VICTORY_D3D12_DEBUG=1` leaves `v1` uncleared (`[0, 0, 0, 0]`) and silently overwrites `v2`'s Arena slice with `v1`'s clear values — with zero D3D12 Debug Layer messages because both slices share the same Arena chunk buffer. (If `visible.make_at` spills into a new chunk, the GPU and CPU descriptors also disagree on the `ID3D12Resource` and `clear_slots` caches the stale `resource.as_raw()`.) - Even single-threaded, every unaligned cache miss allocates and immediately drops an `Arena` slice and `MARKS` range in `make_view`, only to allocate them again in `visible.make_at`. 2. **Concurrent texture eviction/recreation mismatch.** - Between `make_view(view, at)` and `visible.make_at(slot, view)`, a concurrent host texture eviction/recreation can cause `visible.make_at` to populate `slot` with a different `ID3D12Resource` (or a null view) than the `resource` written into `at` and stored in `clear_slots`. **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.
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/2871/head:github-bot/gh-2871'
git switch 'github-bot/gh-2871'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-2871'
git switch 'github-bot/gh-2871'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-2871'
git switch 'github-bot/gh-2871'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-2871'
git switch 'main'
git merge --squash 'github-bot/gh-2871'
git switch 'main'
git merge --ff-only 'github-bot/gh-2871'
git switch 'main'
git merge 'github-bot/gh-2871'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No reviewers
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
github/Marvisak--VIctory!2871
No description provided.