mesa: Set the base format of GL_ALPHA FBOs and teach swrast about it.
authorEric Anholt <eric@anholt.net>
Tue, 7 Sep 2010 21:31:22 +0000 (14:31 -0700)
committerEric Anholt <eric@anholt.net>
Tue, 7 Sep 2010 21:34:23 +0000 (14:34 -0700)
Fixes assertion failures in fbo-alpha with a debug build of Mesa.
Bug #29781.

src/mesa/main/fbobject.c
src/mesa/swrast/s_readpix.c
src/mesa/swrast/s_span.c

index defdebbdefa913d816c95d2e3744a4f8231c98a9..72cbb09ab832a1275184b174fc3a022c32299b7d 100644 (file)
@@ -925,6 +925,12 @@ GLenum
 _mesa_base_fbo_format(GLcontext *ctx, GLenum internalFormat)
 {
    switch (internalFormat) {
+   case GL_ALPHA:
+   case GL_ALPHA4:
+   case GL_ALPHA8:
+   case GL_ALPHA12:
+   case GL_ALPHA16:
+      return GL_ALPHA;
    case GL_RGB:
    case GL_R3_G3_B2:
    case GL_RGB4:
index 553fd9a76d85ac692e134a0ab7cd4beaef497150..1de481248b1ca81a88f05e35cbc002e6cd1bbb8a 100644 (file)
@@ -191,7 +191,8 @@ fast_read_rgba_pixels( GLcontext *ctx,
    if (!rb)
       return GL_FALSE;
 
-   ASSERT(rb->_BaseFormat == GL_RGBA || rb->_BaseFormat == GL_RGB);
+   ASSERT(rb->_BaseFormat == GL_RGBA || rb->_BaseFormat == GL_RGB ||
+         rb->_BaseFormat == GL_ALPHA);
 
    /* clipping should have already been done */
    ASSERT(x + width <= (GLint) rb->Width);
index 8931cdec1bc4569ba111ddc840eb84b83e8582b3..28c82990e0854c85d6e02c4affa5e2f957ced159 100644 (file)
@@ -1248,7 +1248,8 @@ _swrast_write_rgba_span( GLcontext *ctx, SWspan *span)
                       4 * span->end * sizeof(GLchan));
             }
 
-            ASSERT(rb->_BaseFormat == GL_RGBA || rb->_BaseFormat == GL_RGB);
+            ASSERT(rb->_BaseFormat == GL_RGBA || rb->_BaseFormat == GL_RGB ||
+                  rb->_BaseFormat == GL_ALPHA);
 
             if (ctx->Color._LogicOpEnabled) {
                _swrast_logicop_rgba_span(ctx, rb, span);
@@ -1346,7 +1347,8 @@ _swrast_read_rgba_span( GLcontext *ctx, struct gl_renderbuffer *rb,
 
       ASSERT(rb);
       ASSERT(rb->GetRow);
-      ASSERT(rb->_BaseFormat == GL_RGB || rb->_BaseFormat == GL_RGBA);
+      ASSERT(rb->_BaseFormat == GL_RGB || rb->_BaseFormat == GL_RGBA ||
+            rb->_BaseFormat == GL_ALPHA);
 
       if (rb->DataType == dstType) {
          rb->GetRow(ctx, rb, length, x + skip, y,