aboutsummaryrefslogtreecommitdiff
path: root/mesalib/src/mesa/main/clear.c
diff options
context:
space:
mode:
authormarha <marha@users.sourceforge.net>2014-03-25 17:54:52 +0100
committermarha <marha@users.sourceforge.net>2014-03-25 17:54:52 +0100
commit13d96866ca5d0e2be51f20a72da9e0f7032a16ea (patch)
treebe456b793acca557025c7abad4ddfa5eb8a7292d /mesalib/src/mesa/main/clear.c
parente0927d908a12c9c140458c355b29b884a7705f2d (diff)
downloadvcxsrv-13d96866ca5d0e2be51f20a72da9e0f7032a16ea.tar.gz
vcxsrv-13d96866ca5d0e2be51f20a72da9e0f7032a16ea.tar.bz2
vcxsrv-13d96866ca5d0e2be51f20a72da9e0f7032a16ea.zip
mesa git update 25 Marc 2014
mesa commit b995a010e688bc4d4557e973e5e28091c378e881
Diffstat (limited to 'mesalib/src/mesa/main/clear.c')
-rw-r--r--mesalib/src/mesa/main/clear.c27
1 files changed, 26 insertions, 1 deletions
diff --git a/mesalib/src/mesa/main/clear.c b/mesalib/src/mesa/main/clear.c
index 077c5fca3..9df1f5e09 100644
--- a/mesalib/src/mesa/main/clear.c
+++ b/mesalib/src/mesa/main/clear.c
@@ -107,6 +107,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.
*
* \param mask bit-mask indicating the buffers to be cleared.
@@ -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;
}
}