Module: Mesa Branch: staging/23.3 Commit: 58e5c892651e3a7e8fb4bd0e5cb7861f610de026 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=58e5c892651e3a7e8fb4bd0e5cb7861f610de026
Author: Lionel Landwerlin <lionel.g.landwer...@intel.com> Date: Wed Nov 22 16:27:39 2023 +0200 anv: track & unbind image aux-tt binding This solves a problem when you have a big memory chunk of which some regions are bound to images. If the image is destroyed, currently the aux-tt mapping stays and prevent any new image aux-tt mapping within that region, until the memory is freed. This maps & unmaps the aux-tt region at respectively bind & destroy time, so that the memory chunks can be map through aux-tt. If there is aliasing of memory to 2 different images, then the first one "wins" the aux mapping and gets compression support. The second one doesn´t. Signed-off-by: Lionel Landwerlin <lionel.g.landwer...@intel.com> Fixes: ee6e2bc4a3 ("anv: Place images into the aux-map when safe to do so") Tested-by: Dmitry Osipenko <dmitry.osipe...@collabora.com> Reviewed-by: José Roberto de Souza <jose.so...@intel.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/26335> (cherry picked from commit 7b87e1afbcd880dd25771a42d65585da44faa444) --- .pick_status.json | 2 +- src/intel/vulkan/anv_image.c | 23 +++++++++++++++++++++-- src/intel/vulkan/anv_private.h | 2 ++ 3 files changed, 24 insertions(+), 3 deletions(-) diff --git a/.pick_status.json b/.pick_status.json index c5bbb4b782d..46e7bd4ef9c 100644 --- a/.pick_status.json +++ b/.pick_status.json @@ -1744,7 +1744,7 @@ "description": "anv: track & unbind image aux-tt binding", "nominated": true, "nomination_type": 1, - "resolution": 0, + "resolution": 1, "main_sha": null, "because_sha": "ee6e2bc4a31345e50b3c674cdae233a5de5179d1", "notes": null diff --git a/src/intel/vulkan/anv_image.c b/src/intel/vulkan/anv_image.c index 43447ecfff6..77a2d733e72 100644 --- a/src/intel/vulkan/anv_image.c +++ b/src/intel/vulkan/anv_image.c @@ -1704,6 +1704,25 @@ anv_image_finish(struct anv_image *image) if (anv_image_is_sparse(image)) anv_image_finish_sparse_bindings(image); + /* Unmap a CCS so that if the bound region of the image is rebound to + * another image, the AUX tables will be cleared to allow for a new + * mapping. + */ + for (int p = 0; p < image->n_planes; ++p) { + if (!image->planes[p].aux_ccs_mapped) + continue; + + const struct anv_address main_addr = + anv_image_address(image, + &image->planes[p].primary_surface.memory_range); + const struct isl_surf *surf = + &image->planes[p].primary_surface.isl; + + intel_aux_map_del_mapping(device->aux_map_ctx, + anv_address_physical(main_addr), + surf->size_B); + } + if (image->from_gralloc) { assert(!image->disjoint); assert(image->n_planes == 1); @@ -2312,12 +2331,12 @@ VkResult anv_BindImageMemory2( &image->planes[p].primary_surface.isl; const uint64_t format_bits = intel_aux_map_format_bits_for_isl_surf(surf); - const bool mapped = + image->planes[p].aux_ccs_mapped = intel_aux_map_add_mapping(device->aux_map_ctx, anv_address_physical(main_addr), anv_address_physical(aux_addr), surf->size_B, format_bits); - if (mapped) + if (image->planes[p].aux_ccs_mapped) continue; } diff --git a/src/intel/vulkan/anv_private.h b/src/intel/vulkan/anv_private.h index 5f0947cb330..d963e6e5177 100644 --- a/src/intel/vulkan/anv_private.h +++ b/src/intel/vulkan/anv_private.h @@ -4686,6 +4686,8 @@ struct anv_image { * boolean will prevent the usage of CC_ONE. */ bool can_non_zero_fast_clear; + + bool aux_ccs_mapped; } planes[3]; struct anv_image_memory_range vid_dmv_top_surface;