s/BlendEquatioRGB/BlendEquationRGB/
[mesa.git] / src / mesa / swrast / s_accum.c
index a70cab0364ad979a558d58bcd33b5d8bc667f0bd..aa2d6b413bfce2bf29f652e673ab09b0dcdbacd9 100644 (file)
@@ -1,21 +1,20 @@
-/* $Id: s_accum.c,v 1.4 2001/01/23 23:39:37 brianp Exp $ */
 
 /*
  * Mesa 3-D graphics library
- * Version:  3.5
- * 
- * Copyright (C) 1999-2001  Brian Paul   All Rights Reserved.
- * 
+ * Version:  4.1
+ *
+ * Copyright (C) 1999-2002  Brian Paul   All Rights Reserved.
+ *
  * Permission is hereby granted, free of charge, to any person obtaining a
  * copy of this software and associated documentation files (the "Software"),
  * to deal in the Software without restriction, including without limitation
  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
  * and/or sell copies of the Software, and to permit persons to whom the
  * Software is furnished to do so, subject to the following conditions:
- * 
+ *
  * The above copyright notice and this permission notice shall be included
  * in all copies or substantial portions of the Software.
- * 
+ *
  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
  */
 
 
+#include "glheader.h"
 #include "context.h"
 #include "macros.h"
-#include "mem.h"
+#include "imports.h"
 
 #include "s_accum.h"
 #include "s_alphabuf.h"
  */
 
 
-#if CHAN_BITS == 8
+#if CHAN_BITS == 8 && ACCUM_BITS < 32
 #define USE_OPTIMIZED_ACCUM   /* enable the optimization */
 #endif
 
 
-
 void
-_mesa_alloc_accum_buffer( GLcontext *ctx )
+_swrast_alloc_accum_buffer( GLframebuffer *buffer )
 {
-   SWcontext *swrast = SWRAST_CONTEXT(ctx);
+   GET_CURRENT_CONTEXT(ctx);
    GLint n;
 
-   if (ctx->DrawBuffer->Accum) {
-      FREE( ctx->DrawBuffer->Accum );
-      ctx->DrawBuffer->Accum = NULL;
+   if (buffer->Accum) {
+      MESA_PBUFFER_FREE( buffer->Accum );
+      buffer->Accum = NULL;
    }
 
    /* allocate accumulation buffer if not already present */
-   n = ctx->DrawBuffer->Width * ctx->DrawBuffer->Height * 4 * sizeof(GLaccum);
-   ctx->DrawBuffer->Accum = (GLaccum *) MALLOC( n );
-   if (!ctx->DrawBuffer->Accum) {
+   n = buffer->Width * buffer->Height * 4 * sizeof(GLaccum);
+   buffer->Accum = (GLaccum *) MESA_PBUFFER_ALLOC( n );
+   if (!buffer->Accum) {
       /* unable to setup accumulation buffer */
-      gl_error( ctx, GL_OUT_OF_MEMORY, "glAccum" );
+      _mesa_error( NULL, GL_OUT_OF_MEMORY, "glAccum" );
    }
+
+   if (ctx) {
+      SWcontext *swrast = SWRAST_CONTEXT(ctx);
+      /* XXX these fields should probably be in the GLframebuffer */
 #ifdef USE_OPTIMIZED_ACCUM
-   swrast->_IntegerAccumMode = GL_TRUE;
+      swrast->_IntegerAccumMode = GL_TRUE;
 #else
-   swrast->_IntegerAccumMode = GL_FALSE;
+      swrast->_IntegerAccumMode = GL_FALSE;
 #endif
-   swrast->_IntegerAccumScaler = 0.0;
+      swrast->_IntegerAccumScaler = 0.0;
+   }
 }
 
 
-
-
-
-
 /*
  * This is called when we fall out of optimized/unscaled accum buffer mode.
  * That is, we convert each unscaled accum buffer value into a scaled value
@@ -106,8 +106,7 @@ static void rescale_accum( GLcontext *ctx )
 {
    SWcontext *swrast = SWRAST_CONTEXT(ctx);
    const GLuint n = ctx->DrawBuffer->Width * ctx->DrawBuffer->Height * 4;
-   const GLfloat fChanMax = (1 << (sizeof(GLchan) * 8)) - 1;
-   const GLfloat s = swrast->_IntegerAccumScaler * (32767.0 / fChanMax);
+   const GLfloat s = swrast->_IntegerAccumScaler * (32767.0F / CHAN_MAXF);
    GLaccum *accum = ctx->DrawBuffer->Accum;
    GLuint i;
 
@@ -130,7 +129,7 @@ static void rescale_accum( GLcontext *ctx )
  * Clear the accumulation Buffer.
  */
 void
-_mesa_clear_accum_buffer( GLcontext *ctx )
+_swarst_clear_accum_buffer( GLcontext *ctx )
 {
    SWcontext *swrast = SWRAST_CONTEXT(ctx);
    GLuint buffersize;
@@ -148,8 +147,7 @@ _mesa_clear_accum_buffer( GLcontext *ctx )
       acc_scale = 32767.0;
    }
    else {
-      /* sizeof(GLaccum) > 2 (Cray) */
-      acc_scale = (float) SHRT_MAX;
+      acc_scale = 1.0F;
    }
 
    /* number of pixels */
@@ -164,14 +162,13 @@ _mesa_clear_accum_buffer( GLcontext *ctx )
    if (ctx->DrawBuffer->Accum) {
       if (ctx->Scissor.Enabled) {
         /* Limit clear to scissor box */
-        GLaccum r, g, b, a;
+        const GLaccum r = (GLaccum) (ctx->Accum.ClearColor[0] * acc_scale);
+        const GLaccum g = (GLaccum) (ctx->Accum.ClearColor[1] * acc_scale);
+        const GLaccum b = (GLaccum) (ctx->Accum.ClearColor[2] * acc_scale);
+        const GLaccum a = (GLaccum) (ctx->Accum.ClearColor[3] * acc_scale);
         GLint i, j;
          GLint width, height;
          GLaccum *row;
-        r = (GLaccum) (ctx->Accum.ClearColor[0] * acc_scale);
-        g = (GLaccum) (ctx->Accum.ClearColor[1] * acc_scale);
-        b = (GLaccum) (ctx->Accum.ClearColor[2] * acc_scale);
-        a = (GLaccum) (ctx->Accum.ClearColor[3] * acc_scale);
          /* size of region to clear */
          width = 4 * (ctx->DrawBuffer->_Xmax - ctx->DrawBuffer->_Xmin);
          height = ctx->DrawBuffer->_Ymax - ctx->DrawBuffer->_Ymin;
@@ -196,18 +193,17 @@ _mesa_clear_accum_buffer( GLcontext *ctx )
             ctx->Accum.ClearColor[2]==0.0 &&
             ctx->Accum.ClearColor[3]==0.0) {
            /* Black */
-           BZERO( ctx->DrawBuffer->Accum, buffersize * 4 * sizeof(GLaccum) );
+           _mesa_bzero( ctx->DrawBuffer->Accum,
+                         buffersize * 4 * sizeof(GLaccum) );
         }
         else {
            /* Not black */
-           GLaccum *acc, r, g, b, a;
+           const GLaccum r = (GLaccum) (ctx->Accum.ClearColor[0] * acc_scale);
+           const GLaccum g = (GLaccum) (ctx->Accum.ClearColor[1] * acc_scale);
+           const GLaccum b = (GLaccum) (ctx->Accum.ClearColor[2] * acc_scale);
+           const GLaccum a = (GLaccum) (ctx->Accum.ClearColor[3] * acc_scale);
+           GLaccum *acc = ctx->DrawBuffer->Accum;
            GLuint i;
-
-           acc = ctx->DrawBuffer->Accum;
-           r = (GLaccum) (ctx->Accum.ClearColor[0] * acc_scale);
-           g = (GLaccum) (ctx->Accum.ClearColor[1] * acc_scale);
-           b = (GLaccum) (ctx->Accum.ClearColor[2] * acc_scale);
-           a = (GLaccum) (ctx->Accum.ClearColor[3] * acc_scale);
            for (i=0;i<buffersize;i++) {
               *acc++ = r;
               *acc++ = g;
@@ -236,7 +232,7 @@ _mesa_clear_accum_buffer( GLcontext *ctx )
 
 void
 _swrast_Accum( GLcontext *ctx, GLenum op, GLfloat value,
-              GLint xpos, GLint ypos, 
+              GLint xpos, GLint ypos,
               GLint width, GLint height )
 
 {
@@ -245,15 +241,13 @@ _swrast_Accum( GLcontext *ctx, GLenum op, GLfloat value,
    GLfloat acc_scale;
    GLchan rgba[MAX_WIDTH][4];
    const GLuint colorMask = *((GLuint *) &ctx->Color.ColorMask);
-   const GLint iChanMax = (1 << (sizeof(GLchan) * 8)) - 1;
-   const GLfloat fChanMax = (1 << (sizeof(GLchan) * 8)) - 1;
-   
+
 
    if (SWRAST_CONTEXT(ctx)->NewState)
       _swrast_validate_derived( ctx );
 
    if (!ctx->DrawBuffer->Accum) {
-      _mesa_warning(ctx, 
+      _mesa_warning(ctx,
                    "Calling glAccum() without an accumulation "
                    "buffer (low memory?)");
       return;
@@ -266,8 +260,7 @@ _swrast_Accum( GLcontext *ctx, GLenum op, GLfloat value,
       acc_scale = 32767.0;
    }
    else {
-      /* sizeof(GLaccum) > 2 (Cray) */
-      acc_scale = (float) SHRT_MAX;
+      acc_scale = 1.0F;
    }
 
    width4 = 4 * width;
@@ -275,16 +268,16 @@ _swrast_Accum( GLcontext *ctx, GLenum op, GLfloat value,
    switch (op) {
       case GL_ADD:
          if (value != 0.0F) {
-           const GLaccum intVal = (GLaccum) (value * acc_scale);
-           GLuint j;
+           const GLaccum val = (GLaccum) (value * acc_scale);
+           GLint j;
             /* Leave optimized accum buffer mode */
             if (swrast->_IntegerAccumMode)
                rescale_accum(ctx);
            for (j = 0; j < height; j++) {
-              GLaccum * acc = ctx->DrawBuffer->Accum + ypos * width4 + 4 * xpos;
+              GLaccum *acc = ctx->DrawBuffer->Accum + ypos * width4 + 4*xpos;
                GLuint i;
               for (i = 0; i < width4; i++) {
-                  acc[i] += intVal;
+                  acc[i] += val;
               }
               ypos++;
            }
@@ -293,7 +286,7 @@ _swrast_Accum( GLcontext *ctx, GLenum op, GLfloat value,
 
       case GL_MULT:
          if (value != 1.0F) {
-           GLuint j;
+           GLint j;
             /* Leave optimized accum buffer mode */
             if (swrast->_IntegerAccumMode)
                rescale_accum(ctx);
@@ -312,27 +305,26 @@ _swrast_Accum( GLcontext *ctx, GLenum op, GLfloat value,
          if (value == 0.0F)
             return;
 
-         (*ctx->Driver.SetReadBuffer)( ctx, ctx->ReadBuffer,
-                                       ctx->Pixel.DriverReadBuffer );
+         _swrast_use_read_buffer(ctx);
 
          /* May have to leave optimized accum buffer mode */
          if (swrast->_IntegerAccumScaler == 0.0 && value > 0.0 && value <= 1.0)
             swrast->_IntegerAccumScaler = value;
          if (swrast->_IntegerAccumMode && value != swrast->_IntegerAccumScaler)
             rescale_accum(ctx);
-            
-         RENDER_START(ctx);
+
+         RENDER_START(swrast,ctx);
 
          if (swrast->_IntegerAccumMode) {
             /* simply add integer color values into accum buffer */
-            GLuint j;
+            GLint j;
             GLaccum *acc = ctx->DrawBuffer->Accum + ypos * width4 + xpos * 4;
             assert(swrast->_IntegerAccumScaler > 0.0);
             assert(swrast->_IntegerAccumScaler <= 1.0);
             for (j = 0; j < height; j++) {
-               
-               GLuint i, i4;
-               gl_read_rgba_span(ctx, ctx->DrawBuffer, width, xpos, ypos, rgba);
+
+               GLint i, i4;
+               _swrast_read_rgba_span(ctx, ctx->DrawBuffer, width, xpos, ypos, rgba);
                for (i = i4 = 0; i < width; i++, i4+=4) {
                   acc[i4+0] += rgba[i][RCOMP];
                   acc[i4+1] += rgba[i][GCOMP];
@@ -344,34 +336,34 @@ _swrast_Accum( GLcontext *ctx, GLenum op, GLfloat value,
             }
          }
          else {
-            /* scaled integer accum buffer */
-            const GLfloat rscale = value * acc_scale / fChanMax;
-            const GLfloat gscale = value * acc_scale / fChanMax;
-            const GLfloat bscale = value * acc_scale / fChanMax;
-            const GLfloat ascale = value * acc_scale / fChanMax;
-            GLuint j;
+            /* scaled integer (or float) accum buffer */
+            const GLfloat rscale = value * acc_scale / CHAN_MAXF;
+            const GLfloat gscale = value * acc_scale / CHAN_MAXF;
+            const GLfloat bscale = value * acc_scale / CHAN_MAXF;
+            const GLfloat ascale = value * acc_scale / CHAN_MAXF;
+            GLint j;
             for (j=0;j<height;j++) {
                GLaccum *acc = ctx->DrawBuffer->Accum + ypos * width4 + xpos * 4;
-               GLuint i;
-               gl_read_rgba_span(ctx, ctx->DrawBuffer, width, xpos, ypos, rgba);
+               GLint i;
+               _swrast_read_rgba_span(ctx, ctx->DrawBuffer, width, xpos, ypos, rgba);
                for (i=0;i<width;i++) {
-                  *acc += (GLaccum) ( (GLfloat) rgba[i][RCOMP] * rscale );  acc++;
-                  *acc += (GLaccum) ( (GLfloat) rgba[i][GCOMP] * gscale );  acc++;
-                  *acc += (GLaccum) ( (GLfloat) rgba[i][BCOMP] * bscale );  acc++;
-                  *acc += (GLaccum) ( (GLfloat) rgba[i][ACOMP] * ascale );  acc++;
+                  acc[0] += (GLaccum) ( (GLfloat) rgba[i][RCOMP] * rscale );
+                  acc[1] += (GLaccum) ( (GLfloat) rgba[i][GCOMP] * gscale );
+                  acc[2] += (GLaccum) ( (GLfloat) rgba[i][BCOMP] * bscale );
+                  acc[3] += (GLaccum) ( (GLfloat) rgba[i][ACOMP] * ascale );
+                  acc += 4;
                }
                ypos++;
             }
          }
          /* restore read buffer = draw buffer (the default) */
-         (*ctx->Driver.SetReadBuffer)( ctx, ctx->DrawBuffer,
-                                       ctx->Color.DriverDrawBuffer );
-         RENDER_FINISH(ctx);
+         _swrast_use_draw_buffer(ctx);
+
+         RENDER_FINISH(swrast,ctx);
         break;
 
       case GL_LOAD:
-         (*ctx->Driver.SetReadBuffer)( ctx, ctx->ReadBuffer,
-                                       ctx->Pixel.DriverReadBuffer );
+         _swrast_use_read_buffer(ctx);
 
          /* This is a change to go into optimized accum buffer mode */
          if (value > 0.0 && value <= 1.0) {
@@ -387,16 +379,16 @@ _swrast_Accum( GLcontext *ctx, GLenum op, GLfloat value,
             swrast->_IntegerAccumScaler = 0.0;
          }
 
-         RENDER_START(ctx);
+         RENDER_START(swrast,ctx);
          if (swrast->_IntegerAccumMode) {
             /* just copy values into accum buffer */
-            GLuint j;
+            GLint j;
             GLaccum *acc = ctx->DrawBuffer->Accum + ypos * width4 + xpos * 4;
             assert(swrast->_IntegerAccumScaler > 0.0);
             assert(swrast->_IntegerAccumScaler <= 1.0);
             for (j = 0; j < height; j++) {
-               GLuint i, i4;
-               gl_read_rgba_span(ctx, ctx->DrawBuffer, width, xpos, ypos, rgba);
+               GLint i, i4;
+               _swrast_read_rgba_span(ctx, ctx->DrawBuffer, width, xpos, ypos, rgba);
                for (i = i4 = 0; i < width; i++, i4 += 4) {
                   acc[i4+0] = rgba[i][RCOMP];
                   acc[i4+1] = rgba[i][GCOMP];
@@ -408,30 +400,39 @@ _swrast_Accum( GLcontext *ctx, GLenum op, GLfloat value,
             }
          }
          else {
-            /* scaled integer accum buffer */
-            const GLfloat rscale = value * acc_scale / fChanMax;
-            const GLfloat gscale = value * acc_scale / fChanMax;
-            const GLfloat bscale = value * acc_scale / fChanMax;
-            const GLfloat ascale = value * acc_scale / fChanMax;
-            const GLfloat d = 3.0 / acc_scale;
-            GLuint i, j;
+            /* scaled integer (or float) accum buffer */
+            const GLfloat rscale = value * acc_scale / CHAN_MAXF;
+            const GLfloat gscale = value * acc_scale / CHAN_MAXF;
+            const GLfloat bscale = value * acc_scale / CHAN_MAXF;
+            const GLfloat ascale = value * acc_scale / CHAN_MAXF;
+#if 0
+            const GLfloat d = 3.0 / acc_scale;  /* XXX what's this? */
+#endif
+            GLint i, j;
             for (j = 0; j < height; j++) {
                GLaccum *acc = ctx->DrawBuffer->Accum + ypos * width4 + xpos * 4;
-               gl_read_rgba_span(ctx, ctx->DrawBuffer, width, xpos, ypos, rgba);
+               _swrast_read_rgba_span(ctx, ctx->DrawBuffer, width, xpos, ypos, rgba);
                for (i=0;i<width;i++) {
+#if 0
                   *acc++ = (GLaccum) ((GLfloat) rgba[i][RCOMP] * rscale + d);
                   *acc++ = (GLaccum) ((GLfloat) rgba[i][GCOMP] * gscale + d);
                   *acc++ = (GLaccum) ((GLfloat) rgba[i][BCOMP] * bscale + d);
                   *acc++ = (GLaccum) ((GLfloat) rgba[i][ACOMP] * ascale + d);
+#else
+                  *acc++ = (GLaccum) ((GLfloat) rgba[i][RCOMP] * rscale);
+                  *acc++ = (GLaccum) ((GLfloat) rgba[i][GCOMP] * gscale);
+                  *acc++ = (GLaccum) ((GLfloat) rgba[i][BCOMP] * bscale);
+                  *acc++ = (GLaccum) ((GLfloat) rgba[i][ACOMP] * ascale);
+#endif
                }
                ypos++;
             }
          }
 
          /* restore read buffer = draw buffer (the default) */
-         (*ctx->Driver.SetReadBuffer)( ctx, ctx->DrawBuffer,
-                                       ctx->Color.DriverDrawBuffer );
-         RENDER_FINISH(ctx);
+         _swrast_use_draw_buffer(ctx);
+
+         RENDER_FINISH(swrast,ctx);
         break;
 
       case GL_RETURN:
@@ -439,17 +440,18 @@ _swrast_Accum( GLcontext *ctx, GLenum op, GLfloat value,
          if (swrast->_IntegerAccumMode && value != 1.0)
             rescale_accum(ctx);
 
-         RENDER_START(ctx);
+         RENDER_START(swrast,ctx);
+#ifdef USE_OPTIMIZED_ACCUM
          if (swrast->_IntegerAccumMode && swrast->_IntegerAccumScaler > 0) {
             /* build lookup table to avoid many floating point multiplies */
             static GLchan multTable[32768];
             static GLfloat prevMult = 0.0;
             const GLfloat mult = swrast->_IntegerAccumScaler;
             const GLint max = MIN2((GLint) (256 / mult), 32767);
-            GLuint j;
+            GLint j;
             if (mult != prevMult) {
                for (j = 0; j < max; j++)
-                  multTable[j] = (GLint) ((GLfloat) j * mult + 0.5F);
+                  multTable[j] = IROUND((GLfloat) j * mult);
                prevMult = mult;
             }
 
@@ -457,7 +459,7 @@ _swrast_Accum( GLcontext *ctx, GLenum op, GLfloat value,
             assert(swrast->_IntegerAccumScaler <= 1.0);
             for (j = 0; j < height; j++) {
                const GLaccum *acc = ctx->DrawBuffer->Accum + ypos * width4 + xpos*4;
-               GLuint i, i4;
+               GLint i, i4;
                for (i = i4 = 0; i < width; i++, i4 += 4) {
                   ASSERT(acc[i4+0] < max);
                   ASSERT(acc[i4+1] < max);
@@ -469,54 +471,57 @@ _swrast_Accum( GLcontext *ctx, GLenum op, GLfloat value,
                   rgba[i][ACOMP] = multTable[acc[i4+3]];
                }
                if (colorMask != 0xffffffff) {
-                  _mesa_mask_rgba_span( ctx, width, xpos, ypos, rgba );
+                  _swrast_mask_rgba_array( ctx, width, xpos, ypos, rgba );
                }
-               (*ctx->Driver.WriteRGBASpan)( ctx, width, xpos, ypos, 
+               (*swrast->Driver.WriteRGBASpan)( ctx, width, xpos, ypos,
                                              (const GLchan (*)[4])rgba, NULL );
                if (ctx->DrawBuffer->UseSoftwareAlphaBuffers
                    && ctx->Color.ColorMask[ACOMP]) {
-                  _mesa_write_alpha_span(ctx, width, xpos, ypos,
-                                         (CONST GLubyte (*)[4]) rgba, NULL);
+                  _swrast_write_alpha_span(ctx, width, xpos, ypos,
+                                         (CONST GLchan (*)[4]) rgba, NULL);
                }
                ypos++;
             }
          }
-         else {
-            const GLfloat rscale = value / acc_scale * fChanMax;
-            const GLfloat gscale = value / acc_scale * fChanMax;
-            const GLfloat bscale = value / acc_scale * fChanMax;
-            const GLfloat ascale = value / acc_scale * fChanMax;
-            GLuint i, j;
+         else
+#endif /* USE_OPTIMIZED_ACCUM */
+         {
+            /* scaled integer (or float) accum buffer */
+            const GLfloat rscale = value / acc_scale * CHAN_MAXF;
+            const GLfloat gscale = value / acc_scale * CHAN_MAXF;
+            const GLfloat bscale = value / acc_scale * CHAN_MAXF;
+            const GLfloat ascale = value / acc_scale * CHAN_MAXF;
+            GLint i, j;
             for (j=0;j<height;j++) {
                const GLaccum *acc = ctx->DrawBuffer->Accum + ypos * width4 + xpos*4;
                for (i=0;i<width;i++) {
-                  GLint r, g, b, a;
-                  r = (GLint) ( (GLfloat) (*acc++) * rscale + 0.5F );
-                  g = (GLint) ( (GLfloat) (*acc++) * gscale + 0.5F );
-                  b = (GLint) ( (GLfloat) (*acc++) * bscale + 0.5F );
-                  a = (GLint) ( (GLfloat) (*acc++) * ascale + 0.5F );
-                  rgba[i][RCOMP] = CLAMP( r, 0, iChanMax );
-                  rgba[i][GCOMP] = CLAMP( g, 0, iChanMax );
-                  rgba[i][BCOMP] = CLAMP( b, 0, iChanMax );
-                  rgba[i][ACOMP] = CLAMP( a, 0, iChanMax );
+                  GLint r = IROUND( (GLfloat) (acc[0]) * rscale );
+                  GLint g = IROUND( (GLfloat) (acc[1]) * gscale );
+                  GLint b = IROUND( (GLfloat) (acc[2]) * bscale );
+                  GLint a = IROUND( (GLfloat) (acc[3]) * ascale );
+                  acc += 4;
+                  rgba[i][RCOMP] = CLAMP( r, 0, CHAN_MAX );
+                  rgba[i][GCOMP] = CLAMP( g, 0, CHAN_MAX );
+                  rgba[i][BCOMP] = CLAMP( b, 0, CHAN_MAX );
+                  rgba[i][ACOMP] = CLAMP( a, 0, CHAN_MAX );
                }
                if (colorMask != 0xffffffff) {
-                  _mesa_mask_rgba_span( ctx, width, xpos, ypos, rgba );
+                  _swrast_mask_rgba_array( ctx, width, xpos, ypos, rgba );
                }
-               (*ctx->Driver.WriteRGBASpan)( ctx, width, xpos, ypos, 
+               (*swrast->Driver.WriteRGBASpan)( ctx, width, xpos, ypos,
                                              (const GLchan (*)[4])rgba, NULL );
                if (ctx->DrawBuffer->UseSoftwareAlphaBuffers
                    && ctx->Color.ColorMask[ACOMP]) {
-                  _mesa_write_alpha_span(ctx, width, xpos, ypos,
-                                         (CONST GLubyte (*)[4]) rgba, NULL);
+                  _swrast_write_alpha_span(ctx, width, xpos, ypos,
+                                         (CONST GLchan (*)[4]) rgba, NULL);
                }
                ypos++;
             }
         }
-         RENDER_FINISH(ctx);
+         RENDER_FINISH(swrast,ctx);
         break;
 
       default:
-         gl_error( ctx, GL_INVALID_ENUM, "glAccum" );
+         _mesa_error( ctx, GL_INVALID_ENUM, "glAccum" );
    }
 }