From a29d0cfaf06653b2dae778e0be9e5bdd6637e93d Mon Sep 17 00:00:00 2001 From: Lionel Landwerlin Date: Mon, 5 Aug 2024 23:03:46 +0300 Subject: [PATCH] vulkan/runtime: track dynamics descriptor in a set layout Signed-off-by: Lionel Landwerlin Reviewed-by: Faith Ekstrand Part-of: --- src/vulkan/runtime/vk_descriptor_set_layout.h | 3 +++ src/vulkan/runtime/vk_pipeline_layout.c | 3 +++ src/vulkan/runtime/vk_pipeline_layout.h | 7 +++++++ 3 files changed, 13 insertions(+) diff --git a/src/vulkan/runtime/vk_descriptor_set_layout.h b/src/vulkan/runtime/vk_descriptor_set_layout.h index 9349ac863db..75476dfb6a4 100644 --- a/src/vulkan/runtime/vk_descriptor_set_layout.h +++ b/src/vulkan/runtime/vk_descriptor_set_layout.h @@ -37,6 +37,9 @@ struct vk_descriptor_set_layout { VkDescriptorSetLayoutCreateFlags flags; + /** Number of dynamic descriptors in this layout */ + uint32_t dynamic_descriptor_count; + /* BLAKE3 hash of the descriptor set layout. This is used by the common * pipeline code to properly cache shaders, including handling pipeline * layouts. It must be populated by the driver or you risk pipeline cache diff --git a/src/vulkan/runtime/vk_pipeline_layout.c b/src/vulkan/runtime/vk_pipeline_layout.c index d4374e943ca..27e960891a4 100644 --- a/src/vulkan/runtime/vk_pipeline_layout.c +++ b/src/vulkan/runtime/vk_pipeline_layout.c @@ -47,10 +47,12 @@ vk_pipeline_layout_init(struct vk_device *device, layout->push_descriptor_idx = UINT32_MAX; layout->destroy = vk_pipeline_layout_destroy; + uint32_t dynamic_descriptor_count = 0; for (uint32_t s = 0; s < pCreateInfo->setLayoutCount; s++) { VK_FROM_HANDLE(vk_descriptor_set_layout, set_layout, pCreateInfo->pSetLayouts[s]); + layout->dynamic_descriptor_offset[s] = dynamic_descriptor_count; if (set_layout != NULL) { layout->set_layouts[s] = vk_descriptor_set_layout_ref(set_layout); if (set_layout->flags & @@ -58,6 +60,7 @@ vk_pipeline_layout_init(struct vk_device *device, assert(layout->push_descriptor_idx == UINT32_MAX); layout->push_descriptor_idx = s; } + dynamic_descriptor_count += set_layout->dynamic_descriptor_count; } else { layout->set_layouts[s] = NULL; } diff --git a/src/vulkan/runtime/vk_pipeline_layout.h b/src/vulkan/runtime/vk_pipeline_layout.h index 2cc8acf2a74..67fc0d866ff 100644 --- a/src/vulkan/runtime/vk_pipeline_layout.h +++ b/src/vulkan/runtime/vk_pipeline_layout.h @@ -65,6 +65,13 @@ struct vk_pipeline_layout { /** Array of pointers to descriptor set layouts, indexed by set index */ struct vk_descriptor_set_layout *set_layouts[MESA_VK_MAX_DESCRIPTOR_SETS]; + /** Dynamic descriptors offset + * + * For each descriptor set layout, this is the sum of dynamic buffers in + * each preceding descriptor set. + */ + uint32_t dynamic_descriptor_offset[MESA_VK_MAX_DESCRIPTOR_SETS]; + /** Number of push constant ranges in this pipeline layout */ uint32_t push_range_count;