fix GL_DOT3_RGBA texture combiner mode in generated fragment programs (bug #11030)
[mesa.git] / src / mesa / swrast / s_accum.c
index 0b8ad0076232df0c4c1436fdb083853ce0ccb56b..3c45dee3998382fb9c815ba36adae3b5c411da1a 100644 (file)
@@ -136,7 +136,9 @@ _swrast_clear_accum_buffer( GLcontext *ctx, struct gl_renderbuffer *rb )
       return;
    }
 
-   assert(rb);
+   if (!rb || !rb->Data)
+      return;
+
    assert(rb->_BaseFormat == GL_RGBA);
    /* add other types in future? */
    assert(rb->DataType == GL_SHORT || rb->DataType == GL_UNSIGNED_SHORT);
@@ -472,7 +474,9 @@ accum_return(GLcontext *ctx, GLfloat value,
          SWspan span;
 
          /* init color span */
-         INIT_SPAN(span, GL_BITMAP, width, 0, SPAN_RGBA);
+         INIT_SPAN(span, GL_BITMAP);
+         span.end = width;
+         span.arrayMask = SPAN_RGBA;
          span.x = xpos;
          span.y = ypos + i;
 
@@ -541,12 +545,10 @@ accum_return(GLcontext *ctx, GLfloat value,
  * Software fallback for glAccum.
  */
 void
-_swrast_Accum( GLcontext *ctx, GLenum op, GLfloat value,
-              GLint xpos, GLint ypos,
-              GLint width, GLint height )
-
+_swrast_Accum(GLcontext *ctx, GLenum op, GLfloat value)
 {
    SWcontext *swrast = SWRAST_CONTEXT(ctx);
+   GLint xpos, ypos, width, height;
 
    if (SWRAST_CONTEXT(ctx)->NewState)
       _swrast_validate_derived( ctx );
@@ -558,6 +560,14 @@ _swrast_Accum( GLcontext *ctx, GLenum op, GLfloat value,
 
    RENDER_START(swrast, ctx);
 
+   /* Compute region after calling RENDER_START so that we know the
+    * drawbuffer's size/bounds are up to date.
+    */
+   xpos = ctx->DrawBuffer->_Xmin;
+   ypos = ctx->DrawBuffer->_Ymin;
+   width =  ctx->DrawBuffer->_Xmax - ctx->DrawBuffer->_Xmin;
+   height = ctx->DrawBuffer->_Ymax - ctx->DrawBuffer->_Ymin;
+
    switch (op) {
       case GL_ADD:
          if (value != 0.0F) {