[Mesa-dev] [PATCH 2/5] anv/image: Refactor how tiling is chosen

Chad Versace chadversary at chromium.org
Mon Mar 6 18:18:41 UTC 2017


The code that chooses the image's tiling flags, extract it into a new
function, choose_isl_tiling_flags().  This reduces the diff in future
patches for the upcoming dma_buf-import extension, in which the the
tiling code will become more complex.
---
 src/intel/vulkan/anv_image.c | 30 ++++++++++++++++++------------
 1 file changed, 18 insertions(+), 12 deletions(-)

diff --git a/src/intel/vulkan/anv_image.c b/src/intel/vulkan/anv_image.c
index 6dc140ad01d..ab92df5d754 100644
--- a/src/intel/vulkan/anv_image.c
+++ b/src/intel/vulkan/anv_image.c
@@ -104,6 +104,23 @@ get_surface(struct anv_image *image, VkImageAspectFlags aspect)
    }
 }
 
+static isl_tiling_flags_t
+choose_isl_tiling_flags(const struct anv_image_create_info *anv_info)
+{
+   isl_tiling_flags_t flags;
+
+   if (anv_info->vk_info->tiling == VK_IMAGE_TILING_LINEAR) {
+      flags = ISL_TILING_LINEAR_BIT;
+   } else {
+      flags = ISL_TILING_ANY_MASK;
+   }
+
+   if (anv_info->isl_tiling_flags)
+      flags &= anv_info->isl_tiling_flags;
+
+   return flags;
+}
+
 static void
 add_surface(struct anv_image *image, struct anv_surface *surf)
 {
@@ -135,18 +152,7 @@ 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);
-
+   const isl_tiling_flags_t tiling_flags = choose_isl_tiling_flags(anv_info);
    struct anv_surface *anv_surf = get_surface(image, aspect);
 
    image->extent = anv_sanitize_image_extent(base_info->imageType,
-- 
2.12.0



More information about the mesa-dev mailing list