On 08/08/2012 10:38 AM, Ian Romanick wrote: > From: Ian Romanick <ian.d.roman...@intel.com> > > Signed-off-by: Ian Romanick <ian.d.roman...@intel.com> > --- > src/mesa/drivers/dri/i915/i915_context.c | 35 > ++++++++++++++++++++++++++++- > src/mesa/drivers/dri/i915/i915_context.h | 3 ++ > src/mesa/drivers/dri/intel/intel_screen.c | 4 +++ > 3 files changed, 41 insertions(+), 1 deletions(-) > > diff --git a/src/mesa/drivers/dri/i915/i915_context.c > b/src/mesa/drivers/dri/i915/i915_context.c > index dc32292..0729479 100644 > --- a/src/mesa/drivers/dri/i915/i915_context.c > +++ b/src/mesa/drivers/dri/i915/i915_context.c > @@ -146,6 +146,9 @@ bool > i915CreateContext(int api, > const struct gl_config * mesaVis, > __DRIcontext * driContextPriv, > + unsigned major_version, > + unsigned minor_version, > + unsigned *error, > void *sharedContextPrivate) > { > struct dd_function_table functions; > @@ -153,8 +156,10 @@ i915CreateContext(int api, > struct intel_context *intel = &i915->intel; > struct gl_context *ctx = &intel->ctx; > > - if (!i915) > + if (!i915) { > + *error = __DRI_CTX_ERROR_NO_MEMORY; > return false; > + } > > i915InitVtbl(i915); > > @@ -163,6 +168,34 @@ i915CreateContext(int api, > if (!intelInitContext(intel, api, mesaVis, driContextPriv, > sharedContextPrivate, &functions)) { > FREE(i915); > + *error = __DRI_CTX_ERROR_NO_MEMORY; > + return false; > + } > + > + /* Now that the extension bits are known, filter against the requested API > + * and version. > + */ > + switch (api) { > + case API_OPENGL: { > + const unsigned max_version = > + (ctx->Extensions.ARB_fragment_shader > + && ctx->Extensions.ARB_occlusion_query) > + ? 0x200 : 0x105; > + const unsigned req_version = (major_version << 8) | minor_version;
Not the most readable of code. I'd prefer: const unsigned max_version = (ctx->Extensions.ARB_fragment_shader && ctx->Extensions.ARB_occlusion_query) ? 20 : 15; const unsigned requested_ver = major_version * 10 + minor_version; That matches the style we use in ctx->Version. Otherwise, Reviewed-by: Kenneth Graunke <kenn...@whitecape.org> > + if (req_version > max_version) { > + *error = __DRI_CTX_ERROR_BAD_VERSION; > + FREE(i915); > + return false; > + } > + break; > + } > + case API_OPENGLES: > + case API_OPENGLES2: > + break; > + default: > + *error = __DRI_CTX_ERROR_BAD_API; > + FREE(i915); > return false; > } > > diff --git a/src/mesa/drivers/dri/i915/i915_context.h > b/src/mesa/drivers/dri/i915/i915_context.h > index 7037465..f5c1596 100644 > --- a/src/mesa/drivers/dri/i915/i915_context.h > +++ b/src/mesa/drivers/dri/i915/i915_context.h > @@ -322,6 +322,9 @@ do { > \ > extern bool i915CreateContext(int api, > const struct gl_config * mesaVis, > __DRIcontext * driContextPriv, > + unsigned major_version, > + unsigned minor_version, > + unsigned *error, > void *sharedContextPrivate); > > > diff --git a/src/mesa/drivers/dri/intel/intel_screen.c > b/src/mesa/drivers/dri/intel/intel_screen.c > index 2fef8fe..bc8c265 100644 > --- a/src/mesa/drivers/dri/intel/intel_screen.c > +++ b/src/mesa/drivers/dri/intel/intel_screen.c > @@ -680,6 +680,9 @@ extern bool > i915CreateContext(int api, > const struct gl_config *mesaVis, > __DRIcontext *driContextPriv, > + unsigned major_version, > + unsigned minor_version, > + unsigned *error, > void *sharedContextPrivate); > extern bool > brwCreateContext(int api, > @@ -721,6 +724,7 @@ intelCreateContext(gl_api api, > #ifdef I915 > if (IS_9XX(intelScreen->deviceID)) { > success = i915CreateContext(api, mesaVis, driContextPriv, > + major_version, minor_version, error, > sharedContextPrivate); > } else { > switch (api) { > _______________________________________________ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev