summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarek Olšák <marek.olsak@amd.com>2013-12-04 00:27:20 +0100
committerCarl Worth <cworth@cworth.org>2014-01-02 15:57:40 -0800
commitc2940d11d0b6b299676897ad7ef45e11fc8b6cfe (patch)
tree48824668afb8bc652f16e689ba8cc5140d4cb78b
parent27623f2645215248aa53e471e2675f1def29dcff (diff)
mesa: fix interpretation of glClearBuffer(drawbuffer)
This corresponding piglit tests supported this incorrect behavior instead of pointing at it. Reviewed-by: Ian Romanick <ian.d.romanick@intel.com> Cc: 10.0 9.2 9.1 <mesa-stable@lists.freedesktop.org> (cherry picked from commit 03d848ea1003abefd8fe51a5b4a780527cd852af)
-rw-r--r--src/mesa/main/clear.c31
1 files changed, 25 insertions, 6 deletions
diff --git a/src/mesa/main/clear.c b/src/mesa/main/clear.c
index 304d135d14e..f0b525fa017 100644
--- a/src/mesa/main/clear.c
+++ b/src/mesa/main/clear.c
@@ -219,7 +219,25 @@ make_color_buffer_mask(struct gl_context *ctx, GLint drawbuffer)
const struct gl_renderbuffer_attachment *att = ctx->DrawBuffer->Attachment;
GLbitfield mask = 0x0;
- switch (drawbuffer) {
+ /* From the GL 4.0 specification:
+ * If buffer is COLOR, a particular draw buffer DRAW_BUFFERi is
+ * specified by passing i as the parameter drawbuffer, and value
+ * points to a four-element vector specifying the R, G, B, and A
+ * color to clear that draw buffer to. If the draw buffer is one
+ * of FRONT, BACK, LEFT, RIGHT, or FRONT_AND_BACK, identifying
+ * multiple buffers, each selected buffer is cleared to the same
+ * value.
+ *
+ * Note that "drawbuffer" and "draw buffer" have different meaning.
+ * "drawbuffer" specifies DRAW_BUFFERi, while "draw buffer" is what's
+ * assigned to DRAW_BUFFERi. It could be COLOR_ATTACHMENT0, FRONT, BACK,
+ * etc.
+ */
+ if (drawbuffer < 0 || drawbuffer >= (GLint)ctx->Const.MaxDrawBuffers) {
+ return INVALID_MASK;
+ }
+
+ switch (ctx->DrawBuffer->ColorDrawBuffer[drawbuffer]) {
case GL_FRONT:
if (att[BUFFER_FRONT_LEFT].Renderbuffer)
mask |= BUFFER_BIT_FRONT_LEFT;
@@ -255,11 +273,12 @@ make_color_buffer_mask(struct gl_context *ctx, GLint drawbuffer)
mask |= BUFFER_BIT_BACK_RIGHT;
break;
default:
- if (drawbuffer < 0 || drawbuffer >= (GLint)ctx->Const.MaxDrawBuffers) {
- mask = INVALID_MASK;
- }
- else if (att[BUFFER_COLOR0 + drawbuffer].Renderbuffer) {
- mask |= (BUFFER_BIT_COLOR0 << drawbuffer);
+ {
+ GLuint buf = ctx->DrawBuffer->_ColorDrawBufferIndexes[drawbuffer];
+
+ if (buf >= 0 && att[buf].Renderbuffer) {
+ mask |= 1 << buf;
+ }
}
}