Repository navigation
vulkan_replay: a dropped indirect dispatch prepares and emits no clamp pass (RT-REPLAY-DROPPED-DISPATCH-CLAMP) - #2523
Conversation
…p pass From kevincommits' finding (item 3) in ProjectLeonida#1608. prepare() set up the clamp pass (vulkan_indirect_clamp.h) of an ExecuteIndirect(DISPATCH) before it resolved the dispatch's compute pipeline. When that pipeline was dropped (skipped on request, or async_build and still building), the command was left out after its clamp was prepared and linked into the list's shared work budget, and emit() then recorded the clamp pass before skipping the dispatch. The pass claimed scratch and counter slots and counted the dropped call's records against the list budget that every later clamped draw and dispatch of the list shares. The pipeline is now resolved first, so a dropped dispatch leaves prepare() before any clamp exists. A pipeline left to PipelineCompiles is not dropped later: a failed deferred build fails the list. New CPU test replay_dropped_indirect_clamp follows the repro: a dropped dispatch alone, before and between built ones, for skipped and async_build pipelines. 10 checks fail on main; all pass with the change. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Reviewed at head Verification
Notes
Approve. AI-assisted review + local MSVC verification. |
|
#2523 | head 4d3badf (merged cleanly with main 09c1539) | |
lixonik
left a comment
There was a problem hiding this comment.
Reviewed the diff and tested merged onto main (493867366) with Ninja Release (MSVC).
Resolving the compute pipeline for ExecuteIndirect(DISPATCH) before preparing the indirect clamp pass ensures skipped/async-building dispatches never allocate clamp scratch or own the list's shared work budget word.
Tests run
ctest --output-on-failure -R "^(replay_dropped_indirect_clamp|replay_pipeline_compiles|replay_pipeline_compiles_strict|indirect_topology_and_stats)$": 4/4 passed (replay_pipeline_compiles0.49 s,replay_pipeline_compiles_strict0.38 s,replay_dropped_indirect_clamp0.02 s,indirect_topology_and_stats0.03 s).
AI-assisted (Antigravity, Gemini).
Claimed in the coordination issue as: RT-REPLAY-DROPPED-DISPATCH-CLAMP (#1608 (comment))
What and why
Item 3 of @kevincommits' finding in #1608 (#1608 (comment)). Thanks for the repro.
In
prepare()(runtime/src/vulkan_replay.h), anExecuteIndirect(DISPATCH)had its clamp pass (vulkan_indirect_clamp.h) prepared and linked into the list's shared work budget (share_list_budget) before its compute pipeline was resolved. When the pipeline was dropped (skippedon request, orasync_buildand still building), the commandcontinued withp.indirect_clampstill set.emit()then recorded the clamp pass and only afterwards skipped the dispatch. So a dispatch that never runs:Change. The dispatch's pipeline is resolved before the clamp is prepared, so a dropped dispatch leaves
prepare()before any clamp exists. The pipeline block moved unchanged (same checks, sameskipped/async_build/strict handling), with a comment saying why it comes first. Indirect draws keep their order: they have no pipeline at this point.A pipeline left to
PipelineCompilesis not dropped later (first_usedefers only pipelines that are neitherskippednorasync_build, and a failed deferred build fails the list incheck_compiled_pipelines), soemit()needs no change.Overlap: none found among open PRs touching
vulkan_replay.h(#2491, #2486, #2485, #2469 and others change other functions). Items 1 and 2 of the same finding come as separate PRs.Tested
Windows 11, MSVC (VS 18), RelWithDebInfo, on
main431ceba. CPU only.replay_dropped_indirect_clamp_test(fake pipelines, buffers and clamp pass; counts clamps prepared and emitted, dispatches emitted, and which budget word each emitted clamp reads):skippedand forasync_build;main'svulkan_replay.h, 10 checks fail (the extra clamp prepared and emitted in each dropped case); all pass with the change.ctest -R "^(replay_dropped_indirect_clamp|replay_pipeline_compiles|replay_pipeline_compiles_strict|indirect_topology_and_stats)$": 4/4 pass.scripts/check_no_game_data.py: clean.Not tested: a game boot. Whether this changes what a boot draws depends on how often a list has a dropped indirect dispatch ahead of clamped work.
GPUs tested: profile M: NVIDIA GeForce RTX 4070 SUPER, 12 GB, desktop, driver 621.01, Windows 11 (CPU tests only)
AI-assisted: yes (Claude Code)
Checklist
mainand merges cleanly (a conflicting pull request is labeledneeds rebase).docs/design.md, with how it was confirmed. (n/a: no translator change)🤖 Generated with Claude Code