<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  </head>
  <body text="#000000" bgcolor="#FFFFFF">
    <div class="moz-cite-prefix">On 27/11/2018 10:53, Tapani Pälli
      wrote:<br>
    </div>
    <blockquote type="cite"
      cite="mid:20181127105321.4267-14-tapani.palli@intel.com">
      <pre class="moz-quote-pre" wrap="">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

Signed-off-by: Tapani Pälli <a class="moz-txt-link-rfc2396E" href="mailto:tapani.palli@intel.com"><tapani.palli@intel.com></a></pre>
    </blockquote>
    <p><br>
    </p>
    <p>One suggestion :<br>
    </p>
    <p><br>
    </p>
    <p>Reviewed-by: Lionel Landwerlin
      <a class="moz-txt-link-rfc2396E" href="mailto:lionel.g.landwerlin@intel.com"><lionel.g.landwerlin@intel.com></a><br>
    </p>
    <p><br>
    </p>
    <blockquote type="cite"
      cite="mid:20181127105321.4267-14-tapani.palli@intel.com">
      <pre class="moz-quote-pre" wrap="">
---
 src/intel/vulkan/anv_image.c | 18 +++++++++++++++++-
 1 file changed, 17 insertions(+), 1 deletion(-)

diff --git a/src/intel/vulkan/anv_image.c b/src/intel/vulkan/anv_image.c
index 79777efe456..2ac3eccbbe0 100644
--- a/src/intel/vulkan/anv_image.c
+++ b/src/intel/vulkan/anv_image.c
@@ -1391,6 +1391,16 @@ 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 (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;
@@ -1435,6 +1445,12 @@ anv_CreateImageView(VkDevice _device,
    iview->n_planes = anv_image_aspect_get_planes(iview->aspect_mask);
    iview->vk_format = pCreateInfo->format;</pre>
    </blockquote>
    <p><br>
    </p>
    <p>Not sure if overly harsh, but I could add this :<br>
    </p>
    <p><br>
    </p>
    <span style="color: rgb(38, 67, 87); font-family: Consolas,
      "Liberation Mono", Courier, monospace; font-size: 16px;
      font-style: normal; font-variant-ligatures: normal;
      font-variant-caps: normal; font-weight: 400; letter-spacing:
      normal; orphans: 2; text-align: left; text-indent: 0px;
      text-transform: none; white-space: normal; widows: 2;
      word-spacing: 0px; -webkit-text-stroke-width: 0px;
      background-color: rgb(255, 255, 255); text-decoration-style:
      initial; text-decoration-color: initial; display: inline
      !important; float: none;">/*</span> "If<span> </span><code
      style="box-sizing: border-box; font-family: Consolas,
      "Liberation Mono", Courier, monospace; font-size:
      inherit; font-weight: normal; color: rgb(38, 67, 87);
      border-radius: 0px; letter-spacing: 0px; padding: 0px;
      background-color: transparent; line-height: inherit;
      overflow-wrap: break-word; font-style: normal !important;">image</code><span> </span>has
    an<span> </span><a
      href="#memory-external-android-hardware-buffer-external-formats"
      style="box-sizing: border-box; background: transparent; color:
      rgb(0, 104, 176); text-decoration: none; line-height: inherit;">external
      format</a>,<span> </span><code style="box-sizing: border-box;
      font-family: Consolas, "Liberation Mono", Courier,
      monospace; font-size: inherit; font-weight: normal; color: rgb(38,
      67, 87); border-radius: 0px; letter-spacing: 0px; padding: 0px;
      background-color: transparent; line-height: inherit;
      overflow-wrap: break-word; font-style: normal !important;">format</code><span> </span><strong
      class="purple" style="box-sizing: border-box; font-weight: bold;
      line-height: inherit; color: rgb(96, 0, 96);">must</strong><span> </span>be<span> </span><code
      style="box-sizing: border-box; font-family: Consolas,
      "Liberation Mono", Courier, monospace; font-size:
      inherit; font-weight: normal; color: rgb(38, 67, 87);
      border-radius: 0px; letter-spacing: 0px; padding: 0px;
      background-color: transparent; line-height: inherit;
      overflow-wrap: break-word; font-style: normal !important;">VK_FORMAT_UNDEFINED</code>."
    <span style="color: rgb(38, 67, 87); font-family: Consolas,
      "Liberation Mono", Courier, monospace; font-size: 16px;
      font-style: normal; font-variant-ligatures: normal;
      font-variant-caps: normal; font-weight: 400; letter-spacing:
      normal; orphans: 2; text-align: left; text-indent: 0px;
      text-transform: none; white-space: normal; widows: 2;
      word-spacing: 0px; -webkit-text-stroke-width: 0px;
      background-color: rgb(255, 255, 255); text-decoration-style:
      initial; text-decoration-color: initial; display: inline
      !important; float: none;">*/<br>
    </span>
    <p><span style="color: rgb(38, 67, 87); font-family: Consolas,
        "Liberation Mono", Courier, monospace; font-size:
        16px; font-style: normal; font-variant-ligatures: normal;
        font-variant-caps: normal; font-weight: 400; letter-spacing:
        normal; orphans: 2; text-align: left; text-indent: 0px;
        text-transform: none; white-space: normal; widows: 2;
        word-spacing: 0px; -webkit-text-stroke-width: 0px;
        background-color: rgb(255, 255, 255); text-decoration-style:
        initial; text-decoration-color: initial; display: inline
        !important; float: none;">assert(!image->external_format ||
        pCreateInfo->format == VK_FORMAT_UNDEFINED);<br>
      </span></p>
    <p>/* " If<span> </span><code style="box-sizing: border-box;
        font-family: Consolas, "Liberation Mono", Courier,
        monospace; font-size: inherit; font-weight: normal; color:
        rgb(38, 67, 87); border-radius: 0px; letter-spacing: 0px;
        padding: 0px; background-color: transparent; line-height:
        inherit; overflow-wrap: break-word; font-style: normal
        !important;">image</code><span> </span>has an<span> </span><a
        href="#memory-external-android-hardware-buffer-external-formats"
        style="box-sizing: border-box; background: transparent; color:
        rgb(0, 104, 176); text-decoration: none; line-height: inherit;">external
        format</a>, the<span> </span><code style="box-sizing:
        border-box; font-family: Consolas, "Liberation Mono",
        Courier, monospace; font-size: inherit; font-weight: normal;
        color: rgb(38, 67, 87); border-radius: 0px; letter-spacing: 0px;
        padding: 0px; background-color: transparent; line-height:
        inherit; overflow-wrap: break-word; font-style: normal
        !important;">pNext</code><span> </span>chain<span> </span><strong
        class="purple" style="box-sizing: border-box; font-weight: bold;
        line-height: inherit; color: rgb(96, 0, 96);">must</strong><span> </span>contain
      an instance of<span> </span><a
        href="#VkSamplerYcbcrConversionInfo" style="box-sizing:
        border-box; background: transparent; color: rgb(0, 104, 176);
        text-decoration: none; line-height: inherit;">VkSamplerYcbcrConversionInfo</a><span> </span>with
      a<span> </span><code style="box-sizing: border-box; font-family:
        Consolas, "Liberation Mono", Courier, monospace;
        font-size: inherit; font-weight: normal; color: rgb(38, 67, 87);
        border-radius: 0px; letter-spacing: 0px; padding: 0px;
        background-color: transparent; line-height: inherit;
        overflow-wrap: break-word; font-style: normal !important;">conversion</code><span> </span>object
      created with the same external format as<span> </span><code
        style="box-sizing: border-box; font-family: Consolas,
        "Liberation Mono", Courier, monospace; font-size:
        inherit; font-weight: normal; color: rgb(38, 67, 87);
        border-radius: 0px; letter-spacing: 0px; padding: 0px;
        background-color: transparent; line-height: inherit;
        overflow-wrap: break-word; font-style: normal !important;">image</code>."
      */<br>
    </p>
    <p>assert(!image->external_format || conv_info);</p>
    <p><br>
    </p>
    <blockquote type="cite"
      cite="mid:20181127105321.4267-14-tapani.palli@intel.com">
      <pre class="moz-quote-pre" wrap="">
 
+   /* 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),
@@ -1451,7 +1467,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;
</pre>
    </blockquote>
    <p><br>
    </p>
  </body>
</html>