[PR #2378] [MERGED] indirect clamp: a draw record of 2^23 vertices or more runs empty and free (RT-INDIRECT-DRAW-UNFILLED-COUNT) #2383

Closed
opened 2026-11-26 21:21:03 +01:00 by 4ld0 · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/ubiquitarianism/leonida/pull/2378
Author: @kawaii-shakal
Created: 11/26/2026
Status: ✅ Merged
Merged: 11/26/2026
Merged by: @aslan2142

Base: main ← Head: indirect-draw-unfilled-count


📝 Commits (2)

  • f324b94 indirect clamp: a draw record of 2^23 vertices or more runs empty and free (RT-INDIRECT-DRAW-UNFILLED-COUNT)
  • 41332d4 Merge remote-tracking branch 'upstream/main' into indirect-draw-unfilled-count

📊 Changes

5 files changed (+294 additions, -239 deletions)

View changed files

📝 docs/d3d12_vulkan.md (+5 -2)
📝 runtime/src/indirect_clamp.comp (+8 -1)
📝 runtime/src/indirect_clamp_spv.h (+229 -223)
📝 runtime/src/vulkan_indirect_clamp.h (+3 -0)
📝 runtime/test/indirect_clamp_test.cpp (+49 -13)

📄 Description

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 lands
second regenerates it from the merged indirect_clamp.comp)

What and why

indirect_clamp.comp treats a draw record as unfilled only when all of its words are 0xFFFFFFFF. A slot with a
garbage 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.md and crates/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_draw for 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:

    • 2b: 2^23 - 1 vertices stay, with their instances cut; 2^23 runs empty;
    • 2c: 16 garbage counts ahead of a real draw in one list. With the old shader the real draw ran empty (checked by
      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 ctest on 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

  • Based on current main and merges cleanly (a conflicting pull request is labeled needs rebase).
  • One topic; follow-up work goes in a new pull request.
  • No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here.
  • A new translator rule is in the contract table of docs/design.md, with how it was confirmed. (n/a: no
    translator change)

🤖 Generated with Claude Code


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/ubiquitarianism/leonida/pull/2378 **Author:** [@kawaii-shakal](https://github.com/kawaii-shakal) **Created:** 11/26/2026 **Status:** ✅ Merged **Merged:** 11/26/2026 **Merged by:** [@aslan2142](https://github.com/aslan2142) **Base:** `main` ← **Head:** `indirect-draw-unfilled-count` --- ### 📝 Commits (2) - [`f324b94`](https://github.com/ubiquitarianism/leonida/commit/f324b94a72169825262dab64b8eb3ba047d3ed70) indirect clamp: a draw record of 2^23 vertices or more runs empty and free (RT-INDIRECT-DRAW-UNFILLED-COUNT) - [`41332d4`](https://github.com/ubiquitarianism/leonida/commit/41332d4665177a2011fca003548a9e2ef8615b26) Merge remote-tracking branch 'upstream/main' into indirect-draw-unfilled-count ### 📊 Changes **5 files changed** (+294 additions, -239 deletions) <details> <summary>View changed files</summary> 📝 `docs/d3d12_vulkan.md` (+5 -2) 📝 `runtime/src/indirect_clamp.comp` (+8 -1) 📝 `runtime/src/indirect_clamp_spv.h` (+229 -223) 📝 `runtime/src/vulkan_indirect_clamp.h` (+3 -0) 📝 `runtime/test/indirect_clamp_test.cpp` (+49 -13) </details> ### 📄 Description 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 lands second regenerates it from the merged `indirect_clamp.comp`) ### What and why `indirect_clamp.comp` treats a draw record as unfilled only when all of its words are 0xFFFFFFFF. A slot with a garbage 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.md` and `crates/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_draw` for 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: - 2b: 2^23 - 1 vertices stay, with their instances cut; 2^23 runs empty; - 2c: 16 garbage counts ahead of a real draw in one list. With the old shader the real draw ran empty (checked by 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 `ctest` on 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 - [x] Based on current `main` and merges cleanly (a conflicting pull request is labeled `needs rebase`). - [x] One topic; follow-up work goes in a new pull request. - [x] No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here. - [ ] A new translator rule is in the contract table of `docs/design.md`, with how it was confirmed. (n/a: no translator change) 🤖 Generated with [Claude Code](https://claude.com/claude-code) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
4ld0 2026-11-26 21:21:03 +01:00
Sign in to join this conversation.
No labels
bug
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
starred/leonida#2383
No description provided.