Get the default GLXPixmap texture target from the server when appropriate.
authorMichel Dänzer <michel@tungstengraphics.com>
Thu, 10 Apr 2008 19:45:52 +0000 (15:45 -0400)
committerKristian Høgsberg <krh@redhat.com>
Thu, 10 Apr 2008 19:47:46 +0000 (15:47 -0400)
Fixes compiz with direct rendering when both GLX_TEXTURE_2D_EXT and
GLX_TEXTURE_RECTANGLE_EXT are supported for a GLXPixmap and the
application didn't specify the texture target as a GLX drawable attribute
when creating the GLX drawable.

src/glx/x11/glx_pbuffer.c

index b0a8f71fd4ab198d6731a9bcb6be12af50b6d883..08743e560fa4c48539739e331b4d906c0c4d6dfd 100644 (file)
@@ -164,6 +164,33 @@ DestroyPbuffer( Display * dpy, GLXDrawable drawable )
 }
 
 
+#ifdef GLX_DIRECT_RENDERING
+extern __GLXDRIdrawable *
+GetGLXDRIDrawable(Display *dpy, GLXDrawable drawable, int * const scrn_num);
+
+static GLenum
+determineTextureTarget(const int *attribs, int numAttribs)
+{
+    GLenum target = 0;
+    int i;
+
+    for (i = 0; i < numAttribs; i++) {
+       if (attribs[2 * i] == GLX_TEXTURE_TARGET_EXT) {
+           switch (attribs[2 * i + 1]) {
+           case GLX_TEXTURE_2D_EXT:
+               target = GL_TEXTURE_2D;
+               break;
+           case GLX_TEXTURE_RECTANGLE_EXT:
+               target = GL_TEXTURE_RECTANGLE_ARB;
+               break;
+           }
+       }
+    }
+    return target;
+}
+#endif
+
 /**
  * Get a drawable's attribute.
  *
@@ -261,6 +288,16 @@ GetDrawableAttribute( Display *dpy, GLXDrawable drawable,
               }
           }
 
+#ifdef GLX_DIRECT_RENDERING
+          {
+               __GLXDRIdrawable *pdraw = GetGLXDRIDrawable(dpy, drawable, NULL);
+
+               if (pdraw != NULL && !pdraw->textureTarget)
+                   pdraw->textureTarget = determineTextureTarget(data,
+                                                                 num_attributes);
+          }
+#endif
+
           Xfree( data );
        }
    }
@@ -271,33 +308,6 @@ GetDrawableAttribute( Display *dpy, GLXDrawable drawable,
    return 0;
 }
 
-#ifdef GLX_DIRECT_RENDERING
-extern __GLXDRIdrawable *
-GetGLXDRIDrawable(Display *dpy, GLXDrawable drawable, int * const scrn_num);
-
-static GLenum
-determineTextureTarget(const int *attribs, int numAttribs)
-{
-    GLenum target = 0;
-    int i;
-
-    for (i = 0; i < numAttribs; i++) {
-       if (attribs[2 * i] == GLX_TEXTURE_TARGET_EXT) {
-           switch (attribs[2 * i + 1]) {
-           case GLX_TEXTURE_2D_EXT:
-               target = GL_TEXTURE_2D;
-               break;
-           case GLX_TEXTURE_RECTANGLE_EXT:
-               target = GL_TEXTURE_RECTANGLE_ARB;
-               break;
-           }
-       }
-    }
-    return target;
-}
-#endif
-
 /**
  * Create a non-pbuffer GLX drawable.
  *