Fix emulator launch crash on MAC 66/205566/1
authorKarthik Bhat <kv.bhat@samsung.com>
Tue, 7 May 2019 11:11:48 +0000 (16:41 +0530)
committerKarthik Bhat <kv.bhat@samsung.com>
Tue, 7 May 2019 11:11:48 +0000 (16:41 +0530)
Change-Id: Ie7d529c93940a1e6fbbd26987cb3d70ef40a4ad0
Signed-off-by: Karthik Bhat <kv.bhat@samsung.com>
hw/yagl/yagl_drivers/egl_cgl/yagl_egl_cgl.c
package/changelog
package/pkginfo.manifest

index 0f398babde77d77119762a7d9b3b75fae9d80add..90cd0bc332da0178d17f35e01d5ed6d6ef4a94fd 100644 (file)
@@ -387,14 +387,24 @@ static EGLSurface yagl_egl_cgl_pbuffer_surface_create(struct yagl_egl_driver *dr
                         width,
                         height);
 
-    error = CGLCreatePBuffer(width, height, GL_TEXTURE_2D, GL_RGBA,
-                             0, &pbuffer);
-
-    if (error) {
-        YAGL_LOG_ERROR("CGLCreatePBuffer failed: %s", CGLErrorString(error));
-        pbuffer = NULL;
+    // TODO: Migrate to Metal Framework
+    // CGLCreatePBuffer is deprecated on MAC.
+    // Below hack is to fix Emulator launch issue on MAC.
+    // The surface returned by CGLCreatePBuffer is not used in case of opengl 3.2
+    // Hence return dummy surface in case of opengl 3.2 instead of returning null and exiting.
+    if (driver->gl_version > yagl_gl_2) {
+       YAGL_LOG_INFO("Creating Dummy EGLSurface\n");
+       pbuffer = (EGLSurface)1;
     }
+    else {
+        error = CGLCreatePBuffer(width, height, GL_TEXTURE_2D, GL_RGBA,
+                                0, &pbuffer);
 
+        if (error) {
+            YAGL_LOG_ERROR("CGLCreatePBuffer failed: %s", CGLErrorString(error));
+            pbuffer = NULL;
+        }
+    }
     YAGL_LOG_FUNC_EXIT("%p", pbuffer);
 
     return pbuffer;
@@ -410,11 +420,12 @@ static void yagl_egl_cgl_pbuffer_surface_destroy(struct yagl_egl_driver *driver,
                         "dpy = %p, sfc = %p",
                         dpy,
                         sfc);
+    if (!(driver->gl_version > yagl_gl_2)) {
+        error = CGLDestroyPBuffer((CGLPBufferObj)sfc);
 
-    error = CGLDestroyPBuffer((CGLPBufferObj)sfc);
-
-    if (error) {
-        YAGL_LOG_ERROR("CGLDestroyPBuffer failed: %s", CGLErrorString(error));
+        if (error) {
+            YAGL_LOG_ERROR("CGLDestroyPBuffer failed: %s", CGLErrorString(error));
+        }
     }
 
     YAGL_LOG_FUNC_EXIT(NULL);
@@ -445,7 +456,7 @@ static EGLContext yagl_egl_cgl_context_create(struct yagl_egl_driver *driver,
         share_ctx = NULL;
     }
 
-    if ((egl_cgl->base.gl_version > yagl_gl_2) && (version != 1)) {
+    if (egl_cgl->base.gl_version > yagl_gl_2) {
         ctx->is_3_2_core = true;
     } else {
         ctx->is_3_2_core = false;
@@ -504,7 +515,7 @@ static bool yagl_egl_cgl_make_current(struct yagl_egl_driver *driver,
                         draw,
                         read,
                         ctx);
-
+    // Call CGLSetPBuffer only in case a valid CGLCreatePBuffer is created.
     if (cgl_ctx && !cgl_ctx->is_3_2_core) {
         if (read_pbuffer) {
             error = CGLSetPBuffer(cgl_ctx->base, read_pbuffer, 0, 0, 0);
index 65437419dae3cee4523796a956b500f1cc3c8cf5..c3d90452b1e0fbe59ff19d51ce2b94b3f47d0ae9 100644 (file)
@@ -1,3 +1,6 @@
+* 2.8.0.19
+- YAGL: Fix emulator launch fail on MAC
+== Karthik Bhat <kv.bhat@samsung.com> 2019-05-07
 * 2.8.0.18
 - MAC build error resolved
 == Rahul Dadhich <r.dadhich@samsung.com> 2018-11-30
index b286f39b8729a614d9b165300d87d947ee7d84e0..5a8fcde5761863b9c8d2b42177e1c15a097c2d8b 100644 (file)
@@ -1,4 +1,4 @@
-Version: 2.8.0.18
+Version: 2.8.0.19
 Maintainer: SeokYeon Hwang <syeon.hwang@samsung.com>
 Source: emulator