glxCreatePixmap is failing for some reason. if that works, then probably glx renderi...
authorDana Jansens <danakj@orodu.net>
Mon, 10 Mar 2008 05:26:04 +0000 (01:26 -0400)
committerDana Jansens <danakj@orodu.net>
Mon, 10 Mar 2008 05:29:22 +0000 (01:29 -0400)
display.c
display.h
glxrender.c

index 6208655..5a18ec2 100644 (file)
--- a/display.c
+++ b/display.c
@@ -13,6 +13,7 @@
 #include <xcb/render.h>
 #include <xcb/xfixes.h>
 #include <xcb/composite.h>
+#include <xcb/glx.h>
 
 typedef struct {
     xcb_atom_t               *atom;
@@ -28,6 +29,7 @@ typedef struct {
 #define find_extension_composite(dpy) &dpy->composite;
 #define find_extension_damage(dpy) &dpy->damage;
 #define find_extension_shape(dpy) &dpy->shape;
+#define find_extension_glx(dpy) &dpy->glx;
 
 #define version_extension_xfixes \
   XCB_XFIXES_MAJOR_VERSION, XCB_XFIXES_MAJOR_VERSION
@@ -37,6 +39,8 @@ typedef struct {
   XCB_COMPOSITE_MAJOR_VERSION, XCB_COMPOSITE_MAJOR_VERSION
 #define version_extension_damage \
   XCB_DAMAGE_MAJOR_VERSION, XCB_DAMAGE_MAJOR_VERSION
+#define version_extension_glx \
+  XCB_GLX_MAJOR_VERSION, XCB_GLX_MAJOR_VERSION
 
 #define query_extension(dpy, name) \
 { \
@@ -165,18 +169,21 @@ query_statics(d_display_t *dpy)
     setup_extension(composite);
     setup_extension(damage);
     setup_extension(shape);
+    setup_extension(glx);
 
     query_extension(dpy, xfixes);
     query_extension(dpy, render);
     query_extension(dpy, composite);
     query_extension(dpy, damage);
     query_extension(dpy, shape);
+    query_extension(dpy, glx);
 
     query_extension_version(dpy, xfixes);
     query_extension_version(dpy, render);
     query_extension_version(dpy, composite);
     query_extension_version(dpy, damage);
     query_extension_version_no_client_version(dpy, shape);
+    query_extension_version(dpy, glx);
 
     for (i = 0; atoms[i].atom != NULL; ++i)
         query_atom(dpy, &atoms[i]);
@@ -188,6 +195,7 @@ query_statics(d_display_t *dpy)
     reply_extension(dpy, composite);
     reply_extension(dpy, damage);
     reply_extension(dpy, shape);
+    reply_extension(dpy, glx);
 
     for (i = 0; atoms[i].atom != NULL; ++i)
         reply_atom(dpy, &atoms[i]);
@@ -405,6 +413,37 @@ display_error(d_display_t *dpy, xcb_generic_error_t *ev)
         case 22: req = "XFixesSetPictureClipRegion";   break;
         default: break;
         }
+    else if (major_opcode == dpy->glx.opcode)
+        switch (minor_opcode)
+        {
+        case 1: req = "glXRender";                  break;
+        case 2: req = "glXRenderLarge";             break;
+        case 3: req = "glxCreateContext";           break;
+        case 4: req = "glxDestroyContext";          break;
+        case 5: req = "glxMakeCurrent";             break;
+        case 6: req = "glXIsDirect";                break;
+        case 7: req = "glXQueryVersion";            break;
+        case 8: req = "glXWaitGL";                  break;
+        case 9: req = "glXWaitX";                   break;
+        case 10: req = "glXCopyContext";            break;
+        case 11: req = "glXSwapBuffers";            break;
+        case 12: req = "glXUseXFont";               break;
+        case 13: req = "glXCreateGLXPixmap";        break;
+        case 14: req = "glXGetVisualConfigs";       break;
+        case 15: req = "glXDestroyGLXPixmap";       break;
+        case 16: req = "glXVendorPrivate";          break;
+        case 17: req = "glXVendorPrivateWithReply"; break;
+        case 18: req = "glXQueryExtensionsString";  break;
+        case 19: req = "glXQueryServerString";      break;
+        case 20: req = "glXClientInfo";             break;
+        case 21: req = "glXGetFBConfigs";           break;
+        case 22: req = "glXCreatePixmap";           break;
+        case 23: req = "glXDestroyPixmap";          break;
+        case 24: req = "glXCreateNewContext";       break;
+        case 25: req = "glXQueryContext";           break;
+        case 26: req = "glXMakeContextCurrent";     break;
+        default: break;
+        }
 
     if (name && req)
         printf("XError: %s %s\n",
index d03bdce..862dbd1 100644 (file)
--- a/display.h
+++ b/display.h
@@ -27,6 +27,7 @@ typedef struct d_display {
     d_display_ext_t composite;
     d_display_ext_t damage;
     d_display_ext_t shape;
+    d_display_ext_t glx;
 
     struct {
         /* types */
index 8eb053a..3aa3b0c 100644 (file)
@@ -6,6 +6,7 @@
 #include "display.h"
 #include "list.h"
 #include <stdio.h>
+#include <string.h>
 #include <assert.h>
 #include <stdlib.h>
 
@@ -57,7 +58,8 @@ static void paint_shadow(d_window_t *w, data_t *d, window_data_t *wd,
                          int x, int y, int width, int height, int bwidth);
 static void glxrender_update_window_pixmap(d_window_t *w, data_t *d,
                                            window_data_t *wd);
-static void glxrender_free_window_pixmap(d_window_t *w, window_data_t *wd);
+static void glxrender_free_window_pixmap(d_window_t *w, data_t *d,
+                                         window_data_t *wd);
 static void glxrender_update_root_pixmap(d_screen_t *sc, data_t *d);
 
 static void glxrender_window_show(d_window_t *window);
@@ -265,8 +267,7 @@ glxrender_find_fb_config(d_screen_t *sc, data_t *d)
     fbprops = xcb_glx_get_fb_configs_property_list(fbrep);
     nfbprops = fbrep->num_properties;
 
-    for (i = 0; i <= MAX_DEPTH; ++i)
-        d->fbconfig[i] = 0;
+    memset(d->fbconfig, 0, (MAX_DEPTH + 1) * sizeof(d->fbconfig[0]));
 
     db = 32767;
     stencil = 32767;
@@ -315,71 +316,74 @@ glxrender_find_fb_config(d_screen_t *sc, data_t *d)
             if (!val > depthsize) continue;
             depthsize = val;
 
-            /* use this visual */
+            /* try this visual */
             vid = visuals[j].visual_id;
-        }
-
-        if (!vid) continue;
-
-        printf("found visual for depth %d\n", depth_it.data->depth);
-
-        for (k = 0; k < fbrep->num_FB_configs; ++k) {
-            uint32_t val;
-
-            //printf("root visual 0x%x\n", sc->super.root_visual);
-            //printf("overlay visual 0x%x\n", sc->overlay_visual);
-
-            val = glxrender_fbconfig_info(fbprops, k, nfbprops,
-                                          GLX_VISUAL_ID);
-            //printf("x visual 0x%x\n", val);
-            if (val != vid) continue;
-
-            val = glxrender_fbconfig_info(fbprops, k, nfbprops,
-                                          GLX_DOUBLEBUFFER);
-            //printf("dbl buffer %s\n", val ? "yes" : "no");
-            if (db) continue;
-
-            val = glxrender_fbconfig_info(fbprops, k, nfbprops,
-                                          GLX_DEPTH_SIZE);
-            //printf("depth size %d\n", val);
-
-            val = glxrender_fbconfig_info(fbprops, k, nfbprops,
-                                          GLX_RED_SIZE);
-            //printf("red size %d\n", val);
-            if (!val) continue;
-
-            val = glxrender_fbconfig_info(fbprops, k, nfbprops,
-                                          GLX_GREEN_SIZE);
-            //printf("green size %d\n", val);
-            if (!val) continue;
 
-            val = glxrender_fbconfig_info(fbprops, k, nfbprops,
-                                          GLX_BLUE_SIZE);
-            //printf("blue size %d\n", val);
-            if (!val) continue;
-
-            val = glxrender_fbconfig_info(fbprops, k, nfbprops,
-                                          GLX_ALPHA_SIZE);
-            //printf("alpha size %d\n", val);
-            if (!val) continue;
-
-            val = glxrender_fbconfig_info(fbprops, j, nfbprops,
-                                          GLX_RENDER_TYPE);
-            //printf("rgba bit %s\n", val & GLX_RGBA_BIT ? "yes" : "no");
-            if (!(val & GLX_RGBA_BIT)) continue;
-
-            val = glxrender_fbconfig_info(fbprops, j, nfbprops,
-                                          GLX_CONFIG_CAVEAT);
-            //printf("caveat 0x%x\n", val);
-
-            val = glxrender_fbconfig_info(fbprops, j, nfbprops,
-                                          GLX_BIND_TO_TEXTURE_RGBA_EXT);
-            //printf("bind ext %s\n", val ? "yes" : "no");
-            if (!val) continue;
+            /* look for an fbconfig for this visual */
+            for (k = 0; k < fbrep->num_FB_configs; ++k) {
+                uint32_t val;
+
+                //printf("root visual 0x%x\n", sc->super.root_visual);
+                //printf("overlay visual 0x%x\n", sc->overlay_visual);
+
+                val = glxrender_fbconfig_info(fbprops, k, nfbprops,
+                                              GLX_VISUAL_ID);
+                //printf("x visual 0x%x\n", val);
+                if (val != vid) continue;
+
+                val = glxrender_fbconfig_info(fbprops, k, nfbprops,
+                                              GLX_DOUBLEBUFFER);
+                printf("dbl buffer %s\n", val ? "yes" : "no");
+                if (val) continue;
+
+                val = glxrender_fbconfig_info(fbprops, k, nfbprops,
+                                              GLX_DEPTH_SIZE);
+                printf("depth size %d\n", val);
+
+                val = glxrender_fbconfig_info(fbprops, k, nfbprops,
+                                              GLX_RED_SIZE);
+                printf("red size %d\n", val);
+                if (!val) continue;
+
+                val = glxrender_fbconfig_info(fbprops, k, nfbprops,
+                                              GLX_GREEN_SIZE);
+                printf("green size %d\n", val);
+                if (!val) continue;
+
+                val = glxrender_fbconfig_info(fbprops, k, nfbprops,
+                                              GLX_BLUE_SIZE);
+                printf("blue size %d\n", val);
+                if (!val) continue;
+
+                val = glxrender_fbconfig_info(fbprops, k, nfbprops,
+                                              GLX_ALPHA_SIZE);
+                printf("alpha size %d\n", val);
+                //if (depth_it.data->depth == 32 && !val) continue;
+
+                val = glxrender_fbconfig_info(fbprops, j, nfbprops,
+                                              GLX_RENDER_TYPE);
+                printf("rgba bit %s\n", val & GLX_RGBA_BIT ? "yes" : "no");
+                if (!(val & GLX_RGBA_BIT)) continue;
+
+                val = glxrender_fbconfig_info(fbprops, j, nfbprops,
+                                              GLX_CONFIG_CAVEAT);
+                printf("caveat 0x%x\n", val);
+
+                val = glxrender_fbconfig_info(fbprops, j, nfbprops,
+                                              GLX_BIND_TO_TEXTURE_RGBA_EXT);
+                printf("bind ext %s\n", val ? "yes" : "no");
+                if (!val) continue;
+
+                d->fbconfig[depth_it.data->depth] =
+                    glxrender_fbconfig_info(fbprops, i, nfbprops,
+                                            GLX_FBCONFIG_ID);
+                break;
+            }
 
-            d->fbconfig[depth_it.data->depth] =
-                glxrender_fbconfig_info(fbprops, i, nfbprops, GLX_FBCONFIG_ID);
-            break;
+            if (d->fbconfig[depth_it.data->depth])
+                printf("found visual 0x%x fbconfig 0x%x for depth %d\n",
+                       vid, d->fbconfig[depth_it.data->depth],
+                       depth_it.data->depth);
         }
     }
 
@@ -411,9 +415,9 @@ glxrender_timeout(struct d_screen *sc, const struct timeval *now)
 }
 
 void
-glxrender_window_free_data(d_window_t *w, window_data_t *wd)
+glxrender_window_free_data(d_window_t *w, data_t *d, window_data_t *wd)
 {
-    glxrender_free_window_pixmap(w, wd);
+    glxrender_free_window_pixmap(w, d, wd);
     glDeleteTextures(1, &wd->texname);
     free(wd);
 }
@@ -431,10 +435,11 @@ glxrender_window_show(d_window_t *w)
 
     wd = window_find_plugin_data(w, plugin_id);
     if (wd)
-        glxrender_window_free_data(w, wd);
+        glxrender_window_free_data(w, d, wd);
    
     wd = malloc(sizeof(window_data_t));
     glGenTextures(1, &wd->texname);
+    wd->glpixmap = XCB_NONE;
 
     window_add_plugin_data(w, plugin_id, wd);
 }
@@ -448,7 +453,7 @@ glxrender_window_zombie_dead(d_window_t *w)
     d = screen_find_plugin_data(w->sc, plugin_id);
     wd = window_find_plugin_data(w, plugin_id);
     if (wd) {
-        glxrender_window_free_data(w, wd);
+        glxrender_window_free_data(w, d, wd);
         window_remove_plugin_data(w, plugin_id);
     }
 
@@ -457,14 +462,33 @@ glxrender_window_zombie_dead(d_window_t *w)
 }
 
 static void
-glxrender_free_window_pixmap(d_window_t *w, window_data_t *wd)
+glxrender_free_window_pixmap(d_window_t *w, data_t *d, window_data_t *wd)
 {
     /* this might cause an error, oh well */
     if (wd->glpixmap) {
         glBindTexture(GL_TEXTURE_2D, wd->texname);
 
-        //d->releaseTexImageEXT(obt_display, lw->glpixmap,
-        //                      GLX_FRONT_LEFT_EXT);
+        {
+            /*
+              ReleaseTexImageEXT
+              1           CARD8           opcode (X assigned)
+              1           16              GLX opcode (glXVendorPrivate)
+              2           5               request length
+              4           1331            vendor specific opcode
+              4           CARD32          context tag
+              4           GLX_DRAWABLE    drawable
+              4           INT32           buffer
+            */
+            unsigned int len = (2 + 0) * sizeof(uint32_t);
+            uint32_t data[] = {
+                wd->glpixmap,
+                GLX_FRONT_LEFT_EXT
+            };
+            xcb_glx_vendor_private(w->sc->dpy->conn,
+                                   1331,
+                                   d->context_tag,
+                                   len, (uint8_t*)data);
+        }
 
         glBindTexture(GL_TEXTURE_2D, 0);
 
@@ -481,35 +505,44 @@ glxrender_update_window_pixmap(d_window_t *w, data_t *d, window_data_t *wd)
 
     static const uint32_t attrs[] = {
         GLX_TEXTURE_FORMAT_EXT,
-        GLX_TEXTURE_FORMAT_RGBA_EXT
+        GLX_TEXTURE_FORMAT_RGBA_EXT,
     };
 
     px = window_get_pixmap(w);
     depth = window_get_depth(w);
     if (px && d->fbconfig[depth]) {
         wd->glpixmap = xcb_generate_id(w->sc->dpy->conn);
+        printf("creating pixmap fbcon 0x%x\n", d->fbconfig[depth]);
         xcb_glx_create_pixmap(w->sc->dpy->conn, w->sc->num, d->fbconfig[depth],
                               px, wd->glpixmap, 2, attrs);
 
         glBindTexture(GL_TEXTURE_2D, wd->texname);
 
-        {
-            unsigned int len = 2 * sizeof(uint32_t);
-            uint32_t data[] = {wd->glpixmap, GLX_FRONT_LEFT_EXT};
-            xcb_void_cookie_t ck;
-            xcb_generic_error_t *err;
-
-            ck = xcb_glx_vendor_private(w->sc->dpy->conn,
-                                        GLX_BIND_TO_TEXTURE_RGBA_EXT,
-                                        d->context_tag,
-                                        len, data);
-            if ((err = xcb_request_check(w->sc->dpy->conn, ck))) {
-                display_error(w->sc->dpy, err);
-                free(err);
-            }
+        if (0) {
+            /*
+              BindTexImageEXT
+              1           CARD8                   opcode (X assigned)
+              1           16                      GLX opcode (glXVendorPrivate)
+              2           6+n                     request length
+              4           1330                    vendor specific opcode
+              4           CARD32                  context tag
+              4           GLX_DRAWABLE            drawable
+              4           INT32                   buffer
+              4           CARD32                  num_attributes
+              4*n         LISTofATTRIBUTE_PAIR    attribute, value pairs.
+            */
+            unsigned int len = (4 + 0) * sizeof(uint32_t);
+            uint32_t data[] = {
+                wd->glpixmap,
+                GLX_FRONT_LEFT_EXT,
+                0,
+                NULL
+            };
+            xcb_glx_vendor_private(w->sc->dpy->conn,
+                                   1330,
+                                   d->context_tag,
+                                   len, (uint8_t*)data);
         }
-        //d->bindTexImageEXT(obt_display, lw->glpixmap,
-        //                   GLX_FRONT_LEFT_EXT, NULL);
 
         glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
         glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
@@ -545,7 +578,7 @@ glxrender_window_resize(d_window_t *w)
     d->window_resize(w);
 
     assert(wd != NULL);
-    glxrender_free_window_pixmap(w, wd);
+    glxrender_free_window_pixmap(w, d, wd);
 }
 
 static void
@@ -561,7 +594,7 @@ glxrender_window_reshape(d_window_t *w)
     d->window_reshape(w);
 
     assert(wd != NULL);
-    glxrender_free_window_pixmap(w, wd);
+    glxrender_free_window_pixmap(w, d, wd);
 }
 
 static void
@@ -586,7 +619,7 @@ glxrender_paint(d_screen_t *sc)
     data_t *d = screen_find_plugin_data(sc, plugin_id);
     d_list_it_t *it;
 
-    printf("painting\n");
+    //printf("painting\n");
 
     paint_root(sc, d);
 
@@ -641,6 +674,7 @@ paint_window(d_window_t *w, data_t *d, window_data_t *wd, gboolean opaque,
     if (!wd->glpixmap)
         glxrender_update_window_pixmap(w, d, wd);
 
+    glBindTexture(GL_TEXTURE_2D, wd->texname);
     glBegin(GL_QUADS);
     glColor3f(1.0, 1.0, 1.0);
     glVertex2i(x, y);