X-Git-Url: https://git.libre-soc.org/?a=blobdiff_plain;ds=sidebyside;f=src%2Fmesa%2Fswrast%2Fs_accum.c;h=854e106b7f052bd0668a05e1a8bc11078b9b99f5;hb=bec87456ed80e7561f7ac73b01e648896971a381;hp=fa760501c2200d21fd1cf42f62401de234b89b93;hpb=43715c711d2c1d1e7624cd7c9c8a44b8866510fd;p=mesa.git diff --git a/src/mesa/swrast/s_accum.c b/src/mesa/swrast/s_accum.c index fa760501c22..854e106b7f0 100644 --- a/src/mesa/swrast/s_accum.c +++ b/src/mesa/swrast/s_accum.c @@ -23,11 +23,10 @@ */ -#include "glheader.h" -#include "context.h" -#include "macros.h" -#include "imports.h" -#include "fbobject.h" +#include "main/glheader.h" +#include "main/context.h" +#include "main/macros.h" +#include "main/imports.h" #include "s_accum.h" #include "s_context.h" @@ -38,7 +37,7 @@ /* XXX this would have to change for accum buffers with more or less * than 16 bits per color channel. */ -#define ACCUM_SCALE16 32767.0 +#define ACCUM_SCALE16 32767.0F /* @@ -131,12 +130,10 @@ _swrast_clear_accum_buffer( GLcontext *ctx, struct gl_renderbuffer *rb ) SWcontext *swrast = SWRAST_CONTEXT(ctx); GLuint x, y, width, height; - if (ctx->Visual.accumRedBits == 0) { - /* No accumulation buffer! Not an error. */ + /* No accumulation buffer! Not an error. */ + if (!rb || !rb->Data) return; - } - assert(rb); assert(rb->_BaseFormat == GL_RGBA); /* add other types in future? */ assert(rb->DataType == GL_SHORT || rb->DataType == GL_UNSIGNED_SHORT); @@ -307,7 +304,7 @@ accum_accum(GLcontext *ctx, GLfloat value, /* read colors from color buffer */ _swrast_read_rgba_span(ctx, ctx->ReadBuffer->_ColorReadBuffer, width, - xpos, ypos + i, rgba); + xpos, ypos + i, CHAN_TYPE, rgba); /* do accumulation */ if (swrast->_IntegerAccumMode) { @@ -391,7 +388,7 @@ accum_load(GLcontext *ctx, GLfloat value, /* read colors from color buffer */ _swrast_read_rgba_span(ctx, ctx->ReadBuffer->_ColorReadBuffer, width, - xpos, ypos + i, rgba); + xpos, ypos + i, CHAN_TYPE, rgba); /* do load */ if (swrast->_IntegerAccumMode) { @@ -434,10 +431,6 @@ accum_return(GLcontext *ctx, GLfloat value, struct gl_renderbuffer *accumRb = fb->Attachment[BUFFER_ACCUM].Renderbuffer; const GLboolean directAccess = (accumRb->GetPointer(ctx, accumRb, 0, 0) != NULL); - const GLboolean masking = (!ctx->Color.ColorMask[RCOMP] || - !ctx->Color.ColorMask[GCOMP] || - !ctx->Color.ColorMask[BCOMP] || - !ctx->Color.ColorMask[ACOMP]); static GLchan multTable[32768]; static GLfloat prevMult = 0.0; @@ -467,9 +460,16 @@ accum_return(GLcontext *ctx, GLfloat value, /* XXX maybe transpose the 'i' and 'buffer' loops??? */ for (i = 0; i < height; i++) { - GLchan rgba[MAX_WIDTH][4]; GLshort accumRow[4 * MAX_WIDTH]; GLshort *acc; + SWspan span; + + /* init color span */ + INIT_SPAN(span, GL_BITMAP); + span.end = width; + span.arrayMask = SPAN_RGBA; + span.x = xpos; + span.y = ypos + i; if (directAccess) { acc = (GLshort *) accumRb->GetPointer(ctx, accumRb, xpos, ypos +i); @@ -487,10 +487,10 @@ accum_return(GLcontext *ctx, GLfloat value, ASSERT(acc[j * 4 + 1] < max); ASSERT(acc[j * 4 + 2] < max); ASSERT(acc[j * 4 + 3] < max); - rgba[j][RCOMP] = multTable[acc[j * 4 + 0]]; - rgba[j][GCOMP] = multTable[acc[j * 4 + 1]]; - rgba[j][BCOMP] = multTable[acc[j * 4 + 2]]; - rgba[j][ACOMP] = multTable[acc[j * 4 + 3]]; + span.array->rgba[j][RCOMP] = multTable[acc[j * 4 + 0]]; + span.array->rgba[j][GCOMP] = multTable[acc[j * 4 + 1]]; + span.array->rgba[j][BCOMP] = multTable[acc[j * 4 + 2]]; + span.array->rgba[j][ACOMP] = multTable[acc[j * 4 + 3]]; } } else { @@ -508,24 +508,24 @@ accum_return(GLcontext *ctx, GLfloat value, GLint b = IROUND( (GLfloat) (acc[j * 4 + 2]) * scale ); GLint a = IROUND( (GLfloat) (acc[j * 4 + 3]) * scale ); #endif - rgba[j][RCOMP] = CLAMP( r, 0, CHAN_MAX ); - rgba[j][GCOMP] = CLAMP( g, 0, CHAN_MAX ); - rgba[j][BCOMP] = CLAMP( b, 0, CHAN_MAX ); - rgba[j][ACOMP] = CLAMP( a, 0, CHAN_MAX ); + span.array->rgba[j][RCOMP] = CLAMP( r, 0, CHAN_MAX ); + span.array->rgba[j][GCOMP] = CLAMP( g, 0, CHAN_MAX ); + span.array->rgba[j][BCOMP] = CLAMP( b, 0, CHAN_MAX ); + span.array->rgba[j][ACOMP] = CLAMP( a, 0, CHAN_MAX ); } } /* store colors */ - for (buffer = 0; buffer < fb->_NumColorDrawBuffers[0]; buffer++) { - struct gl_renderbuffer *rb = fb->_ColorDrawBuffers[0][buffer]; + for (buffer = 0; buffer < fb->_NumColorDrawBuffers; buffer++) { + struct gl_renderbuffer *rb = fb->_ColorDrawBuffers[buffer]; + const GLboolean masking = (!ctx->Color.ColorMask[buffer][RCOMP] || + !ctx->Color.ColorMask[buffer][GCOMP] || + !ctx->Color.ColorMask[buffer][BCOMP] || + !ctx->Color.ColorMask[buffer][ACOMP]); if (masking) { - struct sw_span span; - INIT_SPAN(span, GL_BITMAP, width, 0, SPAN_RGBA); - span.x = xpos; - span.y = ypos + i; - _swrast_mask_rgba_span(ctx, rb, &span, rgba); + _swrast_mask_rgba_span(ctx, rb, &span, buffer); } - rb->PutRow(ctx, rb, width, xpos, ypos + i, rgba, NULL); + rb->PutRow(ctx, rb, width, xpos, ypos + i, span.array->rgba, NULL); } } } @@ -540,14 +540,12 @@ 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) + if (swrast->NewState) _swrast_validate_derived( ctx ); if (!ctx->DrawBuffer->Attachment[BUFFER_ACCUM].Renderbuffer) { @@ -555,7 +553,15 @@ _swrast_Accum( GLcontext *ctx, GLenum op, GLfloat value, return; } - RENDER_START(swrast, ctx); + swrast_render_start(ctx); + + /* Compute region after calling swrast_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: @@ -584,5 +590,5 @@ _swrast_Accum( GLcontext *ctx, GLenum op, GLfloat value, break; } - RENDER_FINISH(swrast, ctx); + swrast_render_finish(ctx); }