[Mesa-dev] [PATCH v2 2/2] glthread/gallium: require safe_glthread to start glthread
Gregory Hainaut
gregory.hainaut at gmail.com
Wed May 3 16:34:29 UTC 2017
Otherwise print a warning
v2: based on Nicolai feedback
Check the DRI extension version
Signed-off-by: Gregory Hainaut <gregory.hainaut at gmail.com>
---
src/gallium/state_trackers/dri/dri_context.c | 12 ++++++++++--
1 file changed, 10 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..7c074be63f 100644
--- a/src/gallium/state_trackers/dri/dri_context.c
+++ b/src/gallium/state_trackers/dri/dri_context.c
@@ -153,22 +153,30 @@ 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);
+ /* v2 gives us isGlThreadSafe to ensure thread safety */
+ screen->sPriv->dri2.backgroundCallable->base.version >= 2 &&
+ 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