On 08/08/2012 10:38 AM, Ian Romanick wrote: > From: Ian Romanick <ian.d.roman...@intel.com> > > 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. > > Signed-off-by: Ian Romanick <ian.d.roman...@intel.com> > --- > src/mesa/drivers/dri/common/dri_util.c | 15 +++++++++++++++ > src/mesa/drivers/dri/intel/intel_screen.c | 17 +++++++++++++++++ > src/mesa/drivers/dri/nouveau/nouveau_context.c | 24 > +++++++++++++++++++++++- > src/mesa/drivers/dri/r200/r200_context.c | 22 +++++++++++++++------- > src/mesa/drivers/dri/radeon/radeon_context.c | 22 +++++++++++++++------- > src/mesa/drivers/dri/swrast/swrast.c | 19 ++++++++++++++----- > 6 files changed, 99 insertions(+), 20 deletions(-) > > diff --git a/src/mesa/drivers/dri/common/dri_util.c > b/src/mesa/drivers/dri/common/dri_util.c > index 91ae186..025a14a 100644 > --- a/src/mesa/drivers/dri/common/dri_util.c > +++ b/src/mesa/drivers/dri/common/dri_util.c > @@ -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,19 @@ 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))) { > + mesa_api = API_OPENGL_CORE; > + }
This doesn't look like rejecting API_OPENGL 3.2+. It looks like it converts it to API_OPENGL_CORE, just like you did for 3.1. I'll take your word for it that r100/r200 can only support GL 1.3, and about the NV chips. Looks OK other than that. > + > /* The EGL_KHR_create_context spec says: > * > * "Flags are only defined for OpenGL context creation, and > specifying > diff --git a/src/mesa/drivers/dri/intel/intel_screen.c > b/src/mesa/drivers/dri/intel/intel_screen.c > index 3c595bc..e541c7f 100644 > --- a/src/mesa/drivers/dri/intel/intel_screen.c > +++ b/src/mesa/drivers/dri/intel/intel_screen.c > @@ -701,6 +701,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)) { > diff --git a/src/mesa/drivers/dri/nouveau/nouveau_context.c > b/src/mesa/drivers/dri/nouveau/nouveau_context.c > index f794308..4409eae 100644 > --- a/src/mesa/drivers/dri/nouveau/nouveau_context.c > +++ b/src/mesa/drivers/dri/nouveau/nouveau_context.c > @@ -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); > diff --git a/src/mesa/drivers/dri/r200/r200_context.c > b/src/mesa/drivers/dri/r200/r200_context.c > index 17e08a1..5f8cc86 100644 > --- a/src/mesa/drivers/dri/r200/r200_context.c > +++ b/src/mesa/drivers/dri/r200/r200_context.c > @@ -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; > diff --git a/src/mesa/drivers/dri/radeon/radeon_context.c > b/src/mesa/drivers/dri/radeon/radeon_context.c > index 34c392e..e17c786 100644 > --- a/src/mesa/drivers/dri/radeon/radeon_context.c > +++ b/src/mesa/drivers/dri/radeon/radeon_context.c > @@ -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; > diff --git a/src/mesa/drivers/dri/swrast/swrast.c > b/src/mesa/drivers/dri/swrast/swrast.c > index ca6bda02..7773fd9 100644 > --- a/src/mesa/drivers/dri/swrast/swrast.c > +++ b/src/mesa/drivers/dri/swrast/swrast.c > @@ -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); > _______________________________________________ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev