Mesa (main): st/mesa: execute glFlush asynchronously if no image has been imported/exported
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Fri Jun 4 16:35:32 UTC 2021
Module: Mesa
Branch: main
Commit: 057a702a3f6a78a8bcd347a74e5a79d70dfc4153
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=057a702a3f6a78a8bcd347a74e5a79d70dfc4153
Author: Marek Olšák <marek.olsak at amd.com>
Date: Fri May 21 17:52:27 2021 -0400
st/mesa: execute glFlush asynchronously if no image has been imported/exported
This improves viewperf performance and it shouldn't break synchronization
with external clients when it's indirectly implied by glFlush.
Reviewed-by: Emma Anholt <emma at anholt.net>
Reviewed-by: Adam Jackson <ajax at redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10937>
---
src/gallium/frontends/dri/dri_helpers.c | 2 ++
src/mesa/main/mtypes.h | 8 ++++++++
src/mesa/state_tracker/st_cb_eglimage.c | 1 +
src/mesa/state_tracker/st_cb_flush.c | 2 +-
4 files changed, 12 insertions(+), 1 deletion(-)
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/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;
}
diff --git a/src/mesa/state_tracker/st_cb_flush.c b/src/mesa/state_tracker/st_cb_flush.c
index bec1c2f177b..ee72c331cdd 100644
--- a/src/mesa/state_tracker/st_cb_flush.c
+++ b/src/mesa/state_tracker/st_cb_flush.c
@@ -98,7 +98,7 @@ st_glFlush(struct gl_context *ctx)
* synchronization issues. Calling finish() here will just hide
* problems that need to be fixed elsewhere.
*/
- st_flush(st, NULL, 0);
+ st_flush(st, NULL, ctx->Shared->HasExternallySharedImages ? 0 : PIPE_FLUSH_ASYNC);
st_manager_flush_frontbuffer(st);
}
More information about the mesa-commit
mailing list