Make glXChooseFBConfig handle unspecified sRGB correctly
authorJon Turney <jon.turney@dronecode.org.uk>
Sat, 14 Jul 2018 14:24:14 +0000 (15:24 +0100)
committerAdam Jackson <ajax@redhat.com>
Tue, 31 Jul 2018 17:56:13 +0000 (13:56 -0400)
Make glXChooseFBConfig properly handle the case where the only matching
configs have the sRGB flag set, but no sRGB attribute is specified.

Since 6e06e281, the sRGBcapable flag is now actually compared, using
MATCH_DONT_CARE.

7b0f912e added defaulting of sRGBcapable to GL_FALSE in
__glXInitializeVisualConfigFromTags(), to handle servers which don't report
it, but this function is also used by glXChooseFBConfig(), so sRGBcapable is
implicitly false when not explicitly specified.

(This can cause e.g. glxinfo to fail to find anything matching the simple
config it looks for if all the candidates have the sRGB flag set to true.
I'm assuming this doesn't happen 'normally' as candidate configs with and
without sRGB true are available)

Move this defaulting to createConfigsFromProperties(), and set the default
for glXChooseFBConfig() in init_fbconfig_for_chooser() to GLX_DONT_CARE.

Reviewed-by: Eric Anholt <eric@anholt.net>
src/glx/glxcmds.c
src/glx/glxext.c

index e8485acd809e60f823b1d35fd8db78b0ffc3dc66..4db0228eaba8164ee79915e2a0b865f1a287cfef 100644 (file)
@@ -937,6 +937,7 @@ init_fbconfig_for_chooser(struct glx_config * config,
    config->fbconfigID = (GLXFBConfigID) (GLX_DONT_CARE);
 
    config->swapMethod = GLX_DONT_CARE;
    config->fbconfigID = (GLXFBConfigID) (GLX_DONT_CARE);
 
    config->swapMethod = GLX_DONT_CARE;
+   config->sRGBCapable = GLX_DONT_CARE;
 }
 
 #define MATCH_DONT_CARE( param )        \
 }
 
 #define MATCH_DONT_CARE( param )        \
index 5f23d3717a4282b40b3167f92337bc7ff6e187fe..ca3bf9d027f6f56e6f1ff6bffb854995b0c750eb 100644 (file)
@@ -402,8 +402,6 @@ __glXInitializeVisualConfigFromTags(struct glx_config * config, int count,
 #endif
    }
 
 #endif
    }
 
-   config->sRGBCapable = GL_FALSE;
-
    /*
     ** Additional properties may be in a list at the end
     ** of the reply.  They are in pairs of property type
    /*
     ** Additional properties may be in a list at the end
     ** of the reply.  They are in pairs of property type
@@ -660,6 +658,8 @@ createConfigsFromProperties(Display * dpy, int nvisuals, int nprops,
        */
       m->drawableType = GLX_WINDOW_BIT | GLX_PIXMAP_BIT | GLX_PBUFFER_BIT;
 #endif
        */
       m->drawableType = GLX_WINDOW_BIT | GLX_PIXMAP_BIT | GLX_PBUFFER_BIT;
 #endif
+      /* Older X servers don't send this so we default it here. */
+      m->sRGBCapable = GL_FALSE;
        __glXInitializeVisualConfigFromTags(m, nprops, props,
                                           tagged_only, GL_TRUE);
       m->screen = screen;
        __glXInitializeVisualConfigFromTags(m, nprops, props,
                                           tagged_only, GL_TRUE);
       m->screen = screen;