[Mesa-dev] [RFC 2/2] glthread/gallium: require safe_glthread to start glthread

Gregory Hainaut gregory.hainaut at gmail.com
Fri Apr 28 21:11:33 UTC 2017


Otherwise print a warning

Signed-off-by: Gregory Hainaut <gregory.hainaut at gmail.com>
---
 src/gallium/state_trackers/dri/dri_context.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/src/gallium/state_trackers/dri/dri_context.c b/src/gallium/state_trackers/dri/dri_context.c
index 92d79849c4..35b0c454be 100644
--- a/src/gallium/state_trackers/dri/dri_context.c
+++ b/src/gallium/state_trackers/dri/dri_context.c
@@ -153,22 +153,28 @@ dri_create_context(gl_api api, const struct gl_config * visual,
 
    if (ctx->st->cso_context) {
       ctx->pp = pp_init(ctx->st->pipe, screen->pp_enabled, ctx->st->cso_context);
       ctx->hud = hud_create(ctx->st->pipe, ctx->st->cso_context);
    }
 
    /* Do this last. */
    if (ctx->st->start_thread &&
        /* the driver loader must implement this */
        screen->sPriv->dri2.backgroundCallable &&
-       driQueryOptionb(&screen->optionCache, "mesa_glthread"))
-      ctx->st->start_thread(ctx->st);
+       driQueryOptionb(&screen->optionCache, "mesa_glthread")) {
+
+      if (ctx->sPriv->dri2.backgroundCallable->isGlThreadSafe(cPriv->loaderPrivate))
+         ctx->st->start_thread(ctx->st);
+      else
+         fprintf(stderr, "MESA warning: glthread can't be enabled because "
+               "the application didn't call XInitThreads\n");
+   }
 
    *error = __DRI_CTX_ERROR_SUCCESS;
    return GL_TRUE;
 
  fail:
    if (ctx && ctx->st)
       ctx->st->destroy(ctx->st);
 
    free(ctx);
    return GL_FALSE;
-- 
2.11.0



More information about the mesa-dev mailing list