/** * Software fallback for glAccum. */ void _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 ); if (!ctx->DrawBuffer->Attachment[BUFFER_ACCUM].Renderbuffer) { _mesa_warning(ctx, "Calling glAccum() without an accumulation buffer"); return; } 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) { accum_add(ctx, value, xpos, ypos, width, height); } break; case GL_MULT: if (value != 1.0F) { accum_mult(ctx, value, xpos, ypos, width, height); } break; case GL_ACCUM: if (value != 0.0F) { accum_accum(ctx, value, xpos, ypos, width, height); } break; case GL_LOAD: accum_load(ctx, value, xpos, ypos, width, height); break; case GL_RETURN: accum_return(ctx, value, xpos, ypos, width, height); break; default: _mesa_problem(ctx, "invalid mode in _swrast_Accum()"); break; } RENDER_FINISH(swrast, ctx); }
static void st_Accum(GLcontext *ctx, GLenum op, GLfloat value) { struct st_context *st = ctx->st; struct st_renderbuffer *acc_strb = st_renderbuffer(ctx->DrawBuffer->Attachment[BUFFER_ACCUM].Renderbuffer); struct st_renderbuffer *color_strb = st_renderbuffer(ctx->ReadBuffer->_ColorReadBuffer); const GLint xpos = ctx->DrawBuffer->_Xmin; const GLint ypos = ctx->DrawBuffer->_Ymin; const GLint width = ctx->DrawBuffer->_Xmax - xpos; const GLint height = ctx->DrawBuffer->_Ymax - ypos; if(!acc_strb->data) return; /* make sure color bufs aren't cached */ st_flush( st, PIPE_FLUSH_RENDER_CACHE, NULL ); switch (op) { case GL_ADD: if (value != 0.0F) { accum_mad(ctx, 1.0, value, xpos, ypos, width, height, acc_strb); } break; case GL_MULT: if (value != 1.0F) { accum_mad(ctx, value, 0.0, xpos, ypos, width, height, acc_strb); } break; case GL_ACCUM: if (value != 0.0F) { accum_accum(st, value, xpos, ypos, width, height, acc_strb, color_strb); } break; case GL_LOAD: accum_load(st, value, xpos, ypos, width, height, acc_strb, color_strb); break; case GL_RETURN: accum_return(ctx, value, xpos, ypos, width, height, acc_strb, color_strb); break; default: assert(0); } }