VK_EXT_shader_uniform_buffer_unsized_array
Other Extension Metadata
Last Modified Date
2025-05-28
Contributors
- Pat Brown, NVIDIA
- Jeff Bolz, NVIDIA
- Pranjal Dubey, NVIDIA
Description
This extension allows the last member of a uniform buffer block to be declared as an unsized array. This capability enables applications to create flexible buffer layouts where the array size can vary based on runtime requirements.
When the last member of a uniform buffer block is declared as an unsized array, the effective array size is inferred at runtime from the size of the buffer object backing the uniform buffer block. Such unsized arrays can be indexed with general integer expressions, but may not be passed as arguments to functions or indexed with negative constant expressions.
This extension leverages existing SPIR-V capabilities, allowing use of
OpTypeRuntimeArray as the last member of a uniform buffer block structure
while prohibiting OpArrayLength.
Applications needing to know array sizes at runtime should calculate the length and pass it to shaders via a separate uniform. This calculation can be performed using the formula: max((buffer_object_size - offset_of_array) / stride_of_array, 0), where buffer_object_size is the size of the bound buffer, offset_of_array is the byte offset of the array in the block, and stride_of_array is the byte stride between consecutive array elements.
Uniform buffers have traditionally required explicit sizes for all arrays which limits flexibility. With this extension, developers can create a single shader that adapts to different data set sizes at runtime by binding differently sized buffers.
New Structures
- Extending VkPhysicalDeviceFeatures2, VkDeviceCreateInfo:
New Enum Constants
VK_EXT_SHADER_UNIFORM_BUFFER_UNSIZED_ARRAY_EXTENSION_NAMEVK_EXT_SHADER_UNIFORM_BUFFER_UNSIZED_ARRAY_SPEC_VERSION- Extending VkStructureType:
VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_UNIFORM_BUFFER_UNSIZED_ARRAY_FEATURES_EXT
Version History
- Revision 1, 2025-05-28 (Pranjal Dubey)
- Initial draft