YaGL/VIGS: GLESv3 workarounds for Mac OS X 10.7 34/20834/1
authorStanislav Vorobiov <s.vorobiov@samsung.com>
Mon, 12 May 2014 12:56:54 +0000 (16:56 +0400)
committerStanislav Vorobiov <s.vorobiov@samsung.com>
Tue, 13 May 2014 06:16:13 +0000 (10:16 +0400)
Mac OS X 10.7 supports OpenGL 3.2, however, it doesn't have
all the necessary functions implemented in order to implement
GLESv3 on target. This workaround checks for some mandatory
functions and if at least one of them is not present - we revert
back to OpenGL 2.1. A nicer fix would be checking for OpenGL
functions globally, not in CGL backend, this is a TODO

Change-Id: I9c0acce3220af9ed7276a8586fa18b97d8223079
Signed-off-by: Stanislav Vorobiov <s.vorobiov@samsung.com>
hw/vigs/vigs_gl_backend_cgl.c
hw/yagl/yagl_drivers/egl_cgl/yagl_egl_cgl.c

index fd22577201ed006d23faa479241dbff9220ecf61..da2f9f63b8ed2266c6ce2c7d6649feb07253d394 100644 (file)
@@ -88,6 +88,16 @@ struct vigs_gl_backend_cgl
     CGLContextObj context;
 };
 
+static const char *gl_3_2_check_funcs[] =
+{
+    "glGenTransformFeedbacks",
+    "glBindTransformFeedback",
+    "glPauseTransformFeedback",
+    "glResumeTransformFeedback",
+    "glDeleteTransformFeedbacks",
+    "glVertexAttribDivisor"
+};
+
 static bool vigs_gl_backend_cgl_check_gl_version(struct vigs_gl_backend_cgl *gl_backend_cgl,
                                                  bool *is_gl_2)
 {
@@ -96,6 +106,7 @@ static bool vigs_gl_backend_cgl_check_gl_version(struct vigs_gl_backend_cgl *gl_
     const char *tmp;
     CGLPixelFormatObj pixel_format;
     int n;
+    unsigned int i;
 
     tmp = getenv("GL_VERSION");
 
@@ -135,6 +146,19 @@ static bool vigs_gl_backend_cgl_check_gl_version(struct vigs_gl_backend_cgl *gl_
 
     CGLDestroyPixelFormat(pixel_format);
 
+    for (i = 0;
+         i < sizeof(gl_3_2_check_funcs)/sizeof(gl_3_2_check_funcs[0]);
+         ++i) {
+        if (!dlsym(gl_backend_cgl->handle,
+                   gl_3_2_check_funcs[i])) {
+            VIGS_LOG_INFO("Failed to find function \"%s\", using OpenGL 2.1",
+                          gl_3_2_check_funcs[i]);
+            *is_gl_2 = true;
+            res = true;
+            goto out;
+        }
+    }
+
     VIGS_LOG_INFO("Using OpenGL 3.2");
     *is_gl_2 = false;
     res = true;
index 32839a6d7f8868bbf6c747e753cf4e1ecac3047d..31bf8d63c2d915211fb5f130a083ac8bfccedcef 100644 (file)
@@ -88,6 +88,16 @@ struct yagl_egl_cgl_context
     bool is_3_2_core;
 };
 
+static const char *gl_3_2_check_funcs[] =
+{
+    "glGenTransformFeedbacks",
+    "glBindTransformFeedback",
+    "glPauseTransformFeedback",
+    "glResumeTransformFeedback",
+    "glDeleteTransformFeedbacks",
+    "glVertexAttribDivisor"
+};
+
 static bool yagl_egl_cgl_get_gl_version(struct yagl_egl_cgl *egl_cgl,
                                         yagl_gl_version *version)
 {
@@ -96,6 +106,7 @@ static bool yagl_egl_cgl_get_gl_version(struct yagl_egl_cgl *egl_cgl,
     const char *tmp;
     CGLPixelFormatObj pixel_format;
     int n;
+    unsigned int i;
 
     YAGL_LOG_FUNC_ENTER(yagl_egl_cgl_get_gl_version, NULL);
 
@@ -137,6 +148,19 @@ static bool yagl_egl_cgl_get_gl_version(struct yagl_egl_cgl *egl_cgl,
 
     CGLDestroyPixelFormat(pixel_format);
 
+    for (i = 0;
+         i < sizeof(gl_3_2_check_funcs)/sizeof(gl_3_2_check_funcs[0]);
+         ++i) {
+        if (!yagl_dyn_lib_get_sym(egl_cgl->base.dyn_lib,
+                                  gl_3_2_check_funcs[i])) {
+            YAGL_LOG_INFO("Failed to find function \"%s\", using OpenGL 2.1",
+                          gl_3_2_check_funcs[i]);
+            *version = yagl_gl_2;
+            res = true;
+            goto out;
+        }
+    }
+
     YAGL_LOG_INFO("Using OpenGL 3.2");
     *version = yagl_gl_3_2;
     res = true;