From 866e719b7b8bba512ff62d2c464e8cccc07c17c2 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Fri, 3 Feb 2012 08:17:24 -0700 Subject: [PATCH] swrast: fix span color type selection Fixes a regression from commit 660ed923ded3552e023ef8c3dd9f92e6792f1bd2. The basic idea is to look at the format of the dest renderbuffer and choose either GLubyte or GLfloat for colors. The previous code used _mesa_format_to_type_and_comps() which could return a bunch types other than ubyte/float. Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=45578 Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=45577 --- src/mesa/swrast/s_span.c | 19 +++++++++++++------ 1 files changed, 13 insertions(+), 6 deletions(-) diff --git a/src/mesa/swrast/s_span.c b/src/mesa/swrast/s_span.c index 422d86c..e256102 100644 --- a/src/mesa/swrast/s_span.c +++ b/src/mesa/swrast/s_span.c @@ -1320,15 +1320,22 @@ _swrast_write_rgba_span( struct gl_context *ctx, SWspan *span) if (rb) { GLchan rgbaSave[MAX_WIDTH][4]; + GLuint rbMaxBits = _mesa_get_format_max_bits(rb->Format); + GLenum rbDatatype = _mesa_get_format_datatype(rb->Format); + GLenum colorType; - GLenum datatype; - GLuint comps; - - _mesa_format_to_type_and_comps(rb->Format, &datatype, &comps); + if (rbDatatype == GL_UNSIGNED_NORMALIZED && rbMaxBits <= 8) { + /* the buffer's values fit in GLubyte values */ + colorType = GL_UNSIGNED_BYTE; + } + else { + /* use floats otherwise */ + colorType = GL_FLOAT; + } /* set span->array->rgba to colors for render buffer's datatype */ - if (datatype != span->array->ChanType) { - convert_color_type(span, datatype, 0); + if (span->array->ChanType != colorType) { + convert_color_type(span, colorType, 0); } else { if (span->array->ChanType == GL_UNSIGNED_BYTE) { -- 1.7.3.4