indirect clamp: a draw record of 2^23 vertices or more runs empty and free (RT-INDIRECT-DRAW-UNFILLED-COUNT) #2378
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!2378
Loading…
Reference in a new issue
No description provided.
Delete branch "indirect-draw-unfilled-count"
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-INDIRECT-DRAW-UNFILLED-COUNT
Depends on: #2230 (conflicts only in the generated
runtime/src/indirect_clamp_spv.h: whichever of the two landssecond regenerates it from the merged
indirect_clamp.comp)What and why
indirect_clamp.comptreats a draw record as unfilled only when all of its words are 0xFFFFFFFF. A slot with agarbage count and its other words set is cut to 2^24 vertices and charged 2^24 units against the list's 2^27 budget.
Eight such slots use up the budget, and every real draw after them in the list runs empty. That shows up as objects
missing for a frame, or as flicker.
A census in codec-d/cool_fox's fork of VIctory found 90 records of 2^24 vertices in one list of the title. That fork
treats 2^23 vertices an instance or more as unfilled (its
docs/findings.mdandcrates/victory-gpu/src/indirect.rs).It suspects such records behind outdoor flicker; nothing in this PR confirms that link. No code of it is used.
With this PR, a draw or indexed-draw record of 2^23 or more vertices (or indices) an instance runs empty, keeps its
locations and charges nothing. It is counted as clamped and zeroed, as unfilled slots already are. Draws under 2^23 are
unchanged, including the 2^26 vertex-instance bound.
indirect_clamp.comp:unfilled_draw = 2^23; such a record's count and instances become 0, at cost 0.vulkan_indirect_clamp.h:indirect_clamp_unfilled_drawfor the tests.indirect_clamp_spv.h: regenerated with glslangValidator 15.1.0 (-V --target-env vulkan1.2 -Os --spirv-val).docs/d3d12_vulkan.md: the clamp's paragraph says so.Tested
indirect_clamp_test. The old garbage-count cases now expect an empty record. New cases:building the test against the old
indirect_clamp_spv.h: 2c fails). With this one it runs.The list-budget case now spends the budget with a real 2^22 x 16 draw instead of a 2^24 one.
Full
cteston the branch merged with current main (fbf100b1): 112 of 112 pass.GPUs tested: Mesa lavapipe (llvmpipe, LLVM 19.1.7), Ubuntu 24.04 container. Not run on a hardware GPU or with the game.
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: notranslator change)
🤖 Generated with Claude Code
I ran the committed clamp shader at
41332d4665on a physical RTX 4090 (Windows 11, NVIDIA 616.64). The stockindirect_clamp_testpassed with Vulkan validation enabled and zero validation errors.I also compared the draw records written back by the GPU against an independent expected value for every word. Each synthetic list had 96 records, spanning two 64-invocation workgroups. The six valid draws included one at the cutoff minus one. The other 90 records had counts at or above the cutoff. The 32 cases covered ordinary and indexed draws, packed and 32-byte strides, uncounted commands and count-buffer values before, at, and after the workgroup boundary.
fbf100b1b141332d46657a761696dcFor the uncounted indexed list with a 32-byte stride, the PR zeroed the counts of all 90 oversized records, preserved their location fields and all six valid draws, and reported zero records over budget. The matrix only reads the clamped arguments back. All three shader binaries passed Vulkan 1.2 SPIR-V validation.
In the local combination, the only Git conflict was the generated
indirect_clamp_spv.h. Regenerating it from the automatically merged GLSL with glslang 16.6.0 also let the combined stock test pass with zero validation errors. This verifies the clamp behavior. The effect on in-game flicker is still unmeasured.AI-assisted hardware verification with OpenAI Codex (GPT-6).
Merging.
mainf107ae044+ this PR (41332d466), Mesa 26.3.1:indirect_clamp_test, validation on, three runs each on llvmpipe, the integrated RDNA2 GPU and the RX 7900 XTX (RADV): passes, with no kernel fault. Withmain's shader the new cases fail.ctest: 113/113 pass.mainand the merge; no test changed.test_ci_registration.py, the docs tests andcheck_no_game_data.pypass.indirect_clamp_spv.his not byte-identical to a rebuild with glslang 16.6.0. With IDs renumbered the only difference is three empty branch and label pairs, which fits the PR's 15.1.0, and the test also passes with the rebuilt header.maindid not already empty, so a run here could not show the change.Notes for a follow-up, none blocking:
max_vertices, now unused) would drop fewer.Thanks @kawaii-shakal.
AI-assisted (Claude Code, Claude Opus 5.5 and Claude Fable 5.2)