From: Lionel Landwerlin Date: Mon, 21 Oct 2019 14:17:44 +0000 (+0300) Subject: anv: Add aux-map translation for gen12+ X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=6af8a4acc4a4a30608d221b80ac3aa848db309a7;p=mesa.git anv: Add aux-map translation for gen12+ Signed-off-by: Lionel Landwerlin Reviewed-by: Jordan Justen --- diff --git a/src/intel/vulkan/anv_image.c b/src/intel/vulkan/anv_image.c index bd00bc83e13..84b9fde0751 100644 --- a/src/intel/vulkan/anv_image.c +++ b/src/intel/vulkan/anv_image.c @@ -34,6 +34,8 @@ #include "vk_util.h" #include "util/u_math.h" +#include "common/gen_aux_map.h" + #include "vk_format_info.h" static isl_surf_usage_flags_t @@ -778,6 +780,12 @@ anv_DestroyImage(VkDevice _device, VkImage _image, return; for (uint32_t p = 0; p < image->n_planes; ++p) { + if (anv_image_plane_uses_aux_map(device, image, p) && + image->planes[p].address.bo) { + gen_aux_map_unmap_range(device->aux_map_ctx, + image->planes[p].aux_map_surface_address, + image->planes[p].surface.isl.size_B); + } if (image->planes[p].bo_is_owned) { assert(image->planes[p].address.bo != NULL); anv_bo_cache_release(device, &device->bo_cache, @@ -797,6 +805,12 @@ static void anv_image_bind_memory_plane(struct anv_device *device, assert(!image->planes[plane].bo_is_owned); if (!memory) { + if (anv_image_plane_uses_aux_map(device, image, plane) && + image->planes[plane].address.bo) { + gen_aux_map_unmap_range(device->aux_map_ctx, + image->planes[plane].aux_map_surface_address, + image->planes[plane].surface.isl.size_B); + } image->planes[plane].address = ANV_NULL_ADDRESS; return; } @@ -805,6 +819,20 @@ static void anv_image_bind_memory_plane(struct anv_device *device, .bo = memory->bo, .offset = memory_offset, }; + + if (anv_image_plane_uses_aux_map(device, image, plane)) { + image->planes[plane].aux_map_surface_address = + anv_address_physical( + anv_address_add(image->planes[plane].address, + image->planes[plane].surface.offset)); + + gen_aux_map_add_image(device->aux_map_ctx, + &image->planes[plane].surface.isl, + image->planes[plane].aux_map_surface_address, + anv_address_physical( + anv_address_add(image->planes[plane].address, + image->planes[plane].aux_surface.offset))); + } } /* We are binding AHardwareBuffer. Get a description, resolve the diff --git a/src/intel/vulkan/anv_private.h b/src/intel/vulkan/anv_private.h index 7e83db04346..ef246e4612e 100644 --- a/src/intel/vulkan/anv_private.h +++ b/src/intel/vulkan/anv_private.h @@ -3202,6 +3202,13 @@ struct anv_image { */ struct anv_address address; + /** + * Address of the main surface used to fill the aux map table. This is + * used at destruction of the image since the Vulkan spec does not + * guarantee that the address.bo field we still be valid at destruction. + */ + uint64_t aux_map_surface_address; + /** * When destroying the image, also free the bo. * */ @@ -3324,6 +3331,15 @@ anv_can_sample_with_hiz(const struct gen_device_info * const devinfo, return image->samples == 1; } +static inline bool +anv_image_plane_uses_aux_map(const struct anv_device *device, + const struct anv_image *image, + uint32_t plane) +{ + return device->info.has_aux_map && + isl_aux_usage_has_ccs(image->planes[plane].aux_usage); +} + void anv_cmd_buffer_mark_image_written(struct anv_cmd_buffer *cmd_buffer, const struct anv_image *image,