diff --git a/src/gallium/drivers/iris/iris_blit.c b/src/gallium/drivers/iris/iris_blit.c index 6cfdadeb80f..30fc6c8b586 100644 --- a/src/gallium/drivers/iris/iris_blit.c +++ b/src/gallium/drivers/iris/iris_blit.c @@ -237,6 +237,7 @@ iris_blorp_surf_for_resource(struct isl_device *isl_dev, bool is_dest) { struct iris_resource *res = (void *) p_res; + const struct intel_device_info *devinfo = isl_dev->info; *surf = (struct blorp_surf) { .surf = &res->surf, @@ -247,6 +248,7 @@ iris_blorp_surf_for_resource(struct isl_device *isl_dev, .mocs = iris_mocs(res->bo, isl_dev, is_dest ? ISL_SURF_USAGE_RENDER_TARGET_BIT : ISL_SURF_USAGE_TEXTURE_BIT), + .local_hint = iris_bo_likely_local(res->bo), }, .aux_usage = aux_usage, }; @@ -258,6 +260,8 @@ iris_blorp_surf_for_resource(struct isl_device *isl_dev, .offset = res->aux.offset, .reloc_flags = is_dest ? EXEC_OBJECT_WRITE : 0, .mocs = iris_mocs(res->bo, isl_dev, 0), + .local_hint = devinfo->has_flat_ccs || + iris_bo_likely_local(res->aux.bo), }; surf->clear_color = res->aux.clear_color; surf->clear_color_addr = (struct blorp_address) { @@ -265,6 +269,8 @@ iris_blorp_surf_for_resource(struct isl_device *isl_dev, .offset = res->aux.clear_color_offset, .reloc_flags = 0, .mocs = iris_mocs(res->aux.clear_color_bo, isl_dev, 0), + .local_hint = devinfo->has_flat_ccs || + iris_bo_likely_local(res->aux.clear_color_bo), }; } } @@ -643,12 +649,14 @@ iris_copy_region(struct blorp_context *blorp, .buffer = src_res->bo, .offset = src_box->x, .mocs = iris_mocs(src_res->bo, &screen->isl_dev, ISL_SURF_USAGE_RENDER_TARGET_BIT), + .local_hint = iris_bo_likely_local(src_res->bo), }; struct blorp_address dst_addr = { .buffer = dst_res->bo, .offset = dstx, .reloc_flags = EXEC_OBJECT_WRITE, .mocs = iris_mocs(dst_res->bo, &screen->isl_dev, ISL_SURF_USAGE_TEXTURE_BIT), + .local_hint = iris_bo_likely_local(dst_res->bo), }; iris_emit_buffer_barrier_for(batch, src_res->bo, diff --git a/src/gallium/drivers/iris/iris_blorp.c b/src/gallium/drivers/iris/iris_blorp.c index 1db81b95b75..11bb3f7f65d 100644 --- a/src/gallium/drivers/iris/iris_blorp.c +++ b/src/gallium/drivers/iris/iris_blorp.c @@ -195,6 +195,7 @@ blorp_alloc_vertex_buffer(struct blorp_batch *blorp_batch, .offset = offset, .mocs = iris_mocs(bo, &batch->screen->isl_dev, ISL_SURF_USAGE_VERTEX_BUFFER_BIT), + .local_hint = iris_bo_likely_local(bo), }; return map; @@ -242,6 +243,8 @@ blorp_get_workaround_address(struct blorp_batch *blorp_batch) return (struct blorp_address) { .buffer = batch->screen->workaround_address.bo, .offset = batch->screen->workaround_address.offset, + .local_hint = + iris_bo_likely_local(batch->screen->workaround_address.bo), }; } diff --git a/src/gallium/drivers/iris/iris_bufmgr.h b/src/gallium/drivers/iris/iris_bufmgr.h index 36564089ce3..8ecea2e51e7 100644 --- a/src/gallium/drivers/iris/iris_bufmgr.h +++ b/src/gallium/drivers/iris/iris_bufmgr.h @@ -414,6 +414,23 @@ iris_bo_is_exported(const struct iris_bo *bo) return bo->real.exported; } +/** + * True if the BO prefers to reside in device-local memory. + * + * We don't consider eviction here; this is meant to be a performance hint. + * It will return true for BOs allocated from the LMEM or LMEM+SMEM heaps, + * even if the buffer has been temporarily evicted to system memory. + */ +static inline bool +iris_bo_likely_local(const struct iris_bo *bo) +{ + if (!bo) + return false; + + bo = iris_get_backing_bo((struct iris_bo *) bo); + return bo->real.heap != IRIS_HEAP_SYSTEM_MEMORY; +} + static inline enum iris_mmap_mode iris_bo_mmap_mode(const struct iris_bo *bo) { diff --git a/src/intel/blorp/blorp.h b/src/intel/blorp/blorp.h index fffbbaa7748..4e4804fee75 100644 --- a/src/intel/blorp/blorp.h +++ b/src/intel/blorp/blorp.h @@ -106,6 +106,13 @@ struct blorp_address { uint64_t offset; unsigned reloc_flags; uint32_t mocs; + + /** + * True if this buffer is intended to live in device-local memory. + * This is only a performance hint; it's OK to set it to true even + * if eviction has temporarily forced the buffer to system memory. + */ + bool local_hint; }; struct blorp_surf