Re: [Mesa-dev] [PATCH v2 2/2] glthread/gallium: require safe_glthread to start glthread

2017-05-04 Thread Emil Velikov
On 3 May 2017 at 17:34, Gregory Hainaut  wrote:
> Otherwise print a warning
>
s/print a warning/$something_bad_that_can_happen/

Print an error message for the user if the requirement is not met, or
we're not thread safe.

> v2: based on Nicolai feedback
> Check the DRI extension version
>
> Signed-off-by: Gregory Hainaut 
> ---
>  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(>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(>optionCache, "mesa_glthread")) {
> +
> +  if 
> (ctx->sPriv->dri2.backgroundCallable->isGlThreadSafe(cPriv->loaderPrivate))
Checking screen->sPriv above to use ctx->sPriv here? Something looks a bit off.

> + ctx->st->start_thread(ctx->st);
> +  else
> + fprintf(stderr, "MESA warning: glthread can't be enabled because "
> +   "the application didn't call XInitThreads\n");
> +   }
>

   if (ctx->st->start_thread &&
   driQueryOptionb(>optionCache, "mesa_glthread")) {

  if (screen->sPriv->dri2.backgroundCallable &&
  screen->sPriv->dri2.backgroundCallable->base.version >= 2 &&
  screen->sPriv->dri2.backgroundCallable->isGlThreadSafe) {

 if 
(screen->sPriv->dri2.backgroundCallable->isGlThreadSafe(cPriv->loaderPrivate))
ctx->st->start_thread(ctx->st);
 else
fprintf("foo not safe - missing call bar");

  } else {
 fprintf("requested X but driver is missing bar");
  }
   }


Regards,
Emil
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


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

2017-05-03 Thread Gregory Hainaut
Otherwise print a warning

v2: based on Nicolai feedback
Check the DRI extension version

Signed-off-by: Gregory Hainaut 
---
 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(>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(>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

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev