summaryrefslogtreecommitdiff
path: root/src/mesa/state_tracker/st_cb_accum.c
diff options
context:
space:
mode:
authorMichel Dänzer <michel@tungstengraphics.com>2008-01-10 17:44:04 +0100
committerMichel Dänzer <michel@tungstengraphics.com>2008-01-14 18:12:58 +0100
commitc76efb96b405e43e3261d1dc9e8812fdb2cfbac8 (patch)
tree001828ee5bca72508f45deacfbb9f2318763ce99 /src/mesa/state_tracker/st_cb_accum.c
parenta511200e5f0c384e68258879bab76563d8e01f01 (diff)
Remove mapping fields from struct pipe_surface.
It's now the responsibility of surface users to keep track of their mappings.
Diffstat (limited to 'src/mesa/state_tracker/st_cb_accum.c')
-rw-r--r--src/mesa/state_tracker/st_cb_accum.c137
1 files changed, 15 insertions, 122 deletions
diff --git a/src/mesa/state_tracker/st_cb_accum.c b/src/mesa/state_tracker/st_cb_accum.c
index cf2e9db51c..73cd7db18d 100644
--- a/src/mesa/state_tracker/st_cb_accum.c
+++ b/src/mesa/state_tracker/st_cb_accum.c
@@ -59,6 +59,7 @@
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;
@@ -69,102 +70,17 @@ st_clear_accum_buffer(GLcontext *ctx, struct gl_renderbuffer *rb)
const GLfloat g = ctx->Accum.ClearColor[1];
const GLfloat b = ctx->Accum.ClearColor[2];
const GLfloat a = ctx->Accum.ClearColor[3];
+ GLfloat *accBuf = (GLfloat *) malloc(width * height * 4 * sizeof(GLfloat));
+ int i;
- (void) pipe_surface_map(acc_ps);
-
- switch (acc_ps->format) {
- case PIPE_FORMAT_R16G16B16A16_SNORM:
- {
- const short sr = (short) (32767 * r);
- const short sg = (short) (32767 * g);
- const short sb = (short) (32767 * b);
- const short sa = (short) (32767 * a);
- short *acc = ((short *) acc_ps->map)
- + (ypos * acc_ps->pitch + xpos) * 4;
- int i, j;
- for (i = 0; i < height; i++) {
- for (j = 0; j < width; j++) {
- acc[j*4+0] = sr;
- acc[j*4+1] = sg;
- acc[j*4+2] = sb;
- acc[j*4+3] = sa;
- }
- acc += acc_ps->pitch * 4;
- }
- }
- break;
- default:
- assert(0);
+ 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;
}
- pipe_surface_unmap(acc_ps);
-}
-
-
-/** Get block of values from accum buffer, converting to float */
-static void
-get_accum_tile(struct pipe_context *pipe,
- struct pipe_surface *acc_surf,
- int xpos, int ypos, int width, int height,
- float *buf)
-{
- switch (acc_surf->format) {
- case PIPE_FORMAT_R16G16B16A16_SNORM:
- {
- const short *acc = ((const short *) acc_surf->map)
- + (ypos * acc_surf->pitch + xpos) * 4;
- int i, j;
- for (i = 0; i < height; i++) {
- for (j = 0; j < width; j++) {
- buf[j*4+0] = SHORT_TO_FLOAT(acc[j*4+0]);
- buf[j*4+1] = SHORT_TO_FLOAT(acc[j*4+1]);
- buf[j*4+2] = SHORT_TO_FLOAT(acc[j*4+2]);
- buf[j*4+3] = SHORT_TO_FLOAT(acc[j*4+3]);
- }
- acc += acc_surf->pitch * 4;
- buf += width * 4;
- }
- }
- break;
- default:
- assert(0);
- }
-}
-
-
-/** Put block of values into accum buffer, converting from float */
-static void
-put_accum_tile(struct pipe_context *pipe,
- struct pipe_surface *acc_surf,
- int xpos, int ypos, int width, int height,
- const float *buf)
-{
- switch (acc_surf->format) {
- case PIPE_FORMAT_R16G16B16A16_SNORM:
- {
- short *acc = ((short *) acc_surf->map)
- + (ypos * acc_surf->pitch + xpos) * 4;
- int i, j;
- for (i = 0; i < height; i++) {
- for (j = 0; j < width; j++) {
- short r, g, b, a;
- UNCLAMPED_FLOAT_TO_SHORT(r, buf[j*4+0]);
- UNCLAMPED_FLOAT_TO_SHORT(g, buf[j*4+1]);
- UNCLAMPED_FLOAT_TO_SHORT(b, buf[j*4+2]);
- UNCLAMPED_FLOAT_TO_SHORT(a, buf[j*4+3]);
- acc[j*4+0] = r;
- acc[j*4+1] = g;
- acc[j*4+2] = b;
- acc[j*4+3] = a;
- }
- acc += acc_surf->pitch * 4;
- buf += width * 4;
- }
- }
- break;
- default:
- assert(0);
- }
+ pipe->put_tile_rgba(pipe, acc_ps, xpos, ypos, width, height, accBuf);
}
@@ -179,19 +95,15 @@ accum_mad(struct pipe_context *pipe, GLfloat scale, GLfloat bias,
accBuf = (GLfloat *) malloc(width * height * 4 * sizeof(GLfloat));
- (void) pipe_surface_map(acc_ps);
-
- get_accum_tile(pipe, acc_ps, xpos, ypos, width, height, accBuf);
+ pipe->get_tile_rgba(pipe, acc_ps, xpos, ypos, width, height, accBuf);
for (i = 0; i < 4 * width * height; i++) {
accBuf[i] = accBuf[i] * scale + bias;
}
- put_accum_tile(pipe, acc_ps, xpos, ypos, width, height, accBuf);
+ pipe->put_tile_rgba(pipe, acc_ps, xpos, ypos, width, height, accBuf);
free(accBuf);
-
- pipe_surface_unmap(acc_ps);
}
@@ -201,30 +113,23 @@ accum_accum(struct pipe_context *pipe, GLfloat value,
struct pipe_surface *acc_ps,
struct pipe_surface *color_ps)
{
- ubyte *colorMap, *accMap;
GLfloat *colorBuf, *accBuf;
GLint i;
colorBuf = (GLfloat *) malloc(width * height * 4 * sizeof(GLfloat));
accBuf = (GLfloat *) malloc(width * height * 4 * sizeof(GLfloat));
- colorMap = pipe_surface_map(color_ps);
- accMap = pipe_surface_map(acc_ps);
-
pipe->get_tile_rgba(pipe, color_ps, xpos, ypos, width, height, colorBuf);
- get_accum_tile(pipe, acc_ps, xpos, ypos, width, height, accBuf);
+ pipe->get_tile_rgba(pipe, acc_ps, xpos, ypos, width, height, accBuf);
for (i = 0; i < 4 * width * height; i++) {
accBuf[i] = accBuf[i] + colorBuf[i] * value;
}
- put_accum_tile(pipe, acc_ps, xpos, ypos, width, height, accBuf);
+ pipe->put_tile_rgba(pipe, acc_ps, xpos, ypos, width, height, accBuf);
free(colorBuf);
free(accBuf);
-
- pipe_surface_unmap(color_ps);
- pipe_surface_unmap(acc_ps);
}
@@ -239,21 +144,15 @@ accum_load(struct pipe_context *pipe, GLfloat value,
buf = (GLfloat *) malloc(width * height * 4 * sizeof(GLfloat));
- (void) pipe_surface_map(color_ps);
- (void) pipe_surface_map(acc_ps);
-
pipe->get_tile_rgba(pipe, color_ps, xpos, ypos, width, height, buf);
for (i = 0; i < 4 * width * height; i++) {
buf[i] = buf[i] * value;
}
- put_accum_tile(pipe, acc_ps, xpos, ypos, width, height, buf);
+ pipe->put_tile_rgba(pipe, acc_ps, xpos, ypos, width, height, buf);
free(buf);
-
- pipe_surface_unmap(color_ps);
- pipe_surface_unmap(acc_ps);
}
@@ -270,10 +169,7 @@ accum_return(GLcontext *ctx, GLfloat value,
abuf = (GLfloat *) malloc(width * height * 4 * sizeof(GLfloat));
- (void) pipe_surface_map(color_ps);
- (void) pipe_surface_map(acc_ps);
-
- get_accum_tile(pipe, acc_ps, xpos, ypos, width, height, abuf);
+ pipe->get_tile_rgba(pipe, acc_ps, xpos, ypos, width, height, abuf);
if (!colormask[0] || !colormask[1] || !colormask[2] || !colormask[3]) {
cbuf = (GLfloat *) malloc(width * height * 4 * sizeof(GLfloat));
@@ -297,9 +193,6 @@ accum_return(GLcontext *ctx, GLfloat value,
free(abuf);
if (cbuf)
free(cbuf);
-
- pipe_surface_unmap(color_ps);
- pipe_surface_unmap(acc_ps);
}