if (!bo)
return NULL;
+ if (bo->aux_map_address) {
+ /* This buffer was associated with an aux-buffer range. We make sure
+ * that buffers are not reused from the cache while the buffer is (busy)
+ * being used by an executing batch. Since we are here, the buffer is no
+ * longer being used by a batch and the buffer was deleted (in order to
+ * end up in the cache). Therefore its old aux-buffer range can be
+ * removed from the aux-map.
+ */
+ if (bo->bufmgr->aux_map_ctx)
+ gen_aux_map_unmap_range(bo->bufmgr->aux_map_ctx, bo->gtt_offset,
+ bo->size);
+ bo->aux_map_address = 0;
+ }
+
/* If the cached BO isn't in the right memory zone, or the alignment
* isn't sufficient, free the old memory and assign it a new address.
*/
bo->gem_handle, bo->name, strerror(errno));
}
+ if (bo->aux_map_address && bo->bufmgr->aux_map_ctx) {
+ gen_aux_map_unmap_range(bo->bufmgr->aux_map_ctx, bo->gtt_offset,
+ bo->size);
+ }
+
/* Return the VMA for reuse */
vma_free(bo->bufmgr, bo->gtt_offset, bo->size);
#include "iris_context.h"
#include "iris_resource.h"
#include "iris_screen.h"
+#include "intel/common/gen_aux_map.h"
#include "intel/dev/gen_debug.h"
#include "isl/isl.h"
#include "drm-uapi/drm_fourcc.h"
return devinfo->gen >= 10 ? screen->isl_dev.ss.clear_color_state_size : 0;
}
+static void
+map_aux_addresses(struct iris_screen *screen, struct iris_resource *res)
+{
+ const struct gen_device_info *devinfo = &screen->devinfo;
+ if (devinfo->gen >= 12 && isl_aux_usage_has_ccs(res->aux.usage)) {
+ void *aux_map_ctx = iris_bufmgr_get_aux_map_context(screen->bufmgr);
+ assert(aux_map_ctx);
+ gen_aux_map_add_image(aux_map_ctx, &res->surf, res->bo->gtt_offset,
+ res->aux.bo->gtt_offset + res->aux.offset);
+ res->bo->aux_map_address = res->aux.bo->gtt_offset;
+ }
+}
+
/**
* Configure aux for the resource, but don't allocate it. For images which
* might be shared with modifiers, we must allocate the image and aux data in
iris_get_aux_clear_color_state_size(screen)))
return false;
+ map_aux_addresses(screen, res);
+
return true;
}
res->aux.clear_color_offset += aux_offset;
if (!iris_resource_init_aux_buf(res, flags, clear_color_state_size))
aux_enabled = false;
+ map_aux_addresses(screen, res);
}
}