[PATCH 5/7] glamor: compute GLSL version from GL_SHADING_LANGUAGE_VERSION

Keith Packard keithp at keithp.com
Mon May 11 21:23:56 PDT 2015


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
-- 
2.1.4



More information about the xorg-devel mailing list