GPU: reduce contention in ordered indirect argument clamps #155
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/155"
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 Zettrox/ztrx. Originally posted by syrrath-creator on 2026-11-25T15:37:20Z.
The indirect-argument clamp charges draws and dispatches against a work budget that lives in CPU-visible memory. The budget and mesh statistics belong to the command list. The first commit uses ordinary loads and stores when only one record can reach those words. The second compiles a separate pipeline on demand for requests of 2–64 records. One threadgroup can charge all active records together if every record fits, or empty positive-cost records if the budget is already full. For partially affordable groups, the original atomics arbitrate against the untouched budget. Zero-cost records, argument payloads and mesh statistics preserve their existing behavior.
Both paths use the existing GPU-side ordering between clamps on the renderer’s single direct queue. The diagnostic switch that omits the global UAV barriers keeps atomic admission. The standard shader for single-record and multi-group requests is byte-identical between the two commits. The group pipeline falls back to the standard shader if its compilation fails. First use of the extra pipeline took 32.48 ms of CPU time on the RTX 4090 (26.84–37.77 ms across six fresh processes with the driver cache active); subsequent calls reuse it.
RTX 4090 results
Each row is a separate synthetic command list with 1,024 clamp calls. The two stages were measured in separate runs. Times are median GPU milliseconds from four fresh processes and 24 warm observations per variant, using alternating AB/BA order and 1 GHz D3D12 timestamps. The mesh and compute execution rows use real ExecuteIndirect commands and check how many groups actually ran.
For the 16-compute case, CPU command recording took 2.380 → 2.403 ms and elapsed time from queue submission through the fence was 130.734 → 33.921 ms. In a separate 128-call boundary test, an already-full 16-record budget took 1.438 → 0.295 ms. When every group had exactly one record’s cost left, the fallback took 0.292 → 0.321 ms. A 65-record control took 177.560 → 178.023 ms on the standard shader. The synthetic command lists do not establish a gameplay FPS change.
On the physical RTX 4090, 1,792 fenced pairs matched byte-for-byte. A separate CPU oracle checked 1,251 further deterministic pairs and 317 contested-budget pairs, including the 63/64/65-record boundaries. The patch also merges cleanly with #139. A combined run exercised its opt-in enhanced barriers on the RTX, with native mesh/compute execution and checked output.
Source, detailed results and reproduction instructions
View 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.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.