dri: Pass API_OPENGL_CORE through to the drivers
This forces the drivers to do at least some validation of context API and version before creating the context. In r100 and r200 drivers, this means that they don't do any post-hoc validation. v2: Actually reject compatibility profile 3.2+ contexts. Thanks Ken. Signed-off-by: Ian Romanick <ian.d.romanick@intel.com> Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
This commit is contained in:
@@ -192,6 +192,8 @@ dri2CreateContextAttribs(__DRIscreen *screen, int api,
|
||||
mesa_api = API_OPENGLES2;
|
||||
break;
|
||||
case __DRI_API_OPENGL_CORE:
|
||||
mesa_api = API_OPENGL_CORE;
|
||||
break;
|
||||
default:
|
||||
*error = __DRI_CTX_ERROR_BAD_API;
|
||||
return NULL;
|
||||
@@ -218,6 +220,20 @@ dri2CreateContextAttribs(__DRIscreen *screen, int api,
|
||||
}
|
||||
}
|
||||
|
||||
/* Mesa does not support the GL_ARB_compatibilty extension or the
|
||||
* compatibility profile. This means that we treat a API_OPENGL 3.1 as
|
||||
* API_OPENGL_CORE and reject API_OPENGL 3.2+.
|
||||
*/
|
||||
if (mesa_api == API_OPENGL && major_version == 3 && minor_version == 1)
|
||||
mesa_api = API_OPENGL_CORE;
|
||||
|
||||
if (mesa_api == API_OPENGL
|
||||
&& ((major_version > 3)
|
||||
|| (major_version == 3 && minor_version >= 2))) {
|
||||
*error = __DRI_CTX_ERROR_BAD_API;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* The EGL_KHR_create_context spec says:
|
||||
*
|
||||
* "Flags are only defined for OpenGL context creation, and specifying
|
||||
|
||||
@@ -714,6 +714,23 @@ intelCreateContext(gl_api api,
|
||||
struct intel_screen *intelScreen = sPriv->driverPrivate;
|
||||
bool success = false;
|
||||
|
||||
switch (api) {
|
||||
case API_OPENGL:
|
||||
case API_OPENGLES:
|
||||
break;
|
||||
case API_OPENGLES2:
|
||||
#ifdef I915
|
||||
if (!IS_9XX(intelScreen->deviceID)) {
|
||||
*error = __DRI_CTX_ERROR_BAD_API;
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
break;
|
||||
case API_OPENGL_CORE:
|
||||
*error = __DRI_CTX_ERROR_BAD_API;
|
||||
return GL_FALSE;
|
||||
}
|
||||
|
||||
#ifdef I915
|
||||
if (IS_9XX(intelScreen->deviceID)) {
|
||||
if (!IS_965(intelScreen->deviceID)) {
|
||||
|
||||
@@ -59,9 +59,31 @@ nouveau_context_create(gl_api api,
|
||||
struct nouveau_context *nctx;
|
||||
struct gl_context *ctx;
|
||||
|
||||
switch (api) {
|
||||
case API_OPENGL:
|
||||
/* Do after-the-fact version checking (below).
|
||||
*/
|
||||
break;
|
||||
case API_OPENGLES:
|
||||
/* NV10 and NV20 can support OpenGL ES 1.0 only. Older chips
|
||||
* cannot do even that.
|
||||
*/
|
||||
if ((screen->device->chipset & 0xf0) == 0x00) {
|
||||
*error = __DRI_CTX_ERROR_BAD_API;
|
||||
return GL_FALSE;
|
||||
} else if (minor_version != 0) {
|
||||
*error = __DRI_CTX_ERROR_BAD_VERSION;
|
||||
return GL_FALSE;
|
||||
}
|
||||
break;
|
||||
case API_OPENGLES2:
|
||||
case API_OPENGL_CORE:
|
||||
*error = __DRI_CTX_ERROR_BAD_API;
|
||||
return GL_FALSE;
|
||||
}
|
||||
|
||||
/* API and flag filtering is handled in dri2CreateContextAttribs.
|
||||
*/
|
||||
(void) api;
|
||||
(void) flags;
|
||||
|
||||
ctx = screen->driver->context_create(screen, visual, share_ctx);
|
||||
|
||||
@@ -212,9 +212,22 @@ GLboolean r200CreateContext( gl_api api,
|
||||
int i;
|
||||
int tcl_mode;
|
||||
|
||||
/* API and flag filtering is handled in dri2CreateContextAttribs.
|
||||
switch (api) {
|
||||
case API_OPENGL:
|
||||
if (major_version > 1 || minor_version > 3) {
|
||||
*error = __DRI_CTX_ERROR_BAD_VERSION;
|
||||
return GL_FALSE;
|
||||
}
|
||||
break;
|
||||
case API_OPENGLES:
|
||||
break;
|
||||
default:
|
||||
*error = __DRI_CTX_ERROR_BAD_API;
|
||||
return GL_FALSE;
|
||||
}
|
||||
|
||||
/* Flag filtering is handled in dri2CreateContextAttribs.
|
||||
*/
|
||||
(void) api;
|
||||
(void) flags;
|
||||
|
||||
assert(glVisual);
|
||||
@@ -454,11 +467,6 @@ GLboolean r200CreateContext( gl_api api,
|
||||
}
|
||||
|
||||
_mesa_compute_version(ctx);
|
||||
if (ctx->Version < major_version * 10 + minor_version) {
|
||||
r200DestroyContext(driContextPriv);
|
||||
*error = __DRI_CTX_ERROR_BAD_VERSION;
|
||||
return GL_FALSE;
|
||||
}
|
||||
|
||||
*error = __DRI_CTX_ERROR_SUCCESS;
|
||||
return GL_TRUE;
|
||||
|
||||
@@ -178,9 +178,22 @@ r100CreateContext( gl_api api,
|
||||
int i;
|
||||
int tcl_mode, fthrottle_mode;
|
||||
|
||||
/* API and flag filtering is handled in dri2CreateContextAttribs.
|
||||
switch (api) {
|
||||
case API_OPENGL:
|
||||
if (major_version > 1 || minor_version > 3) {
|
||||
*error = __DRI_CTX_ERROR_BAD_VERSION;
|
||||
return GL_FALSE;
|
||||
}
|
||||
break;
|
||||
case API_OPENGLES:
|
||||
break;
|
||||
default:
|
||||
*error = __DRI_CTX_ERROR_BAD_API;
|
||||
return GL_FALSE;
|
||||
}
|
||||
|
||||
/* Flag filtering is handled in dri2CreateContextAttribs.
|
||||
*/
|
||||
(void) api;
|
||||
(void) flags;
|
||||
|
||||
assert(glVisual);
|
||||
@@ -402,11 +415,6 @@ r100CreateContext( gl_api api,
|
||||
}
|
||||
|
||||
_mesa_compute_version(ctx);
|
||||
if (ctx->Version < major_version * 10 + minor_version) {
|
||||
radeonDestroyContext(driContextPriv);
|
||||
*error = __DRI_CTX_ERROR_BAD_VERSION;
|
||||
return GL_FALSE;
|
||||
}
|
||||
|
||||
*error = __DRI_CTX_ERROR_SUCCESS;
|
||||
return GL_TRUE;
|
||||
|
||||
@@ -719,11 +719,20 @@ dri_create_context(gl_api api,
|
||||
*/
|
||||
(void) flags;
|
||||
|
||||
if (api == API_OPENGL
|
||||
&& (major_version > 2
|
||||
|| (major_version == 2 && minor_version > 1))) {
|
||||
*error = __DRI_CTX_ERROR_BAD_VERSION;
|
||||
goto context_fail;
|
||||
switch (api) {
|
||||
case API_OPENGL:
|
||||
if (major_version > 2
|
||||
|| (major_version == 2 && minor_version > 1)) {
|
||||
*error = __DRI_CTX_ERROR_BAD_VERSION;
|
||||
return GL_FALSE;
|
||||
}
|
||||
break;
|
||||
case API_OPENGLES:
|
||||
case API_OPENGLES2:
|
||||
break;
|
||||
case API_OPENGL_CORE:
|
||||
*error = __DRI_CTX_ERROR_BAD_API;
|
||||
return GL_FALSE;
|
||||
}
|
||||
|
||||
ctx = CALLOC_STRUCT(dri_context);
|
||||
|
||||
Reference in New Issue
Block a user