[Cogl] [PATCH] gpu-info: consider "(Core Profile)" GL version annotation
Robert Bragg
robert at sixbynine.org
Tue Jul 16 18:01:21 PDT 2013
From: Robert Bragg <robert at linux.intel.com>
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.
---
cogl/cogl-gpu-info.c | 26 ++++++++++++++++++++++++--
1 file changed, 24 insertions(+), 2 deletions(-)
diff --git a/cogl/cogl-gpu-info.c b/cogl/cogl-gpu-info.c
index 0d23c97..b6b1ae6 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)
--
1.8.3.1
More information about the Cogl
mailing list