check-gl: Modified check-gl 33/29033/2
authorjinhyung.jo <jinhyung.jo@samsung.com>
Mon, 20 Oct 2014 11:48:55 +0000 (20:48 +0900)
committerjinhyung.jo <jinhyung.jo@samsung.com>
Tue, 21 Oct 2014 02:09:00 +0000 (11:09 +0900)
Add the routine to check GL driver vendor on Ubuntu

Change-Id: I373dcbbf61e6d0a71ec33fd968771ff526481341
Signed-off-by: Jinhyung Jo <jinhyung.jo@samsung.com>
tizen/src/emulator.c
tizen/src/util/check_gl_core.c

index a66de95..f101f64 100644 (file)
@@ -245,10 +245,33 @@ static void prepare_opengl_acceleration(gchar * const kernel_cmdline)
     if (enable_yagl) {
         capability_check_gl = check_gl();
 
-        if (capability_check_gl != 0) {
+        if (capability_check_gl == 1) {
             enable_yagl = 0;
-            LOG_INFO("<WARNING> GL acceleration was disabled due to the fail of GL check!\n");
+            LOG_INFO("<WARNING> GL acceleration was disabled "
+                     "due to the fail of GL check!\n");
+#ifndef CONFIG_LINUX
         }
+#else
+        } else if (capability_check_gl == 2) {
+            int ret = 0;
+            gchar *cmd = NULL;
+            char exec_cmd[] = "zenity --error --no-wrap --text=";
+            char err_msg[] =
+                 "\"You are using invalid graphic card driver for "
+                 "the emulator.\n"
+                 "You have to use the lastest vendor-provided graphic "
+                 "card driver.\n\nFor more information, see under ubuntu"
+                 " driver help page.\n"
+                 "https://help.ubuntu.com/community/BinaryDriverHowto/\"";
+            int cmd_len = strlen(exec_cmd) + strlen(err_msg);
+            cmd = g_malloc0(cmd_len);
+            snprintf(cmd, cmd_len + 1, "%s%s", exec_cmd, err_msg);
+            ret = system(cmd);
+            LOG_SEVERE("%s\nzenity return=%d\n", err_msg, ret);
+            g_free(cmd);
+            exit(-1);
+        }
+#endif
     }
 
     gchar * const tmp_str = g_strdup_printf(" yagl=%d", enable_yagl);
index c2280cf..a9ae1e4 100644 (file)
@@ -76,7 +76,11 @@ static const GLubyte *(GLAPIENTRY *get_stringi)(GLenum, GLuint);
 static void (GLAPIENTRY *get_integerv)(GLenum, GLint*);
 static void (GLAPIENTRY *dummy)(void);
 
+#if defined(__linux__) && !defined(__APPLE__)
+static struct gl_context *check_gl_version(gl_version version, int *isGallium)
+#else
 static struct gl_context *check_gl_version(gl_version version)
+#endif
 {
     struct gl_context *ctx = NULL;
     int hw = 1;
@@ -115,6 +119,14 @@ static struct gl_context *check_gl_version(gl_version version)
     check_gl_log(gl_info, "+ GL_RENDERER = %s", (const char*)get_string(GL_RENDERER));
     check_gl_log(gl_info, "+ GL_VERSION = %s", (const char*)get_string(GL_VERSION));
 
+#if defined(__linux__) && !defined(__APPLE__)
+    if ((strstr((const char *)get_string(GL_RENDERER), "Gallium") != NULL)) {
+        *isGallium = 1;
+    } else {
+        *isGallium = 0;
+    }
+#endif
+
     if (!hw) {
         check_gl_context_destroy(ctx);
         ctx = NULL;
@@ -145,6 +157,11 @@ int check_gl(void)
     int have_es3 = 0;
     int have_es3_compatibility = 0;
     int have_es1 = 0;
+#if defined(__linux__) && !defined(__APPLE__)
+    int isGallium_2 = 0;
+    int isGallium_3_1 = 0;
+    int isGallium_3_2 = 0;
+#endif
 
     if (!check_gl_init()) {
         return 1;
@@ -156,9 +173,21 @@ int check_gl(void)
         goto out;
     }
 
+#if defined(__linux__) && !defined(__APPLE__)
+    ctx_2 = check_gl_version(gl_2, &isGallium_2);
+    ctx_3_1 = check_gl_version(gl_3_1, &isGallium_3_1);
+    ctx_3_2 = check_gl_version(gl_3_2, &isGallium_3_2);
+
+    if (isGallium_2 || isGallium_3_1 || isGallium_3_2) {
+        check_gl_log(gl_error, "Host has Gallium GL driver!");
+        res = 2;
+        goto out;
+    }
+#else
     ctx_2 = check_gl_version(gl_2);
     ctx_3_1 = check_gl_version(gl_3_1);
     ctx_3_2 = check_gl_version(gl_3_2);
+#endif
 
     if (!ctx_2 && !ctx_3_1 && !ctx_3_2) {
         check_gl_log(gl_info, "Host does not have hardware GL acceleration!");