On Mon, Apr 27, 2015 at 9:58 AM, Brian Paul <bri...@vmware.com> wrote: > On 04/27/2015 07:39 AM, Ilia Mirkin wrote: >> >> On Mon, Apr 27, 2015 at 9:38 AM, Brian Paul <bri...@vmware.com> wrote: >>> >>> On 04/27/2015 07:23 AM, Ilia Mirkin wrote: >>>> >>>> >>>> Some required extension might be missing, and we may expose a GLSL >>>> version that does not match up with the GL version. Fix that up when >>>> computing the GL version. >>>> >>>> Signed-off-by: Ilia Mirkin <imir...@alum.mit.edu> >>>> --- >>>> src/mesa/main/version.c | 11 ++++++++++- >>>> 1 file changed, 10 insertions(+), 1 deletion(-) >>>> >>>> diff --git a/src/mesa/main/version.c b/src/mesa/main/version.c >>>> index a65ace0..bf0a1cf 100644 >>>> --- a/src/mesa/main/version.c >>>> +++ b/src/mesa/main/version.c >>>> @@ -207,7 +207,7 @@ _mesa_override_glsl_version(struct gl_constants >>>> *consts) >>>> */ >>>> static GLuint >>>> compute_version(const struct gl_extensions *extensions, >>>> - const struct gl_constants *consts, gl_api api) >>>> + struct gl_constants *consts, gl_api api) >>>> { >>>> GLuint major, minor, version; >>>> >>>> @@ -330,38 +330,47 @@ compute_version(const struct gl_extensions >>>> *extensions, >>>> if (ver_4_2) { >>>> major = 4; >>>> minor = 2; >>>> + consts->GLSLVersion = 420; >>>> } >>>> else if (ver_4_1) { >>>> major = 4; >>>> minor = 1; >>>> + consts->GLSLVersion = 410; >>>> } >>>> else if (ver_4_0) { >>>> major = 4; >>>> minor = 0; >>>> + consts->GLSLVersion = 400; >>>> } >>>> else if (ver_3_3) { >>>> major = 3; >>>> minor = 3; >>>> + consts->GLSLVersion = 330; >>>> } >>>> else if (ver_3_2) { >>>> major = 3; >>>> minor = 2; >>>> + consts->GLSLVersion = 150; >>>> } >>>> else if (ver_3_1) { >>>> major = 3; >>>> minor = 1; >>>> + consts->GLSLVersion = 140; >>>> } >>>> else if (ver_3_0) { >>>> major = 3; >>>> minor = 0; >>>> + consts->GLSLVersion = 130; >>>> } >>>> else if (ver_2_1) { >>>> major = 2; >>>> minor = 1; >>>> + consts->GLSLVersion = 120; >>>> } >>>> else if (ver_2_0) { >>>> major = 2; >>>> minor = 0; >>>> + consts->GLSLVersion = 110; >>>> } >>>> else if (ver_1_5) { >>>> major = 1; >>>> >>> >>> This looks OK, but another approach might be to have a new function which >>> returns the GLSL version for a given GL version (could be encoded in a >>> small >>> table). Then, use that function to clamp/set consts->GLSLVersion. That >>> way >>> we can keep the nice const-ness of the compute_version() parameters. >> >> >> Where do you envision the clamping be done? > > > How about _mesa_compute_version()?
... which is the only caller of compute_version(). You just want it split up into a separate switch statement or something? _______________________________________________ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev