Mesa (8.0): mesa: Convert colors if span ChanType and renderbuffer data type don't match

Ian Romanick idr at kemper.freedesktop.org
Thu Feb 2 18:51:57 UTC 2012


Module: Mesa
Branch: 8.0
Commit: 65b9c1dee6edbafb46f782ecc525c1dbdbf76e0d
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=65b9c1dee6edbafb46f782ecc525c1dbdbf76e0d

Author: Ian Romanick <ian.d.romanick at intel.com>
Date:   Tue Jan 31 11:29:06 2012 -0700

mesa: Convert colors if span ChanType and renderbuffer data type don't match

This is a partial revert of f9874fe.  It turns out that the types
don't always match.  Specifically, this can happen when doing
glCopyPixels from a float FBO to a RGBA8 FBO.

NOTE: This is a candidate for the 8.0 branch.

Signed-off-by: Ian Romanick <ian.d.romanick at intel.com>
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=45429
Reviewed-by: Brian Paul <brianp at vmware.com>
(cherry picked from commit 660ed923ded3552e023ef8c3dd9f92e6792f1bd2)

---

 src/mesa/swrast/s_span.c |   19 +++++++++++++++----
 1 files changed, 15 insertions(+), 4 deletions(-)

diff --git a/src/mesa/swrast/s_span.c b/src/mesa/swrast/s_span.c
index 7ab60b1..51666ba 100644
--- a/src/mesa/swrast/s_span.c
+++ b/src/mesa/swrast/s_span.c
@@ -1337,12 +1337,23 @@ _swrast_write_rgba_span( struct gl_context *ctx, SWspan *span)
          if (rb) {
             GLchan rgbaSave[MAX_WIDTH][4];
 
-            if (span->array->ChanType == GL_UNSIGNED_BYTE) {
-               span->array->rgba = span->array->rgba8;
+	    GLenum datatype;
+	    GLuint comps;
+
+	    _mesa_format_to_type_and_comps(rb->Format, &datatype, &comps);
+
+            /* set span->array->rgba to colors for render buffer's datatype */
+            if (datatype != span->array->ChanType) {
+               convert_color_type(span, datatype, 0);
             }
             else {
-               span->array->rgba = (void *)
-                  span->array->attribs[FRAG_ATTRIB_COL0];
+               if (span->array->ChanType == GL_UNSIGNED_BYTE) {
+                  span->array->rgba = span->array->rgba8;
+               }
+               else {
+                  span->array->rgba = (void *)
+                     span->array->attribs[FRAG_ATTRIB_COL0];
+               }
             }
 
             if (!multiFragOutputs && numBuffers > 1) {




More information about the mesa-commit mailing list