[PATCH 5/7] glamor: compute GLSL version from GL_SHADING_LANGUAGE_VERSION
Kenneth Graunke
kenneth at whitecape.org
Mon May 11 23:43:17 PDT 2015
On Monday, May 11, 2015 09:23:56 PM Keith Packard wrote:
> This replaces a kludge which used the GL version as a proxy for the
> GLSL version.
>
> Signed-off-by: Keith Packard <keithp at keithp.com>
> ---
> glamor/glamor.c | 20 +++++++++++++-------
> 1 file changed, 13 insertions(+), 7 deletions(-)
>
> diff --git a/glamor/glamor.c b/glamor/glamor.c
> index 6f4f309..641c2e4 100644
> --- a/glamor/glamor.c
> +++ b/glamor/glamor.c
> @@ -337,6 +337,8 @@ glamor_init(ScreenPtr screen, unsigned int flags)
> glamor_screen_private *glamor_priv;
> int gl_version;
> int max_viewport_size[2];
> + const char *shading_version_string;
> +
> PictureScreenPtr ps = GetPictureScreenIfSet(screen);
>
> if (flags & ~GLAMOR_VALID_FLAGS) {
> @@ -380,14 +382,18 @@ glamor_init(ScreenPtr screen, unsigned int flags)
>
> gl_version = epoxy_gl_version();
>
> - /* Would be nice to have a cleaner test for GLSL 1.30 support,
> - * but for now this should suffice
> - */
> - if (glamor_priv->gl_flavor == GLAMOR_GL_DESKTOP && gl_version >= 30)
> - glamor_priv->glsl_version = 130;
> - else
> - glamor_priv->glsl_version = 120;
> + shading_version_string = (char *) glGetString(GL_SHADING_LANGUAGE_VERSION);
>
> + glamor_priv->glsl_version = 0;
> + if (shading_version_string)
> + glamor_priv->glsl_version = (int) (strtof(shading_version_string, NULL) * 100.0 + 0.5);
> +
> + if (glamor_priv->glsl_version < 100 || glamor_priv->glsl_version > 1000) {
> + if (glamor_priv->gl_flavor == GLAMOR_GL_DESKTOP && gl_version >= 30)
> + glamor_priv->glsl_version = 130;
> + else
> + glamor_priv->glsl_version = 120;
> + }
>
> /* We'd like to require GL_ARB_map_buffer_range or
> * GL_OES_map_buffer_range, since it offers more information to
>
Sadly, this won't work for GLES contexts.
The format of the GL_SHADING_LANGUAGE_VERSION string, on GL, is:
<version number><space>vendor-specific information>
i.e. "3.30 from the totally awesome X.org project"
but in GLES, it's:
"OpenGL ES GLSL ES N.M vendor-specific information"
i.e. "OpenGL ES GLSL ES 3.00"
If you care about making that work, I recommend swiping Piglit's
piglit_get_glsl_version() function, available here:
http://cgit.freedesktop.org/piglit/tree/tests/util/piglit-shader.c#n28
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: This is a digitally signed message part.
URL: <http://lists.x.org/archives/xorg-devel/attachments/20150511/fead12b6/attachment.sig>
More information about the xorg-devel
mailing list