diff options
Diffstat (limited to 'src/mesa/state_tracker')
-rw-r--r-- | src/mesa/state_tracker/st_atom_pixeltransfer.c | 13 | ||||
-rw-r--r-- | src/mesa/state_tracker/st_cb_accum.c | 154 | ||||
-rw-r--r-- | src/mesa/state_tracker/st_cb_bitmap.c | 52 | ||||
-rw-r--r-- | src/mesa/state_tracker/st_cb_drawpixels.c | 106 | ||||
-rw-r--r-- | src/mesa/state_tracker/st_cb_fbo.c | 4 | ||||
-rw-r--r-- | src/mesa/state_tracker/st_cb_readpixels.c | 104 | ||||
-rw-r--r-- | src/mesa/state_tracker/st_cb_texture.c | 109 | ||||
-rw-r--r-- | src/mesa/state_tracker/st_gen_mipmap.c | 34 | ||||
-rw-r--r-- | src/mesa/state_tracker/st_texture.c | 36 | ||||
-rw-r--r-- | src/mesa/state_tracker/st_texture.h | 6 |
10 files changed, 331 insertions, 287 deletions
diff --git a/src/mesa/state_tracker/st_atom_pixeltransfer.c b/src/mesa/state_tracker/st_atom_pixeltransfer.c index a357b716771..ce872458e39 100644 --- a/src/mesa/state_tracker/st_atom_pixeltransfer.c +++ b/src/mesa/state_tracker/st_atom_pixeltransfer.c @@ -140,7 +140,7 @@ load_color_map_texture(GLcontext *ctx, struct pipe_texture *pt) { struct pipe_context *pipe = ctx->st->pipe; struct pipe_screen *screen = pipe->screen; - struct pipe_surface *surface; + struct pipe_transfer *transfer; const GLuint rSize = ctx->PixelMaps.RtoR.Size; const GLuint gSize = ctx->PixelMaps.GtoG.Size; const GLuint bSize = ctx->PixelMaps.BtoB.Size; @@ -149,10 +149,9 @@ load_color_map_texture(GLcontext *ctx, struct pipe_texture *pt) uint *dest; uint i, j; - surface = screen->get_tex_surface(screen, pt, 0, 0, 0, - PIPE_BUFFER_USAGE_CPU_WRITE); - dest = (uint *) screen->surface_map(screen, surface, - PIPE_BUFFER_USAGE_CPU_WRITE); + transfer = screen->get_tex_transfer(screen, pt, 0, 0, 0, PIPE_TRANSFER_WRITE, + 0, 0, texSize, texSize); + dest = (uint *) screen->transfer_map(screen, transfer); /* Pack four 1D maps into a 2D texture: * R map is placed horizontally, indexed by S, in channel 0 @@ -171,8 +170,8 @@ load_color_map_texture(GLcontext *ctx, struct pipe_texture *pt) } } - screen->surface_unmap(screen, surface); - pipe_surface_reference(&surface, NULL); + screen->transfer_unmap(screen, transfer); + screen->tex_transfer_release(screen, &transfer); } diff --git a/src/mesa/state_tracker/st_cb_accum.c b/src/mesa/state_tracker/st_cb_accum.c index 2fc37343bdf..33c648856a2 100644 --- a/src/mesa/state_tracker/st_cb_accum.c +++ b/src/mesa/state_tracker/st_cb_accum.c @@ -63,21 +63,21 @@ * See also: st_renderbuffer_alloc_storage() */ static void -acc_get_tile_rgba(struct pipe_context *pipe, struct pipe_surface *acc_ps, +acc_get_tile_rgba(struct pipe_context *pipe, struct pipe_transfer *acc_pt, uint x, uint y, uint w, uint h, float *p) { - const enum pipe_format f = acc_ps->format; - const struct pipe_format_block b = acc_ps->block; + const enum pipe_format f = acc_pt->format; + const struct pipe_format_block b = acc_pt->block; - acc_ps->format = DEFAULT_ACCUM_PIPE_FORMAT; - acc_ps->block.size = 8; - acc_ps->block.width = 1; - acc_ps->block.height = 1; + acc_pt->format = DEFAULT_ACCUM_PIPE_FORMAT; + acc_pt->block.size = 8; + acc_pt->block.width = 1; + acc_pt->block.height = 1; - pipe_get_tile_rgba(acc_ps, x, y, w, h, p); + pipe_get_tile_rgba(acc_pt, x, y, w, h, p); - acc_ps->format = f; - acc_ps->block = b; + acc_pt->format = f; + acc_pt->block = b; } @@ -87,21 +87,21 @@ acc_get_tile_rgba(struct pipe_context *pipe, struct pipe_surface *acc_ps, * See also: st_renderbuffer_alloc_storage() */ static void -acc_put_tile_rgba(struct pipe_context *pipe, struct pipe_surface *acc_ps, +acc_put_tile_rgba(struct pipe_context *pipe, struct pipe_transfer *acc_pt, uint x, uint y, uint w, uint h, const float *p) { - enum pipe_format f = acc_ps->format; - const struct pipe_format_block b = acc_ps->block; + enum pipe_format f = acc_pt->format; + const struct pipe_format_block b = acc_pt->block; - acc_ps->format = DEFAULT_ACCUM_PIPE_FORMAT; - acc_ps->block.size = 8; - acc_ps->block.width = 1; - acc_ps->block.height = 1; + acc_pt->format = DEFAULT_ACCUM_PIPE_FORMAT; + acc_pt->block.size = 8; + acc_pt->block.width = 1; + acc_pt->block.height = 1; - pipe_put_tile_rgba(acc_ps, x, y, w, h, p); + pipe_put_tile_rgba(acc_pt, x, y, w, h, p); - acc_ps->format = f; - acc_ps->block = b; + acc_pt->format = f; + acc_pt->block = b; } @@ -110,7 +110,7 @@ void st_clear_accum_buffer(GLcontext *ctx, struct gl_renderbuffer *rb) { struct st_renderbuffer *acc_strb = st_renderbuffer(rb); - struct pipe_surface *acc_ps; + struct pipe_transfer *acc_pt; struct pipe_screen *screen = ctx->st->pipe->screen; const GLint xpos = ctx->DrawBuffer->_Xmin; const GLint ypos = ctx->DrawBuffer->_Ymin; @@ -118,12 +118,12 @@ st_clear_accum_buffer(GLcontext *ctx, struct gl_renderbuffer *rb) const GLint height = ctx->DrawBuffer->_Ymax - ypos; GLubyte *map; - acc_ps = screen->get_tex_surface(screen, acc_strb->texture, 0, 0, 0, - PIPE_BUFFER_USAGE_CPU_WRITE); - map = screen->surface_map(screen, acc_ps, - PIPE_BUFFER_USAGE_CPU_WRITE); + acc_pt = screen->get_tex_transfer(screen, acc_strb->texture, 0, 0, 0, + PIPE_TRANSFER_WRITE, xpos, ypos, + width, height); + map = screen->transfer_map(screen, acc_pt); - /* note acc_strb->format might not equal acc_ps->format */ + /* note acc_strb->format might not equal acc_pt->format */ switch (acc_strb->format) { case PIPE_FORMAT_R16G16B16A16_SNORM: { @@ -133,7 +133,7 @@ st_clear_accum_buffer(GLcontext *ctx, struct gl_renderbuffer *rb) GLshort a = FLOAT_TO_SHORT(ctx->Accum.ClearColor[3]); int i, j; for (i = 0; i < height; i++) { - GLshort *dst = (GLshort *) (map + (ypos + i) * acc_ps->stride + xpos * 8); + GLshort *dst = (GLshort *) (map + i * acc_pt->stride + xpos * 8); for (j = 0; j < width; j++) { dst[0] = r; dst[1] = g; @@ -148,8 +148,8 @@ st_clear_accum_buffer(GLcontext *ctx, struct gl_renderbuffer *rb) _mesa_problem(ctx, "unexpected format in st_clear_accum_buffer()"); } - screen->surface_unmap(screen, acc_ps); - pipe_surface_reference(&acc_ps, NULL); + screen->transfer_unmap(screen, acc_pt); + screen->tex_transfer_release(screen, &acc_pt); } @@ -160,19 +160,21 @@ accum_mad(GLcontext *ctx, GLfloat scale, GLfloat bias, struct st_renderbuffer *acc_strb) { struct pipe_screen *screen = ctx->st->pipe->screen; - struct pipe_surface *acc_ps = acc_strb->surface; + struct pipe_transfer *acc_pt; GLubyte *map; - map = screen->surface_map(screen, acc_ps, - PIPE_BUFFER_USAGE_CPU_WRITE); + acc_pt = screen->get_tex_transfer(screen, acc_strb->texture, 0, 0, 0, + PIPE_TRANSFER_READ_WRITE, xpos, ypos, + width, height); + map = screen->transfer_map(screen, acc_pt); - /* note acc_strb->format might not equal acc_ps->format */ + /* note acc_strb->format might not equal acc_pt->format */ switch (acc_strb->format) { case PIPE_FORMAT_R16G16B16A16_SNORM: { int i, j; for (i = 0; i < height; i++) { - GLshort *acc = (GLshort *) (map + (ypos + i) * acc_ps->stride + xpos * 8); + GLshort *acc = (GLshort *) (map + (ypos + i) * acc_pt->stride + xpos * 8); for (j = 0; j < width * 4; j++) { float val = SHORT_TO_FLOAT(acc[j]) * scale + bias; acc[j] = FLOAT_TO_SHORT(val); @@ -184,7 +186,8 @@ accum_mad(GLcontext *ctx, GLfloat scale, GLfloat bias, _mesa_problem(NULL, "unexpected format in st_clear_accum_buffer()"); } - screen->surface_unmap(screen, acc_ps); + screen->transfer_unmap(screen, acc_pt); + screen->tex_transfer_release(screen, &acc_pt); } @@ -195,33 +198,46 @@ accum_accum(struct pipe_context *pipe, GLfloat value, struct st_renderbuffer *color_strb) { struct pipe_screen *screen = pipe->screen; - struct pipe_surface *acc_surf, *color_surf; + struct pipe_transfer *acc_trans, *color_trans; GLfloat *colorBuf, *accBuf; GLint i; - acc_surf = screen->get_tex_surface(screen, acc_strb->texture, 0, 0, 0, - (PIPE_BUFFER_USAGE_CPU_WRITE | - PIPE_BUFFER_USAGE_CPU_READ)); + acc_trans = screen->get_tex_transfer(screen, acc_strb->texture, 0, 0, 0, + PIPE_TRANSFER_READ, xpos, ypos, + width, height); - color_surf = screen->get_tex_surface(screen, color_strb->texture, 0, 0, 0, - PIPE_BUFFER_USAGE_CPU_READ); + color_trans = screen->get_tex_transfer(screen, color_strb->texture, 0, 0, 0, + PIPE_TRANSFER_READ, xpos, ypos, + width, height); colorBuf = (GLfloat *) _mesa_malloc(width * height * 4 * sizeof(GLfloat)); accBuf = (GLfloat *) _mesa_malloc(width * height * 4 * sizeof(GLfloat)); - pipe_get_tile_rgba(color_surf, xpos, ypos, width, height, colorBuf); - acc_get_tile_rgba(pipe, acc_surf, xpos, ypos, width, height, accBuf); + pipe_get_tile_rgba(color_trans, 0, 0, width, height, colorBuf); + acc_get_tile_rgba(pipe, acc_trans, 0, 0, width, height, accBuf); for (i = 0; i < 4 * width * height; i++) { accBuf[i] = accBuf[i] + colorBuf[i] * value; } - acc_put_tile_rgba(pipe, acc_surf, xpos, ypos, width, height, accBuf); + screen->tex_transfer_release(screen, &acc_trans); + acc_trans = screen->get_tex_transfer(screen, acc_strb->texture, 0, 0, 0, + PIPE_TRANSFER_WRITE, xpos, ypos, + width, height); + acc_put_tile_rgba(pipe, acc_trans, 0, 0, width, height, accBuf); + +<<<<<<< HEAD:src/mesa/state_tracker/st_cb_accum.c + free(colorBuf); + free(accBuf); + screen->tex_transfer_release(screen, &acc_trans); + screen->tex_transfer_release(screen, &color_trans); +======= _mesa_free(colorBuf); _mesa_free(accBuf); pipe_surface_reference(&acc_surf, NULL); pipe_surface_reference(&color_surf, NULL); +>>>>>>> master:src/mesa/state_tracker/st_cb_accum.c } @@ -232,29 +248,37 @@ accum_load(struct pipe_context *pipe, GLfloat value, struct st_renderbuffer *color_strb) { struct pipe_screen *screen = pipe->screen; - struct pipe_surface *acc_surf, *color_surf; + struct pipe_transfer *acc_trans, *color_trans; GLfloat *buf; GLint i; - acc_surf = screen->get_tex_surface(screen, acc_strb->texture, 0, 0, 0, - PIPE_BUFFER_USAGE_CPU_WRITE); + acc_trans = screen->get_tex_transfer(screen, acc_strb->texture, 0, 0, 0, + PIPE_TRANSFER_WRITE, xpos, ypos, + width, height); - color_surf = screen->get_tex_surface(screen, color_strb->texture, 0, 0, 0, - PIPE_BUFFER_USAGE_CPU_READ); + color_trans = screen->get_tex_transfer(screen, color_strb->texture, 0, 0, 0, + PIPE_TRANSFER_READ, xpos, ypos, + width, height); buf = (GLfloat *) _mesa_malloc(width * height * 4 * sizeof(GLfloat)); - pipe_get_tile_rgba(color_surf, xpos, ypos, width, height, buf); + pipe_get_tile_rgba(color_trans, 0, 0, width, height, buf); for (i = 0; i < 4 * width * height; i++) { buf[i] = buf[i] * value; } - acc_put_tile_rgba(pipe, acc_surf, xpos, ypos, width, height, buf); + acc_put_tile_rgba(pipe, acc_trans, 0, 0, width, height, buf); +<<<<<<< HEAD:src/mesa/state_tracker/st_cb_accum.c + free(buf); + screen->tex_transfer_release(screen, &acc_trans); + screen->tex_transfer_release(screen, &color_trans); +======= _mesa_free(buf); pipe_surface_reference(&acc_surf, NULL); pipe_surface_reference(&color_surf, NULL); +>>>>>>> master:src/mesa/state_tracker/st_cb_accum.c } @@ -267,24 +291,30 @@ accum_return(GLcontext *ctx, GLfloat value, struct pipe_context *pipe = ctx->st->pipe; struct pipe_screen *screen = pipe->screen; const GLubyte *colormask = ctx->Color.ColorMask; - struct pipe_surface *acc_surf, *color_surf; + struct pipe_transfer *acc_trans, *color_trans; GLfloat *abuf, *cbuf = NULL; GLint i, ch; abuf = (GLfloat *) _mesa_malloc(width * height * 4 * sizeof(GLfloat)); - acc_surf = screen->get_tex_surface(screen, acc_strb->texture, 0, 0, 0, - PIPE_BUFFER_USAGE_CPU_READ); + acc_trans = screen->get_tex_transfer(screen, acc_strb->texture, 0, 0, 0, + PIPE_TRANSFER_READ, xpos, ypos, + width, height); - color_surf = screen->get_tex_surface(screen, color_strb->texture, 0, 0, 0, - (PIPE_BUFFER_USAGE_CPU_READ | - PIPE_BUFFER_USAGE_CPU_WRITE)); + color_trans = screen->get_tex_transfer(screen, color_strb->texture, 0, 0, 0, + PIPE_TRANSFER_READ_WRITE, xpos, ypos, + width, height); - acc_get_tile_rgba(pipe, acc_surf, xpos, ypos, width, height, abuf); + acc_get_tile_rgba(pipe, acc_trans, 0, 0, width, height, abuf); if (!colormask[0] || !colormask[1] || !colormask[2] || !colormask[3]) { +<<<<<<< HEAD:src/mesa/state_tracker/st_cb_accum.c + cbuf = (GLfloat *) malloc(width * height * 4 * sizeof(GLfloat)); + pipe_get_tile_rgba(color_trans, 0, 0, width, height, cbuf); +======= cbuf = (GLfloat *) _mesa_malloc(width * height * 4 * sizeof(GLfloat)); pipe_get_tile_rgba(color_surf, xpos, ypos, width, height, cbuf); +>>>>>>> master:src/mesa/state_tracker/st_cb_accum.c } for (i = 0; i < width * height; i++) { @@ -299,13 +329,19 @@ accum_return(GLcontext *ctx, GLfloat value, } } - pipe_put_tile_rgba(color_surf, xpos, ypos, width, height, abuf); + pipe_put_tile_rgba(color_trans, 0, 0, width, height, abuf); _mesa_free(abuf); if (cbuf) +<<<<<<< HEAD:src/mesa/state_tracker/st_cb_accum.c + free(cbuf); + screen->tex_transfer_release(screen, &acc_trans); + screen->tex_transfer_release(screen, &color_trans); +======= _mesa_free(cbuf); pipe_surface_reference(&acc_surf, NULL); pipe_surface_reference(&color_surf, NULL); +>>>>>>> master:src/mesa/state_tracker/st_cb_accum.c } diff --git a/src/mesa/state_tracker/st_cb_bitmap.c b/src/mesa/state_tracker/st_cb_bitmap.c index da0ea645580..77aac8507e1 100644 --- a/src/mesa/state_tracker/st_cb_bitmap.c +++ b/src/mesa/state_tracker/st_cb_bitmap.c @@ -93,7 +93,7 @@ struct bitmap_cache GLfloat color[4]; struct pipe_texture *texture; - struct pipe_surface *surf; + struct pipe_transfer *trans; GLboolean empty; @@ -308,7 +308,7 @@ make_bitmap_texture(GLcontext *ctx, GLsizei width, GLsizei height, { struct pipe_context *pipe = ctx->st->pipe; struct pipe_screen *screen = pipe->screen; - struct pipe_surface *surface; + struct pipe_transfer *transfer; ubyte *dest; struct pipe_texture *pt; @@ -329,22 +329,21 @@ make_bitmap_texture(GLcontext *ctx, GLsizei width, GLsizei height, return NULL; } - surface = screen->get_tex_surface(screen, pt, 0, 0, 0, - PIPE_BUFFER_USAGE_CPU_WRITE); + transfer = screen->get_tex_transfer(screen, pt, 0, 0, 0, PIPE_TRANSFER_WRITE, + 0, 0, width, height); - /* map texture surface */ - dest = screen->surface_map(screen, surface, PIPE_BUFFER_USAGE_CPU_WRITE); + dest = screen->transfer_map(screen, transfer); - /* Put image into texture surface */ - memset(dest, 0xff, height * surface->stride); + /* Put image into texture transfer */ + memset(dest, 0xff, height * transfer->stride); unpack_bitmap(ctx->st, 0, 0, width, height, unpack, bitmap, - dest, surface->stride); + dest, transfer->stride); _mesa_unmap_bitmap_pbo(ctx, unpack); - /* Release surface */ - screen->surface_unmap(screen, surface); - pipe_surface_reference(&surface, NULL); + /* Release transfer */ + screen->transfer_unmap(screen, transfer); + screen->tex_transfer_release(screen, &transfer); return pt; } @@ -569,8 +568,8 @@ reset_cache(struct st_context *st) cache->ymin = 1000000; cache->ymax = -1000000; - if (cache->surf) - screen->tex_surface_release(screen, &cache->surf); + if (cache->trans) + screen->tex_transfer_release(screen, &cache->trans); assert(!cache->texture); @@ -581,16 +580,17 @@ reset_cache(struct st_context *st) 1, 0, PIPE_TEXTURE_USAGE_SAMPLER); - /* Map the texture surface. + /* Map the texture transfer. * Subsequent glBitmap calls will write into the texture image. */ - cache->surf = screen->get_tex_surface(screen, cache->texture, 0, 0, 0, - PIPE_BUFFER_USAGE_CPU_WRITE); - cache->buffer = screen->surface_map(screen, cache->surf, - PIPE_BUFFER_USAGE_CPU_WRITE); + cache->trans = screen->get_tex_transfer(screen, cache->texture, 0, 0, 0, + PIPE_TRANSFER_WRITE, 0, 0, + BITMAP_CACHE_WIDTH, + BITMAP_CACHE_HEIGHT); + cache->buffer = screen->transfer_map(screen, cache->trans); /* init image to all 0xff */ - memset(cache->buffer, 0xff, BITMAP_CACHE_WIDTH * BITMAP_CACHE_HEIGHT); + memset(cache->buffer, 0xff, cache->trans->stride * BITMAP_CACHE_HEIGHT); } @@ -615,13 +615,13 @@ st_flush_bitmap_cache(struct st_context *st) cache->xpos, cache->ypos); */ - /* The texture surface has been mapped until now. - * So unmap and release the texture surface before drawing. + /* The texture transfer has been mapped until now. + * So unmap and release the texture transfer before drawing. */ - screen->surface_unmap(screen, cache->surf); + screen->transfer_unmap(screen, cache->trans); cache->buffer = NULL; - screen->tex_surface_release(screen, &cache->surf); + screen->tex_transfer_release(screen, &cache->trans); draw_bitmap_quad(st->ctx, cache->xpos, @@ -812,8 +812,8 @@ st_destroy_bitmap(struct st_context *st) struct pipe_screen *screen = pipe->screen; struct bitmap_cache *cache = st->bitmap.cache; - screen->surface_unmap(screen, cache->surf); - screen->tex_surface_release(screen, &cache->surf); + screen->transfer_unmap(screen, cache->trans); + screen->tex_transfer_release(screen, &cache->trans); if (st->bitmap.vs) { cso_delete_vertex_shader(st->cso_context, st->bitmap.vs); diff --git a/src/mesa/state_tracker/st_cb_drawpixels.c b/src/mesa/state_tracker/st_cb_drawpixels.c index cb4a01c22b6..13307fc2c12 100644 --- a/src/mesa/state_tracker/st_cb_drawpixels.c +++ b/src/mesa/state_tracker/st_cb_drawpixels.c @@ -358,7 +358,7 @@ make_texture(struct st_context *st, } { - struct pipe_surface *surface; + struct pipe_transfer *transfer; static const GLuint dstImageOffsets = 0; GLboolean success; GLubyte *dest; @@ -367,14 +367,14 @@ make_texture(struct st_context *st, /* we'll do pixel transfer in a fragment shader */ ctx->_ImageTransferState = 0x0; - surface = screen->get_tex_surface(screen, pt, 0, 0, 0, - PIPE_BUFFER_USAGE_CPU_WRITE); + transfer = screen->get_tex_transfer(screen, pt, 0, 0, 0, + PIPE_TRANSFER_WRITE, 0, 0, + width, height); - /* map texture surface */ - dest = screen->surface_map(screen, surface, - PIPE_BUFFER_USAGE_CPU_WRITE); + /* map texture transfer */ + dest = screen->transfer_map(screen, transfer); - /* Put image into texture surface. + /* Put image into texture transfer. * Note that the image is actually going to be upside down in * the texture. We deal with that with texcoords. */ @@ -383,7 +383,7 @@ make_texture(struct st_context *st, mformat, /* gl_texture_format */ dest, /* dest */ 0, 0, 0, /* dstX/Y/Zoffset */ - surface->stride, /* dstRowStride, bytes */ + transfer->stride, /* dstRowStride, bytes */ &dstImageOffsets, /* dstImageOffsets */ width, height, 1, /* size */ format, type, /* src format/type */ @@ -391,8 +391,8 @@ make_texture(struct st_context *st, unpack); /* unmap */ - screen->surface_unmap(screen, surface); - pipe_surface_reference(&surface, NULL); + screen->transfer_unmap(screen, transfer); + screen->tex_transfer_release(screen, &transfer); assert(success); @@ -740,7 +740,7 @@ draw_stencil_pixels(GLcontext *ctx, GLint x, GLint y, struct pipe_context *pipe = st->pipe; struct pipe_screen *screen = pipe->screen; struct st_renderbuffer *strb; - struct pipe_surface *ps; + struct pipe_transfer *pt; const GLboolean zoom = ctx->Pixel.ZoomX != 1.0 || ctx->Pixel.ZoomY != 1.0; GLint skipPixels; ubyte *stmap; @@ -749,21 +749,20 @@ draw_stencil_pixels(GLcontext *ctx, GLint x, GLint y, strb = st_renderbuffer(ctx->DrawBuffer-> Attachment[BUFFER_STENCIL].Renderbuffer); - ps = screen->get_tex_surface(screen, strb->texture, 0, 0, 0, - PIPE_BUFFER_USAGE_CPU_WRITE); + pt = screen->get_tex_transfer(screen, strb->texture, 0, 0, 0, + PIPE_TRANSFER_WRITE, x, y, + width, height); - /* map the stencil buffer */ - stmap = screen->surface_map(screen, ps, - PIPE_BUFFER_USAGE_CPU_WRITE); + stmap = screen->transfer_map(screen, pt); /* if width > MAX_WIDTH, have to process image in chunks */ skipPixels = 0; while (skipPixels < width) { - const GLint spanX = x + skipPixels; + const GLint spanX = skipPixels; const GLint spanWidth = MIN2(width - skipPixels, MAX_WIDTH); GLint row; for (row = 0; row < height; row++) { - GLint spanY = y + row; + GLint spanY = row; GLubyte values[MAX_WIDTH]; GLenum destType = GL_UNSIGNED_BYTE; const GLvoid *source = _mesa_image_address2d(unpack, pixels, @@ -775,25 +774,25 @@ draw_stencil_pixels(GLcontext *ctx, GLint x, GLint y, ctx->_ImageTransferState); if (zoom) { /* - _swrast_write_zoomed_stencil_span(ctx, x, y, spanWidth, + _swrast_write_zoomed_stencil_span(ctx, 0, 0, spanWidth, spanX, spanY, values); */ } else { if (st_fb_orientation(ctx->DrawBuffer) == Y_0_TOP) { - spanY = ctx->DrawBuffer->Height - spanY - 1; + spanY = height - spanY - 1; } - switch (ps->format) { + switch (pt->format) { case PIPE_FORMAT_S8_UNORM: { - ubyte *dest = stmap + spanY * ps->stride + spanX; + ubyte *dest = stmap + spanY * pt->stride + spanX; memcpy(dest, values, spanWidth); } break; case PIPE_FORMAT_S8Z24_UNORM: { - uint *dest = (uint *) (stmap + spanY * ps->stride + spanX*4); + uint *dest = (uint *) (stmap + spanY * pt->stride + spanX*4); GLint k; for (k = 0; k < spanWidth; k++) { uint p = dest[k]; @@ -811,8 +810,8 @@ draw_stencil_pixels(GLcontext *ctx, GLint x, GLint y, } /* unmap the stencil buffer */ - screen->surface_unmap(screen, ps); - pipe_surface_reference(&ps, NULL); + screen->transfer_unmap(screen, pt); + screen->tex_transfer_release(screen, &pt); } @@ -891,7 +890,7 @@ copy_stencil_pixels(GLcontext *ctx, GLint srcx, GLint srcy, { struct st_renderbuffer *rbDraw = st_renderbuffer(ctx->DrawBuffer->_StencilBuffer); struct pipe_screen *screen = ctx->st->pipe->screen; - struct pipe_surface *psDraw; + struct pipe_transfer *ptDraw; ubyte *drawMap; ubyte *buffer; int i; @@ -906,14 +905,15 @@ copy_stencil_pixels(GLcontext *ctx, GLint srcx, GLint srcy, st_read_stencil_pixels(ctx, srcx, srcy, width, height, GL_UNSIGNED_BYTE, &ctx->DefaultPacking, buffer); - psDraw = screen->get_tex_surface(screen, rbDraw->texture, 0, 0, 0, - PIPE_BUFFER_USAGE_CPU_WRITE); + ptDraw = screen->get_tex_transfer(screen, rbDraw->texture, 0, 0, 0, + PIPE_TRANSFER_WRITE, dstx, dsty, + width, height); - assert(psDraw->block.width == 1); - assert(psDraw->block.height == 1); + assert(ptDraw->block.width == 1); + assert(ptDraw->block.height == 1); /* map the stencil buffer */ - drawMap = screen->surface_map(screen, psDraw, PIPE_BUFFER_USAGE_CPU_WRITE); + drawMap = screen->transfer_map(screen, ptDraw); /* draw */ /* XXX PixelZoom not handled yet */ @@ -922,16 +922,16 @@ copy_stencil_pixels(GLcontext *ctx, GLint srcx, GLint srcy, const ubyte *src; int y; - y = dsty + i; + y = i; if (st_fb_orientation(ctx->DrawBuffer) == Y_0_TOP) { - y = ctx->DrawBuffer->Height - y - 1; + y = height - y - 1; } - dst = drawMap + y * psDraw->stride + dstx * psDraw->block.size; + dst = drawMap + y * ptDraw->stride; src = buffer + i * width; - switch (psDraw->format) { + switch (ptDraw->format) { case PIPE_FORMAT_S8Z24_UNORM: { uint *dst4 = (uint *) dst; @@ -953,8 +953,8 @@ copy_stencil_pixels(GLcontext *ctx, GLint srcx, GLint srcy, _mesa_free(buffer); /* unmap the stencil buffer */ - screen->surface_unmap(screen, psDraw); - pipe_surface_reference(&psDraw, NULL); + screen->transfer_unmap(screen, ptDraw); + screen->tex_transfer_release(screen, &ptDraw); } @@ -969,7 +969,6 @@ st_CopyPixels(GLcontext *ctx, GLint srcx, GLint srcy, struct st_renderbuffer *rbRead; struct st_vertex_program *stvp; struct st_fragment_program *stfp; - struct pipe_surface *psTex; struct pipe_texture *pt; GLfloat *color; enum pipe_format srcFormat, texFormat; @@ -1035,7 +1034,7 @@ st_CopyPixels(GLcontext *ctx, GLint srcx, GLint srcy, struct pipe_surface *psRead = screen->get_tex_surface(screen, rbRead->texture, 0, 0, 0, PIPE_BUFFER_USAGE_GPU_READ); - psTex = screen->get_tex_surface(screen, pt, 0, 0, 0, + struct pipe_surface *psTex = screen->get_tex_surface(screen, pt, 0, 0, 0, PIPE_BUFFER_USAGE_GPU_WRITE ); pipe->surface_copy(pipe, FALSE, @@ -1043,37 +1042,40 @@ st_CopyPixels(GLcontext *ctx, GLint srcx, GLint srcy, 0, 0, /* destx/y */ psRead, srcx, srcy, width, height); - pipe_surface_reference(&psRead, NULL); + pipe_surface_reference(&psRead, NULL); + pipe_surface_reference(&psTex, NULL); } else { /* CPU-based fallback/conversion */ - struct pipe_surface *psRead = screen->get_tex_surface(screen, - rbRead->texture, 0, 0, 0, - PIPE_BUFFER_USAGE_CPU_READ); + struct pipe_transfer *ptRead = + screen->get_tex_transfer(screen, rbRead->texture, 0, 0, 0, + PIPE_TRANSFER_READ, srcx, srcy, width, + height); - psTex = screen->get_tex_surface(screen, pt, 0, 0, 0, - PIPE_BUFFER_USAGE_CPU_WRITE ); + struct pipe_transfer *ptTex = + screen->get_tex_transfer(screen, pt, 0, 0, 0, PIPE_TRANSFER_WRITE, + 0, 0, width, height); if (type == GL_COLOR) { /* alternate path using get/put_tile() */ GLfloat *buf = (GLfloat *) _mesa_malloc(width * height * 4 * sizeof(GLfloat)); - pipe_get_tile_rgba(psRead, srcx, srcy, width, height, buf); - pipe_put_tile_rgba(psTex, 0, 0, width, height, buf); + pipe_get_tile_rgba(ptRead, 0, 0, width, height, buf); + pipe_put_tile_rgba(ptTex, 0, 0, width, height, buf); _mesa_free(buf); } else { /* GL_DEPTH */ GLuint *buf = (GLuint *) _mesa_malloc(width * height * sizeof(GLuint)); - pipe_get_tile_z(psRead, srcx, srcy, width, height, buf); - pipe_put_tile_z(psTex, 0, 0, width, height, buf); + pipe_get_tile_z(ptRead, 0, 0, width, height, buf); + pipe_put_tile_z(ptTex, 0, 0, width, height, buf); _mesa_free(buf); } - pipe_surface_reference(&psRead, NULL); - } - pipe_surface_reference(&psTex, NULL); + screen->tex_transfer_release(screen, &ptRead); + screen->tex_transfer_release(screen, &ptTex); + } /* draw textured quad */ draw_textured_quad(ctx, dstx, dsty, ctx->Current.RasterPos[2], diff --git a/src/mesa/state_tracker/st_cb_fbo.c b/src/mesa/state_tracker/st_cb_fbo.c index 611d78df0c4..5cc6960c064 100644 --- a/src/mesa/state_tracker/st_cb_fbo.c +++ b/src/mesa/state_tracker/st_cb_fbo.c @@ -172,12 +172,8 @@ st_renderbuffer_alloc_storage(GLcontext * ctx, struct gl_renderbuffer *rb, assert(strb->surface->texture); assert(strb->surface->format); - assert(strb->surface->block.size); - assert(strb->surface->block.width); - assert(strb->surface->block.height); assert(strb->surface->width == width); assert(strb->surface->height == height); - assert(strb->surface->stride); return strb->surface != NULL; diff --git a/src/mesa/state_tracker/st_cb_readpixels.c b/src/mesa/state_tracker/st_cb_readpixels.c index 646eaff1903..5a4a7f0a616 100644 --- a/src/mesa/state_tracker/st_cb_readpixels.c +++ b/src/mesa/state_tracker/st_cb_readpixels.c @@ -63,44 +63,48 @@ st_read_stencil_pixels(GLcontext *ctx, GLint x, GLint y, struct gl_framebuffer *fb = ctx->ReadBuffer; struct pipe_screen *screen = ctx->st->pipe->screen; struct st_renderbuffer *strb = st_renderbuffer(fb->_StencilBuffer); - struct pipe_surface *ps; + struct pipe_transfer *pt; ubyte *stmap; GLint j; - /* Create a CPU-READ surface/view into the renderbuffer's texture */ - ps = screen->get_tex_surface(screen, strb->texture, 0, 0, 0, - PIPE_BUFFER_USAGE_CPU_READ); + if (st_fb_orientation(ctx->DrawBuffer) == Y_0_TOP) { + y = ctx->DrawBuffer->Height - y - 1; + } + + /* Create a read transfer from the renderbuffer's texture */ + pt = screen->get_tex_transfer(screen, strb->texture, 0, 0, 0, + PIPE_TRANSFER_READ, x, y, width, height); /* map the stencil buffer */ - stmap = screen->surface_map(screen, ps, PIPE_BUFFER_USAGE_CPU_READ); + stmap = screen->transfer_map(screen, pt); /* width should never be > MAX_WIDTH since we did clipping earlier */ ASSERT(width <= MAX_WIDTH); /* process image row by row */ - for (j = 0; j < height; j++, y++) { + for (j = 0; j < height; j++) { GLvoid *dest; GLstencil values[MAX_WIDTH]; GLint srcY; if (st_fb_orientation(ctx->DrawBuffer) == Y_0_TOP) { - srcY = ctx->DrawBuffer->Height - y - 1; + srcY = height - j - 1; } else { - srcY = y; + srcY = j; } /* get stencil values */ - switch (ps->format) { + switch (pt->format) { case PIPE_FORMAT_S8_UNORM: { - const ubyte *src = stmap + srcY * ps->stride + x; + const ubyte *src = stmap + srcY * pt->stride; memcpy(values, src, width); } break; case PIPE_FORMAT_S8Z24_UNORM: { - const uint *src = (uint *) (stmap + srcY * ps->stride + x*4); + const uint *src = (uint *) (stmap + srcY * pt->stride); GLint k; for (k = 0; k < width; k++) { values[k] = src[k] >> 24; @@ -109,7 +113,7 @@ st_read_stencil_pixels(GLcontext *ctx, GLint x, GLint y, break; case PIPE_FORMAT_Z24S8_UNORM: { - const uint *src = (uint *) (stmap + srcY * ps->stride + x*4); + const uint *src = (uint *) (stmap + srcY * pt->stride); GLint k; for (k = 0; k < width; k++) { values[k] = src[k] & 0xff; @@ -129,8 +133,8 @@ st_read_stencil_pixels(GLcontext *ctx, GLint x, GLint y, /* unmap the stencil buffer */ - screen->surface_unmap(screen, ps); - pipe_surface_reference(&ps, NULL); + screen->transfer_unmap(screen, pt); + screen->tex_transfer_release(screen, &pt); } @@ -203,28 +207,33 @@ st_fast_readpixels(GLcontext *ctx, struct st_renderbuffer *strb, { struct pipe_context *pipe = ctx->st->pipe; struct pipe_screen *screen = pipe->screen; - struct pipe_surface *surf; + struct pipe_transfer *trans; const GLubyte *map; GLubyte *dst; GLint row, col, dy, dstStride; - surf = screen->get_tex_surface(screen, strb->texture, 0, 0, 0, - PIPE_BUFFER_USAGE_CPU_READ); - if (!surf) { + if (st_fb_orientation(ctx->ReadBuffer) == Y_0_TOP) { + y = strb->texture->height[0] - y - height; + } + + trans = screen->get_tex_transfer(screen, strb->texture, 0, 0, 0, + PIPE_TRANSFER_READ, x, y, width, height); + if (!trans) { return GL_FALSE; } - map = screen->surface_map(screen, surf, PIPE_BUFFER_USAGE_CPU_READ); + map = screen->transfer_map(screen, trans); if (!map) { - pipe_surface_reference(&surf, NULL); + screen->tex_transfer_release(screen, &trans); return GL_FALSE; } if (st_fb_orientation(ctx->ReadBuffer) == Y_0_TOP) { - y = surf->height - y - 1; + y = height - 1; dy = -1; } else { + y = 0; dy = 1; } @@ -235,7 +244,7 @@ st_fast_readpixels(GLcontext *ctx, struct st_renderbuffer *strb, switch (combo) { case A8R8G8B8_UNORM_TO_RGBA_UBYTE: for (row = 0; row < height; row++) { - const GLubyte *src = map + y * surf->stride + x * 4; + const GLubyte *src = map + y * trans->stride; for (col = 0; col < width; col++) { GLuint pixel = ((GLuint *) src)[col]; dst[col*4+0] = (pixel >> 16) & 0xff; @@ -249,7 +258,7 @@ st_fast_readpixels(GLcontext *ctx, struct st_renderbuffer *strb, break; case A8R8G8B8_UNORM_TO_RGB_UBYTE: for (row = 0; row < height; row++) { - const GLubyte *src = map + y * surf->stride + x * 4; + const GLubyte *src = map + y * trans->stride; for (col = 0; col < width; col++) { GLuint pixel = ((GLuint *) src)[col]; dst[col*3+0] = (pixel >> 16) & 0xff; @@ -262,7 +271,7 @@ st_fast_readpixels(GLcontext *ctx, struct st_renderbuffer *strb, break; case A8R8G8B8_UNORM_TO_BGRA_UINT: for (row = 0; row < height; row++) { - const GLubyte *src = map + y * surf->stride + x * 4; + const GLubyte *src = map + y * trans->stride; memcpy(dst, src, 4 * width); dst += dstStride; y += dy; @@ -272,8 +281,8 @@ st_fast_readpixels(GLcontext *ctx, struct st_renderbuffer *strb, ; /* nothing */ } - screen->surface_unmap(screen, surf); - pipe_surface_reference(&surf, NULL); + screen->transfer_unmap(screen, trans); + screen->tex_transfer_release(screen, &trans); } return GL_TRUE; @@ -281,7 +290,7 @@ st_fast_readpixels(GLcontext *ctx, struct st_renderbuffer *strb, /** - * Do glReadPixels by getting rows from the framebuffer surface with + * Do glReadPixels by getting rows from the framebuffer transfer with * get_tile(). Convert to requested format/type with Mesa image routines. * Image transfer ops are done in software too. */ @@ -300,7 +309,7 @@ st_readpixels(GLcontext *ctx, GLint x, GLint y, GLsizei width, GLsizei height, GLfloat *df; struct st_renderbuffer *strb; struct gl_pixelstore_attrib clippedPacking = *pack; - struct pipe_surface *surf; + struct pipe_transfer *trans; assert(ctx->ReadBuffer->Width > 0); @@ -309,7 +318,7 @@ st_readpixels(GLcontext *ctx, GLint x, GLint y, GLsizei width, GLsizei height, /* Do all needed clipping here, so that we can forget about it later */ if (!_mesa_clip_readpixels(ctx, &x, &y, &width, &height, &clippedPacking)) { - /* The ReadPixels surface is totally outside the window bounds */ + /* The ReadPixels transfer is totally outside the window bounds */ return; } @@ -355,21 +364,26 @@ st_readpixels(GLcontext *ctx, GLint x, GLint y, GLsizei width, GLsizei height, dfStride = 0; } + if (st_fb_orientation(ctx->ReadBuffer) == Y_0_TOP) { + y = strb->Base.Height - y - height; + } + + /* Create a read transfer from the renderbuffer's texture */ + trans = screen->get_tex_transfer(screen, strb->texture, 0, 0, 0, + PIPE_TRANSFER_READ, x, y, width, height); + /* determine bottom-to-top vs. top-to-bottom order */ if (st_fb_orientation(ctx->ReadBuffer) == Y_0_TOP) { - y = strb->Base.Height - 1 - y; + y = height - 1; yStep = -1; } else { + y = 0; yStep = 1; } - /* Create a CPU-READ surface/view into the renderbuffer's texture */ - surf = screen->get_tex_surface(screen, strb->texture, 0, 0, 0, - PIPE_BUFFER_USAGE_CPU_READ); - /* - * Copy pixels from pipe_surface to user memory + * Copy pixels from pipe_transfer to user memory */ { /* dest of first pixel in client memory */ @@ -379,14 +393,14 @@ st_readpixels(GLcontext *ctx, GLint x, GLint y, GLsizei width, GLsizei height, const GLint dstStride = _mesa_image_row_stride(&clippedPacking, width, format, type); - if (surf->format == PIPE_FORMAT_S8Z24_UNORM || - surf->format == PIPE_FORMAT_X8Z24_UNORM) { + if (trans->format == PIPE_FORMAT_S8Z24_UNORM || + trans->format == PIPE_FORMAT_X8Z24_UNORM) { if (format == GL_DEPTH_COMPONENT) { for (i = 0; i < height; i++) { GLuint ztemp[MAX_WIDTH]; GLfloat zfloat[MAX_WIDTH]; const double scale = 1.0 / ((1 << 24) - 1); - pipe_get_tile_raw(surf, x, y, width, 1, ztemp, 0); + pipe_get_tile_raw(trans, 0, y, width, 1, ztemp, 0); y += yStep; for (j = 0; j < width; j++) { zfloat[j] = (float) (scale * (ztemp[j] & 0xffffff)); @@ -400,18 +414,18 @@ st_readpixels(GLcontext *ctx, GLint x, GLint y, GLsizei width, GLsizei height, /* untested, but simple: */ assert(format == GL_DEPTH_STENCIL_EXT); for (i = 0; i < height; i++) { - pipe_get_tile_raw(surf, x, y, width, 1, dst, 0); + pipe_get_tile_raw(trans, 0, y, width, 1, dst, 0); y += yStep; dst += dstStride; } } } - else if (surf->format == PIPE_FORMAT_Z16_UNORM) { + else if (trans->format == PIPE_FORMAT_Z16_UNORM) { for (i = 0; i < height; i++) { GLushort ztemp[MAX_WIDTH]; GLfloat zfloat[MAX_WIDTH]; const double scale = 1.0 / 0xffff; - pipe_get_tile_raw(surf, x, y, width, 1, ztemp, 0); + pipe_get_tile_raw(trans, 0, y, width, 1, ztemp, 0); y += yStep; for (j = 0; j < width; j++) { zfloat[j] = (float) (scale * ztemp[j]); @@ -421,12 +435,12 @@ st_readpixels(GLcontext *ctx, GLint x, GLint y, GLsizei width, GLsizei height, dst += dstStride; } } - else if (surf->format == PIPE_FORMAT_Z32_UNORM) { + else if (trans->format == PIPE_FORMAT_Z32_UNORM) { for (i = 0; i < height; i++) { GLuint ztemp[MAX_WIDTH]; GLfloat zfloat[MAX_WIDTH]; const double scale = 1.0 / 0xffffffff; - pipe_get_tile_raw(surf, x, y, width, 1, ztemp, 0); + pipe_get_tile_raw(trans, 0, y, width, 1, ztemp, 0); y += yStep; for (j = 0; j < width; j++) { zfloat[j] = (float) (scale * ztemp[j]); @@ -440,7 +454,7 @@ st_readpixels(GLcontext *ctx, GLint x, GLint y, GLsizei width, GLsizei height, /* RGBA format */ /* Do a row at a time to flip image data vertically */ for (i = 0; i < height; i++) { - pipe_get_tile_rgba(surf, x, y, width, 1, df); + pipe_get_tile_rgba(trans, 0, y, width, 1, df); y += yStep; df += dfStride; if (!dfStride) { @@ -452,7 +466,7 @@ st_readpixels(GLcontext *ctx, GLint x, GLint y, GLsizei width, GLsizei height, } } - pipe_surface_reference(&surf, NULL); + screen->tex_transfer_release(screen, &trans); _mesa_unmap_readpix_pbo(ctx, &clippedPacking); } diff --git a/src/mesa/state_tracker/st_cb_texture.c b/src/mesa/state_tracker/st_cb_texture.c index 3dd1f1d737d..0ece8f9514b 100644 --- a/src/mesa/state_tracker/st_cb_texture.c +++ b/src/mesa/state_tracker/st_cb_texture.c @@ -524,9 +524,10 @@ st_TexImage(GLcontext * ctx, if (stImage->pt) { texImage->Data = st_texture_image_map(ctx->st, stImage, 0, - PIPE_BUFFER_USAGE_CPU_WRITE); - if (stImage->surface) - dstRowStride = stImage->surface->stride; + PIPE_TRANSFER_WRITE, 0, 0, + stImage->base.Width, + stImage->base.Height); + dstRowStride = stImage->transfer->stride; } else { /* Allocate regular memory and store the image there temporarily. */ @@ -581,7 +582,9 @@ st_TexImage(GLcontext * ctx, if (stImage->pt && i < depth) { st_texture_image_unmap(ctx->st, stImage); texImage->Data = st_texture_image_map(ctx->st, stImage, i, - PIPE_BUFFER_USAGE_CPU_WRITE); + PIPE_TRANSFER_WRITE, 0, 0, + stImage->base.Width, + stImage->base.Height); src += srcImageStride; } } @@ -688,8 +691,10 @@ st_get_tex_image(GLcontext * ctx, GLenum target, GLint level, * kernel. Need to explicitly map and unmap it. */ texImage->Data = st_texture_image_map(ctx->st, stImage, 0, - PIPE_BUFFER_USAGE_CPU_READ); - texImage->RowStride = stImage->surface->stride / stImage->pt->block.size; + PIPE_TRANSFER_READ, 0, 0, + stImage->base.Width, + stImage->base.Height); + texImage->RowStride = stImage->transfer->stride / stImage->pt->block.size; } else { /* Otherwise, the image should actually be stored in @@ -720,7 +725,9 @@ st_get_tex_image(GLcontext * ctx, GLenum target, GLint level, if (stImage->pt && i < depth) { st_texture_image_unmap(ctx->st, stImage); texImage->Data = st_texture_image_map(ctx->st, stImage, i, - PIPE_BUFFER_USAGE_CPU_READ); + PIPE_TRANSFER_READ, 0, 0, + stImage->base.Width, + stImage->base.Height); dest += dstImageStride; } } @@ -792,9 +799,11 @@ st_TexSubimage(GLcontext * ctx, */ if (stImage->pt) { texImage->Data = st_texture_image_map(ctx->st, stImage, zoffset, - PIPE_BUFFER_USAGE_CPU_WRITE); - if (stImage->surface) - dstRowStride = stImage->surface->stride; + PIPE_TRANSFER_WRITE, + xoffset, yoffset, + stImage->base.Width, + stImage->base.Height); + dstRowStride = stImage->transfer->stride; } if (!texImage->Data) { @@ -808,7 +817,7 @@ st_TexSubimage(GLcontext * ctx, if (!texImage->TexFormat->StoreImage(ctx, dims, texImage->_BaseFormat, texImage->TexFormat, texImage->Data, - xoffset, yoffset, 0, + 0, 0, 0, dstRowStride, texImage->ImageOffsets, width, height, 1, @@ -820,7 +829,10 @@ st_TexSubimage(GLcontext * ctx, /* map next slice of 3D texture */ st_texture_image_unmap(ctx->st, stImage); texImage->Data = st_texture_image_map(ctx->st, stImage, zoffset + i, - PIPE_BUFFER_USAGE_CPU_WRITE); + PIPE_TRANSFER_WRITE, + xoffset, yoffset, + stImage->base.Width, + stImage->base.Height); src += srcImageStride; } } @@ -898,26 +910,8 @@ st_TexSubImage1D(GLcontext * ctx, /** - * Return 0 for GL_TEXTURE_CUBE_MAP_POSITIVE_X, - * 1 for GL_TEXTURE_CUBE_MAP_NEGATIVE_X, - * etc. - * XXX duplicated from main/teximage.c - */ -static uint -texture_face(GLenum target) -{ - if (target >= GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB && - target <= GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB) - return (GLuint) target - (GLuint) GL_TEXTURE_CUBE_MAP_POSITIVE_X; - else - return 0; -} - - - -/** - * Do a CopyTexSubImage operation by mapping the source surface and - * dest surface and using get_tile()/put_tile() to access the pixels/texels. + * Do a CopyTexSubImage operation using a read transfer from the source, a write + * transfer to the destination and get_tile()/put_tile() to access the pixels/texels. * * Note: srcY=0=TOP of renderbuffer */ @@ -934,20 +928,24 @@ fallback_copy_texsubimage(GLcontext *ctx, { struct pipe_context *pipe = ctx->st->pipe; struct pipe_screen *screen = pipe->screen; - const uint face = texture_face(target); - struct pipe_texture *pt = stImage->pt; - struct pipe_surface *src_surf, *dest_surf; + struct pipe_transfer *src_trans; + GLvoid *texDest; + + assert(width <= MAX_WIDTH); - /* We'd use strb->surface, here but it's created for GPU read/write only */ - src_surf = pipe->screen->get_tex_surface( pipe->screen, - strb->texture, - 0, 0, 0, - PIPE_BUFFER_USAGE_CPU_READ); + if (st_fb_orientation(ctx->ReadBuffer) == Y_0_TOP) { + srcY = strb->Base.Height - srcY - height; + } - dest_surf = screen->get_tex_surface(screen, pt, face, level, destZ, - PIPE_BUFFER_USAGE_CPU_WRITE); + src_trans = pipe->screen->get_tex_transfer( pipe->screen, + strb->texture, + 0, 0, 0, + PIPE_TRANSFER_READ, + srcX, srcY, + width, height); - assert(width <= MAX_WIDTH); + texDest = st_texture_image_map(ctx->st, stImage, 0, PIPE_TRANSFER_WRITE, + destX, destY, width, height); if (baseFormat == GL_DEPTH_COMPONENT) { const GLboolean scaleOrBias = (ctx->Pixel.DepthScale != 1.0F || @@ -956,39 +954,36 @@ fallback_copy_texsubimage(GLcontext *ctx, /* determine bottom-to-top vs. top-to-bottom order for src buffer */ if (st_fb_orientation(ctx->ReadBuffer) == Y_0_TOP) { - srcY = strb->Base.Height - 1 - srcY; + srcY = height - 1; yStep = -1; } else { + srcY = 0; yStep = 1; } /* To avoid a large temp memory allocation, do copy row by row */ - for (row = 0; row < height; row++, srcY += yStep, destY++) { + for (row = 0; row < height; row++, srcY += yStep) { uint data[MAX_WIDTH]; - pipe_get_tile_z(src_surf, srcX, srcY, width, 1, data); + pipe_get_tile_z(src_trans, 0, srcY, width, 1, data); if (scaleOrBias) { _mesa_scale_and_bias_depth_uint(ctx, width, data); } - pipe_put_tile_z(dest_surf, destX, destY, width, 1, data); + pipe_put_tile_z(stImage->transfer, 0, row, width, 1, data); } } else { /* RGBA format */ GLfloat *tempSrc = (GLfloat *) _mesa_malloc(width * height * 4 * sizeof(GLfloat)); - GLvoid *texDest = - st_texture_image_map(ctx->st, stImage, 0,PIPE_BUFFER_USAGE_CPU_WRITE); if (tempSrc && texDest) { const GLint dims = 2; struct gl_texture_image *texImage = &stImage->base; - GLint dstRowStride = stImage->surface->stride; + GLint dstRowStride = stImage->transfer->stride; struct gl_pixelstore_attrib unpack = ctx->DefaultPacking; if (st_fb_orientation(ctx->ReadBuffer) == Y_0_TOP) { - /* need to invert src */ - srcY = strb->Base.Height - srcY - height; unpack.Invert = GL_TRUE; } @@ -996,7 +991,7 @@ fallback_copy_texsubimage(GLcontext *ctx, /* XXX this usually involves a lot of int/float conversion. * try to avoid that someday. */ - pipe_get_tile_rgba(src_surf, srcX, srcY, width, height, tempSrc); + pipe_get_tile_rgba(src_trans, 0, 0, width, height, tempSrc); /* Store into texture memory. * Note that this does some special things such as pixel transfer @@ -1008,7 +1003,7 @@ fallback_copy_texsubimage(GLcontext *ctx, texImage->_BaseFormat, texImage->TexFormat, texDest, - destX, destY, destZ, + 0, 0, 0, dstRowStride, texImage->ImageOffsets, width, height, 1, @@ -1021,12 +1016,10 @@ fallback_copy_texsubimage(GLcontext *ctx, if (tempSrc) _mesa_free(tempSrc); - if (texDest) - st_texture_image_unmap(ctx->st, stImage); } - screen->tex_surface_release(screen, &dest_surf); - screen->tex_surface_release(screen, &src_surf); + st_texture_image_unmap(ctx->st, stImage); + screen->tex_transfer_release(screen, &src_trans); } diff --git a/src/mesa/state_tracker/st_gen_mipmap.c b/src/mesa/state_tracker/st_gen_mipmap.c index 6a3455aaba2..08e48030681 100644 --- a/src/mesa/state_tracker/st_gen_mipmap.c +++ b/src/mesa/state_tracker/st_gen_mipmap.c @@ -119,36 +119,36 @@ fallback_generate_mipmap(GLcontext *ctx, GLenum target, for (dstLevel = baseLevel + 1; dstLevel <= lastLevel; dstLevel++) { const uint srcLevel = dstLevel - 1; - struct pipe_surface *srcSurf, *dstSurf; + struct pipe_transfer *srcTrans, *dstTrans; const ubyte *srcData; ubyte *dstData; - srcSurf = screen->get_tex_surface(screen, pt, face, srcLevel, zslice, - PIPE_BUFFER_USAGE_CPU_READ); - dstSurf = screen->get_tex_surface(screen, pt, face, dstLevel, zslice, - PIPE_BUFFER_USAGE_CPU_WRITE); + srcTrans = screen->get_tex_transfer(screen, pt, face, srcLevel, zslice, + PIPE_TRANSFER_READ, 0, 0, + pt->width[srcLevel], + pt->height[srcLevel]); + dstTrans = screen->get_tex_transfer(screen, pt, face, dstLevel, zslice, + PIPE_TRANSFER_WRITE, 0, 0, + pt->width[dstLevel], + pt->height[dstLevel]); - srcData = (ubyte *) pipe_surface_map(srcSurf, - PIPE_BUFFER_USAGE_CPU_READ) - + srcSurf->offset; - dstData = (ubyte *) pipe_surface_map(dstSurf, - PIPE_BUFFER_USAGE_CPU_WRITE) - + dstSurf->offset; + srcData = (ubyte *) screen->transfer_map(screen, srcTrans); + dstData = (ubyte *) screen->transfer_map(screen, dstTrans); _mesa_generate_mipmap_level(target, datatype, comps, 0 /*border*/, pt->width[srcLevel], pt->height[srcLevel], pt->depth[srcLevel], srcData, - srcSurf->stride, /* stride in bytes */ + srcTrans->stride, /* stride in bytes */ pt->width[dstLevel], pt->height[dstLevel], pt->depth[dstLevel], dstData, - dstSurf->stride); /* stride in bytes */ + dstTrans->stride); /* stride in bytes */ - pipe_surface_unmap(srcSurf); - pipe_surface_unmap(dstSurf); + screen->transfer_unmap(screen, srcTrans); + screen->transfer_unmap(screen, dstTrans); - pipe_surface_reference(&srcSurf, NULL); - pipe_surface_reference(&dstSurf, NULL); + screen->tex_transfer_release(screen, &srcTrans); + screen->tex_transfer_release(screen, &dstTrans); } } diff --git a/src/mesa/state_tracker/st_texture.c b/src/mesa/state_tracker/st_texture.c index 63cfe5fc163..63a36324d42 100644 --- a/src/mesa/state_tracker/st_texture.c +++ b/src/mesa/state_tracker/st_texture.c @@ -191,19 +191,19 @@ st_texture_image_offset(const struct pipe_texture * pt, */ GLubyte * st_texture_image_map(struct st_context *st, struct st_texture_image *stImage, - GLuint zoffset, - GLuint flags ) + GLuint zoffset, enum pipe_transfer_usage usage, + GLuint x, GLuint y, GLuint w, GLuint h) { struct pipe_screen *screen = st->pipe->screen; struct pipe_texture *pt = stImage->pt; DBG("%s \n", __FUNCTION__); - stImage->surface = screen->get_tex_surface(screen, pt, stImage->face, - stImage->level, zoffset, - flags); + stImage->transfer = screen->get_tex_transfer(screen, pt, stImage->face, + stImage->level, zoffset, + usage, x, y, w, h); - if (stImage->surface) - return screen->surface_map(screen, stImage->surface, flags); + if (stImage->transfer) + return screen->transfer_map(screen, stImage->transfer); else return NULL; } @@ -217,9 +217,9 @@ st_texture_image_unmap(struct st_context *st, DBG("%s\n", __FUNCTION__); - screen->surface_unmap(screen, stImage->surface); + screen->transfer_unmap(screen, stImage->transfer); - pipe_surface_reference(&stImage->surface, NULL); + screen->tex_transfer_release(screen, &stImage->transfer); } @@ -234,13 +234,13 @@ st_texture_image_unmap(struct st_context *st, */ static void st_surface_data(struct pipe_context *pipe, - struct pipe_surface *dst, + struct pipe_transfer *dst, unsigned dstx, unsigned dsty, const void *src, unsigned src_stride, unsigned srcx, unsigned srcy, unsigned width, unsigned height) { struct pipe_screen *screen = pipe->screen; - void *map = screen->surface_map(screen, dst, PIPE_BUFFER_USAGE_CPU_WRITE); + void *map = screen->transfer_map(screen, dst); pipe_copy_rect(map, &dst->block, @@ -250,7 +250,7 @@ st_surface_data(struct pipe_context *pipe, src, src_stride, srcx, srcy); - screen->surface_unmap(screen, dst); + screen->transfer_unmap(screen, dst); } @@ -268,21 +268,23 @@ st_texture_image_data(struct pipe_context *pipe, GLuint depth = dst->depth[level]; GLuint i; const GLubyte *srcUB = src; - struct pipe_surface *dst_surface; + struct pipe_transfer *dst_transfer; DBG("%s\n", __FUNCTION__); for (i = 0; i < depth; i++) { - dst_surface = screen->get_tex_surface(screen, dst, face, level, i, - PIPE_BUFFER_USAGE_CPU_WRITE); + dst_transfer = screen->get_tex_transfer(screen, dst, face, level, i, + PIPE_TRANSFER_WRITE, 0, 0, + dst->width[level], + dst->height[level]); - st_surface_data(pipe, dst_surface, + st_surface_data(pipe, dst_transfer, 0, 0, /* dstx, dsty */ srcUB, src_row_stride, 0, 0, /* source x, y */ dst->width[level], dst->height[level]); /* width, height */ - screen->tex_surface_release(screen, &dst_surface); + screen->tex_transfer_release(screen, &dst_transfer); srcUB += src_image_stride; } diff --git a/src/mesa/state_tracker/st_texture.h b/src/mesa/state_tracker/st_texture.h index 31f66ad52cf..840b7e27cc0 100644 --- a/src/mesa/state_tracker/st_texture.h +++ b/src/mesa/state_tracker/st_texture.h @@ -50,7 +50,7 @@ struct st_texture_image */ struct pipe_texture *pt; - struct pipe_surface *surface; + struct pipe_transfer *transfer; }; @@ -132,7 +132,9 @@ extern GLubyte * st_texture_image_map(struct st_context *st, struct st_texture_image *stImage, GLuint zoffset, - GLuint flags); + enum pipe_transfer_usage usage, + unsigned x, unsigned y, + unsigned w, unsigned h); extern void st_texture_image_unmap(struct st_context *st, |