GPU/Hitch: targeted RT UAV barriers, async 5s sweep without GPU settle, stack SetDescriptorHeaps #464
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/gamingwithhomie--larp!464
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-464"
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?
@Lakanya on GitHub · 2026-12-06 01:16 UTC · original
Lakanya:pr/rt-targeted-uav-and-async-sweep→main· +46 −27 · 4 files · 1 commits · openThree low-risk GPU/hitch optimizations with zero visual or rendering shortcuts:
What is in it
crates/larp-gpu/src/rt.rs):uav_barrier_for(&ID3D12Resource)(using the same borrowedtransmute_copypattern ashost::transition, zero COM ref leak).pResource = NoneUAV barriers with resource-targeted barriers onCopyRaytracingAccelerationStructure(&from_resourcebefore,&resource+&ready.copies._poolafter) and indecode_instances(&ready.copies._poolbefore each dispatch,&ready.counts+&ready.copies._poolalongside thewrittenUAV->SRV transitions).sweep()without full GPU pipeline drain (crates/larp-gpu/src/host.rs,crates/larp-gpu/src/shadow.rs):sweep()under async present (SWEEP_SETTLE_MS), but remove the forced synchronousself.settle(&mut submitted, WHY_SYNC)GPU drain before callingsweep().descriptor::stage::sweep()andshadow::let_go_idle()already guard in-flight resources viaIDLE_FRAMES,Arc::strong_count == 1,references(&s.buffer) == 1, and deferred retirement.shadow::let_go_idle()drops throughcrate::host::retire_release()solarp-reaperdrops them off the submit thread.SetDescriptorHeaps(crates/larp-gpu/src/draw.rs):Vec<Option<ID3D12DescriptorHeap>>heap allocation with a 2-element stack array[Option<ID3D12DescriptorHeap>; 2].Tested
cargo test --lib -p larp-gpu -- --test-threads=4: 24 passed / 0 failed / 6 ignored.0 dropped draws,0 regions errors): worst-case frame hitch dropped to 167.0 ms (lowest of all runs; p99 85.4 ms, VRAM 6,140 MB avg).AI-assisted by Antigravity (Gemini 4 Neon Medium).
@vanya890 on GitHub · 2026-12-06 01:19 UTC · original
The targeted UAV barriers and stack-backed descriptor-heap array are focused changes, and avoiding the per-change
Vecallocation is straightforward. The part I would like to see defended more explicitly before merge is removingself.settle(&mut submitted, WHY_SYNC)from the periodic sweep path.IDLE_FRAMES,Arc::strong_count, resource reference counts, and deferred retirement are promising guards, but the old settle was a GPU-completion boundary; CPU-side reference counts alone do not prove that every descriptor/shadow resource is no longer referenced by submitted GPU work.Could you add a focused regression/stress test or a short invariant explanation covering both descriptor-stage sweep and shadow retirement while submissions are in flight, including the relevant fence/queue ordering? In particular, show that the deferred release cannot run before the last GPU use completes. I am flagging this as a validation gap, not claiming the change is definitely unsafe.
@vanya890 on GitHub · 2026-12-06 01:20 UTC · original
The main risk-bearing change here is removing the periodic
self.settle()beforesweep(), not the stack allocation or narrower barriers. The safety argument relies on the descriptor-stage idle-frame/refcount checks and deferred shadow retirement continuing to protect every resource still referenced by submitted command lists. Could you add a focused regression/stress check (or include a trace from a run with sustained in-flight submissions across multiple 5-second sweeps) that demonstrates no descriptor/shadow is reclaimed early and no device-removal/regions errors appear? The single-machine hitch result is promising, but this is the part that needs correctness evidence before broad adoption.@Lakanya on GitHub · 2026-12-06 01:21 UTC · original
Thanks for the review — happy to make the fence/ordering invariant explicit here:
Submission fence ordering (
host.rs:STARTED/FINISHED/bury):sweep()runs insideHost::submit()whileSTARTEDholds the highest submission number already queued to the GPU (beforethis_submissionincrementsSTARTED).FINISHEDis only advanced after the host GPU fence for that submission completes, at which pointbury(finished)drains entries withat <= finished.started > FINISHED), bothhost::retire()andhost::retire_release()stamp the object withstarted = STARTED.load(Acquire)and enqueue it inRETIRED/RETIRED_RELEASErather than dropping inline. Therefore, no COMRelease()or descriptor slot reuse can occur before the GPU fence completes for every submission that was in flight whensweep()ran.Shadow retirement (
shadow::let_go_idle()):HostLists holdArc<Shadow>indeferred.copies_helduntil their submission lands inlarp-land.LOOSEmutex (blocking concurrentloose()hand-outs),let_go_idle()requires!s.owned && Arc::strong_count(s) == 1 && host::references(&s.buffer) == 1 && long_ago(s.used, idle_ms, IDLE_FRAMES = 4).host::retire_release()guarantees that even if an in-flight submission referenced the buffer,Dropis deferred tolarp-reaperstrictly afterFINISHED >= started.Staged descriptor sweep (
descriptor::stage::sweep()):> IDLE_FRAMES(4 frames), clearse.keyande.viewatomically, and retiresEnded::Kept(kept)throughcrate::host::retire()— holding both the staged descriptor slot and its keptID3D12ResourceuntilFINISHED >= started.So removing the synchronous
self.settle()drain only removes the CPU stall waiting for the GPU to go idle; the actual GPU-completion boundary is still enforced bySTARTED/FINISHEDfence retirement on every swept object.@vanya890 on GitHub · 2026-12-06 01:22 UTC · original
The resource scoping is materially better than the previous global UAV barriers: the AS copy now orders the source resource before the copy and the written destination afterward, with the positions pool included only when the copy path uses it. The periodic sweep also no longer forces a full submit-thread settle, while the existing idle/refcount/deferred-retirement guards remain responsible for lifetime safety. The stack array is bounded to the two descriptor heaps represented by the state. Please retain the RT-heavy stress validation in the PR evidence, since barrier/lifetime regressions can be workload-dependent.
@TrinityForever15 on GitHub · 2026-12-06 03:17 UTC · original
Running on RX 6650 XT 8 GB (RDNA 2), Series S profile, with #393/#392/#435, on top of
amd-testv1.1.7. No RT artifacts or device-removed errors with the per-resource UAV barriers. The combined stutter numbers are in #393 (1% low 112 ms, longest frame 434 ms, down from 6,519 ms). Thanks! https://github.com/iceboerg00/larp-amd/issues/64View 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.