anv: introduce a new descriptor set layout type
authorLionel Landwerlin <lionel.g.landwerlin@intel.com>
Mon, 27 Mar 2023 14:11:44 +0000 (17:11 +0300)
committerMarge Bot <emma+marge@anholt.net>
Tue, 30 May 2023 06:36:38 +0000 (06:36 +0000)
Signed-off-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/21645>

src/intel/vulkan/anv_descriptor_set.c
src/intel/vulkan/anv_private.h

index bf4f0e7..ef03750 100644 (file)
@@ -579,6 +579,13 @@ VkResult anv_CreateDescriptorSetLayout(
    set_layout->dynamic_offset_count = dynamic_offset_count;
    set_layout->descriptor_buffer_size = descriptor_buffer_size;
 
+   if (pCreateInfo->flags & VK_DESCRIPTOR_SET_LAYOUT_CREATE_DESCRIPTOR_BUFFER_BIT_EXT)
+      set_layout->type = ANV_PIPELINE_DESCRIPTOR_SET_LAYOUT_TYPE_BUFFER;
+   else if (device->physical->indirect_descriptors)
+      set_layout->type = ANV_PIPELINE_DESCRIPTOR_SET_LAYOUT_TYPE_INDIRECT;
+   else
+      set_layout->type = ANV_PIPELINE_DESCRIPTOR_SET_LAYOUT_TYPE_DIRECT;
+
    *pSetLayout = anv_descriptor_set_layout_to_handle(set_layout);
 
    return VK_SUCCESS;
@@ -764,6 +771,11 @@ anv_pipeline_sets_layout_add(struct anv_pipeline_sets_layout *layout,
    if (layout->independent_sets && anv_descriptor_set_layout_empty(set_layout))
       return;
 
+   if (layout->type == ANV_PIPELINE_DESCRIPTOR_SET_LAYOUT_TYPE_UNKNOWN)
+      layout->type = set_layout->type;
+   else
+      assert(layout->type == set_layout->type);
+
    layout->num_sets = MAX2(set_idx + 1, layout->num_sets);
 
    layout->set[set_idx].layout =
index 9d294e8..e052a70 100644 (file)
@@ -1695,6 +1695,13 @@ struct anv_descriptor_set_binding_layout {
    struct anv_sampler **immutable_samplers;
 };
 
+enum anv_descriptor_set_layout_type {
+   ANV_PIPELINE_DESCRIPTOR_SET_LAYOUT_TYPE_UNKNOWN,
+   ANV_PIPELINE_DESCRIPTOR_SET_LAYOUT_TYPE_INDIRECT,
+   ANV_PIPELINE_DESCRIPTOR_SET_LAYOUT_TYPE_DIRECT,
+   ANV_PIPELINE_DESCRIPTOR_SET_LAYOUT_TYPE_BUFFER,
+};
+
 bool anv_descriptor_supports_bindless(const struct anv_physical_device *pdevice,
                                       const struct anv_descriptor_set_binding_layout *binding,
                                       bool sampler);
@@ -1708,6 +1715,9 @@ struct anv_descriptor_set_layout {
 
    VkDescriptorSetLayoutCreateFlags flags;
 
+   /* Type of descriptor set layout */
+   enum anv_descriptor_set_layout_type type;
+
    /* Descriptor set layouts can be destroyed at almost any time */
    uint32_t ref_cnt;
 
@@ -2023,6 +2033,8 @@ struct anv_pipeline_sets_layout {
       uint32_t dynamic_offset_start;
    } set[MAX_SETS];
 
+   enum anv_descriptor_set_layout_type type;
+
    uint32_t num_sets;
    uint32_t num_dynamic_buffers;