anv: Implement VK_KHR_image_format_list
authorJason Ekstrand <jason.ekstrand@intel.com>
Mon, 19 Jun 2017 15:38:48 +0000 (08:38 -0700)
committerJason Ekstrand <jason.ekstrand@intel.com>
Mon, 18 Sep 2017 14:35:37 +0000 (07:35 -0700)
Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
src/intel/vulkan/anv_extensions.py
src/intel/vulkan/anv_image.c

index cb0e36b7233f9301482168fb6e612f1767284853..c94149c130af75237b7f57d93b87390f7fd208e4 100644 (file)
@@ -62,6 +62,7 @@ EXTENSIONS = [
     Extension('VK_KHR_get_memory_requirements2',          1, True),
     Extension('VK_KHR_get_physical_device_properties2',   1, True),
     Extension('VK_KHR_get_surface_capabilities2',         1, True),
+    Extension('VK_KHR_image_format_list',                 1, True),
     Extension('VK_KHR_incremental_present',               1, True),
     Extension('VK_KHR_maintenance1',                      1, True),
     Extension('VK_KHR_push_descriptor',                   1, True),
index 982461c82c8eab7380b27dc718d612da0f5243c9..559e50da9a20b8169cf83f5560f3b33d0c5effbb 100644 (file)
@@ -30,6 +30,7 @@
 
 #include "anv_private.h"
 #include "util/debug.h"
+#include "vk_util.h"
 
 #include "vk_format_info.h"
 
@@ -116,6 +117,39 @@ add_surface(struct anv_image *image, struct anv_surface *surf)
    image->alignment = MAX2(image->alignment, surf->isl.alignment);
 }
 
+
+static bool
+all_formats_ccs_e_compatible(const struct gen_device_info *devinfo,
+                             const struct VkImageCreateInfo *vk_info)
+{
+   enum isl_format format =
+      anv_get_isl_format(devinfo, vk_info->format,
+                         VK_IMAGE_ASPECT_COLOR_BIT, vk_info->tiling);
+
+   if (!isl_format_supports_ccs_e(devinfo, format))
+      return false;
+
+   if (!(vk_info->flags & VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT))
+      return true;
+
+   const VkImageFormatListCreateInfoKHR *fmt_list =
+      vk_find_struct_const(vk_info->pNext, IMAGE_FORMAT_LIST_CREATE_INFO_KHR);
+
+   if (!fmt_list || fmt_list->viewFormatCount == 0)
+      return false;
+
+   for (uint32_t i = 0; i < fmt_list->viewFormatCount; i++) {
+      enum isl_format view_format =
+         anv_get_isl_format(devinfo, fmt_list->pViewFormats[i],
+                            VK_IMAGE_ASPECT_COLOR_BIT, vk_info->tiling);
+
+      if (!isl_formats_are_ccs_e_compatible(devinfo, format, view_format))
+         return false;
+   }
+
+   return true;
+}
+
 /**
  * For color images that have an auxiliary surface, request allocation for an
  * additional buffer that mainly stores fast-clear values. Use of this buffer
@@ -319,8 +353,7 @@ make_surface(const struct anv_device *dev,
              * compression on at all times for these formats.
              */
             if (!(vk_info->usage & VK_IMAGE_USAGE_STORAGE_BIT) &&
-                !(vk_info->flags & VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT) &&
-                isl_format_supports_ccs_e(&dev->info, format)) {
+                all_formats_ccs_e_compatible(&dev->info, vk_info)) {
                image->aux_usage = ISL_AUX_USAGE_CCS_E;
             }
          }