From cce2fa9af621b77743566538122450673910e348 Mon Sep 17 00:00:00 2001 From: John Anthony Date: Thu, 19 Jun 2025 14:08:18 +0200 Subject: [PATCH] panvk: report the maximum supported size for a variable count iub If VkDescriptorSetVariableDescriptorCountLayoutSupport is passed to vkGetDescriptorSetLayoutSupport, we should report the maximum size in bytes for inline uniform blocks. Reviewed-by: Boris Brezillon Reviewed-by: Olivia Lee Reviewed-by: Christoph Pillmayer Fixes: 5fe5e317 ("panvk: advertise descriptor indexing on valhall") Part-of: --- .../vulkan/panvk_descriptor_set_layout.h | 9 ++++--- .../vulkan/panvk_vX_descriptor_set_layout.c | 25 ++++++++++++++++--- .../vulkan/panvk_vX_physical_device.c | 1 - 3 files changed, 27 insertions(+), 8 deletions(-) diff --git a/src/panfrost/vulkan/panvk_descriptor_set_layout.h b/src/panfrost/vulkan/panvk_descriptor_set_layout.h index 968b3f87fbb..431a0a123ae 100644 --- a/src/panfrost/vulkan/panvk_descriptor_set_layout.h +++ b/src/panfrost/vulkan/panvk_descriptor_set_layout.h @@ -19,10 +19,11 @@ #include "genxml/gen_macros.h" -#define PANVK_DESCRIPTOR_SIZE 32 -#define MAX_DYNAMIC_UNIFORM_BUFFERS 16 -#define MAX_DYNAMIC_STORAGE_BUFFERS 8 -#define MAX_PUSH_DESCS 32 +#define PANVK_DESCRIPTOR_SIZE 32 +#define MAX_DYNAMIC_UNIFORM_BUFFERS 16 +#define MAX_DYNAMIC_STORAGE_BUFFERS 8 +#define MAX_PUSH_DESCS 32 +#define MAX_INLINE_UNIFORM_BLOCK_SIZE (1 << 16) #define MAX_DYNAMIC_BUFFERS \ (MAX_DYNAMIC_UNIFORM_BUFFERS + MAX_DYNAMIC_STORAGE_BUFFERS) diff --git a/src/panfrost/vulkan/panvk_vX_descriptor_set_layout.c b/src/panfrost/vulkan/panvk_vX_descriptor_set_layout.c index d7a406b20a3..a12280826a7 100644 --- a/src/panfrost/vulkan/panvk_vX_descriptor_set_layout.c +++ b/src/panfrost/vulkan/panvk_vX_descriptor_set_layout.c @@ -253,6 +253,7 @@ panvk_per_arch(GetDescriptorSetLayoutSupport)( unsigned desc_count = 0, dyn_buf_count = 0, non_variable_count = 0, variable_stride = 0; + VkDescriptorType variable_type = {0}; for (unsigned i = 0; i < pCreateInfo->bindingCount; i++) { const VkDescriptorSetLayoutBinding *binding = &pCreateInfo->pBindings[i]; VkDescriptorType type = binding->descriptorType; @@ -321,6 +322,7 @@ panvk_per_arch(GetDescriptorSetLayoutSupport)( type == VK_DESCRIPTOR_TYPE_INLINE_UNIFORM_BLOCK ? 4 : 1; } + variable_type = type; variable_stride = stride; assert(variable_stride); } @@ -340,7 +342,24 @@ 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; + + if (!var_desc_count) + return; + + var_desc_count->maxVariableDescriptorCount = 0; + + if (!variable_stride) + return; + + if (variable_type == VK_DESCRIPTOR_TYPE_INLINE_UNIFORM_BLOCK) { + /* Maximum byte size for inline uniform block */ + unsigned available_size = + panvk_get_iub_size(PANVK_MAX_DESCS_PER_SET - non_variable_count); + var_desc_count->maxVariableDescriptorCount = + MIN2(available_size, MAX_INLINE_UNIFORM_BLOCK_SIZE); + } else { + /* Maximum descriptor count for any other descriptor type */ + var_desc_count->maxVariableDescriptorCount = + (PANVK_MAX_DESCS_PER_SET - non_variable_count) / variable_stride; + } } diff --git a/src/panfrost/vulkan/panvk_vX_physical_device.c b/src/panfrost/vulkan/panvk_vX_physical_device.c index ba342cc989b..a09a93c56b5 100644 --- a/src/panfrost/vulkan/panvk_vX_physical_device.c +++ b/src/panfrost/vulkan/panvk_vX_physical_device.c @@ -32,7 +32,6 @@ * descriptor metadata */ #define RESERVED_UBO_COUNT 6 #define MAX_INLINE_UNIFORM_BLOCK_DESCRIPTORS (32 - RESERVED_UBO_COUNT) -#define MAX_INLINE_UNIFORM_BLOCK_SIZE (1 << 16) void panvk_per_arch(get_physical_device_extensions)(