summaryrefslogtreecommitdiffstats
path: root/src/gallium/state_trackers/dri
diff options
context:
space:
mode:
authorGregory Hainaut <[email protected]>2017-05-29 13:18:28 +0200
committerEmil Velikov <[email protected]>2017-05-29 17:07:04 +0100
commit79f0fe655dfe3e572a6f5325844f96150b8c5cee (patch)
tree05012d250b301562822db933f1109fb0f3179d25 /src/gallium/state_trackers/dri
parent3fde8db53a6296ad8f635843f58717ebd9a36e85 (diff)
glthread/gallium: require safe_glthread to start glthread
Print an error message for the user if the requirement isn't met, or we're not thread safe. v2: based on Nicolai feedbacks Check the DRI extension version v3: based on Emil feedbacks improve commit and error messages. use backgroundCallable variable to improve readability v5: based on Emil feedbacks Properly check the function pointer Signed-off-by: Gregory Hainaut <[email protected]> Reviewed-by: Emil Velikov <[email protected]>
Diffstat (limited to 'src/gallium/state_trackers/dri')
-rw-r--r--src/gallium/state_trackers/dri/dri_context.c21
1 files changed, 17 insertions, 4 deletions
diff --git a/src/gallium/state_trackers/dri/dri_context.c b/src/gallium/state_trackers/dri/dri_context.c
index 92d79849c4a..ec555e44d74 100644
--- a/src/gallium/state_trackers/dri/dri_context.c
+++ b/src/gallium/state_trackers/dri/dri_context.c
@@ -58,6 +58,8 @@ dri_create_context(gl_api api, const struct gl_config * visual,
enum st_context_error ctx_err = 0;
unsigned allowed_flags = __DRI_CTX_FLAG_DEBUG |
__DRI_CTX_FLAG_FORWARD_COMPATIBLE;
+ const __DRIbackgroundCallableExtension *backgroundCallable =
+ screen->sPriv->dri2.backgroundCallable;
if (screen->has_reset_status_query)
allowed_flags |= __DRI_CTX_FLAG_ROBUST_BUFFER_ACCESS;
@@ -158,10 +160,21 @@ dri_create_context(gl_api api, const struct gl_config * visual,
/* 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 (backgroundCallable && backgroundCallable->base.version >= 2 &&
+ backgroundCallable->isThreadSafe) {
+
+ 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");
+ }
+ }
*error = __DRI_CTX_ERROR_SUCCESS;
return GL_TRUE;