Skip to content

GPU: specialize the indirect argument clamp for single records - #1016

Open
Lkxex wants to merge 1 commit into
fxceless:mainfrom
Lkxex:perf/single-record-indirect-clamp
Open

Lkxex wants to merge 1 commit into
fxceless:mainfrom
Lkxex:perf/single-record-indirect-clamp

Conversation

@Lkxex

@Lkxex Lkxex commented Nov 25, 2026

Copy link
Copy Markdown

The latest frame breakdown reports about 2,400 indirect calls per frame that still run separate clamps with draw windows enabled, including about 960 compute calls and 1,000 scattered mesh draws. This targets the one-record calls that reach the inline clamp, including pipelines that are ineligible for draw windows.

With VICTORY_INDIRECT_SINGLE=1, one-record calls use a one-thread variant of the existing shader. Both variants share argument decoding, bounds checks and record writes. The specialized shader drops group-memory synchronization and the lane scans, and preserves the saturating atomic budget charge, mesh diagnostics, padding, count-buffer rules and D3D12 barriers. Larger calls and windows continue through the group shader. The switch defaults to off and falls back to the group shader if compilation fails.

RX 6600, 3,200 synthetic indirect draws, GPU timestamp medians of nine samples per case, device-local budget and identical barriers in both cases:

Run Group kernel Single-record kernel GPU time
1 7.98 ms 6.71 ms -15.9%
2 8.91 ms 7.32 ms -17.8%
3 8.06 ms 6.72 ms -16.6%

The benchmark includes the clamp and tiny graphics draws. These figures describe the synthetic workload. A game run and NVIDIA measurements are pending.

The diagnostics indirect suite passed 14 tests on Windows with VICTORY_D3D12_DEBUG=1 and VICTORY_INDIRECT_SINGLE=1. The new WARP parity test compares scratch and all three budget words across draw, indexed draw, dispatch and mesh, including a zero count, exact budget fit, saturation, and an unfilled ahead record. The ignored timestamp benchmark also passed on the hardware adapter.

Related: #1001 reduces the number of clamp passes for compatible prefixes. This change reduces the cost of a clamp that runs individually.

AI-assisted.

CernyMuzCZ pushed a commit to CernyMuzCZ/vitezstvi-fork that referenced this pull request Nov 25, 2026
Port of fxceless PR fxceless#1016 (e377a5c) onto the ring/early/split-dispatch/gather stack:
- Add opt-in SINGLE_RECORD 1-thread compute shader variant (VICTORY_INDIRECT_SINGLE=1, off by default) without group barriers, keeping the multi-record kernel byte-for-byte unchanged on all other paths.
- Gate single-record selection in clamp_to and record_early with is_single_record: used only for records == 1, no count buffer (bit 0), not ahead (bit 1), not gathered (bit 2/value 4), and not SPLIT_DISPATCH (kind 3).
- Keep mesh diagnostics on kind > 3 and identical budget words 0/4/8 and BUDGET saturation.
- Update indirect::bench with the single-lane card case.
- Add eligibility unit test and WARP equivalence test covering kinds 0, 1, 2, 10 and over-budget records.
dkdknight added a commit to dkdknight/victory-fork that referenced this pull request Nov 25, 2026
…d barrier, in its prelude where the list did not write them (all off)

Ported from fxceless/victory-fork PR fxceless#1000 (by PiloteCode / Pilote
Production: "indirect records clamped into a ring of the list's behind one
enhanced barrier, and in the list's prelude where the list did not write
them") and PR fxceless#1016 (a one-lane clamp for single records) onto our clamp,
which keeps its budget on the card, VICTORY_CLAMP_WAIT, VICTORY_INDIRECT_LAZY,
VICTORY_INDIRECT_AMPLIFY and the ahead windows. Not merged: our indirect.rs
differs too much from theirs.

Each host list reads the switches once, when it begins recording (made or
reset), and keeps them until its next reset; the live file's
indirect_ring= / indirect_prelude= / indirect_single= lines override the
environment, so a run can toggle them without a restart and no list mixes
two ways.

- VICTORY_INDIRECT_RING=1: each clamp writes room of its own in a ring of
  the list's, so no clamp overwrites records an earlier indirect call still
  reads. The change of state before the clamp goes; the one after it is one
  enhanced barrier on the ring (compute shading / unordered access ->
  execute indirect / indirect argument). The wait for the title's shader
  writes before the clamp stays as VICTORY_CLAMP_WAIT says (fxceless#1000 dropped
  it). The ring is made as the scratch buffer is, as fxceless#1000 makes it, and
  only enhanced barriers ever name it; the scratch buffer keeps its legacy
  changes of state. A full ring is replaced by one twice as big, the old one
  held until the reset. Without EnhancedBarriersSupported a warning is
  logged once and the lists use the scratch buffer.
- VICTORY_INDIRECT_PRELUDE=1, with the ring: records no shader recorded
  before in the list may write (by the ranges the list's shaders declare;
  count buffers and title memory in place stay in the list) are clamped in
  the list's prelude at each submission: a global barrier for earlier
  shader and copy writes, the clamps, one barrier per ring. The list's
  budget on the card is zeroed there instead of in the list, so the
  prelude's charges are not forgotten.
- VICTORY_INDIRECT_SINGLE=1: a single record is clamped by a group of one
  lane. Our clamp charges the budget lane by lane, so it is the same code
  in a group of one.

The frame log gets two lines (clamps into rings and scratch buffers,
enhanced barriers, lists begun each way, rings made, grown, largest, most
taken, fallbacks by reason; prelude clamps noted and recorded, records
left in the list by reason, one-lane clamps), a line when the asked
switches change, and a removed device's report says per list its form,
how far its ring was taken and its address, and its prelude's clamps.

Tests: the same records (dispatches, draws, indexed draws, mesh records,
an ahead window, a count buffer) through the scratch buffer, the ring, the
ring with the prelude, and with the one-lane clamp come out the same; the
prelude clamps anew at a second submission; the ring gives each clamp room
of its own, grows, and starts again after a reset; the one-lane clamp
matches the clamp of 64 lanes on WARP (after fxceless#1016's test). Run on the
RTX and on WARP with the debug layer.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
dkdknight added a commit to dkdknight/victory-fork that referenced this pull request Nov 25, 2026
… what to read in the log

From fxceless/victory-fork PRs fxceless#1000 (PiloteCode) and fxceless#1016. Not measured
yet.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
rcioletti added a commit to rcioletti/victory-gta6 that referenced this pull request Nov 25, 2026
PiloteCode pushed a commit to PiloteCode/victory-fork that referenced this pull request Nov 25, 2026
…-bytes

XMA: gather frame payloads one byte at a time
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant