From 3da170faaec2a57d76e668ab56781621c23c6703 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Ol=C5=A1=C3=A1k?= Date: Sat, 12 Jun 2021 12:31:28 -0400 Subject: [PATCH] glthread: change when glFlush flushes asynchronously This fixes the flushing with external textures. We don't know if we need to flush synchronously with multiple contexts, so I removed that. Acked-By: Mike Blumenkrantz Reviewed-by: Adam Jackson Part-of: --- src/gallium/frontends/dri/dri_helpers.c | 2 ++ src/mapi/glapi/gen/gl_API.xml | 8 +------- src/mesa/main/mtypes.h | 8 ++++++++ src/mesa/state_tracker/st_cb_eglimage.c | 1 + 4 files changed, 12 insertions(+), 7 deletions(-) diff --git a/src/gallium/frontends/dri/dri_helpers.c b/src/gallium/frontends/dri/dri_helpers.c index 4170a4c9533..583ce67978d 100644 --- a/src/gallium/frontends/dri/dri_helpers.c +++ b/src/gallium/frontends/dri/dri_helpers.c @@ -309,6 +309,7 @@ dri2_create_image_from_renderbuffer2(__DRIcontext *context, if (dri2_get_mapping_by_format(img->dri_format)) p_ctx->flush_resource(p_ctx, tex); + ctx->Shared->HasExternallySharedImages = true; *error = __DRI_IMAGE_ERROR_SUCCESS; return img; } @@ -407,6 +408,7 @@ dri2_create_from_texture(__DRIcontext *context, int target, unsigned texture, if (dri2_get_mapping_by_format(img->dri_format)) p_ctx->flush_resource(p_ctx, tex); + ctx->Shared->HasExternallySharedImages = true; *error = __DRI_IMAGE_ERROR_SUCCESS; return img; } diff --git a/src/mapi/glapi/gen/gl_API.xml b/src/mapi/glapi/gen/gl_API.xml index f0496a14285..1d5575f296a 100644 --- a/src/mapi/glapi/gen/gl_API.xml +++ b/src/mapi/glapi/gen/gl_API.xml @@ -2399,14 +2399,8 @@ - + marshal_call_after="_mesa_glthread_flush_batch(ctx); if (ctx->Shared->HasExternallySharedImages) _mesa_glthread_finish(ctx);"> diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h index ee1c19df9a2..e7474ad0262 100644 --- a/src/mesa/main/mtypes.h +++ b/src/mesa/main/mtypes.h @@ -3474,6 +3474,14 @@ struct gl_shared_state * frequency changes. */ bool DisjointOperation; + + /** + * Whether at least one image has been imported or exported, excluding + * the default framebuffer. If this is false, glFlush can be executed + * asynchronously because there is no invisible dependency on external + * users. + */ + bool HasExternallySharedImages; }; diff --git a/src/mesa/state_tracker/st_cb_eglimage.c b/src/mesa/state_tracker/st_cb_eglimage.c index 0c487d01021..9bd53148aa7 100644 --- a/src/mesa/state_tracker/st_cb_eglimage.c +++ b/src/mesa/state_tracker/st_cb_eglimage.c @@ -192,6 +192,7 @@ st_get_egl_image(struct gl_context *ctx, GLeglImageOES image_handle, return false; } + ctx->Shared->HasExternallySharedImages = true; return true; }