[Mesa-dev] [PATCH 1/2] mesa: fix up GLSL version when computing GL version

Brian Paul brianp at vmware.com
Mon Apr 27 06:38:23 PDT 2015


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 <imirkin at 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.

Otherwise, we should at least update the comments to indicate that the 
gl_constants can change.

-Brian



More information about the mesa-dev mailing list