Skip to content

GPU: batch requested indirect prefixes in one prelude (opt-in) - #1001

Open
Demon12377 wants to merge 11 commits into
fxceless:mainfrom
Demon12377:perf/ordered-indirect-prefix
Open

Demon12377 wants to merge 11 commits into
fxceless:mainfrom
Demon12377:perf/ordered-indirect-prefix

Conversation

@Demon12377

@Demon12377 Demon12377 commented Nov 25, 2026 •

Copy link
Copy Markdown

Indirect calls switch from drawing to compute and back for each argument clamp. With VICTORY_INDIRECT_BATCH=1 (off by default), an actual prefix of up to 256 nonwriting, single-record draw/indexed/mesh calls is prepared in one native prelude. Independent prepares share a binding with no inter-prepare barriers; one final group charges the original list budget in call order. Consumers keep their own pipeline and root state.

Latest sync: upstream 3973179 is an ancestor of this branch. Its new pipeline meters, joined submissions, copy-back own-view fixes, monitorx/mwaitx counters, spread experiment and WINDOW_JUMP diagnostics are preserved. Jump/read state is tracked per cached window when combined with the existing eight-window cache.

This proposal includes and supersedes #889, including its repaired coalesced hash (paired sign-bit regression), disjoint window scratch, guarded copy repairs and staging reuse. It includes current upstream 39731795d2d5117e6f90939273ee130428d28137, preserving the frame log, card meter, driver-watch fallback and latest plain-copy/affinity changes.

The new prefix:

  • Ends before a GPU write, copy, barrier, query, count-buffered/multi-record call or other execution; it never cuts a native list or predicts future records.
  • Uses the ordinary clamp for a prefix of one. Longer prefixes have N independent prepares, one ordered charge and two global UAV barriers for the whole prefix, instead of two per call.
  • Leaves scratch readable through the consumer list's close, including a draw whose preparation helper ends the prefix before its execution is recorded.
  • Reclamps on every replay, resets only after the owner's executions finish, bounds the full record/padding and falls back for in-place title arguments or capacity exhaustion.
  • Disables speculative ahead windows while batch mode is enabled, including its inline fallback. The batch also disables itself for serial GPU timing or a tripped driver watch.

Measured synthetic WARP timestamps on Windows/Rust 1.98.1, debug layer/GBV/card meter/serial timing off, five warmups and ten samples. Both modes assert the same weighted work every execution; timestamps include the prelude and consumers:

Calls Inline median, us Batch median, us Inline / batch
1 431.829 493.149 0.88x
16 749.118 763.086 0.98x
64 2146.781 1340.813 1.60x
256 9468.522 4942.667 1.92x

Short prefixes can cost more. These are software-adapter compute-consumer measurements, not game FPS or native mesh/graphics results. A comparable scene benchmark is still needed; no 60-FPS claim is made. Upstream's former 6.0 -> 8.9 FPS comparison was withdrawn in 0b0074e.

The table above was measured on the combined 0b0074e tree; the ordinary clamp shader is unchanged in 3973179. Validation below was rerun after integrating 3973179.

Validation of the current combined tree:

  • Both workspace Clippy configurations (--all-targets, with and without --all-features, --locked -- -D warnings) pass.
  • Asset policy: 182 files pass.
  • Diagnostics victory-gpu, WARP + debug, batch/window flags set: 206 passed, 7 ignored, one inherited depth-bounds test excluded.
  • victory-loader: 26 unit tests pass; the unchanged crash::tests::unwinds_like_the_system_walk fails because the system walk returns an empty vector. The same 26/1 result reproduces on unmodified upstream 3973179. This is recorded as a failure, not a passed/skipped check.
  • Nine new batch tests also pass with GPU Based Validation: ordered budget/counts/padding vs inline; per-call roots; producer before/after the prefix; query boundary; capacity/tail; pending consumer; replay/reset.
  • The timestamp benchmark ran separately with assertions, rather than treating its ignored status as validation.

The excluded depth_bounds_pipeline_loads_and_filters_draws test has a previously reproduced upstream E_INVALIDARG at root-signature creation on this machine. Shader Model 6.6/game validation was not performed here. Follow-on work remains for prefixes after an in-list producer, physical-page coherence and translated shader cost. Related budget-order proposals #864/#899 address a different grouping boundary.

AI-assisted implementation and source review; local tests use synthetic data only. No game assets or derived fixtures.

Retain true upstream ancestry; final combined draw code is restored in the next commit.

Copy link
Copy Markdown

Independent native D3D12 result for fe30da8 on an RTX 5090 (driver 617.42), Ryzen 7 9800X3D, Windows 11 build 26200, Rust 1.98.1.

All nine indirect::batch::tests correctness tests passed with VICTORY_INDIRECT_BATCH=1 and VICTORY_INDIRECT_WINDOW=1. A second correctness run with VICTORY_D3D12_DEBUG=1 and VICTORY_D3D12_GBV=1 also passed all nine.

I ran measure_indirect_prefix_against_inline_with_equal_work in 12 fresh processes, six with inline first and six with batch first. The local fixture edits printed the actual DXGI adapter and allowed reversing the timed mode order. The D3D12 debug layer, GPU-based validation, card meter (VICTORY_CARD_METER=0), and serial GPU timing were off for the benchmark. Each process used the existing five warmups and ten samples per mode per case, with the weighted-work assertion passing every execution.

Calls Inline GPU time (µs) Batch GPU time (µs) Median paired inline/batch Per-process ratio range
1 8.24 10.18 0.81× 0.76–0.90×
16 55.33 25.63 2.16× 2.06–2.20×
64 206.35 73.76 2.79× 2.73–3.20×
256 1069.30 224.32 4.80× 3.61–6.54×

The 256-call case was the most variable (median paired ratio 6.12× with inline first and 4.40× with batch first). Batching reduced GPU time for 16, 64, and 256 calls in every process. These are synthetic compute-consumer timings including the prelude. Graphics/mesh workloads and in-game frame times remain open.

Tested and summarized with Codex.

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.

2 participants