From e7a439f73b87ab1fb6eb68e0b74c10c0218cf483 Mon Sep 17 00:00:00 2001 From: Olivia Lee Date: Mon, 9 Jun 2025 23:14:26 -0700 Subject: [PATCH] panvk: implement runtimeDescriptorArray and descriptorBindingVariableDescriptorCount Runtime descriptor array doesn't require any changes, variable descriptor count is already mostly supported and just needs handling for maxVariableDescriptorCount. Signed-off-by: Olivia Lee Reviewed-by: Boris Brezillon Acked-by: Erik Faye-Lund Reviewed-by: Lars-Ivar Hesselberg Simonsen Part-of: --- .../vulkan/panvk_vX_descriptor_set_layout.c | 24 +++++++++++++++++-- .../vulkan/panvk_vX_physical_device.c | 4 ++-- 2 files changed, 24 insertions(+), 4 deletions(-) diff --git a/src/panfrost/vulkan/panvk_vX_descriptor_set_layout.c b/src/panfrost/vulkan/panvk_vX_descriptor_set_layout.c index f46d26eb330..73fd726c10b 100644 --- a/src/panfrost/vulkan/panvk_vX_descriptor_set_layout.c +++ b/src/panfrost/vulkan/panvk_vX_descriptor_set_layout.c @@ -243,12 +243,23 @@ panvk_per_arch(GetDescriptorSetLayoutSupport)( VkDevice _device, const VkDescriptorSetLayoutCreateInfo *pCreateInfo, VkDescriptorSetLayoutSupport *pSupport) { + const VkDescriptorSetLayoutBindingFlagsCreateInfo *binding_flags = + vk_find_struct_const(pCreateInfo->pNext, + DESCRIPTOR_SET_LAYOUT_BINDING_FLAGS_CREATE_INFO); + VkDescriptorSetVariableDescriptorCountLayoutSupport *var_desc_count = + vk_find_struct(pSupport->pNext, + DESCRIPTOR_SET_VARIABLE_DESCRIPTOR_COUNT_LAYOUT_SUPPORT); + pSupport->supported = false; - unsigned desc_count = 0, dyn_buf_count = 0; + unsigned desc_count = 0, dyn_buf_count = 0, non_variable_count = 0, + variable_stride = 0; for (unsigned i = 0; i < pCreateInfo->bindingCount; i++) { const VkDescriptorSetLayoutBinding *binding = &pCreateInfo->pBindings[i]; VkDescriptorType type = binding->descriptorType; + VkDescriptorBindingFlags flags = + binding_flags && binding_flags->bindingCount > 0 ? + binding_flags->pBindingFlags[i] : 0; if (vk_descriptor_type_is_dynamic(type)) { dyn_buf_count += binding->descriptorCount; @@ -279,7 +290,13 @@ panvk_per_arch(GetDescriptorSetLayoutSupport)( .samplers_per_desc = samplers_per_desc, }; - desc_count += panvk_get_desc_stride(&layout) * binding->descriptorCount; + unsigned stride = panvk_get_desc_stride(&layout); + unsigned count = stride * binding->descriptorCount; + desc_count += count; + if (flags & VK_DESCRIPTOR_BINDING_VARIABLE_DESCRIPTOR_COUNT_BIT) + variable_stride = stride; + else + non_variable_count += count; } if (desc_count > PANVK_MAX_DESCS_PER_SET || @@ -287,4 +304,7 @@ panvk_per_arch(GetDescriptorSetLayoutSupport)( return; pSupport->supported = true; + if (var_desc_count) + var_desc_count->maxVariableDescriptorCount = variable_stride != 0 ? + (PANVK_MAX_DESCS_PER_SET - non_variable_count) / variable_stride : 0; } diff --git a/src/panfrost/vulkan/panvk_vX_physical_device.c b/src/panfrost/vulkan/panvk_vX_physical_device.c index 1f4836e89f7..8f2143b719c 100644 --- a/src/panfrost/vulkan/panvk_vX_physical_device.c +++ b/src/panfrost/vulkan/panvk_vX_physical_device.c @@ -300,8 +300,8 @@ panvk_per_arch(get_physical_device_features)( .descriptorBindingStorageTexelBufferUpdateAfterBind = false, .descriptorBindingUpdateUnusedWhilePending = false, .descriptorBindingPartiallyBound = false, - .descriptorBindingVariableDescriptorCount = false, - .runtimeDescriptorArray = false, + .descriptorBindingVariableDescriptorCount = true, + .runtimeDescriptorArray = true, .samplerFilterMinmax = PAN_ARCH >= 10, .scalarBlockLayout = true,