anv: VkDescriptorSetLayoutBinding can have descriptorCount == 0
[mesa.git] / src / intel / vulkan / anv_descriptor_set.c
index 4b58b0be95cccacd7b0f69bfff46618f189505fa..e4e39f5c7b48be298f049814563c5b5ca6141edc 100644 (file)
@@ -103,7 +103,9 @@ VkResult anv_CreateDescriptorSetLayout(
       if (binding == NULL)
          continue;
 
-      assert(binding->descriptorCount > 0);
+      if (binding->descriptorCount == 0)
+         continue;
+
 #ifndef NDEBUG
       set_layout->binding[b].type = binding->descriptorType;
 #endif
@@ -400,6 +402,19 @@ anv_descriptor_set_layout_size(const struct anv_descriptor_set_layout *layout)
       layout->buffer_count * sizeof(struct anv_buffer_view);
 }
 
+size_t
+anv_descriptor_set_binding_layout_get_hw_size(const struct anv_descriptor_set_binding_layout *binding)
+{
+   if (!binding->immutable_samplers)
+      return binding->array_size;
+
+   uint32_t total_plane_count = 0;
+   for (uint32_t i = 0; i < binding->array_size; i++)
+      total_plane_count += binding->immutable_samplers[i]->n_planes;
+
+   return total_plane_count;
+}
+
 struct surface_state_free_list_entry {
    void *next;
    struct anv_state state;
@@ -615,12 +630,9 @@ anv_descriptor_set_write_image_view(struct anv_descriptor_set *set,
 
    *desc = (struct anv_descriptor) {
       .type = type,
+      .layout = info->imageLayout,
       .image_view = image_view,
       .sampler = sampler,
-      .aux_usage = image_view == NULL ? ISL_AUX_USAGE_NONE :
-                   anv_layout_to_aux_usage(devinfo, image_view->image,
-                                           image_view->aspect_mask,
-                                           info->imageLayout),
    };
 }
 
@@ -767,7 +779,7 @@ void anv_UpdateDescriptorSets(
 
    for (uint32_t i = 0; i < descriptorCopyCount; i++) {
       const VkCopyDescriptorSet *copy = &pDescriptorCopies[i];
-      ANV_FROM_HANDLE(anv_descriptor_set, src, copy->dstSet);
+      ANV_FROM_HANDLE(anv_descriptor_set, src, copy->srcSet);
       ANV_FROM_HANDLE(anv_descriptor_set, dst, copy->dstSet);
 
       const struct anv_descriptor_set_binding_layout *src_layout =