Mesa (master): mesa: Set the base format of GL_ALPHA FBOs and teach swrast about it.

Eric Anholt anholt at kemper.freedesktop.org
Tue Sep 7 21:37:11 UTC 2010


Module: Mesa
Branch: master
Commit: 50a3349bee04088bee3491622d6ef3c032d01eac
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=50a3349bee04088bee3491622d6ef3c032d01eac

Author: Eric Anholt <eric at anholt.net>
Date:   Tue Sep  7 14:31:22 2010 -0700

mesa: Set the base format of GL_ALPHA FBOs and teach swrast about it.

Fixes assertion failures in fbo-alpha with a debug build of Mesa.
Bug #29781.

---

 src/mesa/main/fbobject.c    |    6 ++++++
 src/mesa/swrast/s_readpix.c |    3 ++-
 src/mesa/swrast/s_span.c    |    6 ++++--
 3 files changed, 12 insertions(+), 3 deletions(-)

diff --git a/src/mesa/main/fbobject.c b/src/mesa/main/fbobject.c
index defdebb..72cbb09 100644
--- a/src/mesa/main/fbobject.c
+++ b/src/mesa/main/fbobject.c
@@ -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:
diff --git a/src/mesa/swrast/s_readpix.c b/src/mesa/swrast/s_readpix.c
index 553fd9a..1de4812 100644
--- a/src/mesa/swrast/s_readpix.c
+++ b/src/mesa/swrast/s_readpix.c
@@ -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);
diff --git a/src/mesa/swrast/s_span.c b/src/mesa/swrast/s_span.c
index 8931cde..28c8299 100644
--- a/src/mesa/swrast/s_span.c
+++ b/src/mesa/swrast/s_span.c
@@ -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,




More information about the mesa-commit mailing list