Merge branch 'glsl2'
[mesa.git] / src / mesa / swrast / s_span.c
index 29f070686fe81b2fe046835fd0cc840a786a1d91..8931cdec1bc4569ba111ddc840eb84b83e8582b3 100644 (file)
@@ -33,7 +33,6 @@
 
 #include "main/glheader.h"
 #include "main/colormac.h"
-#include "main/context.h"
 #include "main/macros.h"
 #include "main/imports.h"
 #include "main/image.h"
@@ -60,6 +59,7 @@
 void
 _swrast_span_default_attribs(GLcontext *ctx, SWspan *span)
 {
+   GLchan r, g, b, a;
    /* Z*/
    {
       const GLfloat depthMax = ctx->DrawBuffer->_DepthMaxF;
@@ -80,7 +80,6 @@ _swrast_span_default_attribs(GLcontext *ctx, SWspan *span)
    span->attrStepY[FRAG_ATTRIB_WPOS][3] = 0.0;
 
    /* primary color, or color index */
-   GLchan r, g, b, a;
    UNCLAMPED_FLOAT_TO_CHAN(r, ctx->Current.RasterColor[0]);
    UNCLAMPED_FLOAT_TO_CHAN(g, ctx->Current.RasterColor[1]);
    UNCLAMPED_FLOAT_TO_CHAN(b, ctx->Current.RasterColor[2]);
@@ -971,6 +970,10 @@ shade_texture_span(GLcontext *ctx, SWspan *span)
       if (span->primitive == GL_BITMAP && span->array->ChanType != GL_FLOAT) {
          convert_color_type(span, GL_FLOAT, 0);
       }
+      else {
+         span->array->rgba = (void *) span->array->attribs[FRAG_ATTRIB_COL0];
+      }
+
       if (span->primitive != GL_POINT ||
          (span->interpMask & SPAN_RGBA) ||
          ctx->Point.PointSprite) {
@@ -1222,9 +1225,22 @@ _swrast_write_rgba_span( GLcontext *ctx, SWspan *span)
             GLchan rgbaSave[MAX_WIDTH][4];
             const GLuint fragOutput = multiFragOutputs ? buf : 0;
 
+            /* set span->array->rgba to colors for render buffer's datatype */
             if (rb->DataType != span->array->ChanType || fragOutput > 0) {
                convert_color_type(span, rb->DataType, fragOutput);
             }
+            else {
+               if (rb->DataType == GL_UNSIGNED_BYTE) {
+                  span->array->rgba = span->array->rgba8;
+               }
+               else if (rb->DataType == GL_UNSIGNED_SHORT) {
+                  span->array->rgba = (void *) span->array->rgba16;
+               }
+               else {
+                  span->array->rgba = (void *)
+                     span->array->attribs[FRAG_ATTRIB_COL0];
+               }
+            }
 
             if (!multiFragOutputs && numBuffers > 1) {
                /* save colors for second, third renderbuffer writes */