mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-14 14:28:08 +02:00
mesa: Skip clearing color buffers when color writes are disabled.
WebGL Aquarium in Chrome 24 actually hits this.
v2: Move to core Mesa (wisely suggested by Ian); only consider
components which actually exist.
v3: Use _mesa_format_has_color_component to determine whether components
actually exist, fixing alpha format handling.
v4: Add a comment, as requested by Brian. No actual code changes.
Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Brian Paul <brianp@vmware.com>
Reviewed-by: Eric Anholt <eric@anholt.net>
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
Tested-by: Dylan Baker <baker.dylan.c@gmail.com>
This commit is contained in:
parent
92234b1b2a
commit
630bf288de
1 changed files with 26 additions and 1 deletions
|
|
@ -106,6 +106,31 @@ _mesa_ClearColorIuiEXT(GLuint r, GLuint g, GLuint b, GLuint a)
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns true if color writes are enabled for the given color attachment.
|
||||
*
|
||||
* Beyond checking ColorMask, this uses _mesa_format_has_color_component to
|
||||
* ignore components that don't actually exist in the format (such as X in
|
||||
* XRGB).
|
||||
*/
|
||||
static bool
|
||||
color_buffer_writes_enabled(const struct gl_context *ctx, unsigned idx)
|
||||
{
|
||||
struct gl_renderbuffer *rb = ctx->DrawBuffer->_ColorDrawBuffers[idx];
|
||||
GLuint c;
|
||||
GLubyte colorMask = 0;
|
||||
|
||||
if (rb) {
|
||||
for (c = 0; c < 4; c++) {
|
||||
if (_mesa_format_has_color_component(rb->Format, c))
|
||||
colorMask |= ctx->Color.ColorMask[idx][c];
|
||||
}
|
||||
}
|
||||
|
||||
return colorMask != 0;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Clear buffers.
|
||||
*
|
||||
|
|
@ -181,7 +206,7 @@ _mesa_Clear( GLbitfield mask )
|
|||
for (i = 0; i < ctx->DrawBuffer->_NumColorDrawBuffers; i++) {
|
||||
GLint buf = ctx->DrawBuffer->_ColorDrawBufferIndexes[i];
|
||||
|
||||
if (buf >= 0) {
|
||||
if (buf >= 0 && color_buffer_writes_enabled(ctx, i)) {
|
||||
bufferMask |= 1 << buf;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue