diff options
author | Tapani Pälli <[email protected]> | 2013-02-18 09:12:27 +0200 |
---|---|---|
committer | Chad Versace <[email protected]> | 2013-02-20 10:01:45 -0800 |
commit | 413941e1a3155b29a190ab7ecfd844b1a5c2e460 (patch) | |
tree | b753485b24252ebb5e328d6e7f7bd539d4feeb62 /src/mesa | |
parent | 73bf626713f7efc43164f7649fc143f4a94299cb (diff) |
gles2: a stub implementation for GL_EXT_discard_framebuffer
This patch implements a stub for GL_EXT_discard_framebuffer with
required checks listed by the extension specification. This extension
is required by GLBenchmark 2.5 when compiled with OpenGL ES 2.0
as the rendering backend.
Signed-off-by: Tapani Pälli <[email protected]>
Reviewed-by: Brian Paul <[email protected]>
Reviewed-and-tested-by: Chad Versace <[email protected]>
Diffstat (limited to 'src/mesa')
-rw-r--r-- | src/mesa/drivers/common/driverfuncs.c | 1 | ||||
-rw-r--r-- | src/mesa/main/dd.h | 4 | ||||
-rw-r--r-- | src/mesa/main/extensions.c | 1 | ||||
-rw-r--r-- | src/mesa/main/fbobject.c | 53 | ||||
-rw-r--r-- | src/mesa/main/fbobject.h | 4 | ||||
-rw-r--r-- | src/mesa/main/tests/dispatch_sanity.cpp | 2 |
6 files changed, 64 insertions, 1 deletions
diff --git a/src/mesa/drivers/common/driverfuncs.c b/src/mesa/drivers/common/driverfuncs.c index aab61e1a4a8..43c9de97f50 100644 --- a/src/mesa/drivers/common/driverfuncs.c +++ b/src/mesa/drivers/common/driverfuncs.c @@ -174,6 +174,7 @@ _mesa_init_driver_functions(struct dd_function_table *driver) driver->ValidateFramebuffer = _mesa_validate_framebuffer; driver->BlitFramebuffer = _swrast_BlitFramebuffer; + driver->DiscardFramebuffer = NULL; _mesa_init_texture_barrier_functions(driver); diff --git a/src/mesa/main/dd.h b/src/mesa/main/dd.h index 9a75fd9541a..9c818ccd86a 100644 --- a/src/mesa/main/dd.h +++ b/src/mesa/main/dd.h @@ -604,7 +604,7 @@ struct dd_function_table { /*@}*/ /** - * \name Functions for GL_EXT_framebuffer_{object,blit}. + * \name Functions for GL_EXT_framebuffer_{object,blit,discard}. */ /*@{*/ struct gl_framebuffer * (*NewFramebuffer)(struct gl_context *ctx, GLuint name); @@ -628,6 +628,8 @@ struct dd_function_table { GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter); + void (*DiscardFramebuffer)(struct gl_context *ctx, + GLenum target, GLsizei numAttachments, const GLenum *attachments); /** * \name Query objects diff --git a/src/mesa/main/extensions.c b/src/mesa/main/extensions.c index 04435e0c97a..e90a2968064 100644 --- a/src/mesa/main/extensions.c +++ b/src/mesa/main/extensions.c @@ -168,6 +168,7 @@ static const struct extension extension_table[] = { { "GL_EXT_blend_color", o(EXT_blend_color), GLL, 1995 }, { "GL_EXT_blend_equation_separate", o(EXT_blend_equation_separate), GL, 2003 }, { "GL_EXT_blend_func_separate", o(EXT_blend_func_separate), GLL, 1999 }, + { "GL_EXT_discard_framebuffer", o(EXT_framebuffer_object), ES1 | ES2, 2009 }, { "GL_EXT_blend_minmax", o(EXT_blend_minmax), GLL | ES1 | ES2, 1995 }, { "GL_EXT_blend_subtract", o(dummy_true), GLL, 1995 }, { "GL_EXT_clip_volume_hint", o(EXT_clip_volume_hint), GL, 1996 }, diff --git a/src/mesa/main/fbobject.c b/src/mesa/main/fbobject.c index 257f839a666..89bc5750932 100644 --- a/src/mesa/main/fbobject.c +++ b/src/mesa/main/fbobject.c @@ -3310,3 +3310,56 @@ _mesa_InvalidateFramebuffer(GLenum target, GLsizei numAttachments, 0, 0, MAX_VIEWPORT_WIDTH, MAX_VIEWPORT_HEIGHT, "glInvalidateFramebuffer"); } + +void GLAPIENTRY +_mesa_DiscardFramebufferEXT(GLenum target, GLsizei numAttachments, + const GLenum *attachments) +{ + struct gl_framebuffer *fb; + GLint i; + + GET_CURRENT_CONTEXT(ctx); + + fb = get_framebuffer_target(ctx, target); + if (!fb) { + _mesa_error(ctx, GL_INVALID_ENUM, + "glDiscardFramebufferEXT(target %s)", + _mesa_lookup_enum_by_nr(target)); + return; + } + + if (numAttachments < 0) { + _mesa_error(ctx, GL_INVALID_VALUE, + "glDiscardFramebufferEXT(numAttachments < 0)"); + return; + } + + for (i = 0; i < numAttachments; i++) { + switch (attachments[i]) { + case GL_COLOR: + case GL_DEPTH: + case GL_STENCIL: + if (_mesa_is_user_fbo(fb)) + goto invalid_enum; + break; + case GL_COLOR_ATTACHMENT0: + case GL_DEPTH_ATTACHMENT: + case GL_STENCIL_ATTACHMENT: + if (_mesa_is_winsys_fbo(fb)) + goto invalid_enum; + break; + default: + goto invalid_enum; + } + } + + if (ctx->Driver.DiscardFramebuffer) + ctx->Driver.DiscardFramebuffer(ctx, target, numAttachments, attachments); + + return; + +invalid_enum: + _mesa_error(ctx, GL_INVALID_ENUM, + "glDiscardFramebufferEXT(attachment %s)", + _mesa_lookup_enum_by_nr(attachments[i])); +} diff --git a/src/mesa/main/fbobject.h b/src/mesa/main/fbobject.h index 9207f59c789..ec8b0afe410 100644 --- a/src/mesa/main/fbobject.h +++ b/src/mesa/main/fbobject.h @@ -214,4 +214,8 @@ extern void GLAPIENTRY _mesa_InvalidateFramebuffer(GLenum target, GLsizei numAttachments, const GLenum *attachments); +extern void GLAPIENTRY +_mesa_DiscardFramebufferEXT(GLenum target, GLsizei numAttachments, + const GLenum *attachments); + #endif /* FBOBJECT_H */ diff --git a/src/mesa/main/tests/dispatch_sanity.cpp b/src/mesa/main/tests/dispatch_sanity.cpp index 519f6a9a46a..bf6b297e139 100644 --- a/src/mesa/main/tests/dispatch_sanity.cpp +++ b/src/mesa/main/tests/dispatch_sanity.cpp @@ -949,6 +949,7 @@ const struct function gles11_functions_possible[] = { { "glDepthRangef", 11, -1 }, { "glDepthRangex", 11, -1 }, { "glDisable", 11, _gloffset_Disable }, + { "glDiscardFramebufferEXT", 11, -1 }, { "glDisableClientState", 11, _gloffset_DisableClientState }, { "glDrawArrays", 11, _gloffset_DrawArrays }, { "glDrawElements", 11, _gloffset_DrawElements }, @@ -1145,6 +1146,7 @@ const struct function gles2_functions_possible[] = { { "glDepthRangef", 20, -1 }, { "glDetachShader", 20, -1 }, { "glDisable", 20, _gloffset_Disable }, + { "glDiscardFramebufferEXT", 20, -1 }, { "glDisableVertexAttribArray", 20, -1 }, { "glDrawArrays", 20, _gloffset_DrawArrays }, { "glDrawBuffersNV", 20, -1 }, |