glx: Validate the GLX_RENDER_TYPE value

Correctly handle the value of renderType in GLX context.  In case of the
value being incorrect, context creation fails.

v2 (idr): indirect_create_context is just a memory allocator, so don't
validate the GLX_RENDER_TYPE there.  Fixes regressions in several
GLX_ARB_create_context piglit tests.

Signed-off-by: Tomasz Lis <tomasz.lis@intel.com>
Signed-off-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
This commit is contained in:
Tomasz Lis
2013-07-18 14:19:38 -07:00
committed by Ian Romanick
parent 27c8aa5cfb
commit 2eed9ff2fb
7 changed files with 59 additions and 1 deletions

View File

@@ -224,6 +224,33 @@ ValidateGLXFBConfig(Display * dpy, GLXFBConfig fbconfig)
return NULL;
}
/**
* Verifies context's GLX_RENDER_TYPE value with config.
*
* \param config GLX FBConfig which will support the returned renderType.
* \param renderType The context render type to be verified.
* \return True if the value of context renderType was approved, or 0 if no
* valid value was found.
*/
Bool
validate_renderType_against_config(const struct glx_config *config,
int renderType)
{
switch (renderType) {
case GLX_RGBA_TYPE:
return (config->renderType & GLX_RGBA_BIT) != 0;
case GLX_COLOR_INDEX_TYPE:
return (config->renderType & GLX_COLOR_INDEX_BIT) != 0;
case GLX_RGBA_FLOAT_TYPE_ARB:
return (config->renderType & GLX_RGBA_FLOAT_BIT_ARB) != 0;
case GLX_RGBA_UNSIGNED_FLOAT_TYPE_EXT:
return (config->renderType & GLX_RGBA_UNSIGNED_FLOAT_BIT_EXT) != 0;
default:
break;
}
return 0;
}
_X_HIDDEN Bool
glx_context_init(struct glx_context *gc,
struct glx_screen *psc, struct glx_config *config)