[Mesa-dev] [PATCH v2] mesa: fix up GLSL version when computing GL version
In some situations it is convenient for a driver to expose a higher GLSL version while some extensions are still incomplete. However in that situation, it would report a GLSL version that was higher than the GL version. Avoid that situation by limiting the GLSL version to the GL version. Signed-off-by: Ilia Mirkin --- v1 -> v2: do work in _mesa_compute_version, not in compute_version only fix up core profile (easier and this situation doesn't come up for compat) src/mesa/main/version.c | 11 +++ 1 file changed, 11 insertions(+) diff --git a/src/mesa/main/version.c b/src/mesa/main/version.c index da255b2..6024dc8 100644 --- a/src/mesa/main/version.c +++ b/src/mesa/main/version.c @@ -483,6 +483,17 @@ _mesa_compute_version(struct gl_context *ctx) ctx->Version = _mesa_get_version(&ctx->Extensions, &ctx->Const, ctx->API); + /* Make sure that the GLSL version lines up with the GL version. In some +* cases it can be too high, e.g. if an extension is missing. +*/ + if (ctx->API == API_OPENGL_CORE) { + switch (ctx->Version) { + case 31: ctx->Const.GLSLVersion = 140; break; + case 32: ctx->Const.GLSLVersion = 150; break; + default: ctx->Const.GLSLVersion = ctx->Version * 10; break; + } + } + switch (ctx->API) { case API_OPENGL_COMPAT: case API_OPENGL_CORE: -- 2.0.5 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH v2] mesa: fix up GLSL version when computing GL version
On Mon, Apr 27, 2015 at 2:11 PM, Ilia Mirkin wrote: > In some situations it is convenient for a driver to expose a higher GLSL > version while some extensions are still incomplete. However in that > situation, it would report a GLSL version that was higher than the GL > version. Avoid that situation by limiting the GLSL version to the GL > version. > > Signed-off-by: Ilia Mirkin > --- > > v1 -> v2: > do work in _mesa_compute_version, not in compute_version > only fix up core profile (easier and this situation doesn't come up for > compat) > > src/mesa/main/version.c | 11 +++ > 1 file changed, 11 insertions(+) > > diff --git a/src/mesa/main/version.c b/src/mesa/main/version.c > index da255b2..6024dc8 100644 > --- a/src/mesa/main/version.c > +++ b/src/mesa/main/version.c > @@ -483,6 +483,17 @@ _mesa_compute_version(struct gl_context *ctx) > > ctx->Version = _mesa_get_version(&ctx->Extensions, &ctx->Const, ctx->API); > > + /* Make sure that the GLSL version lines up with the GL version. In some > +* cases it can be too high, e.g. if an extension is missing. > +*/ > + if (ctx->API == API_OPENGL_CORE) { > + switch (ctx->Version) { > + case 31: ctx->Const.GLSLVersion = 140; break; > + case 32: ctx->Const.GLSLVersion = 150; break; I could be off here (not being ultra familiar w/ this bit of code), but shouldn't it be something like: ctx->Const.GLSLVersion = MAX2(ctx->Const.GLSLVersion, 140); (and so on) Also, not quite related to this patch, but is it just me or does GL version override not work w/ gles for some reason? BR, -R > + default: ctx->Const.GLSLVersion = ctx->Version * 10; break; > + } > + } > + > switch (ctx->API) { > case API_OPENGL_COMPAT: > case API_OPENGL_CORE: > -- > 2.0.5 > > ___ > mesa-dev mailing list > mesa-dev@lists.freedesktop.org > http://lists.freedesktop.org/mailman/listinfo/mesa-dev ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH v2] mesa: fix up GLSL version when computing GL version
On Mon, Apr 27, 2015 at 3:10 PM, Rob Clark wrote: > On Mon, Apr 27, 2015 at 2:11 PM, Ilia Mirkin wrote: >> In some situations it is convenient for a driver to expose a higher GLSL >> version while some extensions are still incomplete. However in that >> situation, it would report a GLSL version that was higher than the GL >> version. Avoid that situation by limiting the GLSL version to the GL >> version. >> >> Signed-off-by: Ilia Mirkin >> --- >> >> v1 -> v2: >> do work in _mesa_compute_version, not in compute_version >> only fix up core profile (easier and this situation doesn't come up for >> compat) >> >> src/mesa/main/version.c | 11 +++ >> 1 file changed, 11 insertions(+) >> >> diff --git a/src/mesa/main/version.c b/src/mesa/main/version.c >> index da255b2..6024dc8 100644 >> --- a/src/mesa/main/version.c >> +++ b/src/mesa/main/version.c >> @@ -483,6 +483,17 @@ _mesa_compute_version(struct gl_context *ctx) >> >> ctx->Version = _mesa_get_version(&ctx->Extensions, &ctx->Const, >> ctx->API); >> >> + /* Make sure that the GLSL version lines up with the GL version. In some >> +* cases it can be too high, e.g. if an extension is missing. >> +*/ >> + if (ctx->API == API_OPENGL_CORE) { >> + switch (ctx->Version) { >> + case 31: ctx->Const.GLSLVersion = 140; break; >> + case 32: ctx->Const.GLSLVersion = 150; break; > > I could be off here (not being ultra familiar w/ this bit of code), > but shouldn't it be something like: > >ctx->Const.GLSLVersion = MAX2(ctx->Const.GLSLVersion, 140); No, I'm trying to make the GLSL version line up exactly to the GL version. > > (and so on) > > Also, not quite related to this patch, but is it just me or does GL > version override not work w/ gles for some reason? Probably for the reason that the GLES stuff is all different and separate... I've just hacked compute_version_es2 when necessary. > > BR, > -R > >> + default: ctx->Const.GLSLVersion = ctx->Version * 10; break; >> + } >> + } >> + >> switch (ctx->API) { >> case API_OPENGL_COMPAT: >> case API_OPENGL_CORE: >> -- >> 2.0.5 >> >> ___ >> mesa-dev mailing list >> mesa-dev@lists.freedesktop.org >> http://lists.freedesktop.org/mailman/listinfo/mesa-dev ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH v2] mesa: fix up GLSL version when computing GL version
On 04/27/2015 12:11 PM, Ilia Mirkin wrote: In some situations it is convenient for a driver to expose a higher GLSL version while some extensions are still incomplete. However in that situation, it would report a GLSL version that was higher than the GL version. Avoid that situation by limiting the GLSL version to the GL version. Signed-off-by: Ilia Mirkin --- v1 -> v2: do work in _mesa_compute_version, not in compute_version only fix up core profile (easier and this situation doesn't come up for compat) src/mesa/main/version.c | 11 +++ 1 file changed, 11 insertions(+) diff --git a/src/mesa/main/version.c b/src/mesa/main/version.c index da255b2..6024dc8 100644 --- a/src/mesa/main/version.c +++ b/src/mesa/main/version.c @@ -483,6 +483,17 @@ _mesa_compute_version(struct gl_context *ctx) ctx->Version = _mesa_get_version(&ctx->Extensions, &ctx->Const, ctx->API); + /* Make sure that the GLSL version lines up with the GL version. In some +* cases it can be too high, e.g. if an extension is missing. +*/ + if (ctx->API == API_OPENGL_CORE) { + switch (ctx->Version) { + case 31: ctx->Const.GLSLVersion = 140; break; + case 32: ctx->Const.GLSLVersion = 150; break; + default: ctx->Const.GLSLVersion = ctx->Version * 10; break; + } Would you mind formatting this like other switch/cases: case 31: ctx->Const.GLSLVersion = 140; break; + } + switch (ctx->API) { case API_OPENGL_COMPAT: case API_OPENGL_CORE: Looks OK otherwise. Reviewed-by: Brian Paul ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH v2] mesa: fix up GLSL version when computing GL version
On Mon, Apr 27, 2015 at 3:53 PM, Brian Paul wrote: > On 04/27/2015 12:11 PM, Ilia Mirkin wrote: >> >> In some situations it is convenient for a driver to expose a higher GLSL >> version while some extensions are still incomplete. However in that >> situation, it would report a GLSL version that was higher than the GL >> version. Avoid that situation by limiting the GLSL version to the GL >> version. >> >> Signed-off-by: Ilia Mirkin >> --- >> >> v1 -> v2: >>do work in _mesa_compute_version, not in compute_version >>only fix up core profile (easier and this situation doesn't come up for >> compat) >> >> src/mesa/main/version.c | 11 +++ >> 1 file changed, 11 insertions(+) >> >> diff --git a/src/mesa/main/version.c b/src/mesa/main/version.c >> index da255b2..6024dc8 100644 >> --- a/src/mesa/main/version.c >> +++ b/src/mesa/main/version.c >> @@ -483,6 +483,17 @@ _mesa_compute_version(struct gl_context *ctx) >> >> ctx->Version = _mesa_get_version(&ctx->Extensions, &ctx->Const, >> ctx->API); >> >> + /* Make sure that the GLSL version lines up with the GL version. In >> some >> +* cases it can be too high, e.g. if an extension is missing. >> +*/ >> + if (ctx->API == API_OPENGL_CORE) { >> + switch (ctx->Version) { >> + case 31: ctx->Const.GLSLVersion = 140; break; >> + case 32: ctx->Const.GLSLVersion = 150; break; >> + default: ctx->Const.GLSLVersion = ctx->Version * 10; break; >> + } > > > Would you mind formatting this like other switch/cases: Sure, done. I thought it was acceptable to do it this way for short statements. > > case 31: >ctx->Const.GLSLVersion = 140; >break; > >> + } >> + >> switch (ctx->API) { >> case API_OPENGL_COMPAT: >> case API_OPENGL_CORE: >> > > Looks OK otherwise. > Reviewed-by: Brian Paul Thanks. Pushed with the above reformatting. -ilia ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev