diff --git a/src/nouveau/vulkan/nvk_descriptor_set_layout.c b/src/nouveau/vulkan/nvk_descriptor_set_layout.c index bbb17c02a30..25598a2e2f6 100644 --- a/src/nouveau/vulkan/nvk_descriptor_set_layout.c +++ b/src/nouveau/vulkan/nvk_descriptor_set_layout.c @@ -171,6 +171,7 @@ nvk_CreateDescriptorSetLayout(VkDevice device, MUTABLE_DESCRIPTOR_TYPE_CREATE_INFO_EXT); uint32_t buffer_size = 0; + uint32_t max_variable_descriptor_size = 0; uint8_t dynamic_buffer_count = 0; for (uint32_t b = 0; b < num_bindings; b++) { /* We stashed the pCreateInfo->pBindings[] index (plus one) in the @@ -263,6 +264,8 @@ nvk_CreateDescriptorSetLayout(VkDevice device, * In other words, it has to be the last binding. */ assert(b == num_bindings - 1); + assert(max_variable_descriptor_size == 0); + max_variable_descriptor_size = stride * binding->descriptorCount; } else { /* the allocation size will be computed at descriptor allocation, * but the buffer size will be already aligned as this binding will @@ -275,6 +278,7 @@ nvk_CreateDescriptorSetLayout(VkDevice device, } layout->non_variable_descriptor_buffer_size = buffer_size; + layout->max_buffer_size = buffer_size + max_variable_descriptor_size; layout->dynamic_buffer_count = dynamic_buffer_count; struct mesa_blake3 blake3_ctx; @@ -435,3 +439,24 @@ nvk_GetDescriptorSetLayoutSupport(VkDevice device, } } } + +VKAPI_ATTR void VKAPI_CALL +nvk_GetDescriptorSetLayoutSizeEXT(VkDevice device, + VkDescriptorSetLayout _layout, + VkDeviceSize *pLayoutSizeInBytes) +{ + VK_FROM_HANDLE(nvk_descriptor_set_layout, layout, _layout); + + *pLayoutSizeInBytes = layout->max_buffer_size; +} + +VKAPI_ATTR void VKAPI_CALL +nvk_GetDescriptorSetLayoutBindingOffsetEXT(VkDevice device, + VkDescriptorSetLayout _layout, + uint32_t binding, + VkDeviceSize *pOffset) +{ + VK_FROM_HANDLE(nvk_descriptor_set_layout, layout, _layout); + + *pOffset = layout->binding[binding].offset; +} diff --git a/src/nouveau/vulkan/nvk_descriptor_set_layout.h b/src/nouveau/vulkan/nvk_descriptor_set_layout.h index 6fbf3e20907..b8b8ce80e95 100644 --- a/src/nouveau/vulkan/nvk_descriptor_set_layout.h +++ b/src/nouveau/vulkan/nvk_descriptor_set_layout.h @@ -51,6 +51,9 @@ struct nvk_descriptor_set_layout { /* Does not contain the size needed for variable count descriptors */ uint32_t non_variable_descriptor_buffer_size; + /* Maximum possible buffer size for this descriptor set */ + uint32_t max_buffer_size; + /* Number of dynamic UBO bindings in this set */ uint8_t dynamic_buffer_count;