[Mesa-dev] [PATCH 15/23] anv/image: Refactor how tiling is chosen

Chad Versace chadversary at chromium.org
Sat Sep 2 08:17:38 UTC 2017


The code that restricts the VkImage's tiling flags, extract it into
a new function named choose_isl_tiling_flags().  This reduces the diff
in upcoming patches for VK_ANDROID_native_buffer.
---
 src/intel/vulkan/anv_image.c | 31 ++++++++++++++++++++-----------
 1 file changed, 20 insertions(+), 11 deletions(-)

diff --git a/src/intel/vulkan/anv_image.c b/src/intel/vulkan/anv_image.c
index 4d3b9d5b6a7..b124eedbd7d 100644
--- a/src/intel/vulkan/anv_image.c
+++ b/src/intel/vulkan/anv_image.c
@@ -106,6 +106,21 @@ get_surface(struct anv_image *image, VkImageAspectFlags aspect)
    }
 }
 
+static VkResult
+choose_isl_tiling_flags(const struct anv_image_create_info *anv_info,
+                        isl_tiling_flags_t *restrict flags)
+{
+   *flags = ISL_TILING_ANY_MASK;
+
+   if (anv_info->vk_info->tiling == VK_IMAGE_TILING_LINEAR)
+      *flags &= ISL_TILING_LINEAR_BIT;
+
+   if (anv_info->isl_tiling_flags)
+      *flags &= anv_info->isl_tiling_flags;
+
+   return VK_SUCCESS;
+}
+
 static void
 add_surface(struct anv_image *image, struct anv_surface *surf)
 {
@@ -205,6 +220,7 @@ make_surface(const struct anv_device *dev,
              VkImageAspectFlags aspect)
 {
    const VkImageCreateInfo *base_info = anv_info->vk_info;
+   VkResult result;
    bool ok UNUSED;
 
    static const enum isl_surf_dim vk_to_isl_surf_dim[] = {
@@ -213,17 +229,10 @@ make_surface(const struct anv_device *dev,
       [VK_IMAGE_TYPE_3D] = ISL_SURF_DIM_3D,
    };
 
-   /* Translate the Vulkan tiling to an equivalent ISL tiling, then filter the
-    * result with an optionally provided ISL tiling argument.
-    */
-   isl_tiling_flags_t tiling_flags =
-      (base_info->tiling == VK_IMAGE_TILING_LINEAR) ?
-      ISL_TILING_LINEAR_BIT : ISL_TILING_ANY_MASK;
-
-   if (anv_info->isl_tiling_flags)
-      tiling_flags &= anv_info->isl_tiling_flags;
-
-   assert(tiling_flags);
+   isl_tiling_flags_t tiling_flags;
+   result = choose_isl_tiling_flags(anv_info, &tiling_flags);
+   if (result != VK_SUCCESS)
+      return result;
 
    struct anv_surface *anv_surf = get_surface(image, aspect);
 
-- 
2.13.5



More information about the mesa-dev mailing list