perf(gpu): lock-free fast path for common indirect host command signatures #285

Open
Mikey970 wants to merge 1 commit from upstream-pr/285 into main
Mikey970 commented 2026-11-27 20:40:41 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by Mikey970 on 2026-11-27T20:40:41Z.


Problem

host_signature(kind, stride) in crates/victory-gpu/src/draw.rs acquires a global Mutex<Vec<...>> on every indirect draw/dispatch lookup across all parallel command-list recording workers (~4,500+ indirect executions per frame).

Fix

  • Adds a lock-free [OnceLock<Option<SyncSignature>>; 4] fast path for the four standard single-argument indirect command signatures: Draw (0, 16), DrawIndexed (1, 20), Dispatch (2, 12), and DispatchMesh (10, 12).
  • Keeps the existing Mutex<Vec<...>> cache as a fallback for any non-standard (kind, stride) pair.
  • ID3D12CommandSignature is immutable and free-threaded in D3D12.

Testing

  • Built and verified with cargo test -p victory-gpu --lib draw::thread_tests.
<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:issue:5532822052 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/285). Originally posted by [Mikey970](https://github.com/Mikey970) on 2026-11-27T20:40:41Z. --- ## Problem `host_signature(kind, stride)` in `crates/victory-gpu/src/draw.rs` acquires a global `Mutex<Vec<...>>` on every indirect draw/dispatch lookup across all parallel command-list recording workers (~4,500+ indirect executions per frame). ## Fix - Adds a lock-free `[OnceLock<Option<SyncSignature>>; 4]` fast path for the four standard single-argument indirect command signatures: Draw `(0, 16)`, DrawIndexed `(1, 20)`, Dispatch `(2, 12)`, and DispatchMesh `(10, 12)`. - Keeps the existing `Mutex<Vec<...>>` cache as a fallback for any non-standard `(kind, stride)` pair. - `ID3D12CommandSignature` is immutable and free-threaded in D3D12. ## Testing - Built and verified with `cargo test -p victory-gpu --lib draw::thread_tests`.
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/285:upstream-pr/285'
git switch 'upstream-pr/285'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/285'
git switch 'upstream-pr/285'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/285'
git switch 'upstream-pr/285'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/285'
git switch 'main'
git merge --squash 'upstream-pr/285'
git switch 'main'
git merge --ff-only 'upstream-pr/285'
git switch 'main'
git merge 'upstream-pr/285'
git push origin 'main'
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!285
No description provided.