fix(gpu/uav_pool): reversed STARTED/QUEUED load order in retire_uavs can recycle in-flight UAV buffers #316
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
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?
Imported from Androtim/MiniVI. Originally posted by RUIZ-Enrique-25002136 on 2026-12-02T09:14:10Z.
Summary
uav_pool::retire_uavsreadsSTARTEDbeforecrate::queue::queued(), which is the opposite order ofhost::retire/host::retire_resourceand races withqueue::behindincrementingSTARTEDbefore decrementingQUEUED. As a result, still-in-flight scratch UAV buffers can be under-counted and immediately recycled intoUAV_SPARE.Evidence (
file:line& Code Proof)crates/victory-gpu/src/host/uav_pool.rs:139-143(uav_pool::retire_uavs):crates/victory-gpu/src/queue/behind.rs:696-712):The submit worker increments
STARTED(insidehost.execute_late/host.execute_parts) before callingQUEUED.fetch_sub(..., Relaxed).crates/victory-gpu/src/host.rs:820-821, 833-834):retireandretire_resourceexplicitly loadqueued()beforeSTARTED.load(Ordering::Acquire).STARTED = 10,QUEUED = 1,FINISHED = 10.retire_uavsevaluates the left operand of+: readsSTARTED == 10.victory-submitexecutes submission #11 (STARTED->11, GPU work in flight) and decrementsQUEUED->0.retire_uavsreadsqueued() == 0, computesstarted = 10 <= finished, and immediately returns the buffers toUAV_SPAREviagive_uavs(bypassingRETIRED_UAVS). Even whenstarted > finished,startedis under-counted by1(or1 + parts.len()forJob::Joined), allowingdrain_retired_uavsto release buffers before submission #11 finishes.Impact
Device-local scratch UAV buffers still referenced by an active GPU submission can be immediately handed out by
take_uavto another command list, causing GPU data corruption, D3D12 resource-state hazards, or device removal (TDR).AI-Ready Fix Specification
crates/victory-gpu/src/host/uav_pool.rs(retire_uavs), loadlet queued = crate::queue::queued();beforeSTARTED.load(Ordering::Acquire)and computelet started = STARTED.load(Ordering::Acquire) + queued;.crates/victory-gpu/src/queue/behind.rs(whereQUEUEDis decremented and read viaqueued()), upgradeQUEUEDmemory ordering fromRelaxedtoReleaseonfetch_subandAcquireonload(matchingSTARTEDsynchronization) so neither the compiler nor CPU can reorder the pair.uav_pool(if pure-logicretire_uavs_at/ atomic ordering helper is testable) and runcargo clippy --workspace --all-targets --locked -- -D warningson Windows CI.Imported from Androtim/MiniVI. Originally posted by github-actions[bot] on 2026-12-02T09:14:21Z.
Please attach both logs from the run that went wrong so we can investigate without guessing. Paste
%LOCALAPPDATA%into the File Explorer address bar to find them:%LOCALAPPDATA%\victory\logs\: the newest.logfrom that run (the console prints its path at startup on theLog: ...line).%LOCALAPPDATA%\victory\data\<TitleId>\crashes.log, and if present, the newest.crash.login%LOCALAPPDATA%\victory\data\<TitleId>\temp\.Please also include:
play-minivi.ps1preset, DLSS/FG/RT, customVICTORY_*vars) and commit SHA(Clean-room policy: please only attach text logs/screenshots — do not upload copyrighted game files or executables.)