From 9f797d8cb323f5f61ac8cffcba3329b6f42721aa Mon Sep 17 00:00:00 2001 From: Brian Date: Sun, 14 Oct 2007 11:52:00 -0600 Subject: Added accum function/files. --- src/mesa/state_tracker/st_cb_accum.h | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 src/mesa/state_tracker/st_cb_accum.h (limited to 'src/mesa/state_tracker/st_cb_accum.h') diff --git a/src/mesa/state_tracker/st_cb_accum.h b/src/mesa/state_tracker/st_cb_accum.h new file mode 100644 index 0000000000..8a4101c627 --- /dev/null +++ b/src/mesa/state_tracker/st_cb_accum.h @@ -0,0 +1,36 @@ +/************************************************************************** + * + * Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas. + * 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, sub license, 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 (including the + * next paragraph) 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 NON-INFRINGEMENT. + * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR + * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + **************************************************************************/ + + +#ifndef ST_CB_ACCUM_H +#define ST_CB_ACCUM_H + + +extern void st_init_accum_functions(struct dd_function_table *functions); + + +#endif /* ST_CB_ACCUM_H */ -- cgit v1.2.3 From 2de9477feea4b2d3996a2118b36924fe8474a7d5 Mon Sep 17 00:00:00 2001 From: Brian Date: Tue, 16 Oct 2007 18:45:28 -0600 Subject: 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. --- src/mesa/state_tracker/st_cb_accum.c | 44 +++++++++++++++++++++++++++++++----- src/mesa/state_tracker/st_cb_accum.h | 3 +++ 2 files changed, 41 insertions(+), 6 deletions(-) (limited to 'src/mesa/state_tracker/st_cb_accum.h') 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); -- cgit v1.2.3