diff options
author | Brian <brian.paul@tungstengraphics.com> | 2007-10-16 18:45:28 -0600 |
---|---|---|
committer | Brian <brian.paul@tungstengraphics.com> | 2007-10-16 18:45:28 -0600 |
commit | 2de9477feea4b2d3996a2118b36924fe8474a7d5 (patch) | |
tree | be2ef91c14368ad79267319a9aca786471004099 /src | |
parent | 495961716430b1ff99078abe1a7ac9bc07dd6116 (diff) |
New st_clear_accum_buffer() function (can't use pipe->clear() since it doesn't handle negative color values)
Also, remove unneeded clamping in the accum ops.
Diffstat (limited to 'src')
-rw-r--r-- | src/mesa/state_tracker/st_cb_accum.c | 44 | ||||
-rw-r--r-- | src/mesa/state_tracker/st_cb_accum.h | 3 |
2 files changed, 41 insertions, 6 deletions
diff --git a/src/mesa/state_tracker/st_cb_accum.c b/src/mesa/state_tracker/st_cb_accum.c index 03c65db70b..192bdbab63 100644 --- a/src/mesa/state_tracker/st_cb_accum.c +++ b/src/mesa/state_tracker/st_cb_accum.c @@ -51,6 +51,41 @@ */ +void +st_clear_accum_buffer(GLcontext *ctx, struct gl_renderbuffer *rb) +{ + struct pipe_context *pipe = ctx->st->pipe; + struct st_renderbuffer *acc_strb = st_renderbuffer(rb); + struct pipe_surface *acc_ps = acc_strb->surface; + 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; + const GLfloat r = ctx->Accum.ClearColor[0]; + const GLfloat g = ctx->Accum.ClearColor[1]; + const GLfloat b = ctx->Accum.ClearColor[2]; + const GLfloat a = ctx->Accum.ClearColor[3]; + GLfloat *accBuf; + GLint i; + + (void) pipe->region_map(pipe, acc_ps->region); + + accBuf = (GLfloat *) malloc(width * height * 4 * sizeof(GLfloat)); + + for (i = 0; i < width * height; i++) { + accBuf[i * 4 + 0] = r; + accBuf[i * 4 + 1] = g; + accBuf[i * 4 + 2] = b; + accBuf[i * 4 + 3] = a; + } + + acc_ps->put_tile(acc_ps, xpos, ypos, width, height, accBuf); + + pipe->region_unmap(pipe, acc_ps->region); +} + + + /** For ADD/MULT */ static void accum_mad(struct pipe_context *pipe, GLfloat scale, GLfloat bias, @@ -67,8 +102,7 @@ accum_mad(struct pipe_context *pipe, GLfloat scale, GLfloat bias, acc_ps->get_tile(acc_ps, xpos, ypos, width, height, accBuf); for (i = 0; i < 4 * width * height; i++) { - GLfloat val = accBuf[i] * scale + bias; - accBuf[i] = CLAMP(val, 0.0, 1.0); + accBuf[i] = accBuf[i] * scale + bias; } acc_ps->put_tile(acc_ps, xpos, ypos, width, height, accBuf); @@ -99,8 +133,7 @@ accum_accum(struct pipe_context *pipe, GLfloat value, acc_ps->get_tile(acc_ps, xpos, ypos, width, height, accBuf); for (i = 0; i < 4 * width * height; i++) { - GLfloat val = accBuf[i] + colorBuf[i] * value; - accBuf[i] = CLAMP(val, 0.0, 1.0); + accBuf[i] = accBuf[i] + colorBuf[i] * value; } acc_ps->put_tile(acc_ps, xpos, ypos, width, height, accBuf); @@ -130,8 +163,7 @@ accum_load(struct pipe_context *pipe, GLfloat value, color_ps->get_tile(color_ps, xpos, ypos, width, height, buf); for (i = 0; i < 4 * width * height; i++) { - GLfloat val = buf[i] * value; - buf[i] = CLAMP(val, 0.0, 1.0); + buf[i] = buf[i] * value; } acc_ps->put_tile(acc_ps, xpos, ypos, width, height, buf); diff --git a/src/mesa/state_tracker/st_cb_accum.h b/src/mesa/state_tracker/st_cb_accum.h index 8a4101c627..ed9b7dab94 100644 --- a/src/mesa/state_tracker/st_cb_accum.h +++ b/src/mesa/state_tracker/st_cb_accum.h @@ -30,6 +30,9 @@ #define ST_CB_ACCUM_H +extern void +st_clear_accum_buffer(GLcontext *ctx, struct gl_renderbuffer *rb); + extern void st_init_accum_functions(struct dd_function_table *functions); |