[Mesa-dev] [PATCH 2/6] mesa: fix interpretation of glClearBuffer(drawbuffer)

Marek Olšák maraeo at gmail.com
Thu Dec 5 09:52:58 PST 2013


From: Marek Olšák <marek.olsak at amd.com>

This corresponding piglit tests supported this incorrect behavior instead of
pointing at it.

See the GL 4.4 spec if the GL 3.0 spec is not clear enough.

Cc: 10.0 9.2 9.1 <mesa-stable at lists.freedesktop.org>
---
 src/mesa/main/clear.c | 17 +++++++++++------
 1 file changed, 11 insertions(+), 6 deletions(-)

diff --git a/src/mesa/main/clear.c b/src/mesa/main/clear.c
index 304d135..4239240 100644
--- a/src/mesa/main/clear.c
+++ b/src/mesa/main/clear.c
@@ -219,7 +219,11 @@ make_color_buffer_mask(struct gl_context *ctx, GLint drawbuffer)
    const struct gl_renderbuffer_attachment *att = ctx->DrawBuffer->Attachment;
    GLbitfield mask = 0x0;
 
-   switch (drawbuffer) {
+   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 +259,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;
+         }
       }
    }
 
-- 
1.8.3.2



More information about the mesa-dev mailing list