[Mesa-dev] [PATCH] glx: Verify that drawable creation on the client side actually worked

Jon TURNEY jon.turney at dronecode.org.uk
Wed Feb 27 06:02:43 PST 2013


On 04/05/2011 22:50, Adam Jackson wrote:
> ... and clean up if it didn't.
> 
> Signed-off-by: Adam Jackson <ajax at redhat.com>
> ---
>  src/glx/glx_pbuffer.c |   76 ++++++++++++++++++++++++++++++++-----------------
>  src/glx/glxcmds.c     |   74 +++++++++++++++++++++++++++++++-----------------
>  2 files changed, 98 insertions(+), 52 deletions(-)
> 
> diff --git a/src/glx/glx_pbuffer.c b/src/glx/glx_pbuffer.c
> index 5f91bc6..1d9c1e9 100644
> --- a/src/glx/glx_pbuffer.c
> +++ b/src/glx/glx_pbuffer.c

>  
>  #else
>  
> -static void
> +static GLboolean
>  CreateDRIDrawable(Display *dpy, const struct glx_config * fbconfig,
>  		  XID drawable, XID glxdrawable,
>  		  const int *attrib_list, size_t num_attribs)
>  {
> +    return GL_FALSE;
>  }
>  

Always returning GL_FALSE (failed) here when built without
GLX_DIRECT_RENDERING defined ...

>  /**
>   * Create a non-pbuffer GLX drawable.
>   *
> @@ -378,6 +402,7 @@ CreateDrawable(Display *dpy, struct glx_config *config,
>                 Drawable drawable, const int *attrib_list, CARD8 glxCode)
>  {
>     xGLXCreateWindowReq *req;
> +   GLXDrawable ret;
>     CARD32 *data;
>     unsigned int i;
>     CARD8 opcode;
> @@ -401,7 +426,7 @@ CreateDrawable(Display *dpy, struct glx_config *config,
>     req->screen = config->screen;
>     req->fbconfig = config->fbconfigID;
>     req->window = drawable;
> -   req->glxwindow = XAllocID(dpy);
> +   req->glxwindow = ret = XAllocID(dpy);
>     req->numAttribs = i;
>  
>     if (attrib_list)
> @@ -410,9 +435,16 @@ CreateDrawable(Display *dpy, struct glx_config *config,
>     UnlockDisplay(dpy);
>     SyncHandle();
>  
> -   CreateDRIDrawable(dpy, config, drawable, req->glxwindow, attrib_list, i);
> +   if (!CreateDRIDrawable(dpy, config, drawable, ret, attrib_list, i)) {
> +      if (glxCode == X_GLXCreatePixmap)
> +         glxCode = X_GLXDestroyPixmap;
> +      else
> +         glxCode = X_GLXDestroyWindow;
> +      protocolDestroyDrawable(dpy, ret, glxCode);
> +      ret = None;
> +   }

... and then always checking the result here, looks like this makes
CreateDrawable (and hence glXCreateWindow() and glXCreatePbuffer()) always
fail (when built without GLX_DIRECT_RENDERING defined)

>  
> -   return req->glxwindow;
> +   return ret;
>  }

>  
> @@ -474,6 +490,7 @@ CreatePbuffer(Display * dpy, struct glx_config *config,
>     CARD8 opcode;
>     unsigned int i;
>     Pixmap pixmap;
> +   GLboolean glx_1_3 = GL_FALSE;
>  
>     i = 0;
>     if (attrib_list) {
> @@ -492,6 +509,8 @@ CreatePbuffer(Display * dpy, struct glx_config *config,
>        xGLXCreatePbufferReq *req;
>        unsigned int extra = (size_in_attribs) ? 0 : 2;
>  
> +      glx_1_3 = GL_TRUE;
> +
>        GetReqExtra(GLXCreatePbuffer, (8 * (i + extra)), req);
>        data = (CARD32 *) (req + 1);
>  
> @@ -536,7 +555,12 @@ CreatePbuffer(Display * dpy, struct glx_config *config,
>     pixmap = XCreatePixmap(dpy, RootWindow(dpy, config->screen),
>  			  width, height, config->rgbBits);
>  
> -   CreateDRIDrawable(dpy, config, pixmap, id, attrib_list, i);
> +   if (!CreateDRIDrawable(dpy, config, pixmap, id, attrib_list, i)) {
> +      CARD32 o = glx_1_3 ? X_GLXDestroyPbuffer : X_GLXvop_DestroyGLXPbufferSGIX;
> +      XFreePixmap(dpy, pixmap);
> +      protocolDestroyDrawable(dpy, id, o);
> +      id = None;
> +   }

Ditto.

>  
>     return id;
>  }

Attached is a patch to fix.

-------------- next part --------------
>From f210b48ed7ae8d0286676ed94c38c5a6ca4338b4 Mon Sep 17 00:00:00 2001
From: Jon TURNEY <jon.turney at dronecode.org.uk>
Date: Tue, 26 Feb 2013 15:47:44 +0000
Subject: [PATCH] glXCreateWindow() always fails when built without
 GLX_DIRECT_RENDERING defined

glXCreateWindow() and glXCreatePbuffer() always fail when built without
GLX_DIRECT_RENDERING defined since commit 4833104718677caad0027d5e7539ca9bba389392

Signed-off-by: Jon TURNEY <jon.turney at dronecode.org.uk>
---
 src/glx/glx_pbuffer.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/src/glx/glx_pbuffer.c b/src/glx/glx_pbuffer.c
index e4b2c86..f11305a 100644
--- a/src/glx/glx_pbuffer.c
+++ b/src/glx/glx_pbuffer.c
@@ -241,7 +241,7 @@ CreateDRIDrawable(Display *dpy, const struct glx_config * fbconfig,
 		  XID drawable, XID glxdrawable,
 		  const int *attrib_list, size_t num_attribs)
 {
-    return GL_FALSE;
+    return GL_TRUE;
 }
 
 static void
-- 
1.7.9



More information about the mesa-dev mailing list