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@anholt.net>
Reviewed-by: Adam Jackson <ajax@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10937>
This commit is contained in:
Marek Olšák 2021-05-21 17:52:27 -04:00 committed by Marge Bot
parent 4304a7adc7
commit 057a702a3f
4 changed files with 12 additions and 1 deletions

View file

@ -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;
}

View file

@ -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;
};

View file

@ -192,6 +192,7 @@ st_get_egl_image(struct gl_context *ctx, GLeglImageOES image_handle,
return false;
}
ctx->Shared->HasExternallySharedImages = true;
return true;
}

View file

@ -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);
}