[PATCH xserver] glx: Fix computation of GLX_X_RENDERABLE fbconfig attribute

Adam Jackson ajax at redhat.com
Wed Mar 30 18:04:04 UTC 2016


>From the GLX spec:

    "GLX_X_RENDERABLE is a boolean indicating whether X can be used to
    render into a drawable created with the GLXFBConfig. This attribute
    is True if the GLXFBConfig supports GLX windows and/or pixmaps."

Every backend was setting this to true unconditionally, and then the
core ignored that value and sent true unconditionally on its own. This
is broken for ARB_fbconfig_float and EXT_fbconfig_packed_float, which
only apply to pbuffers, which are not renderable from non-GLX APIs.

Instead compute GLX_X_RENDERABLE from the supported drawable types. The
dri backends were getting _that_ wrong too, so fix that as well.

This is not a functional change, as there are no mesa drivers that claim
to support __DRI_ATTRIB_{UNSIGNED_,}FLOAT_BIT yet.

Signed-off-by: Adam Jackson <ajax at redhat.com>
---
 glx/glxcmds.c                  |  5 +++-
 glx/glxdri2.c                  |  6 ++--
 glx/glxdricommon.c             | 62 +++++++++++++++---------------------------
 glx/glxdricommon.h             |  3 +-
 glx/glxdriswrast.c             |  6 ++--
 glx/glxscreens.h               |  1 -
 hw/xquartz/GL/glcontextmodes.c |  1 -
 hw/xquartz/GL/visualConfigs.c  |  1 -
 hw/xwin/glx/indirect.c         |  2 --
 9 files changed, 31 insertions(+), 56 deletions(-)

diff --git a/glx/glxcmds.c b/glx/glxcmds.c
index 0f0b714..f2faf99 100644
--- a/glx/glxcmds.c
+++ b/glx/glxcmds.c
@@ -1114,7 +1114,10 @@ DoGetFBConfigs(__GLXclientState * cl, unsigned screen)
 
         WRITE_PAIR(GLX_VISUAL_ID, modes->visualID);
         WRITE_PAIR(GLX_FBCONFIG_ID, modes->fbconfigID);
-        WRITE_PAIR(GLX_X_RENDERABLE, GL_TRUE);
+        WRITE_PAIR(GLX_X_RENDERABLE,
+                   (modes->drawableType & (GLX_WINDOW_BIT | GLX_PIXMAP_BIT)
+                    ? GL_TRUE
+                    : GL_FALSE));
 
         WRITE_PAIR(GLX_RGBA,
                    (modes->renderType & GLX_RGBA_BIT) ? GL_TRUE : GL_FALSE);
diff --git a/glx/glxdri2.c b/glx/glxdri2.c
index d1fc3f9..85e13c6 100644
--- a/glx/glxdri2.c
+++ b/glx/glxdri2.c
@@ -991,10 +991,8 @@ __glXDRIscreenProbe(ScreenPtr pScreen)
 
     initializeExtensions(&screen->base);
 
-    screen->base.fbconfigs = glxConvertConfigs(screen->core, screen->driConfigs,
-                                               GLX_WINDOW_BIT |
-                                               GLX_PIXMAP_BIT |
-                                               GLX_PBUFFER_BIT);
+    screen->base.fbconfigs = glxConvertConfigs(screen->core,
+                                               screen->driConfigs);
 
     options = xnfalloc(sizeof(GLXOptions));
     memcpy(options, GLXOptions, sizeof(GLXOptions));
diff --git a/glx/glxdricommon.c b/glx/glxdricommon.c
index 62cce13..f6c6fcd 100644
--- a/glx/glxdricommon.c
+++ b/glx/glxdricommon.c
@@ -122,14 +122,28 @@ setScalar(__GLXconfig * config, unsigned int attrib, unsigned int value)
         }
 }
 
+static Bool
+render_type_is_pbuffer_only(unsigned renderType)
+{
+    /* The GL_ARB_color_buffer_float spec says:
+     *
+     *     "Note that floating point rendering is only supported for
+     *     GLXPbuffer drawables.  The GLX_DRAWABLE_TYPE attribute of the
+     *     GLXFBConfig must have the GLX_PBUFFER_BIT bit set and the
+     *     GLX_RENDER_TYPE attribute must have the GLX_RGBA_FLOAT_BIT set."
+     */
+    return !!(renderType & (__DRI_ATTRIB_UNSIGNED_FLOAT_BIT
+                            | __DRI_ATTRIB_FLOAT_BIT));
+}
+
 static __GLXconfig *
 createModeFromConfig(const __DRIcoreExtension * core,
                      const __DRIconfig * driConfig,
-                     unsigned int visualType, unsigned int drawableType)
+                     unsigned int visualType)
 {
     __GLXDRIconfig *config;
     GLint renderType = 0;
-    unsigned int attrib, value;
+    unsigned int attrib, value, drawableType = GLX_PBUFFER_BIT;
     int i;
 
     config = calloc(1, sizeof *config);
@@ -173,8 +187,10 @@ createModeFromConfig(const __DRIcoreExtension * core,
         }
     }
 
+    if (!render_type_is_pbuffer_only(renderType))
+        drawableType |= GLX_WINDOW_BIT | GLX_PIXMAP_BIT;
+
     config->config.next = NULL;
-    config->config.xRenderable = GL_TRUE;
     config->config.visualType = visualType;
     config->config.renderType = renderType;
     config->config.drawableType = drawableType;
@@ -183,23 +199,9 @@ createModeFromConfig(const __DRIcoreExtension * core,
     return &config->config;
 }
 
-static Bool
-render_type_is_pbuffer_only(unsigned renderType)
-{
-    /* The GL_ARB_color_buffer_float spec says:
-     *
-     *     "Note that floating point rendering is only supported for
-     *     GLXPbuffer drawables.  The GLX_DRAWABLE_TYPE attribute of the
-     *     GLXFBConfig must have the GLX_PBUFFER_BIT bit set and the
-     *     GLX_RENDER_TYPE attribute must have the GLX_RGBA_FLOAT_BIT set."
-     */
-    return !!(renderType & (__DRI_ATTRIB_UNSIGNED_FLOAT_BIT
-                            | __DRI_ATTRIB_FLOAT_BIT));
-}
-
 __GLXconfig *
 glxConvertConfigs(const __DRIcoreExtension * core,
-                  const __DRIconfig ** configs, unsigned int drawableType)
+                  const __DRIconfig ** configs)
 {
     __GLXconfig head, *tail;
     int i;
@@ -208,17 +210,7 @@ glxConvertConfigs(const __DRIcoreExtension * core,
     head.next = NULL;
 
     for (i = 0; configs[i]; i++) {
-        unsigned renderType = 0;
-        if (core->getConfigAttrib(configs[i], __DRI_ATTRIB_RENDER_TYPE,
-                                  &renderType)) {
-            if (render_type_is_pbuffer_only(renderType) &&
-                !(drawableType & GLX_PBUFFER_BIT))
-                continue;
-        }
-        /* Add all the others */
-        tail->next = createModeFromConfig(core,
-                                          configs[i], GLX_TRUE_COLOR,
-                                          drawableType);
+        tail->next = createModeFromConfig(core, configs[i], GLX_TRUE_COLOR);
         if (tail->next == NULL)
             break;
 
@@ -226,17 +218,7 @@ glxConvertConfigs(const __DRIcoreExtension * core,
     }
 
     for (i = 0; configs[i]; i++) {
-        unsigned int renderType = 0;
-        if (core->getConfigAttrib(configs[i], __DRI_ATTRIB_RENDER_TYPE,
-                                  &renderType)) {
-            if (render_type_is_pbuffer_only(renderType) &&
-                !(drawableType & GLX_PBUFFER_BIT))
-                continue;
-        }
-        /* Add all the others */
-        tail->next = createModeFromConfig(core,
-                                          configs[i], GLX_DIRECT_COLOR,
-                                          drawableType);
+        tail->next = createModeFromConfig(core, configs[i], GLX_DIRECT_COLOR);
         if (tail->next == NULL)
             break;
 
diff --git a/glx/glxdricommon.h b/glx/glxdricommon.h
index f4fcf00..2db46dc 100644
--- a/glx/glxdricommon.h
+++ b/glx/glxdricommon.h
@@ -33,8 +33,7 @@ struct __GLXDRIconfig {
 };
 
 __GLXconfig *glxConvertConfigs(const __DRIcoreExtension * core,
-                               const __DRIconfig ** configs,
-                               unsigned int drawableType);
+                               const __DRIconfig ** configs);
 
 extern const __DRIsystemTimeExtension systemTimeExtension;
 
diff --git a/glx/glxdriswrast.c b/glx/glxdriswrast.c
index 1e46d97..db295a0 100644
--- a/glx/glxdriswrast.c
+++ b/glx/glxdriswrast.c
@@ -482,10 +482,8 @@ __glXDRIscreenProbe(ScreenPtr pScreen)
 
     initializeExtensions(&screen->base);
 
-    screen->base.fbconfigs = glxConvertConfigs(screen->core, screen->driConfigs,
-                                               GLX_WINDOW_BIT |
-                                               GLX_PIXMAP_BIT |
-                                               GLX_PBUFFER_BIT);
+    screen->base.fbconfigs = glxConvertConfigs(screen->core,
+                                               screen->driConfigs);
 
 #if !defined(XQUARTZ) && !defined(WIN32)
     screen->base.glvnd = strdup("mesa");
diff --git a/glx/glxscreens.h b/glx/glxscreens.h
index 15196fa..0f9a2b9 100644
--- a/glx/glxscreens.h
+++ b/glx/glxscreens.h
@@ -78,7 +78,6 @@ struct __GLXconfig {
     /* SGIX_fbconfig / GLX 1.3 */
     GLint drawableType;
     GLint renderType;
-    GLint xRenderable;
     GLint fbconfigID;
 
     /* SGIX_pbuffer / GLX 1.3 */
diff --git a/hw/xquartz/GL/glcontextmodes.c b/hw/xquartz/GL/glcontextmodes.c
index 1ce3570..17e7a58 100644
--- a/hw/xquartz/GL/glcontextmodes.c
+++ b/hw/xquartz/GL/glcontextmodes.c
@@ -136,7 +136,6 @@ _gl_copy_visual_to_context_mode(__GLcontextModes * mode,
 
     mode->visualID = config->vid;
     mode->visualType = _gl_convert_from_x_visual_type(config->class);
-    mode->xRenderable = GL_TRUE;
     mode->fbconfigID = config->vid;
     mode->drawableType = GLX_WINDOW_BIT | GLX_PIXMAP_BIT;
 
diff --git a/hw/xquartz/GL/visualConfigs.c b/hw/xquartz/GL/visualConfigs.c
index 687bf80..ce68663 100644
--- a/hw/xquartz/GL/visualConfigs.c
+++ b/hw/xquartz/GL/visualConfigs.c
@@ -229,7 +229,6 @@ __GLXconfig *__glXAquaCreateVisualConfigs(int *numConfigsPtr, int screenNumber)
                                         /* SGIX_fbconfig / GLX 1.3 */
                                         c->drawableType = GLX_WINDOW_BIT | GLX_PIXMAP_BIT | GLX_PBUFFER_BIT;
                                         c->renderType = GLX_RGBA_BIT;
-                                        c->xRenderable = GL_TRUE;
                                         c->fbconfigID = -1;
 
                                         /* SGIX_pbuffer / GLX 1.3 */
diff --git a/hw/xwin/glx/indirect.c b/hw/xwin/glx/indirect.c
index 26832e6..9184252 100644
--- a/hw/xwin/glx/indirect.c
+++ b/hw/xwin/glx/indirect.c
@@ -1903,7 +1903,6 @@ glxWinCreateConfigs(HDC hdc, glxWinScreen * screen)
             c->base.renderType = GLX_RGBA_BIT;
         }
 
-        c->base.xRenderable = GL_TRUE;
         c->base.fbconfigID = -1;        // will be set by __glXScreenInit()
 
         /* SGIX_pbuffer / GLX 1.3 */
@@ -2263,7 +2262,6 @@ glxWinCreateConfigsExt(HDC hdc, glxWinScreen * screen)
             c->base.renderType = GLX_RGBA_BIT;
         }
 
-        c->base.xRenderable = GL_TRUE;
         c->base.fbconfigID = -1;        // will be set by __glXScreenInit()
 
         /* SGIX_pbuffer / GLX 1.3 */
-- 
2.5.0



More information about the xorg-devel mailing list