Repository navigation
vulkan: a counted dispatch with no count buffer ignores the count offset (RT-INDIRECT-DISPATCH-COUNT-NULL-OFFSET) - #2491
Open
Tyrannys wants to merge 1 commit into
Conversation
With LEONIDA_INDIRECT_GROUP_BUDGET, IndirectDispatchCounter::Batch::prepare accepts a dispatch batch that has no count buffer. It still applied the count offset: an unaligned offset was refused, and an aligned one became the job's count address (0x40 for offset 64 on a null buffer). emit() then pushed that address with has_count 1, so the shader read memory at a raw GPU address. prepare now zeroes the offset when there is no count buffer, as IndirectArgumentClamp::prepare ignores it. The replay passes a null count buffer and offset 0 when the command has no count buffer, as it already does for prepare_indirect_clamp. From kevincommits' finding in ubiquitarianism#1608 (item 2). indirect_dispatch_count_alloc_test gains a case that follows the repro. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Claimed in the coordination issue as: RT-INDIRECT-DISPATCH-COUNT-NULL-OFFSET (#1608 (comment))
What and why
Item 2 of @kevincommits' finding in #1608 (#1608 (comment)). Thanks for the audit and the repro.
With
LEONIDA_INDIRECT_GROUP_BUDGETset,IndirectDispatchCounter::Batch::prepare(vulkan_indirect_dispatch_count.h) accepts a dispatch batch with no count buffer. It still applied the count offset:0x40.emit()then pushed that address withhas_count = 1, soindirect_dispatch_count.compread a raw GPU address. The replay (vulkan_replay.h) passedp.source.buffer_offset + ind->count_offseteven for a command with no count buffer.The fix ignores the offset without a count buffer, as
IndirectArgumentClamp::preparedoes:preparesetscount_offsetto 0 whencountis null. The alignment and overflow checks then pass, and the count address stays 0, soemit()pusheshas_count = 0.ind->count_bufferis null, asprepare_indirect_clampjust above it already does.With a count buffer nothing changes: the offset is still checked and added.
Overlap: #1863 also edits
vulkan_replay.h. It already conflicts withmain(labeledneeds rebase); its rebase would meet this two-line change too. No conflict with #2469 or #2489.Tested
Windows 11, MSVC (VS 18), RelWithDebInfo, on
main43a9d56.indirect_dispatch_count_alloc_test(CPU, mock driver) gains case 6, which follows the repro. It sets the budget to 4 before anything reads it.~3all prepare, with a count address of 0.emit()pushes count 0 andhas_count0.emit()pushes that address withhas_count1.With
main'svulkan_indirect_dispatch_count.hthe case fails on its first check (offset 2 refused). With the fix the whole test passes.ctest -R "^(indirect_dispatch_count_alloc|d3d12_indirect_dispatch_count|d3d12_indirect_group_budget|d3d12_indirect_zero|indirect_clamp)$": 5/5 pass. The GPU ones run in seconds;d3d12_indirect_group_budgetcovers the replay path with the budget set.scripts/check_no_game_data.py: clean.The replay change has no test of its own: no CPU test drives
prepare_counted_dispatchthrough the replay.GPUs tested: profile M: NVIDIA GeForce RTX 4070 SUPER, 12 GB, desktop, driver 621.01, Windows 11
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