summaryrefslogtreecommitdiffstats
path: root/src/intel
diff options
context:
space:
mode:
authorChad Versace <[email protected]>2017-11-06 18:51:53 -0800
committerChad Versace <[email protected]>2017-11-09 16:01:59 -0800
commit69e3f0b02ee10f9704238c8957cd270007236ec4 (patch)
treea490f5c4489fd4867f2bffb49efd7d90ddf7de4c /src/intel
parent7bb4387105491e9efd4c412002fb4a6e72a4ceda (diff)
anv/image: Refactor choice of isl_tiling_flags_t
Instead of choosing the tiling flags inside make_surface(), which is called once per aspect in a loop, and which chooses the same tiling for each aspect, choose the tiling flags exactly once before entering the aspect loop. Reviewed-by: Jason Ekstrand <[email protected]> Reviewed-by: Lionel Landwerlin <[email protected]>
Diffstat (limited to 'src/intel')
-rw-r--r--src/intel/vulkan/anv_image.c44
1 files changed, 31 insertions, 13 deletions
diff --git a/src/intel/vulkan/anv_image.c b/src/intel/vulkan/anv_image.c
index 32aa8741ffd..34df2a348e0 100644
--- a/src/intel/vulkan/anv_image.c
+++ b/src/intel/vulkan/anv_image.c
@@ -90,6 +90,31 @@ choose_isl_surf_usage(VkImageCreateFlags vk_create_flags,
return isl_usage;
}
+static isl_tiling_flags_t
+choose_isl_tiling_flags(const struct anv_image_create_info *anv_info)
+{
+ const VkImageCreateInfo *base_info = anv_info->vk_info;
+ isl_tiling_flags_t flags = 0;
+
+ switch (base_info->tiling) {
+ default:
+ unreachable("bad VkImageTiling");
+ case VK_IMAGE_TILING_OPTIMAL:
+ flags = ISL_TILING_ANY_MASK;
+ break;
+ case VK_IMAGE_TILING_LINEAR:
+ flags = ISL_TILING_LINEAR_BIT;
+ break;
+ }
+
+ if (anv_info->isl_tiling_flags)
+ flags &= anv_info->isl_tiling_flags;
+
+ assert(flags);
+
+ return flags;
+}
+
static struct anv_surface *
get_surface(struct anv_image *image, VkImageAspectFlagBits aspect)
{
@@ -252,6 +277,7 @@ static VkResult
make_surface(const struct anv_device *dev,
struct anv_image *image,
const struct anv_image_create_info *anv_info,
+ isl_tiling_flags_t tiling_flags,
VkImageAspectFlagBits aspect)
{
const VkImageCreateInfo *vk_info = anv_info->vk_info;
@@ -263,18 +289,6 @@ 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 =
- (vk_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);
-
image->extent = anv_sanitize_image_extent(vk_info->imageType,
vk_info->extent);
@@ -518,11 +532,15 @@ anv_image_create(VkDevice _device,
const struct anv_format *format = anv_get_format(image->vk_format);
assert(format != NULL);
+ const isl_tiling_flags_t isl_tiling_flags =
+ choose_isl_tiling_flags(create_info);
+
image->n_planes = format->n_planes;
uint32_t b;
for_each_bit(b, image->aspects) {
- r = make_surface(device, image, create_info, (1 << b));
+ r = make_surface(device, image, create_info, isl_tiling_flags,
+ (1 << b));
if (r != VK_SUCCESS)
goto fail;
}