From 41bffe091350d858ae4f82d179671c6cfb44253b Mon Sep 17 00:00:00 2001 From: Jason Ekstrand Date: Tue, 21 Jan 2020 17:21:47 -0600 Subject: [PATCH] anv: Replace aux_surface.isl.size_B checks with aux_usage checks Now that aux_usage has a unified meaning, aux_usage == NONE if and only if aux_surface.isl.size_B > 0. In most of these cases, the question we're asking is "does have compression?" and not "have we allocated an aux surface for compression?". Reviewed-by: Lionel Landwerlin Tested-by: Marge Bot Part-of: --- src/intel/vulkan/anv_image.c | 10 +++++----- src/intel/vulkan/anv_private.h | 12 +++++------- src/intel/vulkan/genX_cmd_buffer.c | 2 +- 3 files changed, 11 insertions(+), 13 deletions(-) diff --git a/src/intel/vulkan/anv_image.c b/src/intel/vulkan/anv_image.c index e11d1659328..4be8f5aee6c 100644 --- a/src/intel/vulkan/anv_image.c +++ b/src/intel/vulkan/anv_image.c @@ -251,7 +251,7 @@ add_aux_state_tracking_buffer(struct anv_image *image, const struct anv_device *device) { assert(image && device); - assert(image->planes[plane].aux_surface.isl.size_B > 0 && + assert(image->planes[plane].aux_usage != ISL_AUX_USAGE_NONE && image->aspects & VK_IMAGE_ASPECT_ANY_COLOR_BIT_ANV); /* Compressed images must be tiled and therefore everything should be 4K @@ -532,7 +532,7 @@ make_surface(struct anv_device *dev, image->planes[plane].surface.isl.size_B)) <= (image->planes[plane].offset + image->planes[plane].size)); - if (image->planes[plane].aux_surface.isl.size_B) { + if (image->planes[plane].aux_usage != ISL_AUX_USAGE_NONE) { /* assert(image->planes[plane].fast_clear_state_offset == */ /* (image->planes[plane].aux_surface.offset + image->planes[plane].aux_surface.isl.size_B)); */ assert(image->planes[plane].fast_clear_state_offset < @@ -1121,7 +1121,7 @@ anv_layout_to_aux_state(const struct gen_device_info * const devinfo, uint32_t plane = anv_image_aspect_to_plane(image->aspects, aspect); /* If we don't have an aux buffer then aux state makes no sense */ - assert(image->planes[plane].aux_surface.isl.size_B > 0); + assert(image->planes[plane].aux_usage != ISL_AUX_USAGE_NONE); /* All images that use an auxiliary surface are required to be tiled. */ assert(image->planes[plane].surface.isl.tiling != ISL_TILING_LINEAR); @@ -1309,7 +1309,7 @@ anv_layout_to_aux_usage(const struct gen_device_info * const devinfo, /* If there is no auxiliary surface allocated, we must use the one and only * main buffer. */ - if (image->planes[plane].aux_surface.isl.size_B == 0) + if (image->planes[plane].aux_usage == ISL_AUX_USAGE_NONE) return ISL_AUX_USAGE_NONE; enum isl_aux_state aux_state = @@ -1381,7 +1381,7 @@ anv_layout_to_fast_clear_type(const struct gen_device_info * const devinfo, uint32_t plane = anv_image_aspect_to_plane(image->aspects, aspect); /* If there is no auxiliary surface allocated, there are no fast-clears */ - if (image->planes[plane].aux_surface.isl.size_B == 0) + if (image->planes[plane].aux_usage == ISL_AUX_USAGE_NONE) return ANV_FAST_CLEAR_NONE; /* We don't support MSAA fast-clears on Ivybridge or Bay Trail because they diff --git a/src/intel/vulkan/anv_private.h b/src/intel/vulkan/anv_private.h index 3c79a5d43e5..2795cbda48f 100644 --- a/src/intel/vulkan/anv_private.h +++ b/src/intel/vulkan/anv_private.h @@ -3487,15 +3487,13 @@ anv_image_aux_levels(const struct anv_image * const image, VkImageAspectFlagBits aspect) { uint32_t plane = anv_image_aspect_to_plane(image->aspects, aspect); + if (image->planes[plane].aux_usage == ISL_AUX_USAGE_NONE) + return 0; /* The Gen12 CCS aux surface is represented with only one level. */ - const uint8_t aux_logical_levels = - image->planes[plane].aux_surface.isl.tiling == ISL_TILING_GEN12_CCS ? - image->planes[plane].surface.isl.levels : - image->planes[plane].aux_surface.isl.levels; - - return image->planes[plane].aux_surface.isl.size_B > 0 ? - aux_logical_levels : 0; + return image->planes[plane].aux_surface.isl.tiling == ISL_TILING_GEN12_CCS ? + image->planes[plane].surface.isl.levels : + image->planes[plane].aux_surface.isl.levels; } /* Returns the number of auxiliary buffer layers attached to an image. */ diff --git a/src/intel/vulkan/genX_cmd_buffer.c b/src/intel/vulkan/genX_cmd_buffer.c index 7d02961a141..55697657505 100644 --- a/src/intel/vulkan/genX_cmd_buffer.c +++ b/src/intel/vulkan/genX_cmd_buffer.c @@ -4827,7 +4827,7 @@ cmd_buffer_begin_subpass(struct anv_cmd_buffer *cmd_buffer, if (GEN_GEN < 10 && (att_state->pending_load_aspects & VK_IMAGE_ASPECT_ANY_COLOR_BIT_ANV) && - image->planes[0].aux_surface.isl.size_B > 0 && + image->planes[0].aux_usage != ISL_AUX_USAGE_NONE && iview->planes[0].isl.base_level == 0 && iview->planes[0].isl.base_array_layer == 0) { if (att_state->aux_usage != ISL_AUX_USAGE_NONE) {