[cogl] Use GL_OES_packed_depth_stencil on GLES2
- From: Neil Roberts <nroberts src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [cogl] Use GL_OES_packed_depth_stencil on GLES2
- Date: Wed, 22 Feb 2012 17:30:11 +0000 (UTC)
commit 31bd4cb22c37796526d466359db433e2e94f23e7
Author: Neil Roberts <neil linux intel com>
Date: Wed Feb 22 17:02:28 2012 +0000
Use GL_OES_packed_depth_stencil on GLES2
If the GL_OES_packed_depth_stencil extension is available then we can
try creating a combined depth-stencil buffer with the
GL_DEPTH24_STENCIL8 format. This adds a private flag for the feature.
https://bugzilla.gnome.org/show_bug.cgi?id=666184
Reviewed-by: Robert Bragg <robert linux intel com>
cogl/cogl-framebuffer.c | 22 ++++++++++++++++------
cogl/cogl-internal.h | 3 ++-
cogl/driver/gles/cogl-gles.c | 3 +++
3 files changed, 21 insertions(+), 7 deletions(-)
---
diff --git a/cogl/cogl-framebuffer.c b/cogl/cogl-framebuffer.c
index 7ae769e..5a549ab 100644
--- a/cogl/cogl-framebuffer.c
+++ b/cogl/cogl-framebuffer.c
@@ -65,6 +65,9 @@
#ifndef GL_DEPTH_STENCIL
#define GL_DEPTH_STENCIL 0x84F9
#endif
+#ifndef GL_DEPTH24_STENCIL8
+#define GL_DEPTH24_STENCIL8 0x88F0
+#endif
#ifndef GL_DEPTH_ATTACHMENT
#define GL_DEPTH_ATTACHMENT 0x8D00
#endif
@@ -100,9 +103,10 @@
#endif
typedef enum {
- _TRY_DEPTH_STENCIL = 1L<<0,
- _TRY_DEPTH = 1L<<1,
- _TRY_STENCIL = 1L<<2
+ _TRY_DEPTH_STENCIL = 1L<<0,
+ _TRY_DEPTH24_STENCIL8 = 1L<<1,
+ _TRY_DEPTH = 1L<<2,
+ _TRY_STENCIL = 1L<<3
} TryFBOFlags;
typedef struct _CoglFramebufferStackEntry
@@ -868,18 +872,21 @@ try_creating_fbo (CoglOffscreen *offscreen,
tex_gl_target, tex_gl_handle,
offscreen->texture_level));
- if (flags & _TRY_DEPTH_STENCIL)
+ if (flags & (_TRY_DEPTH_STENCIL | _TRY_DEPTH24_STENCIL8))
{
+ GLenum format = ((flags & _TRY_DEPTH_STENCIL) ?
+ GL_DEPTH_STENCIL : GL_DEPTH24_STENCIL8);
+
/* Create a renderbuffer for depth and stenciling */
GE (ctx, glGenRenderbuffers (1, &gl_depth_stencil_handle));
GE (ctx, glBindRenderbuffer (GL_RENDERBUFFER, gl_depth_stencil_handle));
if (n_samples)
GE (ctx, glRenderbufferStorageMultisampleIMG (GL_RENDERBUFFER,
n_samples,
- GL_DEPTH_STENCIL,
+ format,
width, height));
else
- GE (ctx, glRenderbufferStorage (GL_RENDERBUFFER, GL_DEPTH_STENCIL,
+ GE (ctx, glRenderbufferStorage (GL_RENDERBUFFER, format,
width, height));
GE (ctx, glBindRenderbuffer (GL_RENDERBUFFER, 0));
GE (ctx, glFramebufferRenderbuffer (GL_FRAMEBUFFER,
@@ -1009,6 +1016,9 @@ _cogl_offscreen_allocate (CoglOffscreen *offscreen,
((ctx->private_feature_flags &
COGL_PRIVATE_FEATURE_EXT_PACKED_DEPTH_STENCIL) &&
try_creating_fbo (offscreen, flags = _TRY_DEPTH_STENCIL)) ||
+ ((ctx->private_feature_flags &
+ COGL_PRIVATE_FEATURE_OES_PACKED_DEPTH_STENCIL) &&
+ try_creating_fbo (offscreen, flags = _TRY_DEPTH24_STENCIL8)) ||
try_creating_fbo (offscreen, flags = _TRY_DEPTH | _TRY_STENCIL) ||
try_creating_fbo (offscreen, flags = _TRY_STENCIL) ||
try_creating_fbo (offscreen, flags = _TRY_DEPTH) ||
diff --git a/cogl/cogl-internal.h b/cogl/cogl-internal.h
index b42c6c7..0cc2f9b 100644
--- a/cogl/cogl-internal.h
+++ b/cogl/cogl-internal.h
@@ -106,7 +106,8 @@ typedef enum
COGL_PRIVATE_FEATURE_FOUR_CLIP_PLANES = 1L<<4,
COGL_PRIVATE_FEATURE_PBOS = 1L<<5,
COGL_PRIVATE_FEATURE_VBOS = 1L<<6,
- COGL_PRIVATE_FEATURE_EXT_PACKED_DEPTH_STENCIL = 1L<<7
+ COGL_PRIVATE_FEATURE_EXT_PACKED_DEPTH_STENCIL = 1L<<7,
+ COGL_PRIVATE_FEATURE_OES_PACKED_DEPTH_STENCIL = 1L<<8
} CoglPrivateFeatureFlags;
/* Sometimes when evaluating pipelines, either during comparisons or
diff --git a/cogl/driver/gles/cogl-gles.c b/cogl/driver/gles/cogl-gles.c
index 9001a04..2afdbeb 100644
--- a/cogl/driver/gles/cogl-gles.c
+++ b/cogl/driver/gles/cogl-gles.c
@@ -162,6 +162,9 @@ _cogl_gles_update_features (CoglContext *context,
if (context->glEGLImageTargetTexture2D)
private_flags |= COGL_PRIVATE_FEATURE_TEXTURE_2D_FROM_EGL_IMAGE;
+ if (_cogl_check_extension ("GL_OES_packed_depth_stencil", gl_extensions))
+ private_flags |= COGL_PRIVATE_FEATURE_OES_PACKED_DEPTH_STENCIL;
+
/* Cache features */
context->private_feature_flags |= private_flags;
context->feature_flags |= flags;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]