From 54db46582aba2252d544fa3956522f9ef06b49cb Mon Sep 17 00:00:00 2001 From: marha Date: Mon, 15 Oct 2012 16:50:35 +0200 Subject: xserver mesa pixman git update 15 oct 2012 xserver: a69429a17bf4630f6e26f61630a1c2b287202627 pixman: d5f2f39319fc358cccda60abe0bc927bd27131c1 mesa: 4004620d34a580c8fdb965d9b640e97453fc8b28 --- mesalib/src/gallium/auxiliary/util/u_blitter.c | 5 +- mesalib/src/gallium/auxiliary/util/u_blitter.h | 3 +- mesalib/src/gallium/auxiliary/util/u_debug.c | 29 +++--- mesalib/src/gallium/auxiliary/util/u_debug.h | 4 +- mesalib/src/gallium/auxiliary/util/u_format_s3tc.c | 5 +- mesalib/src/gallium/auxiliary/util/u_gen_mipmap.c | 62 +++++------- mesalib/src/gallium/auxiliary/util/u_inlines.h | 66 ++++--------- mesalib/src/gallium/auxiliary/util/u_pstipple.c | 6 +- mesalib/src/gallium/auxiliary/util/u_resource.c | 28 ++---- mesalib/src/gallium/auxiliary/util/u_slab.h | 2 +- mesalib/src/gallium/auxiliary/util/u_surface.c | 74 ++++++--------- mesalib/src/gallium/auxiliary/util/u_tile.c | 105 +++++++-------------- mesalib/src/gallium/auxiliary/util/u_tile.h | 52 +++++----- mesalib/src/gallium/auxiliary/util/u_transfer.c | 50 ++-------- mesalib/src/gallium/auxiliary/util/u_transfer.h | 44 +++------ mesalib/src/gallium/auxiliary/util/u_upload_mgr.c | 4 +- 16 files changed, 189 insertions(+), 350 deletions(-) (limited to 'mesalib/src/gallium') diff --git a/mesalib/src/gallium/auxiliary/util/u_blitter.c b/mesalib/src/gallium/auxiliary/util/u_blitter.c index 4ad7a6be4..1072a0e9a 100644 --- a/mesalib/src/gallium/auxiliary/util/u_blitter.c +++ b/mesalib/src/gallium/auxiliary/util/u_blitter.c @@ -1704,7 +1704,8 @@ void util_blitter_custom_resolve_color(struct blitter_context *blitter, struct pipe_resource *src, unsigned src_layer, unsigned sample_mask, - void *custom_blend) + void *custom_blend, + enum pipe_format format) { struct blitter_context_priv *ctx = (struct blitter_context_priv*)blitter; struct pipe_context *pipe = ctx->base.pipe; @@ -1724,7 +1725,7 @@ void util_blitter_custom_resolve_color(struct blitter_context *blitter, pipe->set_sample_mask(pipe, sample_mask); memset(&surf_tmpl, 0, sizeof(surf_tmpl)); - surf_tmpl.format = dst->format; + surf_tmpl.format = format; surf_tmpl.u.tex.level = dst_level; surf_tmpl.u.tex.first_layer = dst_layer; surf_tmpl.u.tex.last_layer = dst_layer; diff --git a/mesalib/src/gallium/auxiliary/util/u_blitter.h b/mesalib/src/gallium/auxiliary/util/u_blitter.h index 40636c616..4f7146701 100644 --- a/mesalib/src/gallium/auxiliary/util/u_blitter.h +++ b/mesalib/src/gallium/auxiliary/util/u_blitter.h @@ -344,7 +344,8 @@ void util_blitter_custom_resolve_color(struct blitter_context *blitter, struct pipe_resource *src, unsigned src_layer, unsigned sampled_mask, - void *custom_blend); + void *custom_blend, + enum pipe_format format); /* The functions below should be used to save currently bound constant state * objects inside a driver. The objects are automatically restored at the end diff --git a/mesalib/src/gallium/auxiliary/util/u_debug.c b/mesalib/src/gallium/auxiliary/util/u_debug.c index bf98f222e..c41585fdd 100644 --- a/mesalib/src/gallium/auxiliary/util/u_debug.c +++ b/mesalib/src/gallium/auxiliary/util/u_debug.c @@ -516,14 +516,12 @@ void debug_dump_surface(struct pipe_context *pipe, */ texture = surface->texture; - transfer = pipe_get_transfer(pipe, texture, surface->u.tex.level, - surface->u.tex.first_layer, - PIPE_TRANSFER_READ, - 0, 0, surface->width, surface->height); - - data = pipe->transfer_map(pipe, transfer); + data = pipe_transfer_map(pipe, texture, surface->u.tex.level, + surface->u.tex.first_layer, + PIPE_TRANSFER_READ, + 0, 0, surface->width, surface->height, &transfer); if(!data) - goto error; + return; debug_dump_image(prefix, texture->format, @@ -534,8 +532,6 @@ void debug_dump_surface(struct pipe_context *pipe, data); pipe->transfer_unmap(pipe, transfer); -error: - pipe->transfer_destroy(pipe, transfer); } @@ -597,20 +593,21 @@ debug_dump_surface_bmp(struct pipe_context *pipe, { struct pipe_transfer *transfer; struct pipe_resource *texture = surface->texture; + void *ptr; - transfer = pipe_get_transfer(pipe, texture, surface->u.tex.level, - surface->u.tex.first_layer, PIPE_TRANSFER_READ, - 0, 0, surface->width, surface->height); + ptr = pipe_transfer_map(pipe, texture, surface->u.tex.level, + surface->u.tex.first_layer, PIPE_TRANSFER_READ, + 0, 0, surface->width, surface->height, &transfer); - debug_dump_transfer_bmp(pipe, filename, transfer); + debug_dump_transfer_bmp(pipe, filename, transfer, ptr); - pipe->transfer_destroy(pipe, transfer); + pipe->transfer_unmap(pipe, transfer); } void debug_dump_transfer_bmp(struct pipe_context *pipe, const char *filename, - struct pipe_transfer *transfer) + struct pipe_transfer *transfer, void *ptr) { float *rgba; @@ -624,7 +621,7 @@ debug_dump_transfer_bmp(struct pipe_context *pipe, if(!rgba) goto error1; - pipe_get_tile_rgba(pipe, transfer, 0, 0, + pipe_get_tile_rgba(transfer, ptr, 0, 0, transfer->box.width, transfer->box.height, rgba); diff --git a/mesalib/src/gallium/auxiliary/util/u_debug.h b/mesalib/src/gallium/auxiliary/util/u_debug.h index 06470f66a..ec7d4a07a 100644 --- a/mesalib/src/gallium/auxiliary/util/u_debug.h +++ b/mesalib/src/gallium/auxiliary/util/u_debug.h @@ -433,7 +433,7 @@ void debug_dump_surface_bmp(struct pipe_context *pipe, struct pipe_surface *surface); void debug_dump_transfer_bmp(struct pipe_context *pipe, const char *filename, - struct pipe_transfer *transfer); + struct pipe_transfer *transfer, void *ptr); void debug_dump_float_rgba_bmp(const char *filename, unsigned width, unsigned height, float *rgba, unsigned stride); @@ -441,7 +441,7 @@ void debug_dump_float_rgba_bmp(const char *filename, #define debug_dump_image(prefix, format, cpp, width, height, stride, data) ((void)0) #define debug_dump_surface(pipe, prefix, surface) ((void)0) #define debug_dump_surface_bmp(pipe, filename, surface) ((void)0) -#define debug_dump_transfer_bmp(filename, transfer) ((void)0) +#define debug_dump_transfer_bmp(filename, transfer, ptr) ((void)0) #define debug_dump_float_rgba_bmp(filename, width, height, rgba, stride) ((void)0) #endif diff --git a/mesalib/src/gallium/auxiliary/util/u_format_s3tc.c b/mesalib/src/gallium/auxiliary/util/u_format_s3tc.c index d8a7c0d45..4a9dc2237 100644 --- a/mesalib/src/gallium/auxiliary/util/u_format_s3tc.c +++ b/mesalib/src/gallium/auxiliary/util/u_format_s3tc.c @@ -109,6 +109,7 @@ util_format_s3tc_init(void) util_dl_proc fetch_2d_texel_rgba_dxt3; util_dl_proc fetch_2d_texel_rgba_dxt5; util_dl_proc tx_compress_dxtn; + char *force_s3tc_enable; if (!first_time) return; @@ -119,8 +120,8 @@ util_format_s3tc_init(void) library = util_dl_open(DXTN_LIBNAME); if (!library) { - if (getenv("force_s3tc_enable") && - !strcmp(getenv("force_s3tc_enable"), "true")) { + if ((force_s3tc_enable = getenv("force_s3tc_enable")) && + !strcmp(force_s3tc_enable, "true")) { debug_printf("couldn't open " DXTN_LIBNAME ", enabling DXTn due to " "force_s3tc_enable=true environment variable\n"); util_format_s3tc_enabled = TRUE; diff --git a/mesalib/src/gallium/auxiliary/util/u_gen_mipmap.c b/mesalib/src/gallium/auxiliary/util/u_gen_mipmap.c index c82c52c84..4d8adb9f3 100644 --- a/mesalib/src/gallium/auxiliary/util/u_gen_mipmap.c +++ b/mesalib/src/gallium/auxiliary/util/u_gen_mipmap.c @@ -1111,17 +1111,14 @@ make_1d_mipmap(struct gen_mipmap_state *ctx, struct pipe_transfer *srcTrans, *dstTrans; void *srcMap, *dstMap; - srcTrans = pipe_get_transfer(pipe, pt, srcLevel, layer, - PIPE_TRANSFER_READ, 0, 0, - u_minify(pt->width0, srcLevel), - u_minify(pt->height0, srcLevel)); - dstTrans = pipe_get_transfer(pipe, pt, dstLevel, layer, - PIPE_TRANSFER_WRITE, 0, 0, - u_minify(pt->width0, dstLevel), - u_minify(pt->height0, dstLevel)); - - srcMap = (ubyte *) pipe->transfer_map(pipe, srcTrans); - dstMap = (ubyte *) pipe->transfer_map(pipe, dstTrans); + srcMap = pipe_transfer_map(pipe, pt, srcLevel, layer, + PIPE_TRANSFER_READ, 0, 0, + u_minify(pt->width0, srcLevel), + u_minify(pt->height0, srcLevel), &srcTrans); + dstMap = pipe_transfer_map(pipe, pt, dstLevel, layer, + PIPE_TRANSFER_WRITE, 0, 0, + u_minify(pt->width0, dstLevel), + u_minify(pt->height0, dstLevel), &dstTrans); reduce_1d(pt->format, srcTrans->box.width, srcMap, @@ -1129,9 +1126,6 @@ make_1d_mipmap(struct gen_mipmap_state *ctx, pipe->transfer_unmap(pipe, srcTrans); pipe->transfer_unmap(pipe, dstTrans); - - pipe->transfer_destroy(pipe, srcTrans); - pipe->transfer_destroy(pipe, dstTrans); } } @@ -1152,17 +1146,14 @@ make_2d_mipmap(struct gen_mipmap_state *ctx, struct pipe_transfer *srcTrans, *dstTrans; ubyte *srcMap, *dstMap; - srcTrans = pipe_get_transfer(pipe, pt, srcLevel, layer, - PIPE_TRANSFER_READ, 0, 0, - u_minify(pt->width0, srcLevel), - u_minify(pt->height0, srcLevel)); - dstTrans = pipe_get_transfer(pipe, pt, dstLevel, layer, - PIPE_TRANSFER_WRITE, 0, 0, - u_minify(pt->width0, dstLevel), - u_minify(pt->height0, dstLevel)); - - srcMap = (ubyte *) pipe->transfer_map(pipe, srcTrans); - dstMap = (ubyte *) pipe->transfer_map(pipe, dstTrans); + srcMap = pipe_transfer_map(pipe, pt, srcLevel, layer, + PIPE_TRANSFER_READ, 0, 0, + u_minify(pt->width0, srcLevel), + u_minify(pt->height0, srcLevel), &srcTrans); + dstMap = pipe_transfer_map(pipe, pt, dstLevel, layer, + PIPE_TRANSFER_WRITE, 0, 0, + u_minify(pt->width0, dstLevel), + u_minify(pt->height0, dstLevel), &dstTrans); reduce_2d(pt->format, srcTrans->box.width, srcTrans->box.height, @@ -1172,9 +1163,6 @@ make_2d_mipmap(struct gen_mipmap_state *ctx, pipe->transfer_unmap(pipe, srcTrans); pipe->transfer_unmap(pipe, dstTrans); - - pipe->transfer_destroy(pipe, srcTrans); - pipe->transfer_destroy(pipe, dstTrans); } } @@ -1207,15 +1195,12 @@ make_3d_mipmap(struct gen_mipmap_state *ctx, dst_box.height = u_minify(pt->height0, dstLevel); dst_box.depth = u_minify(pt->depth0, dstLevel); - srcTrans = pipe->get_transfer(pipe, pt, srcLevel, - PIPE_TRANSFER_READ, - &src_box); - dstTrans = pipe->get_transfer(pipe, pt, dstLevel, - PIPE_TRANSFER_WRITE, - &dst_box); - - srcMap = (ubyte *) pipe->transfer_map(pipe, srcTrans); - dstMap = (ubyte *) pipe->transfer_map(pipe, dstTrans); + srcMap = pipe->transfer_map(pipe, pt, srcLevel, + PIPE_TRANSFER_READ, + &src_box, &srcTrans); + dstMap = pipe->transfer_map(pipe, pt, dstLevel, + PIPE_TRANSFER_WRITE, + &dst_box, &dstTrans); reduce_3d(pt->format, srcTrans->box.width, srcTrans->box.height, srcTrans->box.depth, @@ -1225,9 +1210,6 @@ make_3d_mipmap(struct gen_mipmap_state *ctx, pipe->transfer_unmap(pipe, srcTrans); pipe->transfer_unmap(pipe, dstTrans); - - pipe->transfer_destroy(pipe, srcTrans); - pipe->transfer_destroy(pipe, dstTrans); } } diff --git a/mesalib/src/gallium/auxiliary/util/u_inlines.h b/mesalib/src/gallium/auxiliary/util/u_inlines.h index 033c100ed..5c6e7eb32 100644 --- a/mesalib/src/gallium/auxiliary/util/u_inlines.h +++ b/mesalib/src/gallium/auxiliary/util/u_inlines.h @@ -251,19 +251,8 @@ pipe_buffer_map_range(struct pipe_context *pipe, u_box_1d(offset, length, &box); - *transfer = pipe->get_transfer( pipe, - buffer, - 0, - usage, - &box); - - if (*transfer == NULL) - return NULL; - - map = pipe->transfer_map( pipe, *transfer ); + map = pipe->transfer_map(pipe, buffer, 0, usage, &box, transfer); if (map == NULL) { - pipe->transfer_destroy( pipe, *transfer ); - *transfer = NULL; return NULL; } @@ -285,10 +274,7 @@ static INLINE void pipe_buffer_unmap(struct pipe_context *pipe, struct pipe_transfer *transfer) { - if (transfer) { - pipe->transfer_unmap(pipe, transfer); - pipe->transfer_destroy(pipe, transfer); - } + pipe->transfer_unmap(pipe, transfer); } static INLINE void @@ -397,35 +383,29 @@ pipe_buffer_read(struct pipe_context *pipe, offset, size, PIPE_TRANSFER_READ, &src_transfer); + if (!map) + return; - if (map) - memcpy(data, map, size); - + memcpy(data, map, size); pipe_buffer_unmap(pipe, src_transfer); } -static INLINE struct pipe_transfer * -pipe_get_transfer( struct pipe_context *context, - struct pipe_resource *resource, - unsigned level, unsigned layer, - enum pipe_transfer_usage usage, - unsigned x, unsigned y, - unsigned w, unsigned h) -{ - struct pipe_box box; - u_box_2d_zslice( x, y, layer, w, h, &box ); - return context->get_transfer( context, - resource, - level, - usage, - &box ); -} - static INLINE void * -pipe_transfer_map( struct pipe_context *context, - struct pipe_transfer *transfer ) +pipe_transfer_map(struct pipe_context *context, + struct pipe_resource *resource, + unsigned level, unsigned layer, + enum pipe_transfer_usage usage, + unsigned x, unsigned y, + unsigned w, unsigned h, + struct pipe_transfer **transfer) { - return context->transfer_map( context, transfer ); + struct pipe_box box; + u_box_2d_zslice(x, y, layer, w, h, &box); + return context->transfer_map(context, + resource, + level, + usage, + &box, transfer); } static INLINE void @@ -435,14 +415,6 @@ pipe_transfer_unmap( struct pipe_context *context, context->transfer_unmap( context, transfer ); } - -static INLINE void -pipe_transfer_destroy( struct pipe_context *context, - struct pipe_transfer *transfer ) -{ - context->transfer_destroy(context, transfer); -} - static INLINE void pipe_set_constant_buffer(struct pipe_context *pipe, uint shader, uint index, struct pipe_resource *buf) diff --git a/mesalib/src/gallium/auxiliary/util/u_pstipple.c b/mesalib/src/gallium/auxiliary/util/u_pstipple.c index 3a91b1da1..68804ae98 100644 --- a/mesalib/src/gallium/auxiliary/util/u_pstipple.c +++ b/mesalib/src/gallium/auxiliary/util/u_pstipple.c @@ -69,9 +69,8 @@ util_pstipple_update_stipple_texture(struct pipe_context *pipe, int i, j; /* map texture memory */ - transfer = pipe_get_transfer(pipe, tex, 0, 0, - PIPE_TRANSFER_WRITE, 0, 0, 32, 32); - data = pipe->transfer_map(pipe, transfer); + data = pipe_transfer_map(pipe, tex, 0, 0, + PIPE_TRANSFER_WRITE, 0, 0, 32, 32, &transfer); /* * Load alpha texture. @@ -94,7 +93,6 @@ util_pstipple_update_stipple_texture(struct pipe_context *pipe, /* unmap */ pipe->transfer_unmap(pipe, transfer); - pipe->transfer_destroy(pipe, transfer); } diff --git a/mesalib/src/gallium/auxiliary/util/u_resource.c b/mesalib/src/gallium/auxiliary/util/u_resource.c index 50a7cd4d5..a32c4f6df 100644 --- a/mesalib/src/gallium/auxiliary/util/u_resource.c +++ b/mesalib/src/gallium/auxiliary/util/u_resource.c @@ -24,28 +24,16 @@ void u_resource_destroy_vtbl(struct pipe_screen *screen, ur->vtbl->resource_destroy(screen, resource); } -struct pipe_transfer *u_get_transfer_vtbl(struct pipe_context *context, - struct pipe_resource *resource, - unsigned level, - unsigned usage, - const struct pipe_box *box) +void *u_transfer_map_vtbl(struct pipe_context *context, + struct pipe_resource *resource, + unsigned level, + unsigned usage, + const struct pipe_box *box, + struct pipe_transfer **transfer) { struct u_resource *ur = u_resource(resource); - return ur->vtbl->get_transfer(context, resource, level, usage, box); -} - -void u_transfer_destroy_vtbl(struct pipe_context *pipe, - struct pipe_transfer *transfer) -{ - struct u_resource *ur = u_resource(transfer->resource); - ur->vtbl->transfer_destroy(pipe, transfer); -} - -void *u_transfer_map_vtbl( struct pipe_context *pipe, - struct pipe_transfer *transfer ) -{ - struct u_resource *ur = u_resource(transfer->resource); - return ur->vtbl->transfer_map(pipe, transfer); + return ur->vtbl->transfer_map(context, resource, level, usage, box, + transfer); } void u_transfer_flush_region_vtbl( struct pipe_context *pipe, diff --git a/mesalib/src/gallium/auxiliary/util/u_slab.h b/mesalib/src/gallium/auxiliary/util/u_slab.h index 3ed8b12d3..29d0252ba 100644 --- a/mesalib/src/gallium/auxiliary/util/u_slab.h +++ b/mesalib/src/gallium/auxiliary/util/u_slab.h @@ -28,7 +28,7 @@ * Good for allocations which have very low lifetime and are allocated * and freed very often. Use a profiler first to know if it's worth using it! * - * Candidates: get_transfer + * Candidates: transfer_map * * @author Marek Olšák */ diff --git a/mesalib/src/gallium/auxiliary/util/u_surface.c b/mesalib/src/gallium/auxiliary/util/u_surface.c index 7fd6b3675..304da9070 100644 --- a/mesalib/src/gallium/auxiliary/util/u_surface.c +++ b/mesalib/src/gallium/auxiliary/util/u_surface.c @@ -145,27 +145,23 @@ util_resource_copy_region(struct pipe_context *pipe, src_format = src->format; dst_format = dst->format; - src_trans = pipe_get_transfer(pipe, - src, - src_level, - src_box->z, - PIPE_TRANSFER_READ, - src_box->x, src_box->y, w, h); - - dst_trans = pipe_get_transfer(pipe, - dst, - dst_level, - dst_z, - PIPE_TRANSFER_WRITE, - dst_x, dst_y, w, h); + src_map = pipe_transfer_map(pipe, + src, + src_level, + src_box->z, + PIPE_TRANSFER_READ, + src_box->x, src_box->y, w, h, &src_trans); + + dst_map = pipe_transfer_map(pipe, + dst, + dst_level, + dst_z, + PIPE_TRANSFER_WRITE, + dst_x, dst_y, w, h, &dst_trans); assert(util_format_get_blocksize(dst_format) == util_format_get_blocksize(src_format)); assert(util_format_get_blockwidth(dst_format) == util_format_get_blockwidth(src_format)); assert(util_format_get_blockheight(dst_format) == util_format_get_blockheight(src_format)); - - src_map = pipe->transfer_map(pipe, src_trans); - dst_map = pipe->transfer_map(pipe, dst_trans); - assert(src_map); assert(dst_map); @@ -187,9 +183,6 @@ util_resource_copy_region(struct pipe_context *pipe, pipe->transfer_unmap(pipe, src_trans); pipe->transfer_unmap(pipe, dst_trans); - - pipe->transfer_destroy(pipe, src_trans); - pipe->transfer_destroy(pipe, dst_trans); } @@ -219,14 +212,12 @@ util_clear_render_target(struct pipe_context *pipe, if (!dst->texture) return; /* XXX: should handle multiple layers */ - dst_trans = pipe_get_transfer(pipe, - dst->texture, - dst->u.tex.level, - dst->u.tex.first_layer, - PIPE_TRANSFER_WRITE, - dstx, dsty, width, height); - - dst_map = pipe->transfer_map(pipe, dst_trans); + dst_map = pipe_transfer_map(pipe, + dst->texture, + dst->u.tex.level, + dst->u.tex.first_layer, + PIPE_TRANSFER_WRITE, + dstx, dsty, width, height, &dst_trans); assert(dst_map); @@ -237,10 +228,9 @@ util_clear_render_target(struct pipe_context *pipe, util_fill_rect(dst_map, dst->texture->format, dst_trans->stride, 0, 0, width, height, &uc); - } - pipe->transfer_unmap(pipe, dst_trans); - pipe->transfer_destroy(pipe, dst_trans); + pipe->transfer_unmap(pipe, dst_trans); + } } /** @@ -270,16 +260,13 @@ util_clear_depth_stencil(struct pipe_context *pipe, assert(dst->texture); if (!dst->texture) return; - dst_trans = pipe_get_transfer(pipe, - dst->texture, - dst->u.tex.level, - dst->u.tex.first_layer, - (need_rmw ? PIPE_TRANSFER_READ_WRITE : - PIPE_TRANSFER_WRITE), - dstx, dsty, width, height); - - dst_map = pipe->transfer_map(pipe, dst_trans); - + dst_map = pipe_transfer_map(pipe, + dst->texture, + dst->u.tex.level, + dst->u.tex.first_layer, + (need_rmw ? PIPE_TRANSFER_READ_WRITE : + PIPE_TRANSFER_WRITE), + dstx, dsty, width, height, &dst_trans); assert(dst_map); if (dst_map) { @@ -376,8 +363,7 @@ util_clear_depth_stencil(struct pipe_context *pipe, assert(0); break; } - } - pipe->transfer_unmap(pipe, dst_trans); - pipe->transfer_destroy(pipe, dst_trans); + pipe->transfer_unmap(pipe, dst_trans); + } } diff --git a/mesalib/src/gallium/auxiliary/util/u_tile.c b/mesalib/src/gallium/auxiliary/util/u_tile.c index 48e73c40b..f4b5cad0e 100644 --- a/mesalib/src/gallium/auxiliary/util/u_tile.c +++ b/mesalib/src/gallium/auxiliary/util/u_tile.c @@ -45,27 +45,18 @@ * Move raw block of pixels from transfer object to user memory. */ void -pipe_get_tile_raw(struct pipe_context *pipe, - struct pipe_transfer *pt, +pipe_get_tile_raw(struct pipe_transfer *pt, + const void *src, uint x, uint y, uint w, uint h, void *dst, int dst_stride) { - const void *src; - if (dst_stride == 0) dst_stride = util_format_get_stride(pt->resource->format, w); if (u_clip_tile(x, y, &w, &h, &pt->box)) return; - src = pipe->transfer_map(pipe, pt); - assert(src); - if(!src) - return; - util_copy_rect(dst, pt->resource->format, dst_stride, 0, 0, w, h, src, pt->stride, x, y); - - pipe->transfer_unmap(pipe, pt); } @@ -73,12 +64,11 @@ pipe_get_tile_raw(struct pipe_context *pipe, * Move raw block of pixels from user memory to transfer object. */ void -pipe_put_tile_raw(struct pipe_context *pipe, - struct pipe_transfer *pt, +pipe_put_tile_raw(struct pipe_transfer *pt, + void *dst, uint x, uint y, uint w, uint h, const void *src, int src_stride) { - void *dst; enum pipe_format format = pt->resource->format; if (src_stride == 0) @@ -87,14 +77,7 @@ pipe_put_tile_raw(struct pipe_context *pipe, if (u_clip_tile(x, y, &w, &h, &pt->box)) return; - dst = pipe->transfer_map(pipe, pt); - assert(dst); - if(!dst) - return; - util_copy_rect(dst, format, pt->stride, x, y, w, h, src, src_stride, 0, 0); - - pipe->transfer_unmap(pipe, pt); } @@ -372,7 +355,7 @@ x32_s8_get_tile_rgba(const unsigned *src, void pipe_tile_raw_to_rgba(enum pipe_format format, - void *src, + const void *src, uint w, uint h, float *dst, unsigned dst_stride) { @@ -419,7 +402,7 @@ pipe_tile_raw_to_rgba(enum pipe_format format, void pipe_tile_raw_to_unsigned(enum pipe_format format, - void *src, + const void *src, uint w, uint h, unsigned *dst, unsigned dst_stride) { @@ -442,18 +425,18 @@ pipe_tile_raw_to_signed(enum pipe_format format, } void -pipe_get_tile_rgba(struct pipe_context *pipe, - struct pipe_transfer *pt, +pipe_get_tile_rgba(struct pipe_transfer *pt, + const void *src, uint x, uint y, uint w, uint h, float *p) { - pipe_get_tile_rgba_format(pipe, pt, x, y, w, h, pt->resource->format, p); + pipe_get_tile_rgba_format(pt, src, x, y, w, h, pt->resource->format, p); } void -pipe_get_tile_rgba_format(struct pipe_context *pipe, - struct pipe_transfer *pt, +pipe_get_tile_rgba_format(struct pipe_transfer *pt, + const void *src, uint x, uint y, uint w, uint h, enum pipe_format format, float *p) @@ -474,7 +457,7 @@ pipe_get_tile_rgba_format(struct pipe_context *pipe, assert((x & 1) == 0); } - pipe_get_tile_raw(pipe, pt, x, y, w, h, packed, 0); + pipe_get_tile_raw(pt, src, x, y, w, h, packed, 0); pipe_tile_raw_to_rgba(format, packed, w, h, p, dst_stride); @@ -483,18 +466,18 @@ pipe_get_tile_rgba_format(struct pipe_context *pipe, void -pipe_put_tile_rgba(struct pipe_context *pipe, - struct pipe_transfer *pt, +pipe_put_tile_rgba(struct pipe_transfer *pt, + void *dst, uint x, uint y, uint w, uint h, const float *p) { - pipe_put_tile_rgba_format(pipe, pt, x, y, w, h, pt->resource->format, p); + pipe_put_tile_rgba_format(pt, dst, x, y, w, h, pt->resource->format, p); } void -pipe_put_tile_rgba_format(struct pipe_context *pipe, - struct pipe_transfer *pt, +pipe_put_tile_rgba_format(struct pipe_transfer *pt, + void *dst, uint x, uint y, uint w, uint h, enum pipe_format format, const float *p) @@ -538,14 +521,14 @@ pipe_put_tile_rgba_format(struct pipe_context *pipe, 0, 0, w, h); } - pipe_put_tile_raw(pipe, pt, x, y, w, h, packed, 0); + pipe_put_tile_raw(pt, dst, x, y, w, h, packed, 0); FREE(packed); } void -pipe_put_tile_i_format(struct pipe_context *pipe, - struct pipe_transfer *pt, +pipe_put_tile_i_format(struct pipe_transfer *pt, + void *dst, uint x, uint y, uint w, uint h, enum pipe_format format, const int *p) @@ -566,14 +549,14 @@ pipe_put_tile_i_format(struct pipe_context *pipe, packed, util_format_get_stride(format, w), 0, 0, w, h); - pipe_put_tile_raw(pipe, pt, x, y, w, h, packed, 0); + pipe_put_tile_raw(pt, dst, x, y, w, h, packed, 0); FREE(packed); } void -pipe_put_tile_ui_format(struct pipe_context *pipe, - struct pipe_transfer *pt, +pipe_put_tile_ui_format(struct pipe_transfer *pt, + void *dst, uint x, uint y, uint w, uint h, enum pipe_format format, const unsigned int *p) @@ -594,7 +577,7 @@ pipe_put_tile_ui_format(struct pipe_context *pipe, packed, util_format_get_stride(format, w), 0, 0, w, h); - pipe_put_tile_raw(pipe, pt, x, y, w, h, packed, 0); + pipe_put_tile_raw(pt, dst, x, y, w, h, packed, 0); FREE(packed); } @@ -603,13 +586,13 @@ pipe_put_tile_ui_format(struct pipe_context *pipe, * Get a block of Z values, converted to 32-bit range. */ void -pipe_get_tile_z(struct pipe_context *pipe, - struct pipe_transfer *pt, +pipe_get_tile_z(struct pipe_transfer *pt, + const void *src, uint x, uint y, uint w, uint h, uint *z) { const uint dstStride = w; - ubyte *map; + const ubyte *map = src; uint *pDest = z; uint i, j; enum pipe_format format = pt->resource->format; @@ -617,12 +600,6 @@ pipe_get_tile_z(struct pipe_context *pipe, if (u_clip_tile(x, y, &w, &h, &pt->box)) return; - map = (ubyte *)pipe->transfer_map(pipe, pt); - if (!map) { - assert(0); - return; - } - switch (format) { case PIPE_FORMAT_Z32_UNORM: { @@ -704,32 +681,24 @@ pipe_get_tile_z(struct pipe_context *pipe, default: assert(0); } - - pipe->transfer_unmap(pipe, pt); } void -pipe_put_tile_z(struct pipe_context *pipe, - struct pipe_transfer *pt, +pipe_put_tile_z(struct pipe_transfer *pt, + void *dst, uint x, uint y, uint w, uint h, const uint *zSrc) { const uint srcStride = w; const uint *ptrc = zSrc; - ubyte *map; + ubyte *map = dst; uint i, j; enum pipe_format format = pt->resource->format; if (u_clip_tile(x, y, &w, &h, &pt->box)) return; - map = (ubyte *)pipe->transfer_map(pipe, pt); - if (!map) { - assert(0); - return; - } - switch (format) { case PIPE_FORMAT_Z32_UNORM: { @@ -825,14 +794,12 @@ pipe_put_tile_z(struct pipe_context *pipe, default: assert(0); } - - pipe->transfer_unmap(pipe, pt); } void -pipe_get_tile_ui_format(struct pipe_context *pipe, - struct pipe_transfer *pt, +pipe_get_tile_ui_format(struct pipe_transfer *pt, + const void *src, uint x, uint y, uint w, uint h, enum pipe_format format, unsigned int *p) @@ -853,7 +820,7 @@ pipe_get_tile_ui_format(struct pipe_context *pipe, assert((x & 1) == 0); } - pipe_get_tile_raw(pipe, pt, x, y, w, h, packed, 0); + pipe_get_tile_raw(pt, src, x, y, w, h, packed, 0); pipe_tile_raw_to_unsigned(format, packed, w, h, p, dst_stride); @@ -862,8 +829,8 @@ pipe_get_tile_ui_format(struct pipe_context *pipe, void -pipe_get_tile_i_format(struct pipe_context *pipe, - struct pipe_transfer *pt, +pipe_get_tile_i_format(struct pipe_transfer *pt, + const void *src, uint x, uint y, uint w, uint h, enum pipe_format format, int *p) @@ -884,7 +851,7 @@ pipe_get_tile_i_format(struct pipe_context *pipe, assert((x & 1) == 0); } - pipe_get_tile_raw(pipe, pt, x, y, w, h, packed, 0); + pipe_get_tile_raw(pt, src, x, y, w, h, packed, 0); pipe_tile_raw_to_signed(format, packed, w, h, p, dst_stride); diff --git a/mesalib/src/gallium/auxiliary/util/u_tile.h b/mesalib/src/gallium/auxiliary/util/u_tile.h index 926f1695f..abcd402c8 100644 --- a/mesalib/src/gallium/auxiliary/util/u_tile.h +++ b/mesalib/src/gallium/auxiliary/util/u_tile.h @@ -61,66 +61,66 @@ extern "C" { #endif void -pipe_get_tile_raw(struct pipe_context *pipe, - struct pipe_transfer *pt, +pipe_get_tile_raw(struct pipe_transfer *pt, + const void *src, uint x, uint y, uint w, uint h, void *p, int dst_stride); void -pipe_put_tile_raw(struct pipe_context *pipe, - struct pipe_transfer *pt, +pipe_put_tile_raw(struct pipe_transfer *pt, + void *dst, uint x, uint y, uint w, uint h, const void *p, int src_stride); void -pipe_get_tile_rgba(struct pipe_context *pipe, - struct pipe_transfer *pt, +pipe_get_tile_rgba(struct pipe_transfer *pt, + const void *src, uint x, uint y, uint w, uint h, float *p); void -pipe_get_tile_rgba_format(struct pipe_context *pipe, - struct pipe_transfer *pt, +pipe_get_tile_rgba_format(struct pipe_transfer *pt, + const void *src, uint x, uint y, uint w, uint h, enum pipe_format format, float *p); void -pipe_put_tile_rgba(struct pipe_context *pipe, - struct pipe_transfer *pt, +pipe_put_tile_rgba(struct pipe_transfer *pt, + void *dst, uint x, uint y, uint w, uint h, const float *p); void -pipe_put_tile_rgba_format(struct pipe_context *pipe, - struct pipe_transfer *pt, +pipe_put_tile_rgba_format(struct pipe_transfer *pt, + void *dst, uint x, uint y, uint w, uint h, enum pipe_format format, const float *p); void -pipe_get_tile_z(struct pipe_context *pipe, - struct pipe_transfer *pt, +pipe_get_tile_z(struct pipe_transfer *pt, + const void *src, uint x, uint y, uint w, uint h, uint *z); void -pipe_put_tile_z(struct pipe_context *pipe, - struct pipe_transfer *pt, +pipe_put_tile_z(struct pipe_transfer *pt, + void *dst, uint x, uint y, uint w, uint h, const uint *z); void pipe_tile_raw_to_rgba(enum pipe_format format, - void *src, + const void *src, uint w, uint h, float *dst, unsigned dst_stride); void pipe_tile_raw_to_unsigned(enum pipe_format format, - void *src, + const void *src, uint w, uint h, unsigned *dst, unsigned dst_stride); @@ -131,29 +131,29 @@ pipe_tile_raw_to_signed(enum pipe_format format, int *dst, unsigned dst_stride); void -pipe_get_tile_ui_format(struct pipe_context *pipe, - struct pipe_transfer *pt, +pipe_get_tile_ui_format(struct pipe_transfer *pt, + const void *src, uint x, uint y, uint w, uint h, enum pipe_format format, unsigned int *p); void -pipe_get_tile_i_format(struct pipe_context *pipe, - struct pipe_transfer *pt, +pipe_get_tile_i_format(struct pipe_transfer *pt, + const void *src, uint x, uint y, uint w, uint h, enum pipe_format format, int *p); void -pipe_put_tile_ui_format(struct pipe_context *pipe, - struct pipe_transfer *pt, +pipe_put_tile_ui_format(struct pipe_transfer *pt, + void *dst, uint x, uint y, uint w, uint h, enum pipe_format format, const unsigned *p); void -pipe_put_tile_i_format(struct pipe_context *pipe, - struct pipe_transfer *pt, +pipe_put_tile_i_format(struct pipe_transfer *pt, + void *dst, uint x, uint y, uint w, uint h, enum pipe_format format, const int *p); diff --git a/mesalib/src/gallium/auxiliary/util/u_transfer.c b/mesalib/src/gallium/auxiliary/util/u_transfer.c index 0b2679ffd..8b4c36592 100644 --- a/mesalib/src/gallium/auxiliary/util/u_transfer.c +++ b/mesalib/src/gallium/auxiliary/util/u_transfer.c @@ -31,17 +31,13 @@ void u_default_transfer_inline_write( struct pipe_context *pipe, usage |= PIPE_TRANSFER_DISCARD_RANGE; } - transfer = pipe->get_transfer(pipe, - resource, - level, - usage, - box ); - if (transfer == NULL) - goto out; - - map = pipe_transfer_map(pipe, transfer); + map = pipe->transfer_map(pipe, + resource, + level, + usage, + box, &transfer); if (map == NULL) - goto out; + return; if (resource->target == PIPE_BUFFER) { assert(box->height == 1); @@ -68,12 +64,7 @@ void u_default_transfer_inline_write( struct pipe_context *pipe, } } -out: - if (map) - pipe_transfer_unmap(pipe, transfer); - - if (transfer) - pipe_transfer_destroy(pipe, transfer); + pipe_transfer_unmap(pipe, transfer); } @@ -94,34 +85,7 @@ void u_default_transfer_flush_region( struct pipe_context *pipe, */ } -struct pipe_transfer * u_default_get_transfer(struct pipe_context *context, - struct pipe_resource *resource, - unsigned level, - unsigned usage, - const struct pipe_box *box) -{ - struct pipe_transfer *transfer = CALLOC_STRUCT(pipe_transfer); - if (transfer == NULL) - return NULL; - - transfer->resource = resource; - transfer->level = level; - transfer->usage = usage; - transfer->box = *box; - - /* Note strides are zero, this is ok for buffers, but not for - * textures 2d & higher at least. - */ - return transfer; -} - void u_default_transfer_unmap( struct pipe_context *pipe, struct pipe_transfer *transfer ) { } - -void u_default_transfer_destroy(struct pipe_context *pipe, - struct pipe_transfer *transfer) -{ - FREE(transfer); -} diff --git a/mesalib/src/gallium/auxiliary/util/u_transfer.h b/mesalib/src/gallium/auxiliary/util/u_transfer.h index f4fdf9a48..6c25ee0f0 100644 --- a/mesalib/src/gallium/auxiliary/util/u_transfer.h +++ b/mesalib/src/gallium/auxiliary/util/u_transfer.h @@ -27,18 +27,9 @@ void u_default_transfer_flush_region( struct pipe_context *pipe, struct pipe_transfer *transfer, const struct pipe_box *box); -struct pipe_transfer * u_default_get_transfer(struct pipe_context *context, - struct pipe_resource *resource, - unsigned level, - unsigned usage, - const struct pipe_box *box); - void u_default_transfer_unmap( struct pipe_context *pipe, struct pipe_transfer *transfer ); -void u_default_transfer_destroy(struct pipe_context *pipe, - struct pipe_transfer *transfer); - /* Useful helper to allow >1 implementation of resource functionality @@ -53,24 +44,20 @@ struct u_resource_vtbl { void (*resource_destroy)(struct pipe_screen *, struct pipe_resource *pt); - struct pipe_transfer *(*get_transfer)(struct pipe_context *, - struct pipe_resource *resource, - unsigned level, - unsigned usage, - const struct pipe_box *); + void *(*transfer_map)(struct pipe_context *, + struct pipe_resource *resource, + unsigned level, + unsigned usage, + const struct pipe_box *, + struct pipe_transfer **); - void (*transfer_destroy)(struct pipe_context *, - struct pipe_transfer *); - - void *(*transfer_map)( struct pipe_context *, - struct pipe_transfer *transfer ); void (*transfer_flush_region)( struct pipe_context *, struct pipe_transfer *transfer, const struct pipe_box *); void (*transfer_unmap)( struct pipe_context *, - struct pipe_transfer *transfer ); + struct pipe_transfer *transfer ); void (*transfer_inline_write)( struct pipe_context *pipe, struct pipe_resource *resource, @@ -96,17 +83,12 @@ boolean u_resource_get_handle_vtbl(struct pipe_screen *screen, void u_resource_destroy_vtbl(struct pipe_screen *screen, struct pipe_resource *resource); -struct pipe_transfer *u_get_transfer_vtbl(struct pipe_context *context, - struct pipe_resource *resource, - unsigned level, - unsigned usage, - const struct pipe_box *box); - -void u_transfer_destroy_vtbl(struct pipe_context *pipe, - struct pipe_transfer *transfer); - -void *u_transfer_map_vtbl( struct pipe_context *pipe, - struct pipe_transfer *transfer ); +void *u_transfer_map_vtbl(struct pipe_context *context, + struct pipe_resource *resource, + unsigned level, + unsigned usage, + const struct pipe_box *box, + struct pipe_transfer **transfer); void u_transfer_flush_region_vtbl( struct pipe_context *pipe, struct pipe_transfer *transfer, diff --git a/mesalib/src/gallium/auxiliary/util/u_upload_mgr.c b/mesalib/src/gallium/auxiliary/util/u_upload_mgr.c index b4b4c91f1..b62973de6 100644 --- a/mesalib/src/gallium/auxiliary/util/u_upload_mgr.c +++ b/mesalib/src/gallium/auxiliary/util/u_upload_mgr.c @@ -82,7 +82,6 @@ void u_upload_unmap( struct u_upload_mgr *upload ) box->x, upload->offset - box->x); } pipe_transfer_unmap(upload->pipe, upload->transfer); - pipe_transfer_destroy(upload->pipe, upload->transfer); upload->transfer = NULL; upload->map = NULL; } @@ -142,13 +141,13 @@ u_upload_alloc_buffer( struct u_upload_mgr *upload, PIPE_TRANSFER_FLUSH_EXPLICIT, &upload->transfer); if (upload->map == NULL) { + upload->transfer = NULL; upload->size = 0; pipe_resource_reference(&upload->buffer, NULL); return PIPE_ERROR_OUT_OF_MEMORY; } upload->size = size; - upload->offset = 0; return PIPE_OK; } @@ -185,6 +184,7 @@ enum pipe_error u_upload_alloc( struct u_upload_mgr *upload, if (!upload->map) { pipe_resource_reference(outbuf, NULL); *ptr = NULL; + upload->transfer = NULL; return PIPE_ERROR_OUT_OF_MEMORY; } -- cgit v1.2.3