<div dir="ltr">I think I'd prefer we not make "Fix" the first word in the title unless it fixes an actual bug.  How about "Refactor"?  Same for the ASTC patch.<br></div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Nov 7, 2017 at 6:47 AM, Chad Versace <span dir="ltr"><<a href="mailto:chadversary@chromium.org" target="_blank">chadversary@chromium.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Teach it to calculate the features of depthstencil formats.<br>
<br>
The goal is to incrementally fix get_image_format_properties() to return<br>
a correct result.  Currently, it returns incorrect VkFormatFeatureFlags<br>
which the caller must clean up.<br>
<br>
v2: New commit message<br>
<br>
Reviewed-by: Jason Ekstrand <<a href="mailto:jason@jlekstrand.net">jason@jlekstrand.net</a>> (v1)<br>
---<br>
 src/intel/vulkan/anv_formats.c | 47 ++++++++++++++++++++++++++++--<wbr>------------<br>
 1 file changed, 31 insertions(+), 16 deletions(-)<br>
<br>
diff --git a/src/intel/vulkan/anv_<wbr>formats.c b/src/intel/vulkan/anv_<wbr>formats.c<br>
index bd03b248ff9..8c9f5a46d2c 100644<br>
--- a/src/intel/vulkan/anv_<wbr>formats.c<br>
+++ b/src/intel/vulkan/anv_<wbr>formats.c<br>
@@ -468,12 +468,35 @@ anv_get_format_plane(const struct gen_device_info *devinfo, VkFormat vk_format,<br>
<br>
 static VkFormatFeatureFlags<br>
 get_image_format_properties(<wbr>const struct gen_device_info *devinfo,<br>
-                            enum isl_format base, struct anv_format_plane format)<br>
+                            VkFormat vk_format,<br>
+                            enum isl_format base,<br>
+                            struct anv_format_plane format,<br>
+                            VkImageTiling vk_tiling)<br>
 {<br>
+   VkFormatFeatureFlags flags = 0;<br>
+<br>
    if (format.isl_format == ISL_FORMAT_UNSUPPORTED)<br>
       return 0;<br>
<br>
-   VkFormatFeatureFlags flags = 0;<br>
+   const VkImageAspectFlags aspects = vk_format_aspects(vk_format);<br>
+<br>
+   if (aspects & (VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT)) {<br>
+      if (vk_tiling == VK_IMAGE_TILING_LINEAR)<br>
+         return 0;<br>
+<br>
+      flags |= VK_FORMAT_FEATURE_DEPTH_<wbr>STENCIL_ATTACHMENT_BIT;<br>
+<br>
+      if (aspects == VK_IMAGE_ASPECT_DEPTH_BIT || devinfo->gen >= 8)<br>
+         flags |= VK_FORMAT_FEATURE_SAMPLED_<wbr>IMAGE_BIT;<br>
+<br>
+      flags |= VK_FORMAT_FEATURE_BLIT_SRC_BIT |<br>
+               VK_FORMAT_FEATURE_BLIT_DST_BIT |<br>
+               VK_FORMAT_FEATURE_TRANSFER_<wbr>SRC_BIT_KHR |<br>
+               VK_FORMAT_FEATURE_TRANSFER_<wbr>DST_BIT_KHR;<br>
+<br>
+      return flags;<br>
+   }<br>
+<br>
    if (isl_format_supports_sampling(<wbr>devinfo, format.isl_format)) {<br>
       flags |= VK_FORMAT_FEATURE_SAMPLED_<wbr>IMAGE_BIT |<br>
                VK_FORMAT_FEATURE_BLIT_SRC_<wbr>BIT;<br>
@@ -563,16 +586,6 @@ anv_physical_device_get_<wbr>format_properties(struct anv_physical_device *physical_d<br>
<br>
    if (format == NULL) {<br>
       /* Nothing to do here */<br>
-   } else if (vk_format_is_depth_or_<wbr>stencil(vk_format)) {<br>
-      tiled |= VK_FORMAT_FEATURE_DEPTH_<wbr>STENCIL_ATTACHMENT_BIT;<br>
-      if (vk_format_aspects(vk_format) == VK_IMAGE_ASPECT_DEPTH_BIT ||<br>
-          physical_device->info.gen >= 8)<br>
-         tiled |= VK_FORMAT_FEATURE_SAMPLED_<wbr>IMAGE_BIT;<br>
-<br>
-      tiled |= VK_FORMAT_FEATURE_BLIT_SRC_BIT |<br>
-               VK_FORMAT_FEATURE_BLIT_DST_BIT |<br>
-               VK_FORMAT_FEATURE_TRANSFER_<wbr>SRC_BIT_KHR |<br>
-               VK_FORMAT_FEATURE_TRANSFER_<wbr>DST_BIT_KHR;<br>
    } else {<br>
       struct anv_format_plane linear_fmt, tiled_fmt;<br>
       linear_fmt = anv_get_format_plane(&<wbr>physical_device->info, vk_format,<br>
@@ -582,10 +595,12 @@ anv_physical_device_get_<wbr>format_properties(struct anv_physical_device *physical_d<br>
                                        VK_IMAGE_ASPECT_COLOR_BIT,<br>
                                        VK_IMAGE_TILING_OPTIMAL);<br>
<br>
-      linear = get_image_format_properties(&<wbr>physical_device->info,<br>
-                                           linear_fmt.isl_format, linear_fmt);<br>
-      tiled = get_image_format_properties(&<wbr>physical_device->info,<br>
-                                          linear_fmt.isl_format, tiled_fmt);<br>
+      linear = get_image_format_properties(&<wbr>physical_device->info, vk_format,<br>
+                                           linear_fmt.isl_format, linear_fmt,<br>
+                                           VK_IMAGE_TILING_LINEAR);<br>
+      tiled = get_image_format_properties(&<wbr>physical_device->info, vk_format,<br>
+                                          linear_fmt.isl_format, tiled_fmt,<br>
+                                          VK_IMAGE_TILING_OPTIMAL);<br>
<br>
       /* XXX: We handle 3-channel formats by switching them out for RGBX or<br>
        * RGBA formats behind-the-scenes.  This works fine for textures<br>
<span class="HOEnZb"><font color="#888888">--<br>
2.13.0<br>
<br>
______________________________<wbr>_________________<br>
mesa-dev mailing list<br>
<a href="mailto:mesa-dev@lists.freedesktop.org">mesa-dev@lists.freedesktop.org</a><br>
<a href="https://lists.freedesktop.org/mailman/listinfo/mesa-dev" rel="noreferrer" target="_blank">https://lists.freedesktop.org/<wbr>mailman/listinfo/mesa-dev</a><br>
</font></span></blockquote></div><br></div>