anv/descriptor_set: Store aux usage of sampled image descriptors
authorNanley Chery <nanley.g.chery@intel.com>
Tue, 31 Jan 2017 19:13:44 +0000 (11:13 -0800)
committerNanley Chery <nanley.g.chery@intel.com>
Thu, 2 Mar 2017 21:17:55 +0000 (13:17 -0800)
v2: Rebase onto latest changes
v3: Account for NULL image_view in aux_usage assignment

Signed-off-by: Nanley Chery <nanley.g.chery@intel.com>
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
src/intel/vulkan/anv_cmd_buffer.c
src/intel/vulkan/anv_descriptor_set.c
src/intel/vulkan/anv_private.h

index a6addd70295b8d7e329390a7024a90f829955f01..a765bfeaff321c6c914cf994515d97dd38e96c02 100644 (file)
@@ -855,10 +855,9 @@ void anv_CmdPushDescriptorSetKHR(
       case VK_DESCRIPTOR_TYPE_STORAGE_IMAGE:
       case VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT:
          for (uint32_t j = 0; j < write->descriptorCount; j++) {
-            anv_descriptor_set_write_image_view(set,
+            anv_descriptor_set_write_image_view(set, &cmd_buffer->device->info,
+                                                write->pImageInfo + j,
                                                 write->descriptorType,
-                                                write->pImageInfo[j].imageView,
-                                                write->pImageInfo[j].sampler,
                                                 write->dstBinding,
                                                 write->dstArrayElement + j);
          }
index bbd3f0f13bab8393ed1509711d117facf085faf4..1e8991ba43bb9571283b771774698e7d45de45f0 100644 (file)
@@ -571,9 +571,9 @@ VkResult anv_FreeDescriptorSets(
 
 void
 anv_descriptor_set_write_image_view(struct anv_descriptor_set *set,
+                                    const struct gen_device_info * const devinfo,
+                                    const VkDescriptorImageInfo * const info,
                                     VkDescriptorType type,
-                                    VkImageView _image_view,
-                                    VkSampler _sampler,
                                     uint32_t binding,
                                     uint32_t element)
 {
@@ -588,18 +588,18 @@ anv_descriptor_set_write_image_view(struct anv_descriptor_set *set,
 
    switch (type) {
    case VK_DESCRIPTOR_TYPE_SAMPLER:
-      sampler = anv_sampler_from_handle(_sampler);
+      sampler = anv_sampler_from_handle(info->sampler);
       break;
 
    case VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER:
-      image_view = anv_image_view_from_handle(_image_view);
-      sampler = anv_sampler_from_handle(_sampler);
+      image_view = anv_image_view_from_handle(info->imageView);
+      sampler = anv_sampler_from_handle(info->sampler);
       break;
 
    case VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE:
    case VK_DESCRIPTOR_TYPE_STORAGE_IMAGE:
    case VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT:
-      image_view = anv_image_view_from_handle(_image_view);
+      image_view = anv_image_view_from_handle(info->imageView);
       break;
 
    default:
@@ -617,6 +617,10 @@ anv_descriptor_set_write_image_view(struct anv_descriptor_set *set,
       .type = type,
       .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),
    };
 }
 
@@ -710,10 +714,9 @@ void anv_UpdateDescriptorSets(
       case VK_DESCRIPTOR_TYPE_STORAGE_IMAGE:
       case VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT:
          for (uint32_t j = 0; j < write->descriptorCount; j++) {
-            anv_descriptor_set_write_image_view(set,
+            anv_descriptor_set_write_image_view(set, &device->info,
+                                                write->pImageInfo + j,
                                                 write->descriptorType,
-                                                write->pImageInfo[j].imageView,
-                                                write->pImageInfo[j].sampler,
                                                 write->dstBinding,
                                                 write->dstArrayElement + j);
          }
@@ -811,10 +814,8 @@ anv_descriptor_set_write_template(struct anv_descriptor_set *set,
          for (uint32_t j = 0; j < entry->array_count; j++) {
             const VkDescriptorImageInfo *info =
                data + entry->offset + j * entry->stride;
-            anv_descriptor_set_write_image_view(set,
-                                                entry->type,
-                                                info->imageView,
-                                                info->sampler,
+            anv_descriptor_set_write_image_view(set, &device->info,
+                                                info, entry->type,
                                                 entry->binding,
                                                 entry->array_element + j);
          }
index b12012d36c67ad3a730bd82152c9302955c4880a..3adf79686bcba06403112b45db31cba0445a0b27 100644 (file)
@@ -902,6 +902,11 @@ struct anv_descriptor {
       struct {
          struct anv_image_view *image_view;
          struct anv_sampler *sampler;
+
+         /* Used to determine whether or not we need the surface state to have
+          * the auxiliary buffer enabled.
+          */
+         enum isl_aux_usage aux_usage;
       };
 
       struct anv_buffer_view *buffer_view;
@@ -995,9 +1000,9 @@ anv_descriptor_set_layout_size(const struct anv_descriptor_set_layout *layout);
 
 void
 anv_descriptor_set_write_image_view(struct anv_descriptor_set *set,
+                                    const struct gen_device_info * const devinfo,
+                                    const VkDescriptorImageInfo * const info,
                                     VkDescriptorType type,
-                                    VkImageView _image_view,
-                                    VkSampler _sampler,
                                     uint32_t binding,
                                     uint32_t element);