perf(gpu): lock-free has_pending fast path in Shadow::nothing_new and writes_pending #1134

Merged
adwen-007 merged 1 commit from upstream-pr/1134 into main 2026-11-28 19:39:38 +00:00
adwen-007 commented 2026-11-28 13:51:34 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by adwen-007 on 2026-11-28T13:51:34Z.


Problem

Shadow::nothing_new and Shadow::writes_pending are called thousands of times per frame on the hot refresh path and unconditionally acquired self.pending.lock() even when no shader writes were pending for that shadow buffer.

Fix

Track pending state with an AtomicBool (has_pending, updated alongside self.pending under its mutex) so nothing_new and writes_pending skip locking the mutex in the common empty case.

Verification

  • cargo check -p victory-gpu passes cleanly on v2026.11.28.01 (63b902f).
  • Verified across multi-hour live title gameplay on Windows 10 x64 + i7-12700K + RTX 3060 Ti with zero synchronization issues.
<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:issue:5540802020 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/1134). Originally posted by [adwen-007](https://github.com/adwen-007) on 2026-11-28T13:51:34Z. --- ## Problem `Shadow::nothing_new` and `Shadow::writes_pending` are called thousands of times per frame on the hot refresh path and unconditionally acquired `self.pending.lock()` even when no shader writes were pending for that shadow buffer. ## Fix Track pending state with an `AtomicBool` (`has_pending`, updated alongside `self.pending` under its mutex) so `nothing_new` and `writes_pending` skip locking the mutex in the common empty case. ## Verification - `cargo check -p victory-gpu` passes cleanly on `v2026.11.28.01` (`63b902f`). - Verified across multi-hour live title gameplay on Windows 10 x64 + i7-12700K + RTX 3060 Ti with zero synchronization issues.
Sign in to join this conversation.
No reviewers
No labels
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.

Reference
trustno1-coder/VIctory-NVIDIA!1134
No description provided.