[Mesa-dev] [PATCH] dri3_glx.c: Pass NULL DRI drawables into driver for None GLX drawables

Axel Davy axel.davy at ens.fr
Mon Mar 23 07:15:45 PDT 2015


You seem to miss the case when one is None and not the other.
It should return BadDrawable too.

This particular case seems not handled by the dri2 code either,
and the gallium state tracker seems to handle it in bindContext,
but not the intel code for example.

Axel Davy

On 23/03/2015 08:07, Xiong Zhang wrote :
> GLX_ARB_create_context spec says:
> If either <draw> or <read> are not a valid GLX drawable, a GLXBadDrawable
> error is generated, unless <draw> and <read> are both None and the OpenGL
> version supported by <ctx> is 3.0 or greater.
>
> So when both <draw> and <read> are None, it could pass NULL drawable into
> driver instead of returing GLXBadDrawable.
>
> v2: Fix spacing issue (Axel Davy)
>
> https://bugs.freedesktop.org/show_bug.cgi?id=79629
> Signed-off-by: Xiong Zhang <xiong.y.zhang at intel.com>
> ---
>   src/glx/dri3_glx.c | 12 +++++++++---
>   1 file changed, 9 insertions(+), 3 deletions(-)
>
> diff --git a/src/glx/dri3_glx.c b/src/glx/dri3_glx.c
> index e3fc4de..a07e8d4 100644
> --- a/src/glx/dri3_glx.c
> +++ b/src/glx/dri3_glx.c
> @@ -133,17 +133,23 @@ dri3_bind_context(struct glx_context *context, struct glx_context *old,
>      struct dri3_context *pcp = (struct dri3_context *) context;
>      struct dri3_screen *psc = (struct dri3_screen *) pcp->base.psc;
>      struct dri3_drawable *pdraw, *pread;
> +   __DRIdrawable *dri_draw = NULL, *dri_read = NULL;
>   
>      pdraw = (struct dri3_drawable *) driFetchDrawable(context, draw);
>      pread = (struct dri3_drawable *) driFetchDrawable(context, read);
>   
>      driReleaseDrawables(&pcp->base);
>   
> -   if (pdraw == NULL || pread == NULL)
> +   if ((pdraw == NULL && draw != None) || (pread == NULL && read != None))
>         return GLXBadDrawable;
>   
> -   if (!(*psc->core->bindContext) (pcp->driContext,
> -                                   pdraw->driDrawable, pread->driDrawable))
> +   if (pdraw)
> +      dri_draw = pdraw->driDrawable;
> +
> +   if (pread)
> +      dri_read = pread->driDrawable;
> +
> +   if (!(*psc->core->bindContext)(pcp->driContext, dri_draw, dri_read))
>         return GLXBadContext;
>   
>      return Success;



More information about the mesa-dev mailing list