Module: Mesa
Branch: master
Commit: eaa49ec3fc21fa98d53a9d020d7665eb7ac87eed
URL:    
http://cgit.freedesktop.org/mesa/mesa/commit/?id=eaa49ec3fc21fa98d53a9d020d7665eb7ac87eed

Author: Chad Versace <[email protected]>
Date:   Fri Nov  3 12:25:51 2017 -0700

anv: Fix get_image_format_properties() - 3-channel formats

Teach it to calculate the format features for 3-channel formats.

The goal is to incrementally fix get_image_format_properties() to return
a correct result.  Currently, it returns incorrect VkFormatFeatureFlags
which the caller must clean up.

Reviewed-by: Jason Ekstrand <[email protected]>
Reviewed-by: Lionel Landwerlin <[email protected]>

---

 src/intel/vulkan/anv_formats.c | 34 +++++++++++++++-------------------
 1 file changed, 15 insertions(+), 19 deletions(-)

diff --git a/src/intel/vulkan/anv_formats.c b/src/intel/vulkan/anv_formats.c
index 151c1c9e06..e6d998204c 100644
--- a/src/intel/vulkan/anv_formats.c
+++ b/src/intel/vulkan/anv_formats.c
@@ -553,6 +553,21 @@ get_image_format_properties(const struct gen_device_info 
*devinfo,
                VK_FORMAT_FEATURE_TRANSFER_DST_BIT_KHR;
    }
 
+   /* XXX: We handle 3-channel formats by switching them out for RGBX or
+    * RGBA formats behind-the-scenes.  This works fine for textures
+    * because the upload process will fill in the extra channel.
+    * We could also support it for render targets, but it will take
+    * substantially more work and we have enough RGBX formats to handle
+    * what most clients will want.
+    */
+   if (vk_tiling == VK_IMAGE_TILING_OPTIMAL &&
+       base_isl_format != ISL_FORMAT_UNSUPPORTED &&
+       !util_is_power_of_two(isl_format_layouts[base_isl_format].bpb) &&
+       isl_format_rgb_to_rgbx(base_isl_format) == ISL_FORMAT_UNSUPPORTED) {
+      flags &= ~VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BIT;
+      flags &= ~VK_FORMAT_FEATURE_BLIT_DST_BIT;
+   }
+
    return flags;
 }
 
@@ -608,29 +623,10 @@ anv_physical_device_get_format_properties(struct 
anv_physical_device *physical_d
    if (format == NULL) {
       /* Nothing to do here */
    } else {
-      struct anv_format_plane linear_fmt;
-      linear_fmt = anv_get_format_plane(&physical_device->info, vk_format,
-                                        VK_IMAGE_ASPECT_COLOR_BIT,
-                                        VK_IMAGE_TILING_LINEAR);
-
       linear = get_image_format_properties(&physical_device->info, vk_format,
                                            format, VK_IMAGE_TILING_LINEAR);
       tiled = get_image_format_properties(&physical_device->info, vk_format,
                                           format, VK_IMAGE_TILING_OPTIMAL);
-
-      /* XXX: We handle 3-channel formats by switching them out for RGBX or
-       * RGBA formats behind-the-scenes.  This works fine for textures
-       * because the upload process will fill in the extra channel.
-       * We could also support it for render targets, but it will take
-       * substantially more work and we have enough RGBX formats to handle
-       * what most clients will want.
-       */
-      if (linear_fmt.isl_format != ISL_FORMAT_UNSUPPORTED &&
-          !util_is_power_of_two(isl_format_layouts[linear_fmt.isl_format].bpb) 
&&
-          isl_format_rgb_to_rgbx(linear_fmt.isl_format) == 
ISL_FORMAT_UNSUPPORTED) {
-         tiled &= ~VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BIT &
-                  ~VK_FORMAT_FEATURE_BLIT_DST_BIT;
-      }
    }
 
    if (format && format->can_ycbcr) {

_______________________________________________
mesa-commit mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/mesa-commit

Reply via email to