anv: Add aux-map translation for gen12+

Signed-off-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Reviewed-by: Jordan Justen <jordan.l.justen@intel.com>
This commit is contained in:
Lionel Landwerlin
2019-10-21 17:17:44 +03:00
committed by Jordan Justen
parent 7737f56544
commit 6af8a4acc4
2 changed files with 44 additions and 0 deletions

View File

@@ -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

View File

@@ -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,