From 859e2de1f35b2e827102628265ab8b63739c7a04 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Tapani=20P=C3=A4lli?= Date: Mon, 2 Jan 2023 11:00:26 +0200 Subject: [PATCH] iris: let isl set tiling mode for external resources MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Patch sets memory object external format (which is otherwise PIPE_FORMAT_NONE for memory objects) before main surface gets configured. With this we can add a check that when dealing with external resource that has no modifier set, we let isl figure out the tiling mode. Fixes memobj tests on DG2: piglit.spec.ext_external_objects.vk-image-display-muliple-textures piglit.spec.ext_external_objects.vk-image-display-overwrite piglit.spec.ext_external_objects.vk-depth-display piglit.spec.ext_external_objects.vk-image-display piglit.spec.ext_external_objects.vk-stencil-display v2: add assert and comment on tiling decision (Ken) Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/7684 Cc: mesa-stable Signed-off-by: Tapani Pälli Reviewed-by: Simon Zeni Reviewed-by: Kenneth Graunke Part-of: (cherry picked from commit 319d485679848f9c48e1fc7b34ecf97fc39ac1d0) --- .pick_status.json | 2 +- src/gallium/drivers/iris/iris_resource.c | 18 +++++++++++++----- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/.pick_status.json b/.pick_status.json index 567c562..e7a25c9 100644 --- a/.pick_status.json +++ b/.pick_status.json @@ -1165,7 +1165,7 @@ "description": "iris: let isl set tiling mode for external resources", "nominated": true, "nomination_type": 0, - "resolution": 0, + "resolution": 1, "main_sha": null, "because_sha": null }, diff --git a/src/gallium/drivers/iris/iris_resource.c b/src/gallium/drivers/iris/iris_resource.c index 56dee15..0199703 100644 --- a/src/gallium/drivers/iris/iris_resource.c +++ b/src/gallium/drivers/iris/iris_resource.c @@ -674,6 +674,14 @@ iris_resource_configure_main(const struct iris_screen *screen, } else if (templ->usage == PIPE_USAGE_STAGING || templ->bind & (PIPE_BIND_LINEAR | PIPE_BIND_CURSOR)) { tiling_flags = ISL_TILING_LINEAR_BIT; + } else if (res->external_format != PIPE_FORMAT_NONE) { + /* This came from iris_resource_from_memobj and didn't have + * PIPE_BIND_LINEAR set, so "optimal" tiling is desired. Let isl + * select the tiling. The implicit contract is that both drivers + * will arrive at the same tiling by using the same code to decide. + */ + assert(modifier == DRM_FORMAT_MOD_INVALID); + tiling_flags = ISL_TILING_ANY_MASK; } else if (!screen->devinfo.has_tiling_uapi && (templ->bind & (PIPE_BIND_SCANOUT | PIPE_BIND_SHARED))) { tiling_flags = ISL_TILING_LINEAR_BIT; @@ -1461,17 +1469,17 @@ iris_resource_from_memobj(struct pipe_screen *pscreen, if (!res) return NULL; + res->bo = memobj->bo; + res->offset = offset; + res->external_format = templ->format; + res->internal_format = templ->format; + if (templ->flags & PIPE_RESOURCE_FLAG_TEXTURING_MORE_LIKELY) { UNUSED const bool isl_surf_created_successfully = iris_resource_configure_main(screen, res, templ, DRM_FORMAT_MOD_INVALID, 0); assert(isl_surf_created_successfully); } - res->bo = memobj->bo; - res->offset = offset; - res->external_format = memobj->format; - res->internal_format = templ->format; - iris_bo_reference(memobj->bo); return &res->base.b; -- 2.7.4