D3D12.X: bound scratch for sliced indirect mesh draws #3681

Open
jeroenhaentjens wants to merge 1 commit from upstream-pr/3681 into main
jeroenhaentjens commented 2026-12-02 08:53:30 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by jeroenhaentjens on 2026-12-02T08:53:30Z.


What & Why

On main a cold two-pass mesh ExecuteIndirect can ask for 32 MiB of records. A recording with space for the whole record buffer and its rewritten arguments keeps one compute and mesh pass pair per command. Under scratch pressure, a 2 MiB buffer covers the same group range across slices and limits the record allocation.

What is in it

  • Try the full cold record reservation without a fence wait, with room for rewritten arguments. Keep immediate cold draws under XCL_TWO_PASS_BATCH=2 and size later recordings from GPU feedback.
  • Reuse the argument block between immediate sliced draws under the existing recording cap.
  • Exercise the native recording path with ample and constrained budgets, including pass counts, offsets, group bases and argument reuse. The fixture checks availability of the D3D12 Debug Layer and info queue.

Tested

  • Commit af49d4a815. Intel Core i7-9750H, NVIDIA Quadro RTX 3000 (driver 597.06 / 32.0.15.9706), Windows 11 25H2 build 26200.9974, Rust MSVC 1.100.0 and DXC 1.9.2609.5.
  • git diff --check passed. cargo test --locked --workspace -- --test-threads=4 reported 3011 passed, 0 failed, 52 ignored and 26 SKIPPED diagnostics. The log recorded 0 D3D12 Debug Layer validation warnings or errors during execution and 8 live-object warnings at process shutdown.
  • The native fixture recorded one compute/mesh pair per command with a 32 MiB record buffer under a 96 MiB budget, and 16 pairs per command with a 2 MiB record buffer under a 4 MiB budget. Both modes reported zero Debug Layer messages.

Regression run

Both 60-second runs used the same installed retail title, seeded profile, input schedule (15:A,35:A,55:A), device settings and shader cache. Each capture recorded zero two-pass mesh ExecuteIndirect log entries. These captures cover startup and presentation.

Baseline (current origin/main)

xcl-smoke v1
commit: e99b0bdfcfa9a172c66a5be3b31f53a2940ed041
gpu: NVIDIA Quadro RTX 3000
title: 0ba91dcb
seconds: 60
exit: 0x0
frames shown: 1453 (PresentX 1453)
presents per 2 s (last 3): 59 59 60
device removals: 0
crashes: 0
peak commit: 13967 MB

PR head

xcl-smoke v1
commit: af49d4a815d032002d6cfd9c69b85879ca2f0568
gpu: NVIDIA Quadro RTX 3000
title: 0ba91dcb
seconds: 60
exit: 0x0
frames shown: 1547 (PresentX 1547)
presents per 2 s (last 3): 59 60 61
device removals: 0
crashes: 0
peak commit: 13994 MB

Not tested

A retail scene that exercises mesh ExecuteIndirect during the measured interval, AMD, Intel discrete GPUs, and Linux.

AI use

OpenAI Codex (GPT-6, specific revision unavailable) assisted with the implementation, tests and PR update.

<!-- greyfinch-sync:ivall/xcl:issue:5603070529 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3681). Originally posted by [jeroenhaentjens](https://github.com/jeroenhaentjens) on 2026-12-02T08:53:30Z. --- **What & Why** On main a cold two-pass mesh ExecuteIndirect can ask for 32 MiB of records. A recording with space for the whole record buffer and its rewritten arguments keeps one compute and mesh pass pair per command. Under scratch pressure, a 2 MiB buffer covers the same group range across slices and limits the record allocation. **What is in it** - Try the full cold record reservation without a fence wait, with room for rewritten arguments. Keep immediate cold draws under XCL_TWO_PASS_BATCH=2 and size later recordings from GPU feedback. - Reuse the argument block between immediate sliced draws under the existing recording cap. - Exercise the native recording path with ample and constrained budgets, including pass counts, offsets, group bases and argument reuse. The fixture checks availability of the D3D12 Debug Layer and info queue. **Tested** - Commit af49d4a815d032002d6cfd9c69b85879ca2f0568. Intel Core i7-9750H, NVIDIA Quadro RTX 3000 (driver 597.06 / 32.0.15.9706), Windows 11 25H2 build 26200.9974, Rust MSVC 1.100.0 and DXC 1.9.2609.5. - git diff --check passed. cargo test --locked --workspace -- --test-threads=4 reported 3011 passed, 0 failed, 52 ignored and 26 SKIPPED diagnostics. The log recorded 0 D3D12 Debug Layer validation warnings or errors during execution and 8 live-object warnings at process shutdown. - The native fixture recorded one compute/mesh pair per command with a 32 MiB record buffer under a 96 MiB budget, and 16 pairs per command with a 2 MiB record buffer under a 4 MiB budget. Both modes reported zero Debug Layer messages. **Regression run** Both 60-second runs used the same installed retail title, seeded profile, input schedule (15:A,35:A,55:A), device settings and shader cache. Each capture recorded zero two-pass mesh ExecuteIndirect log entries. These captures cover startup and presentation. Baseline (current origin/main) ``` xcl-smoke v1 commit: e99b0bdfcfa9a172c66a5be3b31f53a2940ed041 gpu: NVIDIA Quadro RTX 3000 title: 0ba91dcb seconds: 60 exit: 0x0 frames shown: 1453 (PresentX 1453) presents per 2 s (last 3): 59 59 60 device removals: 0 crashes: 0 peak commit: 13967 MB ``` PR head ``` xcl-smoke v1 commit: af49d4a815d032002d6cfd9c69b85879ca2f0568 gpu: NVIDIA Quadro RTX 3000 title: 0ba91dcb seconds: 60 exit: 0x0 frames shown: 1547 (PresentX 1547) presents per 2 s (last 3): 59 60 61 device removals: 0 crashes: 0 peak commit: 13994 MB ``` **Not tested** A retail scene that exercises mesh ExecuteIndirect during the measured interval, AMD, Intel discrete GPUs, and Linux. **AI use** OpenAI Codex (GPT-6, specific revision unavailable) assisted with the implementation, tests and PR update.
Foniass commented 2026-12-02 09:04:38 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Foniass on 2026-12-02T09:04:38Z.


Review (head bc9f4ebf, diff read, not a merge-check; checks red):

  • Several unrelated changes in one PR, one of them not described. 770+/152-, over ~800 with no reason given, holding at least five changes: mesh indirect slicing; PSO wait budgets plus waiting on the whole compute form (dispatch_chain.rs); the empty-BVH fallback (real.rs ~3311); new stats and diagnostic logs; and copying indirect arguments and counts from PC buffers outside the memory windows into scratch. The last is in neither the description nor the commit messages: RewriteInput::Pc, indirect_pc_source and record_indirect_pc_copy in bind.rs, plus a note_indirect_source_barriers hook every title ResourceBarrier now goes through (list_x.rs ~6489). It overlaps draft #3105, which stages only UPLOAD-heap sources on purpose; this also stages DEFAULT-heap buffers whose state it assumes is COMMON. A natural split: the BVH fallback; the wait budgets; the PC staging (or #3105); the mesh slicing; the stats.
  • Mesh ExecuteIndirect now records far more passes and barriers by default. sliced depends only on tp.kind == "MS" (bind.rs ~4028), and total_cap is always the old 32 MiB group limit even when feedback gave a hint, so slices = total_cap / cap (~4036-4038) ignores it: the PR's own 47,632-byte record gives 16 slices cold and 32 with a 10-group hint, where main had 1. Each command records up to 32 compute + mesh pairs, each followed by a UAV barrier (Records::Whole), most with zero groups. Not opt-in, and the smoke run is "pending".
  • XCL_CS_PSO_WAIT_MS on pinned and retained compute pipelines conflicts with #3318. resolve_for_indirect (pso_async.rs ~11604), ResolveMode::Wait (~12396) and resolve_retained_for_emission (~12489) now pass cs_wait_budget(); draft #3318 changes the same functions and deliberately leaves the compute budget off these paths after measuring ~300 left-out compute passes a session and a device hang with it on.
  • Setting only XCL_CS_PSO_WAIT_MS changes more than described. waits_bounded() now returns compute_wait_budget().is_some() (~11175), so direct dispatches whose pipeline is still building are no longer deferred to the submit (list_x.rs defer_pipeline_wait) but wait on the title thread, and whole_ready now blocks for up to the compute budget instead of skipping at once.
  • The BVH test does not exercise the change. gpu_empty_bvh_in_uma_returns_a_miss checks bvh::alloc_empty's structure, the same data empty_bvh() already wrote on main; the new decision in dev_create_srv_inner (~3311), a non-null VA outside UMA getting the shared empty BVH instead of a zero descriptor on the default path, has no test.

Fine: the SCALE_ARGS_HLSL slice layout matches the recorded steps; the console-buffer offsets for arguments and count are overflow-checked; WholeRequest wakes waiters on every exit path through WholeSentGuard. The xcl-smoke blocks are owed (the reason PR description is red).

AI review: Claude Code (Claude Opus 5.5), posted by Foniass without a human check of each point.

<!-- greyfinch-sync:ivall/xcl:comment:7340339243 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3681#issuecomment-7340339243). Originally posted by [Foniass](https://github.com/Foniass) on 2026-12-02T09:04:38Z. --- Review (head bc9f4ebf, diff read, not a merge-check; checks red): - **Several unrelated changes in one PR, one of them not described.** 770+/152-, over ~800 with no reason given, holding at least five changes: mesh indirect slicing; PSO wait budgets plus waiting on the whole compute form (`dispatch_chain.rs`); the empty-BVH fallback (`real.rs` ~3311); new stats and diagnostic logs; and copying indirect arguments and counts from PC buffers outside the memory windows into scratch. The last is in neither the description nor the commit messages: `RewriteInput::Pc`, `indirect_pc_source` and `record_indirect_pc_copy` in `bind.rs`, plus a `note_indirect_source_barriers` hook every title `ResourceBarrier` now goes through (`list_x.rs` ~6489). It overlaps draft #3105, which stages only UPLOAD-heap sources on purpose; this also stages DEFAULT-heap buffers whose state it assumes is `COMMON`. A natural split: the BVH fallback; the wait budgets; the PC staging (or #3105); the mesh slicing; the stats. - **Mesh `ExecuteIndirect` now records far more passes and barriers by default.** `sliced` depends only on `tp.kind == "MS"` (`bind.rs` ~4028), and `total_cap` is always the old 32 MiB group limit even when feedback gave a hint, so `slices = total_cap / cap` (~4036-4038) ignores it: the PR's own 47,632-byte record gives 16 slices cold and 32 with a 10-group hint, where `main` had 1. Each command records up to 32 compute + mesh pairs, each followed by a UAV barrier (`Records::Whole`), most with zero groups. Not opt-in, and the smoke run is "pending". - **`XCL_CS_PSO_WAIT_MS` on pinned and retained compute pipelines conflicts with #3318.** `resolve_for_indirect` (`pso_async.rs` ~11604), `ResolveMode::Wait` (~12396) and `resolve_retained_for_emission` (~12489) now pass `cs_wait_budget()`; draft #3318 changes the same functions and deliberately leaves the compute budget off these paths after measuring ~300 left-out compute passes a session and a device hang with it on. - **Setting only `XCL_CS_PSO_WAIT_MS` changes more than described.** `waits_bounded()` now returns `compute_wait_budget().is_some()` (~11175), so direct dispatches whose pipeline is still building are no longer deferred to the submit (`list_x.rs` `defer_pipeline_wait`) but wait on the title thread, and `whole_ready` now blocks for up to the compute budget instead of skipping at once. - **The BVH test does not exercise the change.** `gpu_empty_bvh_in_uma_returns_a_miss` checks `bvh::alloc_empty`'s structure, the same data `empty_bvh()` already wrote on `main`; the new decision in `dev_create_srv_inner` (~3311), a non-null VA outside UMA getting the shared empty BVH instead of a zero descriptor on the default path, has no test. Fine: the `SCALE_ARGS_HLSL` slice layout matches the recorded steps; the console-buffer offsets for arguments and count are overflow-checked; `WholeRequest` wakes waiters on every exit path through `WholeSentGuard`. The `xcl-smoke` blocks are owed (the reason `PR description` is red). AI review: Claude Code (Claude Opus 5.5), posted by Foniass without a human check of each point.
jeroenhaentjens commented 2026-12-02 14:01:39 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by jeroenhaentjens on 2026-12-02T14:01:39Z.


The duplicate empty-BVH commit has been removed. I addressed the feedback on mesh slice counts and pinned/retained compute waits, and dropped the PC staging and extra diagnostics. The description includes both 60-second smoke runs and the workspace-test abort reproduced on main.

<!-- greyfinch-sync:ivall/xcl:comment:7347860343 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3681#issuecomment-7347860343). Originally posted by [jeroenhaentjens](https://github.com/jeroenhaentjens) on 2026-12-02T14:01:39Z. --- The duplicate empty-BVH commit has been removed. I addressed the feedback on mesh slice counts and pinned/retained compute waits, and dropped the PC staging and extra diagnostics. The description includes both 60-second smoke runs and the workspace-test abort reproduced on main.
Foniass commented 2026-12-02 14:07:27 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Foniass on 2026-12-02T14:07:27Z.


Follow-up review (head 77a7d262, since bc9f4ebf, diff read, not a merge-check):

  • BVH test not exercising the change: fixed; the BVH fallback moved to #3688.
  • Several unrelated changes in one PR: partly fixed. The PC-buffer staging, the stats, the BVH fallback and the dispatch_chain.rs changes are gone (now 243+/56-), but the mesh ExecuteIndirect slicing (bind.rs) and the retained graphics wait budgets (pso_async.rs) are still two unrelated changes, plus undescribed overflow-checked console-buffer offsets (bind.rs ~3659); the title still says "split PSO waits".
  • Mesh ExecuteIndirect always sliced, ignoring the feedback hint: partly fixed. With a hint cap now equals total_groups, so a warm draw takes one pass pair (~3758-3768), but cold draws, and any pipeline without a feedback slot (fb_slot == 0), still get total_cap / cap slices with a UAV barrier after every pass: 16 for the PR's 47,632-byte record, more for records just over 1 MiB.
  • XCL_CS_PSO_WAIT_MS on pinned / retained paths: partly fixed. The compute budget is now None there (~11607, ~12374, ~12467), but the graphics half of those changes is what draft #3318 already does on the same functions, so the two duplicate and conflict; one should be dropped.
  • waits_bounded() changing direct-dispatch deferral: still open, now through the graphics budget. waits_bounded() returns gfx_wait_budget().or_else(wait_budget).is_some() (~11151), so with only XCL_GFX_PSO_WAIT_MS set a direct Dispatch or dispatching ExecuteIndirect whose compute pipeline is still building is no longer put off to the submit (list_x.rs defer_retained ~4381) and waits on the title thread with no bound, since compute still uses the unset XCL_PSO_WAIT_MS. The new test asserts it (~6384) and the description does not mention it; the PR's smoke run set XCL_GFX_PSO_WAIT_MS=500.

New:

  • Cold slicing multiplies the argument scratch each draw takes. prepare_scaled_args now writes 2 · max · stride · slices bytes (~3355) into the recording's 16 MiB argument scratch (SCRATCH_CAP, ~3235), so a cold draw uses the budget up to 16× faster than on main, and once it runs out later two-pass ExecuteIndirects in the recording are skipped.
  • The sliced recording path has no test. scale_args_sliced covers the shader's output layout, but nothing covers what execute_indirect_snapshot records (the per-slice stage stages[k % slices] ~3791, the mesh arguments at at + commands · slices ~3800, the sliced / total_cap choice); gpu_two_pass_records drives its own one-command plan.

Fine: the SCALE_ARGS_HLSL slice layout matches the recorded steps and the unsliced form still works through the bit-31 flag; each compute slice gets group_base = slice · cap as the direct mesh slicing does; the feedback overflow is measured against total_cap.

AI review: Claude Code (Claude Opus 5.5), posted by Foniass without a human check of each point.

<!-- greyfinch-sync:ivall/xcl:comment:7348026873 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3681#issuecomment-7348026873). Originally posted by [Foniass](https://github.com/Foniass) on 2026-12-02T14:07:27Z. --- Follow-up review (head 77a7d262, since bc9f4ebf, diff read, not a merge-check): - **BVH test not exercising the change:** fixed; the BVH fallback moved to #3688. - **Several unrelated changes in one PR:** partly fixed. The PC-buffer staging, the stats, the BVH fallback and the `dispatch_chain.rs` changes are gone (now 243+/56-), but the mesh `ExecuteIndirect` slicing (`bind.rs`) and the retained graphics wait budgets (`pso_async.rs`) are still two unrelated changes, plus undescribed overflow-checked console-buffer offsets (`bind.rs` ~3659); the title still says "split PSO waits". - **Mesh `ExecuteIndirect` always sliced, ignoring the feedback hint:** partly fixed. With a hint `cap` now equals `total_groups`, so a warm draw takes one pass pair (~3758-3768), but cold draws, and any pipeline without a feedback slot (`fb_slot == 0`), still get `total_cap / cap` slices with a UAV barrier after every pass: 16 for the PR's 47,632-byte record, more for records just over 1 MiB. - **`XCL_CS_PSO_WAIT_MS` on pinned / retained paths:** partly fixed. The compute budget is now `None` there (~11607, ~12374, ~12467), but the graphics half of those changes is what draft #3318 already does on the same functions, so the two duplicate and conflict; one should be dropped. - **`waits_bounded()` changing direct-dispatch deferral:** still open, now through the graphics budget. `waits_bounded()` returns `gfx_wait_budget().or_else(wait_budget).is_some()` (~11151), so with only `XCL_GFX_PSO_WAIT_MS` set a direct `Dispatch` or dispatching `ExecuteIndirect` whose compute pipeline is still building is no longer put off to the submit (`list_x.rs` `defer_retained` ~4381) and waits on the title thread with no bound, since compute still uses the unset `XCL_PSO_WAIT_MS`. The new test asserts it (~6384) and the description does not mention it; the PR's smoke run set `XCL_GFX_PSO_WAIT_MS=500`. New: - **Cold slicing multiplies the argument scratch each draw takes.** `prepare_scaled_args` now writes `2 · max · stride · slices` bytes (~3355) into the recording's 16 MiB argument scratch (`SCRATCH_CAP`, ~3235), so a cold draw uses the budget up to 16× faster than on `main`, and once it runs out later two-pass `ExecuteIndirect`s in the recording are skipped. - **The sliced recording path has no test.** `scale_args_sliced` covers the shader's output layout, but nothing covers what `execute_indirect_snapshot` records (the per-slice stage `stages[k % slices]` ~3791, the mesh arguments at `at + commands · slices` ~3800, the `sliced` / `total_cap` choice); `gpu_two_pass_records` drives its own one-command plan. Fine: the `SCALE_ARGS_HLSL` slice layout matches the recorded steps and the unsliced form still works through the bit-31 flag; each compute slice gets `group_base = slice · cap` as the direct mesh slicing does; the feedback overflow is measured against `total_cap`. AI review: Claude Code (Claude Opus 5.5), posted by Foniass without a human check of each point.
jeroenhaentjens commented 2026-12-02 23:26:42 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by jeroenhaentjens on 2026-12-02T23:26:42Z.


@Foniass I removed the PSO wait changes and updated the PR scope. Immediate sliced draws now reuse the same argument scratch. The new GPU test calls execute_indirect_snapshot and checks the recorded slice group bases and offsets.

<!-- greyfinch-sync:ivall/xcl:comment:7362003216 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3681#issuecomment-7362003216). Originally posted by [jeroenhaentjens](https://github.com/jeroenhaentjens) on 2026-12-02T23:26:42Z. --- @Foniass I removed the PSO wait changes and updated the PR scope. Immediate sliced draws now reuse the same argument scratch. The new GPU test calls execute_indirect_snapshot and checks the recorded slice group bases and offsets.
Foniass commented 2026-12-02 23:34:11 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Foniass on 2026-12-02T23:34:11Z.


Follow-up review of b0819749, since 77a7d262 (code reading only, not a merge-check) · 1 high, 1 medium, 2 nits

In short: Since 77a7d262 the two commits were folded into one, and the PR now covers only the sliced mesh ExecuteIndirect in bind.rs. The graphics wait budgets, the waits_bounded() change and their README text are gone. Sliced draws reuse one argument block, and a new test records the sliced path through execute_indirect_snapshot. One problem blocks it: the new test panics instead of skipping without the D3D12 Debug Layer. Cold draws still get 16 pass pairs per command, and that cost is unmeasured.

High

  1. The new test fails instead of skipping without the D3D12 Debug Layer.

    • execute_indirect_snapshot_records_sliced_arguments_and_reuses_scratch calls enable_debug_layer().as_ref().expect("D3D12 Debug Layer") (bind.rs ~9048) before it checks for an adapter. Later it calls dev.cast::<ID3D12InfoQueue>().expect(...) (~9094).
    • Without the Graphics Tools optional feature (and no Agility SDK carrying the SDK layers), D3D12GetDebugInterface fails, so the test panics on an ordinary GPU PC with DXC.
    • No test on main requires the debug layer; it is used only when XCL_D3D12_DEBUG is set.

    Fix: skip_test("no D3D12 Debug Layer") and return when either call fails, or count the messages only when the layer is present.

Medium

  1. Cold mesh ExecuteIndirect still records 16 pass pairs per command (still open).

    • A cold MS draw now gets a 2 MiB record buffer (INDIRECT_INITIAL_RECORDS, ~2622), while its total stays at the old 32 MiB group limit. For the 47,632-byte record that is 44 groups per slice out of 704, so 16 slices (~3779-3790).
    • Each title command then records 16 compute and 16 mesh ExecuteIndirects, each with a UAV barrier, where main records one pair. Slices past a command's groups still run with zero groups.
    • This lasts until feedback arrives, and for good for a pipeline with no feedback slot. The smoke runs (1508 vs 1546 frames) do not show whether the title reaches this path.

    Fix: measure what the 2 MiB cold buffer saves against the extra passes, or keep the cold buffer whole when the budget has room and slice only when it is shrunk.

Nit

  1. The description and commit message do not say what changes against main. "Keep cold two-pass indirect mesh draws within the existing per-recording argument scratch budget" describes a problem the slicing itself creates. Against main, cold MS draws drop from 32 MiB to 2 MiB of records and are sliced. With XCL_TWO_PASS_BATCH=2, cold MS draws are no longer deferred (~2575). The commit has no body.
  2. Changes the slicing does not need (partly still open). The overflow-checked console-buffer offsets (~3680-3687) are still in the PR and not described. gpu_two_pass_indirect_commands_keep_their_own_records (~8993) was rewritten to use runner::device() and a debug-layer child process, which is unrelated to the sliced path. Both belong in their own PRs.
Checked and fine
  • Earlier findings fixed by removal: the retained graphics PSO wait budgets and the overlap with #3318, the waits_bounded() deferral change, and XCL_CS_PSO_WAIT_MS on pinned and retained paths. The BVH test went to #3688.
  • Earlier finding fixed: cold slicing multiplied the argument scratch. Immediate sliced draws reuse one block (sliced_scratch, scratch_args ~3232) at offset 0. It goes COMMON → UAV → INDIRECT_ARGUMENT → COMMON for each draw (~3839), so the next rewrite is ordered after the previous draw's reads. reset and prepare_split clear it, and it counts toward scratch_taken.
  • Earlier finding fixed: the sliced recording path had no test. The new test checks each slice's group base, the compute and mesh offsets, and that the second draw takes no new scratch.
  • SCALE_ARGS_HLSL's slice layout matches the host offsets. Each compute slice gets IO_MESH_GROUP_BASE = slice·cap. Unsliced callers keep the old ten-dword layout.
  • max_slices keeps commands·slices·2 within SCRATCH_CAP, and prepare_scaled_args checks it again (~3371). The feedback overflow is measured against total_cap.
  • 381+/59- in two files. #3056 edits the same raw_n lines in SCALE_ARGS_HLSL, so expect a textual conflict.

Written by Claude Code (Claude Opus 5.5) and posted by Foniass without a human check of each point.

<!-- greyfinch-sync:ivall/xcl:comment:7362163610 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3681#issuecomment-7362163610). Originally posted by [Foniass](https://github.com/Foniass) on 2026-12-02T23:34:11Z. --- **Follow-up review** of `b0819749`, since `77a7d262` (code reading only, not a merge-check) · 1 high, 1 medium, 2 nits **In short:** Since `77a7d262` the two commits were folded into one, and the PR now covers only the sliced mesh `ExecuteIndirect` in `bind.rs`. The graphics wait budgets, the `waits_bounded()` change and their README text are gone. Sliced draws reuse one argument block, and a new test records the sliced path through `execute_indirect_snapshot`. One problem blocks it: the new test panics instead of skipping without the D3D12 Debug Layer. Cold draws still get 16 pass pairs per command, and that cost is unmeasured. #### High 1. **The new test fails instead of skipping without the D3D12 Debug Layer.** - `execute_indirect_snapshot_records_sliced_arguments_and_reuses_scratch` calls `enable_debug_layer().as_ref().expect("D3D12 Debug Layer")` (`bind.rs` ~9048) before it checks for an adapter. Later it calls `dev.cast::<ID3D12InfoQueue>().expect(...)` (~9094). - Without the Graphics Tools optional feature (and no Agility SDK carrying the SDK layers), `D3D12GetDebugInterface` fails, so the test panics on an ordinary GPU PC with DXC. - No test on `main` requires the debug layer; it is used only when `XCL_D3D12_DEBUG` is set. Fix: `skip_test("no D3D12 Debug Layer")` and return when either call fails, or count the messages only when the layer is present. #### Medium 2. **Cold mesh `ExecuteIndirect` still records 16 pass pairs per command (still open).** - A cold MS draw now gets a 2 MiB record buffer (`INDIRECT_INITIAL_RECORDS`, ~2622), while its total stays at the old 32 MiB group limit. For the 47,632-byte record that is 44 groups per slice out of 704, so 16 slices (~3779-3790). - Each title command then records 16 compute and 16 mesh `ExecuteIndirect`s, each with a UAV barrier, where `main` records one pair. Slices past a command's groups still run with zero groups. - This lasts until feedback arrives, and for good for a pipeline with no feedback slot. The smoke runs (1508 vs 1546 frames) do not show whether the title reaches this path. Fix: measure what the 2 MiB cold buffer saves against the extra passes, or keep the cold buffer whole when the budget has room and slice only when it is shrunk. #### Nit 3. **The description and commit message do not say what changes against `main`.** "Keep cold two-pass indirect mesh draws within the existing per-recording argument scratch budget" describes a problem the slicing itself creates. Against `main`, cold MS draws drop from 32 MiB to 2 MiB of records and are sliced. With `XCL_TWO_PASS_BATCH=2`, cold MS draws are no longer deferred (~2575). The commit has no body. 4. **Changes the slicing does not need (partly still open).** The overflow-checked console-buffer offsets (~3680-3687) are still in the PR and not described. `gpu_two_pass_indirect_commands_keep_their_own_records` (~8993) was rewritten to use `runner::device()` and a debug-layer child process, which is unrelated to the sliced path. Both belong in their own PRs. <details><summary>Checked and fine</summary> - Earlier findings fixed by removal: the retained graphics PSO wait budgets and the overlap with #3318, the `waits_bounded()` deferral change, and `XCL_CS_PSO_WAIT_MS` on pinned and retained paths. The BVH test went to #3688. - Earlier finding fixed: cold slicing multiplied the argument scratch. Immediate sliced draws reuse one block (`sliced_scratch`, `scratch_args` ~3232) at offset 0. It goes COMMON → UAV → INDIRECT_ARGUMENT → COMMON for each draw (~3839), so the next rewrite is ordered after the previous draw's reads. `reset` and `prepare_split` clear it, and it counts toward `scratch_taken`. - Earlier finding fixed: the sliced recording path had no test. The new test checks each slice's group base, the compute and mesh offsets, and that the second draw takes no new scratch. - `SCALE_ARGS_HLSL`'s slice layout matches the host offsets. Each compute slice gets `IO_MESH_GROUP_BASE = slice·cap`. Unsliced callers keep the old ten-dword layout. - `max_slices` keeps `commands·slices·2` within `SCRATCH_CAP`, and `prepare_scaled_args` checks it again (~3371). The feedback overflow is measured against `total_cap`. - 381+/59- in two files. #3056 edits the same `raw_n` lines in `SCALE_ARGS_HLSL`, so expect a textual conflict. </details> <sub>Written by Claude Code (Claude Opus 5.5) and posted by Foniass without a human check of each point.</sub>
jeroenhaentjens commented 2026-12-03 07:25:39 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by jeroenhaentjens on 2026-12-03T07:25:39Z.


@Foniass The sliced recording fixture now skips when the D3D12 Debug Layer or its info queue is unavailable. The unrelated buffer-offset and existing fixture changes are out of the diff. The commit and description explain the 32 MiB to 2 MiB cold record change, its extra pass pairs, and why cold draws record immediately in batch mode 2. The targeted checks and the fresh 60-second head smoke are recorded above.

<!-- greyfinch-sync:ivall/xcl:comment:7370983468 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3681#issuecomment-7370983468). Originally posted by [jeroenhaentjens](https://github.com/jeroenhaentjens) on 2026-12-03T07:25:39Z. --- @Foniass The sliced recording fixture now skips when the D3D12 Debug Layer or its info queue is unavailable. The unrelated buffer-offset and existing fixture changes are out of the diff. The commit and description explain the 32 MiB to 2 MiB cold record change, its extra pass pairs, and why cold draws record immediately in batch mode 2. The targeted checks and the fresh 60-second head smoke are recorded above.
Foniass commented 2026-12-03 07:27:19 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Foniass on 2026-12-03T07:27:19Z.


Follow-up review of 61408de0, since b0819749 (code reading only, not a merge-check) · 1 medium

In short: This push fixes the blocking test point and narrows the commit. The new GPU test now skips when the D3D12 Debug Layer or info queue is missing. The overflow-checked offsets and the unrelated rewrite of gpu_two_pass_indirect_commands_keep_their_own_records are gone. The commit message and the description now say what changes against main, including the cold pass-pair cost. That cost is stated but still not measured.

Medium

  1. Cold mesh ExecuteIndirect still records up to 16 pass pairs per command, unmeasured (still open). The description now says so: a cold draw starts at 2 MiB of records and is sliced across the old group limit, up to 16 compute and mesh pairs per command for the 47,632-byte record, and a pipeline with no feedback slot keeps that cost. Not tested says the smoke run neither isolates the cost nor confirms it reaches this path. A frame-time comparison on a scene with cold mesh ExecuteIndirect draws would settle it. Otherwise keep the cold buffer whole when the budget has room, and slice only when it is shrunk.
Checked and fine
  • Earlier finding fixed: the test panicked without the debug layer. execute_indirect_snapshot_records_sliced_arguments_and_reuses_scratch returns through skip_test("no D3D12 Debug Layer") when enable_debug_layer() fails or the device has no ID3D12InfoQueue.
  • Earlier finding fixed: the changes the slicing does not need are gone. The console-buffer offset computation in execute_indirect_snapshot is back to main's, and so is the rewritten two-pass record test.
  • Earlier finding fixed: the commit body now explains the change against main, including that cold MS draws are not deferred with XCL_TWO_PASS_BATCH=2. The description says the same.
  • The slicing, the shared argument block and the feedback sizing are unchanged since b0819749.

Written by Claude Code (Claude Opus 5.5) and posted by Foniass without a human check of each point.

<!-- greyfinch-sync:ivall/xcl:comment:7371016700 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3681#issuecomment-7371016700). Originally posted by [Foniass](https://github.com/Foniass) on 2026-12-03T07:27:19Z. --- **Follow-up review** of `61408de0`, since `b0819749` (code reading only, not a merge-check) · 1 medium **In short:** This push fixes the blocking test point and narrows the commit. The new GPU test now skips when the D3D12 Debug Layer or info queue is missing. The overflow-checked offsets and the unrelated rewrite of `gpu_two_pass_indirect_commands_keep_their_own_records` are gone. The commit message and the description now say what changes against `main`, including the cold pass-pair cost. That cost is stated but still not measured. #### Medium 1. **Cold mesh `ExecuteIndirect` still records up to 16 pass pairs per command, unmeasured (still open).** The description now says so: a cold draw starts at 2 MiB of records and is sliced across the old group limit, up to 16 compute and mesh pairs per command for the 47,632-byte record, and a pipeline with no feedback slot keeps that cost. **Not tested** says the smoke run neither isolates the cost nor confirms it reaches this path. A frame-time comparison on a scene with cold mesh `ExecuteIndirect` draws would settle it. Otherwise keep the cold buffer whole when the budget has room, and slice only when it is shrunk. <details><summary>Checked and fine</summary> - Earlier finding fixed: the test panicked without the debug layer. `execute_indirect_snapshot_records_sliced_arguments_and_reuses_scratch` returns through `skip_test("no D3D12 Debug Layer")` when `enable_debug_layer()` fails or the device has no `ID3D12InfoQueue`. - Earlier finding fixed: the changes the slicing does not need are gone. The console-buffer offset computation in `execute_indirect_snapshot` is back to `main`'s, and so is the rewritten two-pass record test. - Earlier finding fixed: the commit body now explains the change against `main`, including that cold MS draws are not deferred with `XCL_TWO_PASS_BATCH=2`. The description says the same. - The slicing, the shared argument block and the feedback sizing are unchanged since `b0819749`. </details> <sub>Written by Claude Code (Claude Opus 5.5) and posted by Foniass without a human check of each point.</sub>
jeroenhaentjens commented 2026-12-03 15:16:22 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by jeroenhaentjens on 2026-12-03T15:16:22Z.


@Foniass A cold indirect mesh command now keeps one compute and mesh pair when the full record buffer and its rewritten arguments fit. It uses the 2 MiB slice path under scratch pressure. The native recording tests cover both budgets and verify the pass sequence and slice scratch reuse. The test and smoke results are recorded in the PR.

<!-- greyfinch-sync:ivall/xcl:comment:7382858718 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3681#issuecomment-7382858718). Originally posted by [jeroenhaentjens](https://github.com/jeroenhaentjens) on 2026-12-03T15:16:22Z. --- @Foniass A cold indirect mesh command now keeps one compute and mesh pair when the full record buffer and its rewritten arguments fit. It uses the 2 MiB slice path under scratch pressure. The native recording tests cover both budgets and verify the pass sequence and slice scratch reuse. The test and smoke results are recorded in the PR.
Foniass commented 2026-12-03 15:19:05 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Foniass on 2026-12-03T15:19:05Z.


Follow-up review of af49d4a8, since 61408de0 (code reading only, not a merge-check) · 2 medium

In short: This push answers the open point. A cold mesh ExecuteIndirect now first tries a whole record buffer, which keeps one compute and mesh pass pair per command. It falls back to the 2 MiB slices only when the exact buffer does not fit the budget without waiting. The fixture covers both budgets. Two evidence gaps remain: Tested lists only named tests, and the regression run is the repository's test fixture, which does not reach this code.

Medium

  1. The whole suite is not reported on this head. Tested runs only named tests in hle::d3d12x::bind::tests, with --test-threads=1. CONTRIBUTING.md asks for cargo test --workspace -- --test-threads=4 on the head under review, with its counts and SKIPPED tests.
  2. The regression run does not reach mesh ExecuteIndirect. Both smoke blocks are of xcl-owned-test-fixture, which shows 1 frame (presents per 2 s: 0 0 0). This PR changes how every cold mesh ExecuteIndirect gets its record scratch, on every adapter. CONTRIBUTING.md asks for the regression run on a real title. Add a pair of runs, on main and on af49d4a8, on a title that issues mesh ExecuteIndirect draws.
Checked and fine
  • Earlier finding fixed: cold draws always recorded up to 16 pass pairs per command.

    • When slicing is possible and there is no feedback hint, execute_indirect_snapshot asks try_ensure_res_buffer_exact_with_cap for the full record buffer. The cap is the budget minus what cold_indirect_record_budget leaves for the rewritten arguments.
    • Only when that returns None does it take the sliced 2 MiB path.
    • The whole buffer gives one slice, so the cost is now one pair per command unless the budget is short.
  • cold_indirect_record_budget reserves the right amount. commands is already max * byte_stride bytes, and the unsliced path writes commands * slices * 2 bytes with slices = 1. The function matches scratch_args: it checks the open block's free bytes first, then a new block of at least SCRATCH_BLOCK within SCRATCH_CAP. Its unit test covers the edge at SCRATCH_CAP - SCRATCH_BLOCK.

  • The fixture now runs as two child processes, with XCL_TWO_PASS_MB at 96 and at 4:

    • at 96 MiB it checks a full-size record buffer with one compute and mesh pair per command;
    • at 4 MiB it checks the 2 MiB buffer, the per-slice group bases and offsets, and argument scratch reuse.

    Both also check for zero Debug Layer messages. The INDIRECT_MESH_CALLS hook now records unsliced draws too, which the whole-buffer case needs.

  • The defer_execute_indirect comment now matches what it does: cold MS draws still record immediately.

Written by Claude Code (Claude Opus 5.5) and posted by Foniass without a human check of each point.

<!-- greyfinch-sync:ivall/xcl:comment:7382935812 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3681#issuecomment-7382935812). Originally posted by [Foniass](https://github.com/Foniass) on 2026-12-03T15:19:05Z. --- **Follow-up review** of `af49d4a8`, since `61408de0` (code reading only, not a merge-check) · 2 medium **In short:** This push answers the open point. A cold mesh `ExecuteIndirect` now first tries a whole record buffer, which keeps one compute and mesh pass pair per command. It falls back to the 2 MiB slices only when the exact buffer does not fit the budget without waiting. The fixture covers both budgets. Two evidence gaps remain: **Tested** lists only named tests, and the regression run is the repository's test fixture, which does not reach this code. #### Medium 1. **The whole suite is not reported on this head.** **Tested** runs only named tests in `hle::d3d12x::bind::tests`, with `--test-threads=1`. CONTRIBUTING.md asks for `cargo test --workspace -- --test-threads=4` on the head under review, with its counts and SKIPPED tests. 2. **The regression run does not reach mesh `ExecuteIndirect`.** Both smoke blocks are of `xcl-owned-test-fixture`, which shows 1 frame (`presents per 2 s: 0 0 0`). This PR changes how every cold mesh `ExecuteIndirect` gets its record scratch, on every adapter. CONTRIBUTING.md asks for the regression run on a real title. Add a pair of runs, on `main` and on `af49d4a8`, on a title that issues mesh `ExecuteIndirect` draws. <details><summary>Checked and fine</summary> - Earlier finding fixed: cold draws always recorded up to 16 pass pairs per command. - When slicing is possible and there is no feedback hint, `execute_indirect_snapshot` asks `try_ensure_res_buffer_exact_with_cap` for the full record buffer. The cap is the budget minus what `cold_indirect_record_budget` leaves for the rewritten arguments. - Only when that returns `None` does it take the sliced 2 MiB path. - The whole buffer gives one slice, so the cost is now one pair per command unless the budget is short. - `cold_indirect_record_budget` reserves the right amount. `commands` is already `max * byte_stride` bytes, and the unsliced path writes `commands * slices * 2` bytes with `slices = 1`. The function matches `scratch_args`: it checks the open block's free bytes first, then a new block of at least `SCRATCH_BLOCK` within `SCRATCH_CAP`. Its unit test covers the edge at `SCRATCH_CAP - SCRATCH_BLOCK`. - The fixture now runs as two child processes, with `XCL_TWO_PASS_MB` at 96 and at 4: - at 96 MiB it checks a full-size record buffer with one compute and mesh pair per command; - at 4 MiB it checks the 2 MiB buffer, the per-slice group bases and offsets, and argument scratch reuse. Both also check for zero Debug Layer messages. The `INDIRECT_MESH_CALLS` hook now records unsliced draws too, which the whole-buffer case needs. - The `defer_execute_indirect` comment now matches what it does: cold MS draws still record immediately. </details> <sub>Written by Claude Code (Claude Opus 5.5) and posted by Foniass without a human check of each point.</sub>
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/3681:upstream-pr/3681'
git switch 'upstream-pr/3681'

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