[cogl/cogl-1.16] webgl: use DEPTH_STENCIL_ATTACHMENT



commit 29f08ef1248032920d8d0440994e9c0897d9b008
Author: Robert Bragg <robert linux intel com>
Date:   Sat May 11 22:14:00 2013 +0100

    webgl: use DEPTH_STENCIL_ATTACHMENT
    
    WebGL doesn't allow you to separately attach buffers to the
    STENCIL_ATTACHMENT and DEPTH_ATTACHMENT framebuffer attachment points
    and instead requires you to use the DEPTH_STENCIL_ATTACHMENT whenever
    you want a depth and stencil buffer.
    
    Reviewed-by: Neil Roberts <neil linux intel com>
    
    (cherry picked from commit ec7b6360c9c4e45e0b113f9dca7bb1502e7e93be)

 cogl/driver/gl/cogl-framebuffer-gl.c |   29 ++++++++++++++++++++++++++---
 1 files changed, 26 insertions(+), 3 deletions(-)
---
diff --git a/cogl/driver/gl/cogl-framebuffer-gl.c b/cogl/driver/gl/cogl-framebuffer-gl.c
index 660098e..efb82e3 100644
--- a/cogl/driver/gl/cogl-framebuffer-gl.c
+++ b/cogl/driver/gl/cogl-framebuffer-gl.c
@@ -65,6 +65,9 @@
 #ifndef GL_DEPTH_ATTACHMENT
 #define GL_DEPTH_ATTACHMENT     0x8D00
 #endif
+#ifndef GL_DEPTH_STENCIL_ATTACHMENT
+#define GL_DEPTH_STENCIL_ATTACHMENT 0x821A
+#endif
 #ifndef GL_DEPTH_COMPONENT16
 #define GL_DEPTH_COMPONENT16    0x81A5
 #endif
@@ -459,6 +462,11 @@ try_creating_renderbuffers (CoglContext *ctx,
     {
       GLenum format;
 
+      /* WebGL adds a GL_DEPTH_STENCIL_ATTACHMENT and requires that we
+       * use the GL_DEPTH_STENCIL format. */
+#ifdef HAVE_COGL_WEBGL
+      format = GL_DEPTH_STENCIL;
+#else
       /* Although GL_OES_packed_depth_stencil is mostly equivalent to
        * GL_EXT_packed_depth_stencil, one notable difference is that
        * GL_OES_packed_depth_stencil doesn't allow GL_DEPTH_STENCIL to
@@ -475,6 +483,7 @@ try_creating_renderbuffers (CoglContext *ctx,
                                   NULL);
           format = GL_DEPTH24_STENCIL8;
         }
+#endif
 
       /* Create a renderbuffer for depth and stenciling */
       GE (ctx, glGenRenderbuffers (1, &gl_depth_stencil_handle));
@@ -488,6 +497,14 @@ try_creating_renderbuffers (CoglContext *ctx,
         GE (ctx, glRenderbufferStorage (GL_RENDERBUFFER, format,
                                         width, height));
       GE (ctx, glBindRenderbuffer (GL_RENDERBUFFER, 0));
+
+
+#ifdef HAVE_COGL_WEBGL
+      GE (ctx, glFramebufferRenderbuffer (GL_FRAMEBUFFER,
+                                          GL_DEPTH_STENCIL_ATTACHMENT,
+                                          GL_RENDERBUFFER,
+                                          gl_depth_stencil_handle));
+#else
       GE (ctx, glFramebufferRenderbuffer (GL_FRAMEBUFFER,
                                           GL_STENCIL_ATTACHMENT,
                                           GL_RENDERBUFFER,
@@ -496,6 +513,7 @@ try_creating_renderbuffers (CoglContext *ctx,
                                           GL_DEPTH_ATTACHMENT,
                                           GL_RENDERBUFFER,
                                           gl_depth_stencil_handle));
+#endif
       renderbuffers =
         g_list_prepend (renderbuffers,
                         GUINT_TO_POINTER (gl_depth_stencil_handle));
@@ -768,9 +786,14 @@ _cogl_offscreen_gl_allocate (CoglOffscreen *offscreen,
                          flags = ctx->last_offscreen_allocate_flags,
                          gl_framebuffer)) ||
 
-      ((ctx->private_feature_flags &
-        (COGL_PRIVATE_FEATURE_EXT_PACKED_DEPTH_STENCIL |
-         COGL_PRIVATE_FEATURE_OES_PACKED_DEPTH_STENCIL)) &&
+      (
+       /* NB: WebGL introduces a DEPTH_STENCIL_ATTACHMENT and doesn't
+        * need an extension to handle _FLAG_DEPTH_STENCIL */
+#ifndef HAVE_COGL_WEBGL
+       (ctx->private_feature_flags
+        & (COGL_PRIVATE_FEATURE_EXT_PACKED_DEPTH_STENCIL |
+           COGL_PRIVATE_FEATURE_OES_PACKED_DEPTH_STENCIL)) &&
+#endif
        try_creating_fbo (ctx,
                          offscreen->texture,
                          offscreen->texture_level,


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]