summaryrefslogtreecommitdiffstats
path: root/src/mesa/main/clear.c
diff options
context:
space:
mode:
authorSamuel Pitoiset <[email protected]>2017-06-26 17:44:44 +0200
committerSamuel Pitoiset <[email protected]>2017-06-28 10:25:13 +0200
commit34e8d0e4baedeb658b87d64577f6acc766b3f51f (patch)
tree145d544c9fefa81bcb16697d7ba9c68c70b07fdd /src/mesa/main/clear.c
parent48400e0bd6f29eb590dc726ba482856d16f1b3e5 (diff)
mesa: add clear() helper
Signed-off-by: Samuel Pitoiset <[email protected]> Reviewed-by: Timothy Arceri <[email protected]>
Diffstat (limited to 'src/mesa/main/clear.c')
-rw-r--r--src/mesa/main/clear.c54
1 files changed, 31 insertions, 23 deletions
diff --git a/src/mesa/main/clear.c b/src/mesa/main/clear.c
index 884cf986c70..1b07a756ee4 100644
--- a/src/mesa/main/clear.c
+++ b/src/mesa/main/clear.c
@@ -140,40 +140,36 @@ color_buffer_writes_enabled(const struct gl_context *ctx, unsigned idx)
* GL_RENDER then requests the driver to clear the buffers, via the
* dd_function_table::Clear callback.
*/
-void GLAPIENTRY
-_mesa_Clear( GLbitfield mask )
+static ALWAYS_INLINE void
+clear(struct gl_context *ctx, GLbitfield mask, bool no_error)
{
- GET_CURRENT_CONTEXT(ctx);
FLUSH_VERTICES(ctx, 0);
-
FLUSH_CURRENT(ctx, 0);
- if (MESA_VERBOSE & VERBOSE_API)
- _mesa_debug(ctx, "glClear 0x%x\n", mask);
-
- if (mask & ~(GL_COLOR_BUFFER_BIT |
- GL_DEPTH_BUFFER_BIT |
- GL_STENCIL_BUFFER_BIT |
- GL_ACCUM_BUFFER_BIT)) {
- /* invalid bit set */
- _mesa_error( ctx, GL_INVALID_VALUE, "glClear(0x%x)", mask);
- return;
- }
+ if (!no_error) {
+ if (mask & ~(GL_COLOR_BUFFER_BIT |
+ GL_DEPTH_BUFFER_BIT |
+ GL_STENCIL_BUFFER_BIT |
+ GL_ACCUM_BUFFER_BIT)) {
+ _mesa_error( ctx, GL_INVALID_VALUE, "glClear(0x%x)", mask);
+ return;
+ }
- /* Accumulation buffers were removed in core contexts, and they never
- * existed in OpenGL ES.
- */
- if ((mask & GL_ACCUM_BUFFER_BIT) != 0
- && (ctx->API == API_OPENGL_CORE || _mesa_is_gles(ctx))) {
- _mesa_error( ctx, GL_INVALID_VALUE, "glClear(GL_ACCUM_BUFFER_BIT)");
- return;
+ /* Accumulation buffers were removed in core contexts, and they never
+ * existed in OpenGL ES.
+ */
+ if ((mask & GL_ACCUM_BUFFER_BIT) != 0
+ && (ctx->API == API_OPENGL_CORE || _mesa_is_gles(ctx))) {
+ _mesa_error( ctx, GL_INVALID_VALUE, "glClear(GL_ACCUM_BUFFER_BIT)");
+ return;
+ }
}
if (ctx->NewState) {
_mesa_update_state( ctx ); /* update _Xmin, etc */
}
- if (ctx->DrawBuffer->_Status != GL_FRAMEBUFFER_COMPLETE_EXT) {
+ if (!no_error && ctx->DrawBuffer->_Status != GL_FRAMEBUFFER_COMPLETE_EXT) {
_mesa_error(ctx, GL_INVALID_FRAMEBUFFER_OPERATION_EXT,
"glClear(incomplete framebuffer)");
return;
@@ -227,6 +223,18 @@ _mesa_Clear( GLbitfield mask )
}
+void GLAPIENTRY
+_mesa_Clear(GLbitfield mask)
+{
+ GET_CURRENT_CONTEXT(ctx);
+
+ if (MESA_VERBOSE & VERBOSE_API)
+ _mesa_debug(ctx, "glClear 0x%x\n", mask);
+
+ clear(ctx, mask, false);
+}
+
+
/** Returned by make_color_buffer_mask() for errors */
#define INVALID_MASK ~0x0U