vkback: size the descriptor layout to the slots the title uses #34

Manually merged
github merged 3 commits from github-bot/gh-34 into gh-pr/34/base 2026-12-01 00:24:25 +00:00 AGit
Owner

@⁠TheRifai on GitHub · 2026-11-30 23:58 UTC · original
TheRifai:vkback-descriptor-counts → main · +56 −14 · 8 files · 3 commits · merged 2026-12-01 00:22 UTC

What

The resource descriptor layout declared 2^21 slots for the five typed bindings and 2^22 for the two storage-buffer bindings (which also hold the raw twins at index + RAW_TWIN). That is 20,971,520 descriptors; the device's maxPerStageResources is 8,388,606. The storage-buffer pair alone was 8,388,608, two over the per-type limit.

The arrays are now sized to the ranges the title actually addresses:

  • typed bindings 0-3, 6: heap_slots
  • bindings 4/5 (typed + raw twins): heap_slots + RAW_TWIN

Evidence

A VKB_SLOT_CENSUS diagnostic (separate, not in this PR) recorded the largest index every binding was asked for on the house scene: heap_slots - 1 (1,245,182) for every typed binding, and RAW_TWIN + heap_slots - 1 (3,342,334) for bindings 4/5. The census reaches the layout's end, so the sizes are the full ranges, not a truncation.

Validation, house save, GE-Proton11-15, errors only, distinct VUIDs:

  • before: VkPipelineLayoutCreateInfo-descriptorType-03018, -03024, -03031, -pSetLayouts-03039 (storage buffers 8,388,608), and VkGraphicsPipelineCreateInfo-layout-01688 / VkComputePipelineCreateInfo-layout-01687 / VkRayTracingPipelineCreateInfoKHR-layout-03428 (20,971,520 resources per stage)
  • after: the four 03018/03024/03031/03039 lines are gone; the per-stage-total lines remain (12,910,592), and no new VUID appears

Not in this PR

The seven ranges still sum to 12,910,592, 54% over maxPerStageResources. Folding the raw twins and uniform buffers into one storage array would reach 8,322,048; that changes descriptor addressing and is a separate design. This PR only removes the over-declared slots (and the descriptor-buffer memory that went with them).

**@⁠TheRifai** on GitHub · 2026-11-30 23:58 UTC · [original](https://github.com/vktory6/VKtory/pull/34) `TheRifai:vkback-descriptor-counts` → `main` · +56 −14 · 8 files · 3 commits · merged 2026-12-01 00:22 UTC ## What The resource descriptor layout declared 2^21 slots for the five typed bindings and 2^22 for the two storage-buffer bindings (which also hold the raw twins at `index + RAW_TWIN`). That is 20,971,520 descriptors; the device's `maxPerStageResources` is 8,388,606. The storage-buffer pair alone was 8,388,608, two over the per-type limit. The arrays are now sized to the ranges the title actually addresses: - typed bindings 0-3, 6: `heap_slots` - bindings 4/5 (typed + raw twins): `heap_slots + RAW_TWIN` ## Evidence A `VKB_SLOT_CENSUS` diagnostic (separate, not in this PR) recorded the largest index every binding was asked for on the house scene: `heap_slots - 1` (1,245,182) for every typed binding, and `RAW_TWIN + heap_slots - 1` (3,342,334) for bindings 4/5. The census reaches the layout's end, so the sizes are the full ranges, not a truncation. Validation, house save, GE-Proton11-15, errors only, distinct VUIDs: - before: `VkPipelineLayoutCreateInfo-descriptorType-03018`, `-03024`, `-03031`, `-pSetLayouts-03039` (storage buffers 8,388,608), and `VkGraphicsPipelineCreateInfo-layout-01688` / `VkComputePipelineCreateInfo-layout-01687` / `VkRayTracingPipelineCreateInfoKHR-layout-03428` (20,971,520 resources per stage) - after: the four 03018/03024/03031/03039 lines are gone; the per-stage-total lines remain (12,910,592), and no new VUID appears ## Not in this PR The seven ranges still sum to 12,910,592, 54% over `maxPerStageResources`. Folding the raw twins and uniform buffers into one storage array would reach 8,322,048; that changes descriptor addressing and is a separate design. This PR only removes the over-declared slots (and the descriptor-buffer memory that went with them).
The layout declared 2^21 slots for the five typed bindings and 2^22 for the
two storage-buffer bindings (raw twins at index + RAW_TWIN), 20,971,520
descriptors against the device's maxPerStageResources 8,388,606
(VUID-VkGraphicsPipelineCreateInfo-layout-01688 and friends). The
storage-buffer pair alone was 8,388,608, two over maxPerStageDescriptorStorageBuffers
(VUID-VkPipelineLayoutCreateInfo-descriptorType-03018/03024/03031/03039).

VKB_SLOT_CENSUS on the house scene reaches slot heap_slots - 1 of every typed
binding and RAW_TWIN + heap_slots - 1 of the raw twins, so the arrays are now
sized to exactly those ranges. The four storage-buffer VUIDs go; the
per-stage-total VUIDs remain (the seven ranges still sum to 12.9M; folding
uniform buffers into the storage array is the next step).
github-bot locked as GitHub sync and limited conversation to collaborators 2026-12-01 00:03:21 +00:00
github-bot referenced this pull request from a commit 2026-12-01 00:24:21 +00:00
0 or more than RAW_TWIN stops the renderer at start (deliberately unhandled: an empty layout, or typed slots of
bindings 4/5 on top of the raw twins); a value that is no number stops it too instead of taking the default.
vk-xlcost now builds the run's layout (it passed 0, which this PR turned into a 1-slot layout).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
desc_counts moves from lib.rs to layout.rs (its readers are the layout, the null fill and desccheck; lib.rs is over
its size limit). The layout is made before the title creates its descriptor heap, so heap_slots is a constant: a
shader-visible CBV/SRV/UAV heap larger than it is now a rule-32 error at its creation, not only per slot written
past the end.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
github-bot changed target branch from main to gh-pr/34/base 2026-12-01 00:24:23 +00:00
github manually merged commit 9778ddf8fd into gh-pr/34/base 2026-12-01 00:24:25 +00:00
Author
Owner

@⁠vktory6 on GitHub · 2026-12-01 00:22 UTC · original

Thanks, this is the right sizing: a slot at or past heap_slots is already refused when it is written (slotwrite.rs), so the arrays only ever need heap_slots entries, plus the raw twins on bindings 4/5. That makes the size exact by construction; the census confirms it.

I pushed two commits on top:

  • VKB_HEAP_SLOTS read in one place (layout::heap_slots(); the run, vk-replay and vk-xlcost used to each parse it, falling back to the default when the value was no number). layout::make refuses 0 and anything above RAW_TWIN: 0 is an empty layout, and above RAW_TWIN the typed slots of bindings 4/5 would land on the raw twins. That replaces .max(1) (AGENTS.md rule 33: no path for a case that cannot happen). vk-xlcost passed 0, which this change would have turned into a 1-slot layout; it now builds the run's layout.
  • desc_counts moved to layout.rs, next to its readers (lib.rs is over its size limit on current main). And since the layout exists before the title creates its descriptor heap, heap_slots stays a constant, now checked against the title's own count: a shader-visible CBV/SRV/UAV heap larger than the layout is a rule-9 error at its creation.

Our validation run (house, RADV): 15 -> 11 distinct VUIDs, the four 03018/03024/03031/03039 gone, nothing new. The remaining per-stage total is now its own task: one descriptor array instead of seven typed ones (mutable descriptors or VK_EXT_descriptor_heap), in docs/TASKS.md.

**@⁠vktory6** on GitHub · 2026-12-01 00:22 UTC · [original](https://github.com/vktory6/VKtory/pull/34#issuecomment-7296267743) Thanks, this is the right sizing: a slot at or past `heap_slots` is already refused when it is written (`slotwrite.rs`), so the arrays only ever need `heap_slots` entries, plus the raw twins on bindings 4/5. That makes the size exact by construction; the census confirms it. I pushed two commits on top: - **`VKB_HEAP_SLOTS` read in one place** (`layout::heap_slots()`; the run, vk-replay and vk-xlcost used to each parse it, falling back to the default when the value was no number). `layout::make` refuses 0 and anything above `RAW_TWIN`: 0 is an empty layout, and above `RAW_TWIN` the typed slots of bindings 4/5 would land on the raw twins. That replaces `.max(1)` (AGENTS.md rule 33: no path for a case that cannot happen). vk-xlcost passed 0, which this change would have turned into a 1-slot layout; it now builds the run's layout. - **`desc_counts` moved to `layout.rs`**, next to its readers (lib.rs is over its size limit on current main). And since the layout exists before the title creates its descriptor heap, `heap_slots` stays a constant, now checked against the title's own count: a shader-visible CBV/SRV/UAV heap larger than the layout is a rule-9 error at its creation. Our validation run (house, RADV): 15 -> 11 distinct VUIDs, the four `03018`/`03024`/`03031`/`03039` gone, nothing new. The remaining per-stage total is now its own task: one descriptor array instead of seven typed ones (mutable descriptors or `VK_EXT_descriptor_heap`), in `docs/TASKS.md`.
This discussion has been locked. Commenting is limited to contributors.
No description provided.