[Mesa-dev] [RFC v2 08/22] anv/image: Refactor how tiling is chosen
Louis-Francis Ratté-Boulianne
lfrb at collabora.com
Thu Aug 31 04:24:09 UTC 2017
From: Chad Versace <chadversary at chromium.org>
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 4d3b9d5b6a..313809803a 100644
--- a/src/intel/vulkan/anv_image.c
+++ b/src/intel/vulkan/anv_image.c
@@ -106,6 +106,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)
{
@@ -213,18 +230,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.13.0
More information about the mesa-dev
mailing list