mirror of
https://github.com/brl/mutter.git
synced 2024-11-29 11:30:45 -05:00
framebuffer: drop _ALLOCATE_FLAG_DEPTH24_STENCIL8
There are two extensions, GL_OES_packed_depth_stencil and GL_EXT_packed_depth_stencil, that inform us that the hardware supports packing the depth and stencil values together into one format. The OES extension is the GLES equivalent of the EXT extension and the two extensions provide the same enums with basically the same semantics, except that the EXT extension is a lot more wordy due to a larger number of features in the full OpenGL api and the OES extension has some asymmetric limitations on when the GL_DEPTH_STENCIL and GL_DEPTH24_STENCIL8 enums can be used as internal formats. GL_OES_packed_depth_stencil doesn't allow the GL_DEPTH_STENCIL enum to be passed to glRenderbufferStorage (GL_DEPTH24_STENCIL8 should be used instead) and GL_OES_packed_depth_stencil doesn't allow GL_DEPTH24_STENCIL8 to be passed as an internal format to glTexImage2D. We had been handling the two extensions differently in Cogl by calling try_creating_fbo with different flags depending on whether the OES or EXT extension was available and passing GL_DEPTH_STENCIL to glRenderbufferStorage when we have the EXT extension or GL_DEPTH24_STENCIL8 with the OES extension. To localize the code that deals with the differences between the extensions this patch does away with the need for separate flags so we now just have COGL_OFFSCREEN_ALLOCATE_FLAG_DEPTH_DEPTH_STENCIL and right before calling glRenderbufferStorage we check which extension we are using to decide whether to use the GL_DEPTH_STENCIL or GL_DEPTH24_STENCIL8 enums. (cherry picked from commit 88a05fac6609f88c0f46d9df2611d9fbaf159939)
This commit is contained in:
parent
8d09b93572
commit
7b5b0bef83
@ -168,9 +168,8 @@ struct _CoglFramebuffer
|
|||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
COGL_OFFSCREEN_ALLOCATE_FLAG_DEPTH_STENCIL = 1L<<0,
|
COGL_OFFSCREEN_ALLOCATE_FLAG_DEPTH_STENCIL = 1L<<0,
|
||||||
COGL_OFFSCREEN_ALLOCATE_FLAG_DEPTH24_STENCIL8 = 1L<<1,
|
COGL_OFFSCREEN_ALLOCATE_FLAG_DEPTH = 1L<<1,
|
||||||
COGL_OFFSCREEN_ALLOCATE_FLAG_DEPTH = 1L<<2,
|
COGL_OFFSCREEN_ALLOCATE_FLAG_STENCIL = 1L<<2
|
||||||
COGL_OFFSCREEN_ALLOCATE_FLAG_STENCIL = 1L<<3
|
|
||||||
} CoglOffscreenAllocateFlags;
|
} CoglOffscreenAllocateFlags;
|
||||||
|
|
||||||
typedef struct _CoglGLFramebuffer
|
typedef struct _CoglGLFramebuffer
|
||||||
|
@ -831,11 +831,26 @@ try_creating_renderbuffers (CoglContext *ctx,
|
|||||||
GList *renderbuffers = NULL;
|
GList *renderbuffers = NULL;
|
||||||
GLuint gl_depth_stencil_handle;
|
GLuint gl_depth_stencil_handle;
|
||||||
|
|
||||||
if (flags & (COGL_OFFSCREEN_ALLOCATE_FLAG_DEPTH_STENCIL |
|
if (flags & COGL_OFFSCREEN_ALLOCATE_FLAG_DEPTH_STENCIL)
|
||||||
COGL_OFFSCREEN_ALLOCATE_FLAG_DEPTH24_STENCIL8))
|
|
||||||
{
|
{
|
||||||
GLenum format = ((flags & COGL_OFFSCREEN_ALLOCATE_FLAG_DEPTH_STENCIL) ?
|
GLenum format;
|
||||||
GL_DEPTH_STENCIL : GL_DEPTH24_STENCIL8);
|
|
||||||
|
/* 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
|
||||||
|
* be passed as an internal format to glRenderbufferStorage.
|
||||||
|
*/
|
||||||
|
if (ctx->private_feature_flags &
|
||||||
|
COGL_PRIVATE_FEATURE_EXT_PACKED_DEPTH_STENCIL)
|
||||||
|
format = GL_DEPTH_STENCIL;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_COGL_RETURN_VAL_IF_FAIL (
|
||||||
|
ctx->private_feature_flags &
|
||||||
|
COGL_PRIVATE_FEATURE_OES_PACKED_DEPTH_STENCIL,
|
||||||
|
NULL);
|
||||||
|
format = GL_DEPTH24_STENCIL8;
|
||||||
|
}
|
||||||
|
|
||||||
/* Create a renderbuffer for depth and stenciling */
|
/* Create a renderbuffer for depth and stenciling */
|
||||||
GE (ctx, glGenRenderbuffers (1, &gl_depth_stencil_handle));
|
GE (ctx, glGenRenderbuffers (1, &gl_depth_stencil_handle));
|
||||||
@ -1073,7 +1088,8 @@ _cogl_offscreen_allocate (CoglOffscreen *offscreen,
|
|||||||
gl_framebuffer)) ||
|
gl_framebuffer)) ||
|
||||||
|
|
||||||
((ctx->private_feature_flags &
|
((ctx->private_feature_flags &
|
||||||
COGL_PRIVATE_FEATURE_EXT_PACKED_DEPTH_STENCIL) &&
|
(COGL_PRIVATE_FEATURE_EXT_PACKED_DEPTH_STENCIL |
|
||||||
|
COGL_PRIVATE_FEATURE_OES_PACKED_DEPTH_STENCIL)) &&
|
||||||
try_creating_fbo (ctx,
|
try_creating_fbo (ctx,
|
||||||
offscreen->texture,
|
offscreen->texture,
|
||||||
offscreen->texture_level,
|
offscreen->texture_level,
|
||||||
@ -1083,17 +1099,6 @@ _cogl_offscreen_allocate (CoglOffscreen *offscreen,
|
|||||||
flags = COGL_OFFSCREEN_ALLOCATE_FLAG_DEPTH_STENCIL,
|
flags = COGL_OFFSCREEN_ALLOCATE_FLAG_DEPTH_STENCIL,
|
||||||
gl_framebuffer)) ||
|
gl_framebuffer)) ||
|
||||||
|
|
||||||
((ctx->private_feature_flags &
|
|
||||||
COGL_PRIVATE_FEATURE_OES_PACKED_DEPTH_STENCIL) &&
|
|
||||||
try_creating_fbo (ctx,
|
|
||||||
offscreen->texture,
|
|
||||||
offscreen->texture_level,
|
|
||||||
offscreen->texture_level_width,
|
|
||||||
offscreen->texture_level_height,
|
|
||||||
&fb->config,
|
|
||||||
flags = COGL_OFFSCREEN_ALLOCATE_FLAG_DEPTH24_STENCIL8,
|
|
||||||
gl_framebuffer)) ||
|
|
||||||
|
|
||||||
try_creating_fbo (ctx,
|
try_creating_fbo (ctx,
|
||||||
offscreen->texture,
|
offscreen->texture,
|
||||||
offscreen->texture_level,
|
offscreen->texture_level,
|
||||||
|
Loading…
Reference in New Issue
Block a user