DescriptorHeapVulkan: the sampler heap is not checked against maxSamplerHeapSize #173

Open
opened 2026-10-31 14:57:57 +00:00 by jorijnvdgraaf · 0 comments

Summary

Initialize sizes the sampler heap from the sampler count without comparing it with VkPhysicalDeviceDescriptorHeapPropertiesEXT::maxSamplerHeapSize, so it accepts counts the device cannot bind. Window::Render then binds the heap every frame in violation of VUID-vkCmdBindSamplerHeapEXT-pBindInfo-11225, and nothing says so unless the validation layer is on.

Line numbers refer to 6e94cc6: the size is computed at interfaces/Crafter.Graphics-DescriptorHeapVulkan.cppm:134 and bound at implementations/Crafter.Graphics-Window.cpp:1366-1379.

Numbers

NVIDIA 615.78.08 (RTX 4090): maxSamplerHeapSize is 0x20000, samplerDescriptorSize 32 and minSamplerHeapReservedRange 0x200, so at most 4080 sampler slots fit. Initialize(16, 16, 4081) builds a 131104-byte sampler heap.

The resource heap has the same rule (VUID-vkCmdBindResourceHeapEXT-pBindInfo-11234, maxResourceHeapSize). Slot counts within 16 bits cannot reach it on NVIDIA: the largest resource heap is about 2 MB of descriptors plus the reserved range, against a 32 MB limit.

Suggested fix

Throw from the layout computation (DescriptorHeapVulkan::ComputeLayout once #163 lands) when a heap would pass its maximum, naming the count and the limit, as the 16-bit check there does. The DescriptorHeapLayout test's Properties helper then has to set the two max fields.

Found in a code review of the #163 change.

## Summary `Initialize` sizes the sampler heap from the sampler count without comparing it with `VkPhysicalDeviceDescriptorHeapPropertiesEXT::maxSamplerHeapSize`, so it accepts counts the device cannot bind. `Window::Render` then binds the heap every frame in violation of VUID-vkCmdBindSamplerHeapEXT-pBindInfo-11225, and nothing says so unless the validation layer is on. Line numbers refer to `6e94cc6`: the size is computed at `interfaces/Crafter.Graphics-DescriptorHeapVulkan.cppm:134` and bound at `implementations/Crafter.Graphics-Window.cpp:1366-1379`. ## Numbers NVIDIA 615.78.08 (RTX 4090): `maxSamplerHeapSize` is 0x20000, `samplerDescriptorSize` 32 and `minSamplerHeapReservedRange` 0x200, so at most 4080 sampler slots fit. `Initialize(16, 16, 4081)` builds a 131104-byte sampler heap. The resource heap has the same rule (VUID-vkCmdBindResourceHeapEXT-pBindInfo-11234, `maxResourceHeapSize`). Slot counts within 16 bits cannot reach it on NVIDIA: the largest resource heap is about 2 MB of descriptors plus the reserved range, against a 32 MB limit. ## Suggested fix Throw from the layout computation (`DescriptorHeapVulkan::ComputeLayout` once #163 lands) when a heap would pass its maximum, naming the count and the limit, as the 16-bit check there does. The `DescriptorHeapLayout` test's `Properties` helper then has to set the two max fields. Found in a code review of the #163 change.
Sign in to join this conversation.
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
Catcrafts/Crafter.Graphics#173
No description provided.