[Mesa-dev] [PATCH] glx: block attempt to swapbuffer on pixmap. (v2)

Dave Airlie airlied at gmail.com
Wed Dec 7 02:24:09 PST 2011


From: Dave Airlie <airlied at redhat.com>

This keeps track of the creation process and stores a drawable type,
it then blocks DRI2 from getting called if the drawable is a pixmap.

v2: check if we have a GLX drawable, which means we aren't a pbuffer,
avoid doing flush at all since its meant to be a no-op.

Suggested by Michel Dänzer <michel at daenzer.net>
Signed-off-by: Dave Airlie <airlied at redhat.com>
---
 src/glx/glx_pbuffer.c |    3 ++-
 src/glx/glxclient.h   |    3 ++-
 src/glx/glxcmds.c     |   10 ++++++++--
 3 files changed, 12 insertions(+), 4 deletions(-)

diff --git a/src/glx/glx_pbuffer.c b/src/glx/glx_pbuffer.c
index 6738252..4bc3292 100644
--- a/src/glx/glx_pbuffer.c
+++ b/src/glx/glx_pbuffer.c
@@ -434,7 +434,8 @@ CreateDrawable(Display *dpy, struct glx_config *config,
    UnlockDisplay(dpy);
    SyncHandle();
 
-   if (InitGLXDrawable(dpy, glxDraw, drawable, xid)) {
+   if (InitGLXDrawable(dpy, glxDraw, drawable, xid, 
+		       (glxCode == X_GLXCreatePixmap) ? GLX_PIXMAP_BIT : GLX_WINDOW_BIT)) {
       free(glxDraw);
       return None;
    }
diff --git a/src/glx/glxclient.h b/src/glx/glxclient.h
index f915426..a47a2f7 100644
--- a/src/glx/glxclient.h
+++ b/src/glx/glxclient.h
@@ -585,6 +585,7 @@ struct glx_drawable {
    XID xDrawable;
    XID drawable;
 
+   uint32_t drawableType;
    uint32_t lastEventSbc;
    int64_t eventSbcWrap;
 };
@@ -797,7 +798,7 @@ applegl_create_display(struct glx_display *display);
 
 extern struct glx_drawable *GetGLXDrawable(Display *dpy, GLXDrawable drawable);
 extern int InitGLXDrawable(Display *dpy, struct glx_drawable *glxDraw,
-			   XID xDrawable, GLXDrawable drawable);
+			   XID xDrawable, GLXDrawable drawable, uint32_t drawableType);
 extern void DestroyGLXDrawable(Display *dpy, GLXDrawable drawable);
 
 extern struct glx_context dummyContext;
diff --git a/src/glx/glxcmds.c b/src/glx/glxcmds.c
index c8ec9c2..634f0c5 100644
--- a/src/glx/glxcmds.c
+++ b/src/glx/glxcmds.c
@@ -107,7 +107,7 @@ GetGLXDrawable(Display *dpy, GLXDrawable drawable)
 
 _X_HIDDEN int
 InitGLXDrawable(Display *dpy, struct glx_drawable *glxDraw, XID xDrawable,
-		GLXDrawable drawable)
+                GLXDrawable drawable, uint32_t drawableType)
 {
    struct glx_display *priv = __glXInitialize(dpy);
 
@@ -118,6 +118,7 @@ InitGLXDrawable(Display *dpy, struct glx_drawable *glxDraw, XID xDrawable,
    glxDraw->drawable = drawable;
    glxDraw->lastEventSbc = 0;
    glxDraw->eventSbcWrap = 0;
+   glxDraw->drawableType = drawableType;
 
    return __glxHashInsert(priv->glXDrawHash, drawable, glxDraw);
 }
@@ -678,7 +679,7 @@ glXCreateGLXPixmap(Display * dpy, XVisualInfo * vis, Pixmap pixmap)
    UnlockDisplay(dpy);
    SyncHandle();
 
-   if (InitGLXDrawable(dpy, glxDraw, pixmap, req->glxpixmap)) {
+   if (InitGLXDrawable(dpy, glxDraw, pixmap, req->glxpixmap, GLX_PIXMAP_BIT)) {
       free(glxDraw);
       return None;
    }
@@ -796,6 +797,11 @@ glXSwapBuffers(Display * dpy, GLXDrawable drawable)
 #if defined(GLX_DIRECT_RENDERING) && !defined(GLX_USE_APPLEGL)
    {
       __GLXDRIdrawable *pdraw = GetGLXDRIDrawable(dpy, drawable);
+      struct glx_drawable *glx_draw = GetGLXDrawable(dpy, drawable);
+
+      /* GLX specifies a swapbuffer on a Pixmap to be a no-op. */
+      if (glx_draw && glx_draw->drawableType == GLX_PIXMAP_BIT)
+         return;
 
       if (pdraw != NULL) {
          if (gc && drawable == gc->currentDrawable) {
-- 
1.7.6.4



More information about the mesa-dev mailing list