WIP: Opt-in root-buffer indices and per-record indirect root batching; texture-only dispatches keep the argument batch; opt-in SRV load passes #598

Draft
deama wants to merge 27 commits from deama/Darner:pr/5-root-indices-indirect-batching into Main
First-time contributor

Not run in the game on Darner. Ported from a local VIctory-NVIDIA branch (before the rename). The notes below describe that branch.

Contributor role (optional)

  • Fluxer ID:

What it changes

  • The problem on main: read from the code, and from the VIctory branch's profiles of root-argument and indirect-clamp overhead.

Seven commits:

  • Port bounded root-buffer indices and preserve null view-bias semantics

  • Batch indirect executions with per-record root constants and bounded GPU arguments

  • Group changing table offsets while preserving heap and fixed-binding boundaries

  • Port opt-in dominated raw SRV load reuse from xmem

  • Add opt-in motion of guaranteed invariant raw SRV reads out of loops

  • gpu: gate argument-clamp reuse after texture-only dispatches

  • gpu: enable measured texture dispatch argument reuse by default

  • DARNER_ROOT_BUFFER_INDICES=1 (off by default, in the shader cache key): a root SRV or UAV can be a bounded heap view whose index the shader reads from one root constant, instead of a one-view table. A null view keeps the view-bias semantics.

  • DARNER_INDIRECT_ROOTS=1 (off by default): indirect executions are batched with per-record root constants and bounded GPU arguments. Changing table offsets are grouped without crossing heap or fixed-binding boundaries. The root writes go through one record_root helper, which also feeds main's DARNER_ROOT_ARG_SKIP cache, so both switches can be on together. The cache is cleared whenever a batch sets arguments itself.

  • DARNER_INDIRECT_TEXTURE_BATCH (on by default): a compute dispatch that writes only images (no buffer stores, no ambient pass) does not end the clamp batch. Its effect is limited to DARNER_INDIRECT_BATCH=1. darner play now defaults to DARNER_INDIRECT_BATCH=2, where this does nothing.

  • Shader optimiser, opt-in bits of DARNER_SHADER_OPT: 512 DOM_LOADS (reuse of a dominating raw SRV load, from lobomfz/VIctory-xmem fd19a206) and 1024 LOOP_LOADS (guaranteed loop-invariant raw SRV reads leave loops). Main's default (511, WIDE included) is unchanged. 1023, 1535 and 2047 ask for them.

How it was tested

  • Tested revision: 5e8ad22a6f
  • Commands and results: on 5e8ad22a6f (this branch's head), Windows 10 22H2 with its built-in Direct3D 12 (no Shader Model 6.6), Rust 1.98.1:
    • cargo clippy --workspace --all-targets --locked -- -D warnings: passed
    • cargo clippy --workspace --all-targets --all-features --locked -- -D warnings: passed
    • cargo --config 'profile.test.package.darner-shader.opt-level=3' test --workspace --locked --no-fail-fast (the opt-level only speeds up darner-shader's exhaustive float tests): 66 failed, all of which fail on unmodified main (c8258f9556) on this PC too (darner-shader tests that need Shader Model 6.6).
    • darner-gpu's test process aborts at the first test that needs Shader Model 6.6, on main too, so its tests were run in batches that survive the abort and compared one by one with main (main: 1658 pass, 8 fail, 139 need Shader Model 6.6, 81 ignored): no test that passes on main fails here, none removed; 31 new tests: 13 ignored, 18 pass.
    • cargo xtask policy: ok on the PR 8 head, which contains this branch.
    • Not run: tests that need Shader Model 6.6 or a GPU, and the strict-WARP tests behind the diagnostics/gpu-validation features.
  • Changes a default: yes, DARNER_INDIRECT_TEXTURE_BATCH for runs with DARNER_INDIRECT_BATCH=1 (not darner play's default). Everything else is opt-in.
  • A/B result: none on Darner. The original commit records an A/B on the VIctory branch (RTX 4080 at PCIe 4.0 x4, 4K, DLSS Balanced, no frame generation, six settled eight-second phases: 50.25 ms off, 48.43 ms on, 3 December 2026). Which DARNER_INDIRECT_BATCH mode that run used is not recorded. In this code the switch acts only with mode 1, and darner play sets 2, so that result may not carry over. Not re-measured on Darner.
  • Gates run on that revision: see above.
  • Gameplay: not run on Darner.
  • Shader wave sizes tested: unit tests only.
  • Hardware dependence: likely general.
  • Coverage gaps: no in-game run. The indirect-roots, root-index and shader-pass paths are covered by unit tests only (their strict-WARP tests were not run here).

Checklist

  • I ran this change in the game, or say below why it can't be (docs, tests only). Not run in the game on Darner.
  • This PR contains one change based on main. No: related root/indirect work, stacked on the PRs below.
  • The diff follows docs/asset-policy.md.
  • I recorded this PR's dependencies below.
    • Depends on #594 (validation and test wiring)
    • Depends on #597 (stacked branch; contains #596 too)

Checked for overlap

  • I searched the open pull requests for the same issue and for the files this touches.
  • Related PRs: #481 (DARNER_INDIRECT_REST findings), #35 (wide indirect dispatches on Intel), #394 and #292 (constant reads from root SRVs; different problem).
  • Replaces or overlaps: none found
**Not run in the game on Darner.** Ported from a local VIctory-NVIDIA branch (before the rename). The notes below describe that branch. ## Contributor role (optional) - Fluxer ID: ## What it changes - The problem on main: read from the code, and from the VIctory branch's profiles of root-argument and indirect-clamp overhead. Seven commits: - Port bounded root-buffer indices and preserve null view-bias semantics - Batch indirect executions with per-record root constants and bounded GPU arguments - Group changing table offsets while preserving heap and fixed-binding boundaries - Port opt-in dominated raw SRV load reuse from xmem - Add opt-in motion of guaranteed invariant raw SRV reads out of loops - gpu: gate argument-clamp reuse after texture-only dispatches - gpu: enable measured texture dispatch argument reuse by default - `DARNER_ROOT_BUFFER_INDICES=1` (off by default, in the shader cache key): a root SRV or UAV can be a bounded heap view whose index the shader reads from one root constant, instead of a one-view table. A null view keeps the view-bias semantics. - `DARNER_INDIRECT_ROOTS=1` (off by default): indirect executions are batched with per-record root constants and bounded GPU arguments. Changing table offsets are grouped without crossing heap or fixed-binding boundaries. The root writes go through one `record_root` helper, which also feeds main's `DARNER_ROOT_ARG_SKIP` cache, so both switches can be on together. The cache is cleared whenever a batch sets arguments itself. - `DARNER_INDIRECT_TEXTURE_BATCH` (on by default): a compute dispatch that writes only images (no buffer stores, no ambient pass) does not end the clamp batch. Its effect is limited to `DARNER_INDIRECT_BATCH=1`. **`darner play` now defaults to `DARNER_INDIRECT_BATCH=2`, where this does nothing.** - Shader optimiser, opt-in bits of `DARNER_SHADER_OPT`: 512 `DOM_LOADS` (reuse of a dominating raw SRV load, from lobomfz/VIctory-xmem fd19a206) and 1024 `LOOP_LOADS` (guaranteed loop-invariant raw SRV reads leave loops). Main's default (511, `WIDE` included) is unchanged. `1023`, `1535` and `2047` ask for them. ## How it was tested - Tested revision: `5e8ad22a6f` - Commands and results: on `5e8ad22a6f` (this branch's head), Windows 10 22H2 with its built-in Direct3D 12 (no Shader Model 6.6), Rust 1.98.1: - `cargo clippy --workspace --all-targets --locked -- -D warnings`: passed - `cargo clippy --workspace --all-targets --all-features --locked -- -D warnings`: passed - `cargo --config 'profile.test.package.darner-shader.opt-level=3' test --workspace --locked --no-fail-fast` (the opt-level only speeds up darner-shader's exhaustive float tests): 66 failed, all of which fail on unmodified `main` (c8258f9556) on this PC too (darner-shader tests that need Shader Model 6.6). - darner-gpu's test process aborts at the first test that needs Shader Model 6.6, on `main` too, so its tests were run in batches that survive the abort and compared one by one with `main` (`main`: 1658 pass, 8 fail, 139 need Shader Model 6.6, 81 ignored): no test that passes on `main` fails here, none removed; 31 new tests: 13 ignored, 18 pass. - `cargo xtask policy`: ok on the PR 8 head, which contains this branch. - Not run: tests that need Shader Model 6.6 or a GPU, and the strict-WARP tests behind the diagnostics/gpu-validation features. - Changes a default: yes, `DARNER_INDIRECT_TEXTURE_BATCH` for runs with `DARNER_INDIRECT_BATCH=1` (not `darner play`'s default). Everything else is opt-in. - A/B result: none on Darner. The original commit records an A/B on the VIctory branch (RTX 4080 at PCIe 4.0 x4, 4K, DLSS Balanced, no frame generation, six settled eight-second phases: 50.25 ms off, 48.43 ms on, 3 December 2026). Which `DARNER_INDIRECT_BATCH` mode that run used is not recorded. In this code the switch acts only with mode 1, and `darner play` sets 2, so that result may not carry over. Not re-measured on Darner. - Gates run on that revision: see above. - Gameplay: not run on Darner. - Shader wave sizes tested: unit tests only. - Hardware dependence: likely general. - Coverage gaps: no in-game run. The indirect-roots, root-index and shader-pass paths are covered by unit tests only (their strict-WARP tests were not run here). ## Checklist - [ ] I ran this change in the game, or say below why it can't be (docs, tests only). **Not run in the game on Darner.** - [ ] This PR contains one change based on `main`. **No:** related root/indirect work, stacked on the PRs below. - [x] The diff follows `docs/asset-policy.md`. - [x] I recorded this PR's dependencies below. - Depends on #594 (validation and test wiring) - Depends on #597 (stacked branch; contains #596 too) ## Checked for overlap - [x] I searched the open pull requests for the same issue and for the files this touches. - Related PRs: #481 (`DARNER_INDIRECT_REST` findings), #35 (wide indirect dispatches on Intel), #394 and #292 (constant reads from root SRVs; different problem). - Replaces or overlaps: none found
Ported to Darner from VIctory-NVIDIA b1443849.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Refuse unsupported strict/software requests, retain bounded validation history, and guard host queue submissions. Preserve removal reports in a dedicated module. Add software-only regressions and optional link-time Agility declarations for tests.

Ported to Darner from VIctory-NVIDIA 3f156266.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Rebuild per-recording caches at both cut sites while retaining descriptor ownership. The current-renderer WARP regression read recycled 0xdeadbeef data before the fix and the expected constants after it; same-part and internal-pass reuse remain intact.

Ported to Darner from VIctory-NVIDIA 615e070f.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Keep current size classes and retention accounting while checking rounding and CPU-visible limits. Cap mapped-VRAM staging and avoid oversized spare reuse. Optional one-pass predictions outside the limit fall back to ordinary staging; six focused CPU checks pass.

Ported to Darner from VIctory-NVIDIA f7f0f1ec.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Reconcile the legacy transition repair with the current memory wrappers and enhanced barriers. Strict WARP catches the previous invalid COPY_DEST-to-CBV use before submission. Constant, texture-source, cross-buffer and overlapping-copy regressions pass with legacy and enhanced barriers.

Ported to Darner from VIctory-NVIDIA 0e7a5c71.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Route relay fetches, card fetches and settling through the existing checked host wait. CPU regressions reject failed waits, incomplete fences and device-removal sentinels; a strict WARP copy/readback check still passes.

Ported to Darner from VIctory-NVIDIA bb4da85e.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The current compiled root signature omitted DATA_VOLATILE. A software regression checks that contract and reads both successive synthetic depth values through the same bound descriptor.

Ported to Darner from VIctory-NVIDIA 838504a0.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Keep readonly depth plus shader-read states legal across views and avoid narrowing an already-compatible state. Preserve alias/read-watch observers and exact transitions for writes and COMMON. The WARP fixture goes from two tracked transitions to none; it and the CPU state checks pass. No game FPS result asserted.

Ported to Darner from VIctory-NVIDIA a04c61e1.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The first guarded rework run stopped on 1024 stored cache-miss warnings rather than a GPU error. Filter only nonfatal severities in strict storage while retaining bounded, persistent errors and corruption. Software tests cover 6144 nonfatal messages followed by both fatal severities, real overflow, repeated refusal and concurrent reporting.

Ported to Darner from VIctory-NVIDIA 651f2399.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Ported to Darner from VIctory-NVIDIA 3c6511be.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Ported to Darner from VIctory-NVIDIA fae572a0.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Ported to Darner from VIctory-NVIDIA eaee9c79.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Ported to Darner from VIctory-NVIDIA af64880d.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Reuse the previously verified pose implementation and background desktop/audio setup. Restore optional frame captures and their output policy, guarded process supervision, and benchmark analysis. Keep normal play opt-in and all artifacts outside source. Pose, capture, desktop-refusal, analyzer and CPU-only watchdog checks pass.

Ported to Darner from VIctory-NVIDIA 90df996f.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Ported to Darner from VIctory-NVIDIA 0493d6cb.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Ported to Darner from VIctory-NVIDIA e744607a.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Ported to Darner from VIctory-NVIDIA 49ce022d.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Ported to Darner from VIctory-NVIDIA 42aa3f0f.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Ported to Darner from VIctory-NVIDIA 4dee6a3b.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Ported to Darner from VIctory-NVIDIA 6edfc508.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Ported to Darner from VIctory-NVIDIA fc34fb12.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Ported to Darner from VIctory-NVIDIA 32f7ae60.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Ported to Darner from VIctory-NVIDIA e7d26434.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Adapted from lobomfz/VIctory-xmem fd19a20614b5e080b4bf6211ac5b7ebda682afc9 by lucalocastro. Preserve the existing alias-aware passes and default 447; add bit 512 with CPU graph and strict software DXIL execution coverage.

Ported to Darner from VIctory-NVIDIA fb5a0c84.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Keep guarded reads and zero-trip paths unchanged, reject every loop write, barrier, unknown effect and volatile read, and preserve the existing 447 defaults. Cover control-flow placement and exact software-rendered output; no frame-rate gain claimed.

Ported to Darner from VIctory-NVIDIA c56196e2.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Ported to Darner from VIctory-NVIDIA b194f581.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Ported to Darner from VIctory-NVIDIA f1d91c6e.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
TrustNo1 changed title from WIP: [pr-performance][shaders] Opt-in root-buffer indices and per-record indirect root batching; texture-only dispatches keep the argument batch; opt-in SRV load passes to WIP: Opt-in root-buffer indices and per-record indirect root batching; texture-only dispatches keep the argument batch; opt-in SRV load passes 2026-12-06 03:26:38 +00:00
This pull request has changes conflicting with the target branch.
  • crates/darner-game/src/lib.rs
  • crates/darner-gpu/src/draw.rs
  • crates/darner-gpu/src/gpu_owned.rs
  • crates/darner-gpu/src/host.rs
  • crates/darner-gpu/src/host/bus.rs
  • crates/darner-gpu/src/host/upq.rs
  • crates/darner-shader/src/emit/mod.rs
View command line instructions

Manual merge helper

Use this merge commit message when completing the merge manually.

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u 'pr/5-root-indices-indirect-batching:deama-pr/5-root-indices-indirect-batching'
git switch 'deama-pr/5-root-indices-indirect-batching'

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 'deama-pr/5-root-indices-indirect-batching'
git switch 'deama-pr/5-root-indices-indirect-batching'
git rebase 'Main'
git switch 'Main'
git merge --ff-only 'deama-pr/5-root-indices-indirect-batching'
git switch 'deama-pr/5-root-indices-indirect-batching'
git rebase 'Main'
git switch 'Main'
git merge --no-ff 'deama-pr/5-root-indices-indirect-batching'
git switch 'Main'
git merge --squash 'deama-pr/5-root-indices-indirect-batching'
git switch 'Main'
git merge --ff-only 'deama-pr/5-root-indices-indirect-batching'
git switch 'Main'
git merge 'deama-pr/5-root-indices-indirect-batching'
git push origin 'Main'
Sign in to join this conversation.
No reviewers
No milestone
No project
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.

Dependencies

No dependencies set

Reference
TrustNo1/Darner!598
No description provided.