indirect clamp: a draw record of 2^23 vertices or more runs empty and free (RT-INDIRECT-DRAW-UNFILLED-COUNT) #2378
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
missing claim
needs rebase
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/ubiquitarianism--leonida!2378
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-2378"
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?
@kawaii-shakal on GitHub · 2026-11-26 16:31 UTC · original
kawaii-shakal:indirect-draw-unfilled-count→main· +294 −239 · 5 files · 2 commits · merged 2026-11-26 18:43 UTCClaimed 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
@ecox982745 on GitHub · 2026-11-26 17:48 UTC · original
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).
@lixonik on GitHub · 2026-11-26 18:02 UTC · original · reviewed
Built and ran
indirect_clampon Windows 11 with MSVC and NVIDIA GeForce RTX 5070 (610.88). CTest passed, including the synthetic records just below and at the new threshold and a subsequent slot retaining its budget. Title workload coverage was outside this run.AI-assisted.
@wavehs on GitHub · 2026-11-26 18:30 UTC · original · reviewed
macOS arm64 / GPU check of #2378 (RT-INDIRECT-DRAW-UNFILLED-COUNT). This is a Vulkan compute pass and a GPU test, so it runs here on two drivers.
Tested head
41332d466merged ontomainbdbc7e923as merge6738bf9d6(clean; the branch has two commits, one an upstream-main merge).Environment: Apple M3 Pro, arm64 (subgroups 4..32), macOS 27.2.1, Apple clang 21.0.0, CMake 4.5.0, MoltenVK 1.4.0; KosmicKrisp = Mesa 26.3.0 (32-wide subgroups).
glslangValidatorhere is 16.6.0.The GPU test runs, and the control bites
indirect_clamp_testfrom the merge and ran it directly:91 record(s) clamped in 4116 call(s), 1 count(s), validation errors 0.validation errors 0.mainbdbc7e923with its own (old) test: exit 0 on both drivers,72 record(s) clamped in 4113 call(s), validation errors 0. The totals differ because the test itself gained cases, not because the pass counts differently on unchanged cases.runtime/src/indirect_clamp_spv.handindirect_clamp.compput back tomain's (the header constantindirect_clamp_unfilled_drawstays, because the new test references it and would not otherwise compile): build OK, run exits 1 with 6CHECK failedlines -words[0] == 0 && words[1] == 0(line 177), the2^23 - 1vs2^23pair (191, 192), and the 16-garbage-records-then-a-real-draw case (204, 205). That is the regression the PR describes.python -I tests/test_indirect_clamp_telemetry.py: OK; the counter offsets in the regenerated header are unchanged.0x2advs0x309). The functional run above is the check that the checked-in bytes implement the new rule.No regressions
main.Findings
indirect_clamp_max_vertices(2^24) is now unreachable for draw and indexed draw: a count ≥ 2^23 becomes 0, and a count < 2^23 ismin(count, 2^24) == count, so the clamp never fires.runtime/src/indirect_clamp.comp:46,111keeps a dead constant, anddocs/d3d12_vulkan.md:4341still lists "2^24 vertices or indices" as a bound, which is no longer true (the new sentence three lines below says 2^23 records run empty). Either cut unfilled records atmax_vertices(2^24) - which still catches the 2^24 records the census found - or drop the constant and fix the limits list.records_clamped. Since the census's garbage records are 2^24, cutting at 2^24 would solve the same problem with twice the headroom and without a new class of dropped draws; if 2^23 is deliberate (e.g. the title's largest real draw is known to be below it), a corpus count from the title's own indirect arguments would settle it. The test pins 2^23 as designed, so this is a design question, not a test gap.leonida::indirect_clamp_unfilled_draw, so a RED control that reverts the whole implementation (header plus shader) fails at compile time (no member named 'indirect_clamp_unfilled_draw'), not at a CHECK. Reverting onlyindirect_clamp_spv.h(and.comp) is the control that shows the 6 failures, as above.No game files. AI-assisted.
@aslan2142 on GitHub · 2026-11-26 18:43 UTC · original
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)