vulkan_replay: a dropped indirect dispatch prepares and emits no clamp pass (RT-REPLAY-DROPPED-DISPATCH-CLAMP) #2523
No reviewers
No assignees
Labels
No labels
bug
dependencies
documentation
enhancement
missing claim
needs rebase
needs-triage
question
ready-for-agent
submodules
No project
No milestone
Dependencies
No dependencies set
Notifications
1 participant
Due date
No due date set.
Reference
leonida/mandy!2523
Loading…
Reference in a new issue
No description provided.
Delete branch "rt-replay-dropped-dispatch-clamp"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Pull request successfully merged and closed
Claimed in the coordination issue as: RT-REPLAY-DROPPED-DISPATCH-CLAMP (https://github.com/ProjectLeonida/mandy/issues/1608#issuecomment-7231080379)
What and why
Item 3 of @kevincommits' finding in #1608 (https://github.com/ProjectLeonida/mandy/issues/1608#issuecomment-7230685285). 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
main431ceba4f. 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
Reviewed at head
4d3badfa4on Windows 11 (MSVC 202219.44).Verification
replay_dropped_indirect_clamp_testandgta6rt.replay_dropped_indirect_clamp_test: ok.Notes
DISPATCHcompute pipeline beforeprepare_indirect_clamp()cleanly keeps skipped and still-building async indirect dispatches from allocating clamp scratch or claimingindirect_list_budget, while preserving command indices for all remaining commands. The 6 ordering checks cover both skipped andasync_buildcases well.vulkan_replay.h:4114-4116): The inline comment says "so the budget word every later clamp of the list reads would be set up by a pass that never runs." Inemit()(vulkan_replay.h:5318-5360),emit_indirect_clamp()actually ran before the dispatch skip at line 5360, so the pass did run (wasting scratch and charging the dropped dispatch against the shared list budget, exactly as the commit message describes). Tweaking that comment line keeps it aligned with the commit message.Approve.
AI-assisted review + local MSVC verification.
#2523 | head 4d3badfa4e8cf7d299015595109e150ed3351fa1 (merged cleanly with main 09c153948386fd658fe2f999f6176efbaa8c8345) |
ctest --test-dir runtime/build -C RelWithDebInfo -R "^(replay_dropped_indirect_clamp|indirect_clamp|indirect_clamp_safety|d3d12_indirect_dispatch_count|d3d12_indirect_group_budget)$" --output-on-failure(LEONIDA_VK_VALIDATION=1) | red on main:replay_dropped_indirect_clamp_testfails (10 failure(s): skipped and async-buildingExecuteIndirect(DISPATCH)commands prepared and emitted orphan clamp passes and took ownership of the list's sharedlist_budget) | green on PR+main:5/5CTests pass (replay_dropped_indirect_clampin0.06s,indirect_clampin0.46s,indirect_clamp_safetyin0.06s,d3d12_indirect_dispatch_countin0.62s, andd3d12_indirect_group_budgetin0.52s) on RTX 3090 withLEONIDA_VK_VALIDATION=1(0Khronos validation errors);check_no_game_data.py0violations | Windows 11, RTX 3090 (610.88), Vulkan SDK 1.4.363.1 | AI-assisted: yesReviewed 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).
Tested
4d3badfa4merged (no commit) withmainc8bf0e7b6. GPUs tested: NVIDIA GeForce RTX 3080, driver 621.40, Windows 11 10.0.26300; MSVC 19.52 (Visual Studio 18), Ninja, RelWithDebInfo.check_no_game_data.pyis clean. Run withLEONIDA_STRICT_REPLAYandLEONIDA_INDIRECT_CLAMPunset.replay_dropped_indirect_clamppasses.runtime/src/vulkan_replay.hback tomain, it fails 10 checks (10 failure(s)), for examplea skipped pipeline: 1 clamps prepared, want 0,a pipeline still building (async_build): 1 clamps emitted, want 0andbuilt, skipped, built: 3 clamps prepared, want 2.xbox_presentfails, as on plainmainhere.gta6rt.exelinked withoutws2_32.libgivesmain's 26 unresolved Rust-std symbols, nothing new. Its imports are identical tomain's.Points for the merge, not blockers here:
vulkan_replay.h. #767 changes thebindless_setcheck to(bindless_set || tail_set)inside the pipeline block this PR moves up. Whichever lands second should carry|| pipeline->tail_setinto the moved block. No conflict with #2530.vulkan_replay.h:4114-4116says "a pass that never runs", but the clamp pass did run.first_use()early only for skipped or async pipelines.LEONIDA_STRICT_REPLAY=0andLEONIDA_INDIRECT_CLAMP=1on the test (CMakeLists.txt:4668): an inherited strict value fails its async cases.AI-assisted (Claude Code).
Merged after TheGeogeo's red/green check (check: green with this PR merged onto
main, red without it;gta6rt.exestill links) and a re-check here: no conflict withmain26036832c, same head as checked, not frozen,no-game-datagreen.AI-assisted (Claude Code, Claude Opus 5.5), merged for MoonEyes.