Commit 392da389 authored by Adam Jackson's avatar Adam Jackson 💣

glx: Fix computation of GLX_X_RENDERABLE fbconfig attribute

>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's avatarAdam Jackson <ajax@redhat.com>
Reviewed-by: Eric Anholt's avatarEric Anholt <eric@anholt.net>
parent 589f42e9
......@@ -1104,7 +1104,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);
......
......@@ -994,10 +994,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));
......
......@@ -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;
......
......@@ -33,8 +33,7 @@ struct __GLXDRIconfig {
};
__GLXconfig *glxConvertConfigs(const __DRIcoreExtension * core,
const __DRIconfig ** configs,
unsigned int drawableType);
const __DRIconfig ** configs);
extern const __DRIsystemTimeExtension systemTimeExtension;
......
......@@ -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");
......
......@@ -78,7 +78,6 @@ struct __GLXconfig {
/* SGIX_fbconfig / GLX 1.3 */
GLint drawableType;
GLint renderType;
GLint xRenderable;
GLint fbconfigID;
/* SGIX_pbuffer / GLX 1.3 */
......
......@@ -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;
......
......@@ -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 */
......
......@@ -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 */
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment