From c769790695d60d3f6a2e0a05adece0573c4e76ac Mon Sep 17 00:00:00 2001 From: Nanley Chery Date: Thu, 17 Jul 2025 10:38:32 -0400 Subject: [PATCH] iris: Fix image reallocation for sharing On XeKMD, BOs need to be created with a vm_id of zero in order to get prime handles. That only occurs if the image was created with PIPE_BIND_SHARED/BO_ALLOC_SHARED. Ensure that shareable images have this flag in iris_flush_resource(). Fixes the dmabufshare demo on BMG with INTEL_DEBUG=noccs and mesa hacked to disable suballocation. Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/13511 Reviewed-by: Jianxun Zhang Part-of: --- src/gallium/drivers/iris/iris_resource.c | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/src/gallium/drivers/iris/iris_resource.c b/src/gallium/drivers/iris/iris_resource.c index 8175fd1e618..58f0958e20c 100644 --- a/src/gallium/drivers/iris/iris_resource.c +++ b/src/gallium/drivers/iris/iris_resource.c @@ -1675,19 +1675,10 @@ iris_flush_resource(struct pipe_context *ctx, struct pipe_resource *resource) { struct iris_context *ice = (struct iris_context *)ctx; struct iris_resource *res = (void *) resource; - const struct isl_drm_modifier_info *mod = res->mod_info; /* flush_resource() may be used to prepare an image for sharing externally - * with other clients (e.g. via eglCreateImage). To account for this, we - * make sure to eliminate suballocation and any compression that a consumer - * wouldn't know how to handle. - * - * On Xe2+ platforms, when an image wasn't created with a modifier that - * supports compression, we need to resolve by copying the image to an - * uncompressed bo. + * with other clients (e.g. via eglCreateImage). */ - bool need_pat_resolve = iris_heap_is_compressed(res->bo->real.heap) && - !(res->base.b.bind & PIPE_BIND_SHARED); - bool need_reallocate = !iris_bo_is_real(res->bo) || need_pat_resolve; + bool need_reallocate = !iris_bo_is_external(res->bo); if (need_reallocate) { const unsigned dmabuf_bind = PIPE_BIND_SHARED | PIPE_BIND_SCANOUT; assert((res->base.b.bind & dmabuf_bind) == 0); @@ -1695,6 +1686,7 @@ iris_flush_resource(struct pipe_context *ctx, struct pipe_resource *resource) assert((res->base.b.bind & dmabuf_bind) == dmabuf_bind); } + const struct isl_drm_modifier_info *mod = res->mod_info; iris_resource_prepare_access(ice, res, 0, INTEL_REMAINING_LEVELS, 0, INTEL_REMAINING_LAYERS,