Repository navigation
indirect clamp: a draw record of 2^23 vertices or more runs empty and free (RT-INDIRECT-DRAW-UNFILLED-COUNT) - #2378
Conversation
… free (RT-INDIRECT-DRAW-UNFILLED-COUNT) The clamp cut a garbage draw count to 2^24 vertices and charged it against the list's 2^27-unit budget. Only records whose words are all 0xFFFFFFFF were treated as unfilled. A slot with a garbage count but other words set therefore cost 2^24 units, so eight such records used up the budget and every real draw after them in the list ran empty. A census in codec-d/cool_fox's fork of VIctory found 90 records of 2^24 vertices in one list, and that fork treats 2^23 vertices an instance or more as unfilled. Here such a record now runs empty, keeps its locations and charges nothing. Draws under 2^23 are unchanged. indirect_clamp_test: the old garbage cases now expect an empty record. New cases check the 2^23 edge and 16 garbage counts ahead of a real draw, which ran empty with the old shader and runs with this one. The list-budget case uses a real 2^22 x 16 draw. indirect_clamp_spv.h was regenerated with glslangValidator 15.1.0 (-V --target-env vulkan1.2 -Os). Tested: full ctest (108 tests) on Linux with Mesa lavapipe (llvmpipe, LLVM 19.1.7). Changes made by Claude Code (AI-assisted). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01JPqXc6svM4pbBagTsVEYA3
|
I ran the committed clamp shader at 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.
For 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 AI-assisted hardware verification with OpenAI Codex (GPT-6). |
lixonik
left a comment
There was a problem hiding this comment.
Built and ran indirect_clamp on 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
left a comment
There was a problem hiding this comment.
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 41332d466 merged onto main bdbc7e923 as merge 6738bf9d6 (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). glslangValidator here is 16.6.0.
The GPU test runs, and the control bites
- Built
indirect_clamp_testfrom the merge and ran it directly:- MoltenVK: exit 0,
91 record(s) clamped in 4116 call(s), 1 count(s), validation errors 0. - KosmicKrisp: exit 0, same line,
validation errors 0.
- MoltenVK: exit 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.- Negative control: new test kept,
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.- The checked-in SPIR-V was not byte-compared: this machine's glslangValidator is 16.6.0 while the header says 15.1.0, and the modules differ from word 3 (the id bound,
0x2advs0x309). The functional run above is the check that the checked-in bytes implement the new rule.
No regressions
- Semantic suite: 500 files / 6,367 tests / 0 files failed at the merge, the same as
main. - The 268 shader fixtures were not re-run: this PR touches no translator code. The same-main baseline from this session is 195 PASS / 3 FAIL / 70 SKIP (MoltenVK) and 190 / 5 / 73 (KosmicKrisp).
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.- The 2^23 boundary is taken from codec-d/cool_fox's fork, and the body is explicit that the flicker link is unconfirmed. A legitimate draw of 8.4M-16.7M vertices, which ran before (the old clamp kept the count below 2^24 and clamped only above it), now runs empty and is only visible as
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. - For other reviewers: the new test references
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.
|
Merging.
Notes for a follow-up, none blocking:
Thanks @kawaii-shakal. AI-assisted (Claude Code, Claude Opus 5.5 and Claude Fable 5.2) |
…dispatch limit and ProjectLeonida#2378's unfilled draw records main's ProjectLeonida#2378 (a draw record of 2^23 vertices or more runs empty and charges nothing) changed indirect_clamp.comp next to this branch's dispatch bound. The .comp, vulkan_indirect_clamp.h and indirect_clamp_test.cpp merged without conflicts and keep both changes. The only conflict was the generated indirect_clamp_spv.h: it is regenerated from the merged indirect_clamp.comp as its header comment says (glslangValidator 16.6.0, -V --target-env vulkan1.2 -Os --spirv-val; spirv-val passes). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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 (fbf100b): 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