From 87d20549c869575b693b3fcc196f5611dcf459ee Mon Sep 17 00:00:00 2001 From: Nanley Chery Date: Wed, 13 Jan 2021 14:34:13 -0800 Subject: [PATCH] iris: Disable aux as needed in iris_flush_resource Disable compression in iris_flush_resource if the resource lacks a modifier. When a caller wants to prepare such a resource for sharing (via eglCreateImage for example), this change enables all reference holders to access the resource in a common manner - without compression. This fixes misrendering with 3D-accelerated qemu. A piglit test which reproduces qemu's behavior, ext_image_dma_buf_import-export-tex, is also enabled to pass. Cc: mesa-stable Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/2678 Reviewed-by: Kenneth Graunke Part-of: (cherry picked from commit 40d6b92de9432137db4799d482afe7ae5ad52ae8) --- .pick_status.json | 2 +- src/gallium/drivers/iris/iris_resource.c | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/.pick_status.json b/.pick_status.json index 24306db0922..11ccc318a1b 100644 --- a/.pick_status.json +++ b/.pick_status.json @@ -346,7 +346,7 @@ "description": "iris: Disable aux as needed in iris_flush_resource", "nominated": true, "nomination_type": 0, - "resolution": 0, + "resolution": 1, "master_sha": null, "because_sha": null }, diff --git a/src/gallium/drivers/iris/iris_resource.c b/src/gallium/drivers/iris/iris_resource.c index 7d1c3ba1180..8ce3c8a2472 100644 --- a/src/gallium/drivers/iris/iris_resource.c +++ b/src/gallium/drivers/iris/iris_resource.c @@ -1165,6 +1165,20 @@ iris_flush_resource(struct pipe_context *ctx, struct pipe_resource *resource) 0, INTEL_REMAINING_LAYERS, mod ? mod->aux_usage : ISL_AUX_USAGE_NONE, mod ? mod->supports_clear_color : false); + + if (!res->mod_info && res->aux.usage != ISL_AUX_USAGE_NONE) { + /* flush_resource may be used to prepare an image for sharing external + * to the driver (e.g. via eglCreateImage). To account for this, make + * sure to get rid of any compression that a consumer wouldn't know how + * to handle. + */ + for (int i = 0; i < IRIS_BATCH_COUNT; i++) { + if (iris_batch_references(&ice->batches[i], res->bo)) + iris_batch_flush(&ice->batches[i]); + } + + iris_resource_disable_aux(res); + } } static void