From c76efb96b405e43e3261d1dc9e8812fdb2cfbac8 Mon Sep 17 00:00:00 2001 From: Michel Dänzer Date: Thu, 10 Jan 2008 17:44:04 +0100 Subject: Remove mapping fields from struct pipe_surface. It's now the responsibility of surface users to keep track of their mappings. --- src/mesa/state_tracker/st_cb_accum.c | 137 ++++-------------------------- src/mesa/state_tracker/st_cb_drawpixels.c | 6 -- src/mesa/state_tracker/st_cb_fbo.c | 3 - src/mesa/state_tracker/st_cb_readpixels.c | 4 - src/mesa/state_tracker/st_cb_texture.c | 13 +-- 5 files changed, 19 insertions(+), 144 deletions(-) (limited to 'src/mesa/state_tracker') diff --git a/src/mesa/state_tracker/st_cb_accum.c b/src/mesa/state_tracker/st_cb_accum.c index cf2e9db51cb..73cd7db18dd 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); } diff --git a/src/mesa/state_tracker/st_cb_drawpixels.c b/src/mesa/state_tracker/st_cb_drawpixels.c index 2db12c653b6..5ea2f08b8a3 100644 --- a/src/mesa/state_tracker/st_cb_drawpixels.c +++ b/src/mesa/state_tracker/st_cb_drawpixels.c @@ -1261,15 +1261,9 @@ st_CopyPixels(GLcontext *ctx, GLint srcx, GLint srcy, /* alternate path using get/put_tile() */ GLfloat *buf = (GLfloat *) malloc(width * height * 4 * sizeof(GLfloat)); - (void) pipe_surface_map(psRead); - (void) pipe_surface_map(psTex); - pipe->get_tile_rgba(pipe, psRead, srcx, srcy, width, height, buf); pipe->put_tile_rgba(pipe, psTex, 0, 0, width, height, buf); - pipe_surface_unmap(psRead); - pipe_surface_unmap(psTex); - free(buf); } diff --git a/src/mesa/state_tracker/st_cb_fbo.c b/src/mesa/state_tracker/st_cb_fbo.c index bc0f26ffb05..2d6b3fc749b 100644 --- a/src/mesa/state_tracker/st_cb_fbo.c +++ b/src/mesa/state_tracker/st_cb_fbo.c @@ -97,9 +97,6 @@ st_renderbuffer_alloc_storage(GLcontext * ctx, struct gl_renderbuffer *rb, return GL_FALSE; } - /* loop here since mapping is refcounted */ - while (strb->surface->map) - pipe_surface_unmap(strb->surface); if (strb->surface->buffer) pipe->winsys->buffer_reference(pipe->winsys, &strb->surface->buffer, NULL); diff --git a/src/mesa/state_tracker/st_cb_readpixels.c b/src/mesa/state_tracker/st_cb_readpixels.c index b0c9275c6f8..585fe04dee8 100644 --- a/src/mesa/state_tracker/st_cb_readpixels.c +++ b/src/mesa/state_tracker/st_cb_readpixels.c @@ -179,8 +179,6 @@ st_readpixels(GLcontext *ctx, GLint x, GLint y, GLsizei width, GLsizei height, if (!strb) return; - pipe_surface_map(strb->surface); - if (format == GL_RGBA && type == GL_FLOAT) { /* write tile(row) directly into user's buffer */ df = (GLfloat *) _mesa_image_address2d(&clippedPacking, dest, width, @@ -229,8 +227,6 @@ st_readpixels(GLcontext *ctx, GLint x, GLint y, GLsizei width, GLsizei height, } } } - - pipe_surface_unmap(strb->surface); } diff --git a/src/mesa/state_tracker/st_cb_texture.c b/src/mesa/state_tracker/st_cb_texture.c index 773fc0012e2..19274570a1c 100644 --- a/src/mesa/state_tracker/st_cb_texture.c +++ b/src/mesa/state_tracker/st_cb_texture.c @@ -1063,15 +1063,13 @@ fallback_copy_texsubimage(GLcontext *ctx, dest_surf = pipe->get_tex_surface(pipe, pt, face, level, destZ); - (void) pipe_surface_map(dest_surf); - (void) pipe_surface_map(src_surf); - /* buffer for one row */ data = (GLfloat *) malloc(width * 4 * sizeof(GLfloat)); /* do copy row by row */ for (row = 0; row < height; row++) { - pipe->get_tile_rgba(pipe, src_surf, srcX, srcY + row, width, 1, data); + pipe->get_tile_rgba(pipe, src_surf, srcX, srcY + row, width, 1, + data); /* XXX we're ignoring convolution for now */ if (ctx->_ImageTransferState) { @@ -1080,14 +1078,11 @@ fallback_copy_texsubimage(GLcontext *ctx, width, (GLfloat (*)[4])data); } - pipe->put_tile_rgba(pipe, dest_surf, destX, destY, width, 1, data); + pipe->put_tile_rgba(pipe, dest_surf, destX, destY, width, 1, + data); destY += yStep; } - - (void) pipe_surface_unmap(dest_surf); - (void) pipe_surface_unmap(src_surf); - free(data); } -- cgit v1.2.3