mesa: add clear() helper
Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com> Reviewed-by: Timothy Arceri <tarceri@itsqueeze.com>
This commit is contained in:
@@ -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
|
* GL_RENDER then requests the driver to clear the buffers, via the
|
||||||
* dd_function_table::Clear callback.
|
* dd_function_table::Clear callback.
|
||||||
*/
|
*/
|
||||||
void GLAPIENTRY
|
static ALWAYS_INLINE void
|
||||||
_mesa_Clear( GLbitfield mask )
|
clear(struct gl_context *ctx, GLbitfield mask, bool no_error)
|
||||||
{
|
{
|
||||||
GET_CURRENT_CONTEXT(ctx);
|
|
||||||
FLUSH_VERTICES(ctx, 0);
|
FLUSH_VERTICES(ctx, 0);
|
||||||
|
|
||||||
FLUSH_CURRENT(ctx, 0);
|
FLUSH_CURRENT(ctx, 0);
|
||||||
|
|
||||||
if (MESA_VERBOSE & VERBOSE_API)
|
if (!no_error) {
|
||||||
_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)) {
|
||||||
|
_mesa_error( ctx, GL_INVALID_VALUE, "glClear(0x%x)", mask);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (mask & ~(GL_COLOR_BUFFER_BIT |
|
/* Accumulation buffers were removed in core contexts, and they never
|
||||||
GL_DEPTH_BUFFER_BIT |
|
* existed in OpenGL ES.
|
||||||
GL_STENCIL_BUFFER_BIT |
|
*/
|
||||||
GL_ACCUM_BUFFER_BIT)) {
|
if ((mask & GL_ACCUM_BUFFER_BIT) != 0
|
||||||
/* invalid bit set */
|
&& (ctx->API == API_OPENGL_CORE || _mesa_is_gles(ctx))) {
|
||||||
_mesa_error( ctx, GL_INVALID_VALUE, "glClear(0x%x)", mask);
|
_mesa_error( ctx, GL_INVALID_VALUE, "glClear(GL_ACCUM_BUFFER_BIT)");
|
||||||
return;
|
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) {
|
if (ctx->NewState) {
|
||||||
_mesa_update_state( ctx ); /* update _Xmin, etc */
|
_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,
|
_mesa_error(ctx, GL_INVALID_FRAMEBUFFER_OPERATION_EXT,
|
||||||
"glClear(incomplete framebuffer)");
|
"glClear(incomplete framebuffer)");
|
||||||
return;
|
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 */
|
/** Returned by make_color_buffer_mask() for errors */
|
||||||
#define INVALID_MASK ~0x0U
|
#define INVALID_MASK ~0x0U
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user