frontend/dri: make the backgroundCallable extension optional

It's only needed by X11/DRI2. This allows glthread to be used by android,
drm, wayland, and device (EGL backend).

This is the only solution to allow the egl/drm backend to work with glthread
without ugly hacks between libgbm and libEGL.

Reviewed-by: Adam Jackson <ajax@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/18223>
This commit is contained in:
Marek Olšák 2022-08-22 22:28:58 -04:00 committed by Marge Bot
parent 7c1f8b63ad
commit c0a05b604a
2 changed files with 12 additions and 18 deletions

View file

@ -206,20 +206,18 @@ dri_create_context(gl_api api, const struct gl_config * visual,
/* Do this last. */
if (ctx->st->start_thread &&
driQueryOptionb(&screen->dev->option_cache, "mesa_glthread")) {
driQueryOptionb(&screen->dev->option_cache, "mesa_glthread")) {
bool safe = true;
if (backgroundCallable && backgroundCallable->base.version >= 2 &&
backgroundCallable->isThreadSafe) {
/* This is only needed by X11/DRI2, which can be unsafe. */
if (backgroundCallable &&
backgroundCallable->base.version >= 2 &&
backgroundCallable->isThreadSafe &&
!backgroundCallable->isThreadSafe(cPriv->loaderPrivate))
safe = false;
if (backgroundCallable->isThreadSafe(cPriv->loaderPrivate))
ctx->st->start_thread(ctx->st);
else
fprintf(stderr, "dri_create_context: glthread isn't thread safe "
"- missing call XInitThreads\n");
} else {
fprintf(stderr, "dri_create_context: requested glthread but driver "
"is missing backgroundCallable V2 extension\n");
}
if (safe)
ctx->st->start_thread(ctx->st);
}
*error = __DRI_CTX_ERROR_SUCCESS;

View file

@ -824,12 +824,8 @@ dri_set_background_context(struct st_context_iface *st,
const __DRIbackgroundCallableExtension *backgroundCallable =
ctx->sPriv->dri2.backgroundCallable;
/* Note: Mesa will only call this function if GL multithreading is enabled
* We only do that if the loader exposed the __DRI_BACKGROUND_CALLABLE
* extension. So we know that backgroundCallable is not NULL.
*/
assert(backgroundCallable);
backgroundCallable->setBackgroundContext(ctx->cPriv->loaderPrivate);
if (backgroundCallable)
backgroundCallable->setBackgroundContext(ctx->cPriv->loaderPrivate);
if (ctx->hud)
hud_add_queue_for_monitoring(ctx->hud, queue_info);