From 8de1f83b1cb631d81cc2629baa68c41705a8d348 Mon Sep 17 00:00:00 2001 From: Robert Bragg Date: Wed, 17 Jul 2013 01:30:39 +0100 Subject: [PATCH] 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 (cherry picked from commit 1a074173d20857c7bedb6a862958713e5ef8d2d1) --- 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 0d23c977b..2aae9fcac 100644 --- a/cogl/cogl-gpu-info.c +++ b/cogl/cogl-gpu-info.c @@ -28,6 +28,8 @@ #include #include +#include + #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)