Mesa (master): anv: support VkSamplerYcbcrConversionInfo in vkCreateImageView
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Wed Dec 19 08:39:56 UTC 2018
Module: Mesa
Branch: master
Commit: a7b7772cfba5856784357e2207fc5b9bedc26714
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=a7b7772cfba5856784357e2207fc5b9bedc26714
Author: Tapani Pälli <tapani.palli at intel.com>
Date: Mon Oct 8 14:42:53 2018 +0300
anv: support VkSamplerYcbcrConversionInfo in vkCreateImageView
If a conversion struct was passed, then initialize view using
format from the conversion structure.
v2: use vk_format directly from the anv_format struct
v3: added some assertions (Lionel)
Signed-off-by: Tapani Pälli <tapani.palli at intel.com>
Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin at intel.com>
---
src/intel/vulkan/anv_image.c | 27 ++++++++++++++++++++++++++-
1 file changed, 26 insertions(+), 1 deletion(-)
diff --git a/src/intel/vulkan/anv_image.c b/src/intel/vulkan/anv_image.c
index 1355d9543c..99f835488c 100644
--- a/src/intel/vulkan/anv_image.c
+++ b/src/intel/vulkan/anv_image.c
@@ -1394,6 +1394,22 @@ anv_CreateImageView(VkDevice _device,
assert(range->layerCount > 0);
assert(range->baseMipLevel < image->levels);
+ /* Check if a conversion info was passed. */
+ const struct anv_format *conv_format = NULL;
+ const struct VkSamplerYcbcrConversionInfo *conv_info =
+ vk_find_struct_const(pCreateInfo->pNext, SAMPLER_YCBCR_CONVERSION_INFO);
+
+ /* If image has an external format, the pNext chain must contain an instance of
+ * VKSamplerYcbcrConversionInfo with a conversion object created with the same
+ * external format as image."
+ */
+ assert(!image->external_format || conv_info);
+
+ if (conv_info) {
+ ANV_FROM_HANDLE(anv_ycbcr_conversion, conversion, conv_info->conversion);
+ conv_format = conversion->format;
+ }
+
const VkImageViewUsageCreateInfo *usage_info =
vk_find_struct_const(pCreateInfo, IMAGE_VIEW_USAGE_CREATE_INFO);
VkImageUsageFlags view_usage = usage_info ? usage_info->usage : image->usage;
@@ -1438,6 +1454,15 @@ anv_CreateImageView(VkDevice _device,
iview->n_planes = anv_image_aspect_get_planes(iview->aspect_mask);
iview->vk_format = pCreateInfo->format;
+ /* "If image has an external format, format must be VK_FORMAT_UNDEFINED." */
+ assert(!image->external_format || pCreateInfo->format == VK_FORMAT_UNDEFINED);
+
+ /* Format is undefined, this can happen when using external formats. Set
+ * view format from the passed conversion info.
+ */
+ if (iview->vk_format == VK_FORMAT_UNDEFINED && conv_format)
+ iview->vk_format = conv_format->vk_format;
+
iview->extent = (VkExtent3D) {
.width = anv_minify(image->extent.width , range->baseMipLevel),
.height = anv_minify(image->extent.height, range->baseMipLevel),
@@ -1454,7 +1479,7 @@ anv_CreateImageView(VkDevice _device,
VkImageAspectFlags vplane_aspect =
anv_plane_to_aspect(iview->aspect_mask, vplane);
struct anv_format_plane format =
- anv_get_format_plane(&device->info, pCreateInfo->format,
+ anv_get_format_plane(&device->info, iview->vk_format,
vplane_aspect, image->tiling);
iview->planes[vplane].image_plane = iplane;
More information about the mesa-commit
mailing list