[cogl] gpu-info: consider "(Core Profile)" GL version annotation



commit 1a074173d20857c7bedb6a862958713e5ef8d2d1
Author: Robert Bragg <robert linux intel com>
Date:   Wed Jul 17 01:30:39 2013 +0100

    gpu-info: consider "(Core Profile)" GL version annotation
    
    Mesa annotates the GL version string with "(Core Profile)" when using
    the OpenGL 3 core profile and so our heuristics that try and determine
    what vendor and GPU is being used where being confused. This updates
    the check_mesa_driver_package() function to consider this optional
    annotation.
    
    This adds a small unit test to verify the parsing of some example
    version strings. We can update this with more real world version strings
    if the format changes again in the future.
    
    Reviewed-by: Neil Roberts <neil linux intel com>

 cogl/cogl-gpu-info.c |   26 ++++++++++++++++++++++++--
 1 files changed, 24 insertions(+), 2 deletions(-)
---
diff --git a/cogl/cogl-gpu-info.c b/cogl/cogl-gpu-info.c
index 0d23c97..2aae9fc 100644
--- a/cogl/cogl-gpu-info.c
+++ b/cogl/cogl-gpu-info.c
@@ -28,6 +28,8 @@
 #include <string.h>
 #include <errno.h>
 
+#include <test-fixtures/test-unit.h>
+
 #include "cogl-gpu-info-private.h"
 #include "cogl-context-private.h"
 #include "cogl-version.h"
@@ -415,8 +417,10 @@ check_mesa_driver_package (const CoglGpuInfoStrings *strings,
                                             NULL /* version_ret */))
     return FALSE;
 
-  /* In mesa this will be followed by a space and the name "Mesa" */
-  if (!g_str_has_prefix (v, " Mesa "))
+  /* In mesa this will be followed optionally by "(Core Profile)" and
+   * then "Mesa" */
+  v = strstr (v, " Mesa ");
+  if (!v)
     return FALSE;
 
   v += 6;
@@ -451,6 +455,24 @@ check_mesa_driver_package (const CoglGpuInfoStrings *strings,
   return TRUE;
 }
 
+UNIT_TEST (check_mesa_driver_package_parser,
+           0, /* no requirements */
+           0 /* no failure cases */)
+{
+  const CoglGpuInfoStrings test_strings[] = {
+    { .version_string = "3.1 Mesa 9.2-devel15436ad" },
+    { .version_string = "3.1 (Core Profile) Mesa 9.2.0-devel (git-15436ad)" }
+  };
+  int i;
+  int version;
+
+  for (i = 0; i < G_N_ELEMENTS (test_strings); i++)
+    {
+      g_assert (check_mesa_driver_package (&test_strings[i], &version));
+      g_assert_cmpint (version, ==, COGL_VERSION_ENCODE (9, 2, 0));
+    }
+}
+
 static CoglBool
 check_unknown_driver_package (const CoglGpuInfoStrings *strings,
                               int *version_out)


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]