diff options
author | Michel Dänzer <[email protected]> | 2009-02-18 16:43:02 +0100 |
---|---|---|
committer | Michel Dänzer <[email protected]> | 2009-02-18 16:43:02 +0100 |
commit | 3bd7c5ceffc88a052c5e8e114df2f2c7549ddb4a (patch) | |
tree | bdb352609c3ef21875a2699428e26b8c8c930f73 /src/gallium/auxiliary/util | |
parent | 76d8951fd3adbb91b2f71d461eec0f304619ca0b (diff) | |
parent | b89aa1d87ad6cebdbb3f2067863c600f50bf0ff1 (diff) |
Merge branch 'gallium-texture-transfer'
Conflicts:
src/gallium/drivers/softpipe/sp_tile_cache.c
Diffstat (limited to 'src/gallium/auxiliary/util')
-rw-r--r-- | src/gallium/auxiliary/util/u_debug.c | 59 | ||||
-rw-r--r-- | src/gallium/auxiliary/util/u_gen_mipmap.c | 125 | ||||
-rw-r--r-- | src/gallium/auxiliary/util/u_rect.c | 112 | ||||
-rw-r--r-- | src/gallium/auxiliary/util/u_tile.c | 127 | ||||
-rw-r--r-- | src/gallium/auxiliary/util/u_tile.h | 30 |
5 files changed, 217 insertions, 236 deletions
diff --git a/src/gallium/auxiliary/util/u_debug.c b/src/gallium/auxiliary/util/u_debug.c index 43d424b1d6a..7f2a113dead 100644 --- a/src/gallium/auxiliary/util/u_debug.c +++ b/src/gallium/auxiliary/util/u_debug.c @@ -643,34 +643,37 @@ void debug_dump_image(const char *prefix, void debug_dump_surface(const char *prefix, struct pipe_surface *surface) { - unsigned surface_usage; + struct pipe_texture *texture; + struct pipe_screen *screen; + struct pipe_transfer *transfer; void *data; if (!surface) - goto error1; + return; + + texture = surface->texture; + screen = texture->screen; - /* XXX: force mappable surface */ - surface_usage = surface->usage; - surface->usage |= PIPE_BUFFER_USAGE_CPU_READ; + transfer = screen->get_tex_transfer(screen, texture, surface->face, + surface->level, surface->zslice, + PIPE_TRANSFER_READ, 0, 0, surface->width, + surface->height); - data = pipe_surface_map(surface, - PIPE_BUFFER_USAGE_CPU_READ); + data = screen->transfer_map(screen, transfer); if(!data) - goto error2; + goto error; debug_dump_image(prefix, - surface->format, - surface->block.size, - surface->nblocksx, - surface->nblocksy, - surface->stride, + transfer->format, + transfer->block.size, + transfer->nblocksx, + transfer->nblocksy, + transfer->stride, data); - pipe_surface_unmap(surface); -error2: - surface->usage = surface_usage; -error1: - ; + screen->transfer_unmap(screen, transfer); +error: + screen->tex_transfer_release(screen, &transfer); } @@ -710,8 +713,10 @@ debug_dump_surface_bmp(const char *filename, struct pipe_surface *surface) { #ifndef PIPE_SUBSYSTEM_WINDOWS_MINIPORT + struct pipe_texture *texture; + struct pipe_screen *screen; struct util_stream *stream; - unsigned surface_usage; + struct pipe_transfer *transfer; struct bmp_file_header bmfh; struct bmp_info_header bmih; float *rgba; @@ -748,14 +753,18 @@ debug_dump_surface_bmp(const char *filename, util_stream_write(stream, &bmfh, 14); util_stream_write(stream, &bmih, 40); + + texture = surface->texture; + screen = texture->screen; - /* XXX: force mappable surface */ - surface_usage = surface->usage; - surface->usage |= PIPE_BUFFER_USAGE_CPU_READ; + transfer = screen->get_tex_transfer(screen, texture, surface->face, + surface->level, surface->zslice, + PIPE_TRANSFER_READ, 0, 0, surface->width, + surface->height); y = surface->height; while(y--) { - pipe_get_tile_rgba(surface, + pipe_get_tile_rgba(transfer, 0, y, surface->width, 1, rgba); for(x = 0; x < surface->width; ++x) @@ -768,9 +777,9 @@ debug_dump_surface_bmp(const char *filename, util_stream_write(stream, &pixel, 4); } } - - surface->usage = surface_usage; + screen->tex_transfer_release(screen, &transfer); + util_stream_close(stream); error2: FREE(rgba); diff --git a/src/gallium/auxiliary/util/u_gen_mipmap.c b/src/gallium/auxiliary/util/u_gen_mipmap.c index 7c20c7ce7bb..90483fcb216 100644 --- a/src/gallium/auxiliary/util/u_gen_mipmap.c +++ b/src/gallium/auxiliary/util/u_gen_mipmap.c @@ -1116,31 +1116,30 @@ make_1d_mipmap(struct gen_mipmap_state *ctx, for (dstLevel = baseLevel + 1; dstLevel <= lastLevel; dstLevel++) { const uint srcLevel = dstLevel - 1; - struct pipe_surface *srcSurf, *dstSurf; + struct pipe_transfer *srcTrans, *dstTrans; void *srcMap, *dstMap; - 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); - - srcMap = ((ubyte *) pipe_surface_map(srcSurf, - PIPE_BUFFER_USAGE_CPU_READ) - + srcSurf->offset); - dstMap = ((ubyte *) pipe_surface_map(dstSurf, - PIPE_BUFFER_USAGE_CPU_WRITE) - + dstSurf->offset); + 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]); + + srcMap = (ubyte *) screen->transfer_map(screen, srcTrans); + dstMap = (ubyte *) screen->transfer_map(screen, dstTrans); reduce_1d(pt->format, - srcSurf->width, srcMap, - dstSurf->width, dstMap); + srcTrans->width, srcMap, + dstTrans->width, dstMap); - 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); } } @@ -1160,32 +1159,32 @@ make_2d_mipmap(struct gen_mipmap_state *ctx, for (dstLevel = baseLevel + 1; dstLevel <= lastLevel; dstLevel++) { const uint srcLevel = dstLevel - 1; - struct pipe_surface *srcSurf, *dstSurf; + struct pipe_transfer *srcTrans, *dstTrans; ubyte *srcMap, *dstMap; - 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); - - srcMap = ((ubyte *) pipe_surface_map(srcSurf, - PIPE_BUFFER_USAGE_CPU_READ) - + srcSurf->offset); - dstMap = ((ubyte *) pipe_surface_map(dstSurf, - PIPE_BUFFER_USAGE_CPU_WRITE) - + dstSurf->offset); + 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]); + + srcMap = (ubyte *) screen->transfer_map(screen, srcTrans); + dstMap = (ubyte *) screen->transfer_map(screen, dstTrans); reduce_2d(pt->format, - srcSurf->width, srcSurf->height, - srcSurf->stride, srcMap, - dstSurf->width, dstSurf->height, - dstSurf->stride, dstMap); + srcTrans->width, srcTrans->height, + srcTrans->stride, srcMap, + dstTrans->width, dstTrans->height, + dstTrans->stride, dstMap); - 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); } } @@ -1195,6 +1194,7 @@ make_3d_mipmap(struct gen_mipmap_state *ctx, struct pipe_texture *pt, uint face, uint baseLevel, uint lastLevel) { +#if 0 struct pipe_context *pipe = ctx->pipe; struct pipe_screen *screen = pipe->screen; uint dstLevel, zslice = 0; @@ -1204,37 +1204,36 @@ make_3d_mipmap(struct gen_mipmap_state *ctx, for (dstLevel = baseLevel + 1; dstLevel <= lastLevel; dstLevel++) { const uint srcLevel = dstLevel - 1; - struct pipe_surface *srcSurf, *dstSurf; + struct pipe_transfer *srcTrans, *dstTrans; ubyte *srcMap, *dstMap; - 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); - - srcMap = ((ubyte *) pipe_surface_map(srcSurf, - PIPE_BUFFER_USAGE_CPU_READ) - + srcSurf->offset); - dstMap = ((ubyte *) pipe_surface_map(dstSurf, - PIPE_BUFFER_USAGE_CPU_WRITE) - + dstSurf->offset); + 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]); + + srcMap = (ubyte *) screen->transfer_map(screen, srcTrans); + dstMap = (ubyte *) screen->transfer_map(screen, dstTrans); -#if 0 reduce_3d(pt->format, - srcSurf->width, srcSurf->height, - srcSurf->stride, srcMap, - dstSurf->width, dstSurf->height, - dstSurf->stride, dstMap); -#else - (void) reduce_3d; -#endif + srcTrans->width, srcTrans->height, + srcTrans->stride, srcMap, + dstTrans->width, dstTrans->height, + dstTrans->stride, dstMap); - 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); } +#else + (void) reduce_3d; +#endif } diff --git a/src/gallium/auxiliary/util/u_rect.c b/src/gallium/auxiliary/util/u_rect.c index fe81a685be1..6e24e594e46 100644 --- a/src/gallium/auxiliary/util/u_rect.c +++ b/src/gallium/auxiliary/util/u_rect.c @@ -169,46 +169,35 @@ util_surface_copy(struct pipe_context *pipe, unsigned w, unsigned h) { struct pipe_screen *screen = pipe->screen; - struct pipe_surface *new_src = NULL, *new_dst = NULL; + struct pipe_transfer *src_trans, *dst_trans; void *dst_map; const void *src_map; - assert(dst->block.size == src->block.size); - assert(dst->block.width == src->block.width); - assert(dst->block.height == src->block.height); - - if ((src->usage & PIPE_BUFFER_USAGE_CPU_READ) == 0) { - /* Need to create new src surface which is CPU readable */ - assert(src->texture); - if (!src->texture) - return; - new_src = screen->get_tex_surface(screen, + assert(src->texture && dst->texture); + if (!src->texture || !dst->texture) + return; + src_trans = screen->get_tex_transfer(screen, src->texture, src->face, src->level, src->zslice, - PIPE_BUFFER_USAGE_CPU_READ); - src = new_src; - } + PIPE_TRANSFER_READ, + src_x, src_y, w, h); - if ((dst->usage & PIPE_BUFFER_USAGE_CPU_WRITE) == 0) { - /* Need to create new dst surface which is CPU writable */ - assert(dst->texture); - if (!dst->texture) - return; - new_dst = screen->get_tex_surface(screen, + dst_trans = screen->get_tex_transfer(screen, dst->texture, dst->face, dst->level, dst->zslice, - PIPE_BUFFER_USAGE_CPU_WRITE); - dst = new_dst; - } + PIPE_TRANSFER_WRITE, + dst_x, dst_y, w, h); - src_map = pipe->screen->surface_map(screen, - src, PIPE_BUFFER_USAGE_CPU_READ); - dst_map = pipe->screen->surface_map(screen, - dst, PIPE_BUFFER_USAGE_CPU_WRITE); + assert(dst_trans->block.size == src_trans->block.size); + assert(dst_trans->block.width == src_trans->block.width); + assert(dst_trans->block.height == src_trans->block.height); + + src_map = pipe->screen->transfer_map(screen, src_trans); + dst_map = pipe->screen->transfer_map(screen, dst_trans); assert(src_map); assert(dst_map); @@ -216,36 +205,25 @@ util_surface_copy(struct pipe_context *pipe, if (src_map && dst_map) { /* If do_flip, invert src_y position and pass negative src stride */ pipe_copy_rect(dst_map, - &dst->block, - dst->stride, - dst_x, dst_y, + &dst_trans->block, + dst_trans->stride, + 0, 0, w, h, src_map, - do_flip ? -(int) src->stride : src->stride, - src_x, - do_flip ? src_y + h - 1 : src_y); + do_flip ? -(int) src_trans->stride : src_trans->stride, + 0, + do_flip ? h - 1 : 0); } - pipe->screen->surface_unmap(pipe->screen, src); - pipe->screen->surface_unmap(pipe->screen, dst); + pipe->screen->transfer_unmap(pipe->screen, src_trans); + pipe->screen->transfer_unmap(pipe->screen, dst_trans); - if (new_src) - screen->tex_surface_release(screen, &new_src); - if (new_dst) - screen->tex_surface_release(screen, &new_dst); + screen->tex_transfer_release(screen, &src_trans); + screen->tex_transfer_release(screen, &dst_trans); } -static void * -get_pointer(struct pipe_surface *dst, void *dst_map, unsigned x, unsigned y) -{ - return (char *)dst_map - + y / dst->block.height * dst->stride - + x / dst->block.width * dst->block.size; -} - - #define UBYTE_TO_USHORT(B) ((B) | ((B) << 8)) @@ -260,42 +238,38 @@ util_surface_fill(struct pipe_context *pipe, unsigned width, unsigned height, unsigned value) { struct pipe_screen *screen = pipe->screen; - struct pipe_surface *new_dst = NULL; + struct pipe_transfer *dst_trans; void *dst_map; - if ((dst->usage & PIPE_BUFFER_USAGE_CPU_WRITE) == 0) { - /* Need to create new dst surface which is CPU writable */ - assert(dst->texture); - if (!dst->texture) - return; - new_dst = screen->get_tex_surface(screen, + assert(dst->texture); + if (!dst->texture) + return; + dst_trans = screen->get_tex_transfer(screen, dst->texture, dst->face, dst->level, dst->zslice, - PIPE_BUFFER_USAGE_CPU_WRITE); - dst = new_dst; - } + PIPE_TRANSFER_WRITE, + dstx, dsty, width, height); - dst_map = pipe->screen->surface_map(screen, - dst, PIPE_BUFFER_USAGE_CPU_WRITE); + dst_map = pipe->screen->transfer_map(screen, dst_trans); assert(dst_map); if (dst_map) { - assert(dst->stride > 0); + assert(dst_trans->stride > 0); - switch (dst->block.size) { + switch (dst_trans->block.size) { case 1: case 2: case 4: - pipe_fill_rect(dst_map, &dst->block, dst->stride, - dstx, dsty, width, height, value); + pipe_fill_rect(dst_map, &dst_trans->block, dst_trans->stride, + 0, 0, width, height, value); break; case 8: { /* expand the 4-byte clear value to an 8-byte value */ - ushort *row = (ushort *) get_pointer(dst, dst_map, dstx, dsty); + ushort *row = (ushort *) dst_map; ushort val0 = UBYTE_TO_USHORT((value >> 0) & 0xff); ushort val1 = UBYTE_TO_USHORT((value >> 8) & 0xff); ushort val2 = UBYTE_TO_USHORT((value >> 16) & 0xff); @@ -312,7 +286,7 @@ util_surface_fill(struct pipe_context *pipe, row[j*4+2] = val2; row[j*4+3] = val3; } - row += dst->stride/2; + row += dst_trans->stride/2; } } break; @@ -322,8 +296,6 @@ util_surface_fill(struct pipe_context *pipe, } } - pipe->screen->surface_unmap(pipe->screen, dst); - - if (new_dst) - screen->tex_surface_release(screen, &new_dst); + pipe->screen->transfer_unmap(pipe->screen, dst_trans); + screen->tex_transfer_release(screen, &dst_trans); } diff --git a/src/gallium/auxiliary/util/u_tile.c b/src/gallium/auxiliary/util/u_tile.c index 32f6b072a00..56f2f577ccf 100644 --- a/src/gallium/auxiliary/util/u_tile.c +++ b/src/gallium/auxiliary/util/u_tile.c @@ -28,7 +28,6 @@ /** * RGBA/float tile get/put functions. * Usable both by drivers and state trackers. - * Surfaces should already be in a mapped state. */ @@ -42,58 +41,58 @@ /** - * Move raw block of pixels from surface to user memory. - * This should be usable by any hw driver that has mappable surfaces. + * Move raw block of pixels from transfer object to user memory. */ void -pipe_get_tile_raw(struct pipe_surface *ps, +pipe_get_tile_raw(struct pipe_transfer *pt, uint x, uint y, uint w, uint h, void *dst, int dst_stride) { + struct pipe_screen *screen = pt->texture->screen; const void *src; if (dst_stride == 0) - dst_stride = pf_get_nblocksx(&ps->block, w) * ps->block.size; + dst_stride = pf_get_nblocksx(&pt->block, w) * pt->block.size; - if (pipe_clip_tile(x, y, &w, &h, ps)) + if (pipe_clip_tile(x, y, &w, &h, pt)) return; - src = pipe_surface_map(ps, PIPE_BUFFER_USAGE_CPU_READ); + src = screen->transfer_map(screen, pt); assert(src); if(!src) return; - pipe_copy_rect(dst, &ps->block, dst_stride, 0, 0, w, h, src, ps->stride, x, y); + pipe_copy_rect(dst, &pt->block, dst_stride, 0, 0, w, h, src, pt->stride, x, y); - pipe_surface_unmap(ps); + screen->transfer_unmap(screen, pt); } /** - * Move raw block of pixels from user memory to surface. - * This should be usable by any hw driver that has mappable surfaces. + * Move raw block of pixels from user memory to transfer object. */ void -pipe_put_tile_raw(struct pipe_surface *ps, +pipe_put_tile_raw(struct pipe_transfer *pt, uint x, uint y, uint w, uint h, const void *src, int src_stride) { + struct pipe_screen *screen = pt->texture->screen; void *dst; if (src_stride == 0) - src_stride = pf_get_nblocksx(&ps->block, w) * ps->block.size; + src_stride = pf_get_nblocksx(&pt->block, w) * pt->block.size; - if (pipe_clip_tile(x, y, &w, &h, ps)) + if (pipe_clip_tile(x, y, &w, &h, pt)) return; - dst = pipe_surface_map(ps, PIPE_BUFFER_USAGE_CPU_WRITE); + dst = screen->transfer_map(screen, pt); assert(dst); if(!dst) return; - pipe_copy_rect(dst, &ps->block, ps->stride, x, y, w, h, src, src_stride, 0, 0); + pipe_copy_rect(dst, &pt->block, pt->stride, x, y, w, h, src, src_stride, 0, 0); - pipe_surface_unmap(ps); + screen->transfer_unmap(screen, pt); } @@ -955,49 +954,49 @@ pipe_tile_raw_to_rgba(enum pipe_format format, void -pipe_get_tile_rgba(struct pipe_surface *ps, +pipe_get_tile_rgba(struct pipe_transfer *pt, uint x, uint y, uint w, uint h, float *p) { unsigned dst_stride = w * 4; void *packed; - if (pipe_clip_tile(x, y, &w, &h, ps)) + if (pipe_clip_tile(x, y, &w, &h, pt)) return; - packed = MALLOC(pf_get_nblocks(&ps->block, w, h) * ps->block.size); + packed = MALLOC(pf_get_nblocks(&pt->block, w, h) * pt->block.size); if (!packed) return; - if(ps->format == PIPE_FORMAT_YCBCR || ps->format == PIPE_FORMAT_YCBCR_REV) + if(pt->format == PIPE_FORMAT_YCBCR || pt->format == PIPE_FORMAT_YCBCR_REV) assert((x & 1) == 0); - pipe_get_tile_raw(ps, x, y, w, h, packed, 0); + pipe_get_tile_raw(pt, x, y, w, h, packed, 0); - pipe_tile_raw_to_rgba(ps->format, packed, w, h, p, dst_stride); + pipe_tile_raw_to_rgba(pt->format, packed, w, h, p, dst_stride); FREE(packed); } void -pipe_put_tile_rgba(struct pipe_surface *ps, +pipe_put_tile_rgba(struct pipe_transfer *pt, uint x, uint y, uint w, uint h, const float *p) { unsigned src_stride = w * 4; void *packed; - if (pipe_clip_tile(x, y, &w, &h, ps)) + if (pipe_clip_tile(x, y, &w, &h, pt)) return; - packed = MALLOC(pf_get_nblocks(&ps->block, w, h) * ps->block.size); + packed = MALLOC(pf_get_nblocks(&pt->block, w, h) * pt->block.size); if (!packed) return; - switch (ps->format) { + switch (pt->format) { case PIPE_FORMAT_A8R8G8B8_UNORM: a8r8g8b8_put_tile_rgba((unsigned *) packed, w, h, p, src_stride); break; @@ -1054,7 +1053,7 @@ pipe_put_tile_rgba(struct pipe_surface *ps, assert(0); } - pipe_put_tile_raw(ps, x, y, w, h, packed, 0); + pipe_put_tile_raw(pt, x, y, w, h, packed, 0); FREE(packed); } @@ -1064,62 +1063,63 @@ pipe_put_tile_rgba(struct pipe_surface *ps, * Get a block of Z values, converted to 32-bit range. */ void -pipe_get_tile_z(struct pipe_surface *ps, +pipe_get_tile_z(struct pipe_transfer *pt, uint x, uint y, uint w, uint h, uint *z) { + struct pipe_screen *screen = pt->texture->screen; const uint dstStride = w; ubyte *map; uint *pDest = z; uint i, j; - if (pipe_clip_tile(x, y, &w, &h, ps)) + if (pipe_clip_tile(x, y, &w, &h, pt)) return; - map = (ubyte *)pipe_surface_map(ps, PIPE_BUFFER_USAGE_CPU_READ); + map = (ubyte *)screen->transfer_map(screen, pt); if (!map) { assert(0); return; } - switch (ps->format) { + switch (pt->format) { case PIPE_FORMAT_Z32_UNORM: { - const uint *pSrc - = (const uint *)(map + y * ps->stride + x*4); + const uint *ptrc + = (const uint *)(map + y * pt->stride + x*4); for (i = 0; i < h; i++) { - memcpy(pDest, pSrc, 4 * w); + memcpy(pDest, ptrc, 4 * w); pDest += dstStride; - pSrc += ps->stride/4; + ptrc += pt->stride/4; } } break; case PIPE_FORMAT_S8Z24_UNORM: case PIPE_FORMAT_X8Z24_UNORM: { - const uint *pSrc - = (const uint *)(map + y * ps->stride + x*4); + const uint *ptrc + = (const uint *)(map + y * pt->stride + x*4); for (i = 0; i < h; i++) { for (j = 0; j < w; j++) { /* convert 24-bit Z to 32-bit Z */ - pDest[j] = (pSrc[j] << 8) | (pSrc[j] & 0xff); + pDest[j] = (ptrc[j] << 8) | (ptrc[j] & 0xff); } pDest += dstStride; - pSrc += ps->stride/4; + ptrc += pt->stride/4; } } break; case PIPE_FORMAT_Z16_UNORM: { - const ushort *pSrc - = (const ushort *)(map + y * ps->stride + x*2); + const ushort *ptrc + = (const ushort *)(map + y * pt->stride + x*2); for (i = 0; i < h; i++) { for (j = 0; j < w; j++) { /* convert 16-bit Z to 32-bit Z */ - pDest[j] = (pSrc[j] << 16) | pSrc[j]; + pDest[j] = (ptrc[j] << 16) | ptrc[j]; } pDest += dstStride; - pSrc += ps->stride/2; + ptrc += pt->stride/2; } } break; @@ -1127,64 +1127,65 @@ pipe_get_tile_z(struct pipe_surface *ps, assert(0); } - pipe_surface_unmap(ps); + screen->transfer_unmap(screen, pt); } void -pipe_put_tile_z(struct pipe_surface *ps, +pipe_put_tile_z(struct pipe_transfer *pt, uint x, uint y, uint w, uint h, const uint *zSrc) { + struct pipe_screen *screen = pt->texture->screen; const uint srcStride = w; - const uint *pSrc = zSrc; + const uint *ptrc = zSrc; ubyte *map; uint i, j; - if (pipe_clip_tile(x, y, &w, &h, ps)) + if (pipe_clip_tile(x, y, &w, &h, pt)) return; - map = (ubyte *)pipe_surface_map(ps, PIPE_BUFFER_USAGE_CPU_WRITE); + map = (ubyte *)screen->transfer_map(screen, pt); if (!map) { assert(0); return; } - switch (ps->format) { + switch (pt->format) { case PIPE_FORMAT_Z32_UNORM: { - uint *pDest = (uint *) (map + y * ps->stride + x*4); + uint *pDest = (uint *) (map + y * pt->stride + x*4); for (i = 0; i < h; i++) { - memcpy(pDest, pSrc, 4 * w); - pDest += ps->stride/4; - pSrc += srcStride; + memcpy(pDest, ptrc, 4 * w); + pDest += pt->stride/4; + ptrc += srcStride; } } break; case PIPE_FORMAT_S8Z24_UNORM: case PIPE_FORMAT_X8Z24_UNORM: { - uint *pDest = (uint *) (map + y * ps->stride + x*4); + uint *pDest = (uint *) (map + y * pt->stride + x*4); for (i = 0; i < h; i++) { for (j = 0; j < w; j++) { /* convert 32-bit Z to 24-bit Z (0 stencil) */ - pDest[j] = pSrc[j] >> 8; + pDest[j] = ptrc[j] >> 8; } - pDest += ps->stride/4; - pSrc += srcStride; + pDest += pt->stride/4; + ptrc += srcStride; } } break; case PIPE_FORMAT_Z16_UNORM: { - ushort *pDest = (ushort *) (map + y * ps->stride + x*2); + ushort *pDest = (ushort *) (map + y * pt->stride + x*2); for (i = 0; i < h; i++) { for (j = 0; j < w; j++) { /* convert 32-bit Z to 16-bit Z */ - pDest[j] = pSrc[j] >> 16; + pDest[j] = ptrc[j] >> 16; } - pDest += ps->stride/2; - pSrc += srcStride; + pDest += pt->stride/2; + ptrc += srcStride; } } break; @@ -1192,7 +1193,7 @@ pipe_put_tile_z(struct pipe_surface *ps, assert(0); } - pipe_surface_unmap(ps); + screen->transfer_unmap(screen, pt); } diff --git a/src/gallium/auxiliary/util/u_tile.h b/src/gallium/auxiliary/util/u_tile.h index a8ac8053083..1453af38b8a 100644 --- a/src/gallium/auxiliary/util/u_tile.h +++ b/src/gallium/auxiliary/util/u_tile.h @@ -30,24 +30,24 @@ #include "pipe/p_compiler.h" -struct pipe_surface; +struct pipe_transfer; /** - * Clip tile against surface dims. + * Clip tile against transfer dims. * \return TRUE if tile is totally clipped, FALSE otherwise */ static INLINE boolean -pipe_clip_tile(uint x, uint y, uint *w, uint *h, const struct pipe_surface *ps) +pipe_clip_tile(uint x, uint y, uint *w, uint *h, const struct pipe_transfer *pt) { - if (x >= ps->width) + if (x >= pt->width) return TRUE; - if (y >= ps->height) + if (y >= pt->height) return TRUE; - if (x + *w > ps->width) - *w = ps->width - x; - if (y + *h > ps->height) - *h = ps->height - y; + if (x + *w > pt->width) + *w = pt->width - x; + if (y + *h > pt->height) + *h = pt->height - y; return FALSE; } @@ -56,34 +56,34 @@ extern "C" { #endif void -pipe_get_tile_raw(struct pipe_surface *ps, +pipe_get_tile_raw(struct pipe_transfer *pt, uint x, uint y, uint w, uint h, void *p, int dst_stride); void -pipe_put_tile_raw(struct pipe_surface *ps, +pipe_put_tile_raw(struct pipe_transfer *pt, uint x, uint y, uint w, uint h, const void *p, int src_stride); void -pipe_get_tile_rgba(struct pipe_surface *ps, +pipe_get_tile_rgba(struct pipe_transfer *pt, uint x, uint y, uint w, uint h, float *p); void -pipe_put_tile_rgba(struct pipe_surface *ps, +pipe_put_tile_rgba(struct pipe_transfer *pt, uint x, uint y, uint w, uint h, const float *p); void -pipe_get_tile_z(struct pipe_surface *ps, +pipe_get_tile_z(struct pipe_transfer *pt, uint x, uint y, uint w, uint h, uint *z); void -pipe_put_tile_z(struct pipe_surface *ps, +pipe_put_tile_z(struct pipe_transfer *pt, uint x, uint y, uint w, uint h, const uint *z); |