Stop allocating per draw for root constants and table slots #33

Manually merged
github merged 1 commit from gh-pr/33/head into gh-pr/33/base 2026-11-26 03:34:02 +00:00
Owner

@⁠romainhedouin on GitHub · 2026-11-25 12:32 UTC · original
romainhedouin:perf/draw-stack-buffers → main · +58 −24 · 1 files · 1 commits · merged 2026-11-25 17:09 UTC

Each draw allocated small vectors on the heap: one per shader stage for its root constants, one for the tables to rebuild, and one for the tables it made. Now root constants go in a 64-word array on the stack (a root signature cannot hold more), the table slots in a small bit set on the stack, and the made tables in a buffer the state reuses between draws.

Example draw: 2 stages, 2 rebuilt tables Before After
Heap allocations per draw 6 2
Heap allocations per frame (~9,000 draws) ~54,000 ~18,000
Model benchmark of the removed work, per draw 133–172 ns 68–90 ns

"Model benchmark" = the same logic copied into a standalone program and timed in release mode on a Mac, not in the game. Type-checked for Windows (cargo clippy --target x86_64-pc-windows-msvc, with and without --all-features, no new warnings); not run. Touches State::tables like #34; whichever merges second needs a small rebase.

🤖 Generated with Claude Code

**@⁠romainhedouin** on GitHub · 2026-11-25 12:32 UTC · [original](https://github.com/Belobug/VIctory-Belobug-AMD/pull/33) `romainhedouin:perf/draw-stack-buffers` → `main` · +58 −24 · 1 files · 1 commits · merged 2026-11-25 17:09 UTC Each draw allocated small vectors on the heap: one per shader stage for its root constants, one for the tables to rebuild, and one for the tables it made. Now root constants go in a 64-word array on the stack (a root signature cannot hold more), the table slots in a small bit set on the stack, and the made tables in a buffer the state reuses between draws. | Example draw: 2 stages, 2 rebuilt tables | Before | After | |---|---|---| | Heap allocations per draw | 6 | 2 | | Heap allocations per frame (~9,000 draws) | ~54,000 | ~18,000 | | Model benchmark of the removed work, per draw | 133–172 ns | 68–90 ns | "Model benchmark" = the same logic copied into a standalone program and timed in release mode on a Mac, not in the game. Type-checked for Windows (`cargo clippy --target x86_64-pc-windows-msvc`, with and without `--all-features`, no new warnings); not run. Touches `State::tables` like #34; whichever merges second needs a small rebase. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 03:33:57 +00:00
github manually merged commit e6b638622b into gh-pr/33/base 2026-11-26 03:34:02 +00:00
This discussion has been locked. Commenting is limited to contributors.
No description provided.