aboutsummaryrefslogtreecommitdiffstats
path: root/src/intel/vulkan/anv_image.c
diff options
context:
space:
mode:
authorJason Ekstrand <[email protected]>2017-06-19 08:38:48 -0700
committerJason Ekstrand <[email protected]>2017-09-18 07:35:37 -0700
commit1a994b053d53d68df92d698e3b82e9278652e958 (patch)
tree986066cf110a939e3c4da60587f3b938513e88fa /src/intel/vulkan/anv_image.c
parent52a89fedf2a2811ca5a06199eb171dea94a579e8 (diff)
anv: Implement VK_KHR_image_format_list
Reviewed-by: Lionel Landwerlin <[email protected]>
Diffstat (limited to 'src/intel/vulkan/anv_image.c')
-rw-r--r--src/intel/vulkan/anv_image.c37
1 files changed, 35 insertions, 2 deletions
diff --git a/src/intel/vulkan/anv_image.c b/src/intel/vulkan/anv_image.c
index 982461c82c8..559e50da9a2 100644
--- a/src/intel/vulkan/anv_image.c
+++ b/src/intel/vulkan/anv_image.c
@@ -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;
}
}