YaGL: Fix for Tizen's WebKit incorrect EGL config choice
authorStanislav Vorobiov <s.vorobiov@samsung.com>
Fri, 17 May 2013 09:36:23 +0000 (13:36 +0400)
committerStanislav Vorobiov <s.vorobiov@samsung.com>
Fri, 17 May 2013 09:36:23 +0000 (13:36 +0400)
YaGL: Enable stencil buffer attachment in GL framebuffers

Tizen's WebKit doesn't choose EGL config the right way, we
fix it inside YaGL

We enable stencil buffer attachment in GL framebuffers, it was
disabled long ago because of the problems with WebGL gallery, I
guess now they're gone, and we can restore things as they should be

hw/yagl_apis/egl/yagl_egl_config.c
hw/yagl_apis/gles/yagl_gles_framebuffer.c

index f730d75..35c9928 100644 (file)
@@ -197,6 +197,25 @@ struct yagl_egl_config
             continue;
         }
 
+        /*
+         * A bugfix for Tizen's WebKit. When it chooses a config it
+         * doesn't always pass EGL_DEPTH_SIZE, thus, if host GPU has at least
+         * one config without a depth buffer it gets chosen (EGL_DEPTH_SIZE is
+         * 0 by default and has an AtLeast,Smaller sorting rule). But WebKit
+         * WANTS THE DEPTH BUFFER! If someone wants to have a depth buffer
+         * a value greater than zero must be passed with EGL_DEPTH_SIZE,
+         * read the manual goddamit!
+         *
+         * P.S: We just drop all configs with depth_size == 0 and
+         * also with stencil_size == 0, just in case.
+         */
+        if ((native_configs[i].depth_size == 0) ||
+            (native_configs[i].stencil_size == 0)) {
+            dpy->backend_dpy->config_cleanup(dpy->backend_dpy,
+                                             &native_configs[i]);
+            continue;
+        }
+
         configs[*num_configs] = yagl_egl_config_create(dpy, &native_configs[i]);
 
         ++*num_configs;
index 900ab50..27aea9e 100644 (file)
@@ -81,21 +81,10 @@ bool yagl_gles_framebuffer_renderbuffer(struct yagl_gles_framebuffer *fb,
         fb->attachment_states[framebuffer_attachment].local_name = 0;
     }
 
-    /*
-     * Standalone stencil attachments are not supported on modern
-     * desktop graphics cards, so we just drop it here. Currently this
-     * doesn't do us any harm, but apps in target system that use
-     * framebuffers with stencil buffers might not be displayed correctly.
-     * If this ever happens we'll have to work around here by create some
-     * dummy texture with both color and stencil buffers and copying stencil
-     * data from that texture to texture/renderbuffer being attached here.
-     */
-    if (attachment != GL_STENCIL_ATTACHMENT) {
-        fb->driver->FramebufferRenderbuffer(target,
-                                            attachment,
-                                            renderbuffer_target,
-                                            (rb ? rb->global_name : 0));
-    }
+    fb->driver->FramebufferRenderbuffer(target,
+                                        attachment,
+                                        renderbuffer_target,
+                                        (rb ? rb->global_name : 0));
 
     return true;
 }
@@ -137,13 +126,11 @@ bool yagl_gles_framebuffer_texture2d(struct yagl_gles_framebuffer *fb,
         fb->attachment_states[framebuffer_attachment].local_name = 0;
     }
 
-    if (attachment != GL_STENCIL_ATTACHMENT) {
-        fb->driver->FramebufferTexture2D(target,
-                                         attachment,
-                                         textarget,
-                                         (texture ? texture->global_name : 0),
-                                         level);
-    }
+    fb->driver->FramebufferTexture2D(target,
+                                     attachment,
+                                     textarget,
+                                     (texture ? texture->global_name : 0),
+                                     level);
 
     return true;
 }