From: Roland Scheidegger Date: Tue, 19 Feb 2013 20:18:29 +0000 (+0100) Subject: llvmpipe: lp_resource_copy cleanup X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=fbbcc1fcc4a1e9e8ab794378a55e797ebaa3ed0a;p=mesa.git llvmpipe: lp_resource_copy cleanup We don't need to flush resources for each layer, and since we don't actually care about layer at all in the flush function just drop the parameter. Also we can use util_copy_box instead of repeated util_copy_rect. Reviewed-by: Jose Fonseca --- diff --git a/src/gallium/drivers/llvmpipe/lp_flush.c b/src/gallium/drivers/llvmpipe/lp_flush.c index 964b792b739..cbfe564a781 100644 --- a/src/gallium/drivers/llvmpipe/lp_flush.c +++ b/src/gallium/drivers/llvmpipe/lp_flush.c @@ -98,7 +98,6 @@ boolean llvmpipe_flush_resource(struct pipe_context *pipe, struct pipe_resource *resource, unsigned level, - int layer, boolean read_only, boolean cpu_access, boolean do_not_block, @@ -106,7 +105,7 @@ llvmpipe_flush_resource(struct pipe_context *pipe, { unsigned referenced; - referenced = llvmpipe_is_resource_referenced(pipe, resource, level, layer); + referenced = llvmpipe_is_resource_referenced(pipe, resource, level); if ((referenced & LP_REFERENCED_FOR_WRITE) || ((referenced & LP_REFERENCED_FOR_READ) && !read_only)) { diff --git a/src/gallium/drivers/llvmpipe/lp_flush.h b/src/gallium/drivers/llvmpipe/lp_flush.h index efff94c8c0c..bc1e2a8ebcd 100644 --- a/src/gallium/drivers/llvmpipe/lp_flush.h +++ b/src/gallium/drivers/llvmpipe/lp_flush.h @@ -47,7 +47,6 @@ boolean llvmpipe_flush_resource(struct pipe_context *pipe, struct pipe_resource *resource, unsigned level, - int layer, boolean read_only, boolean cpu_access, boolean do_not_block, diff --git a/src/gallium/drivers/llvmpipe/lp_surface.c b/src/gallium/drivers/llvmpipe/lp_surface.c index dbaed95d2d5..a83a9033c40 100644 --- a/src/gallium/drivers/llvmpipe/lp_surface.c +++ b/src/gallium/drivers/llvmpipe/lp_surface.c @@ -57,14 +57,12 @@ lp_resource_copy(struct pipe_context *pipe, struct pipe_resource *src, unsigned src_level, const struct pipe_box *src_box) { - /* XXX this used to ignore srcz/dstz - * assume it works the same for cube and 3d - */ struct llvmpipe_resource *src_tex = llvmpipe_resource(src); struct llvmpipe_resource *dst_tex = llvmpipe_resource(dst); const enum pipe_format format = src_tex->base.format; unsigned width = src_box->width; unsigned height = src_box->height; + unsigned depth = src_box->depth; unsigned z; /* Fallback for buffers. */ @@ -74,27 +72,28 @@ lp_resource_copy(struct pipe_context *pipe, return; } + llvmpipe_flush_resource(pipe, + dst, dst_level, + FALSE, /* read_only */ + TRUE, /* cpu_access */ + FALSE, /* do_not_block */ + "blit dest"); + + llvmpipe_flush_resource(pipe, + src, src_level, + TRUE, /* read_only */ + TRUE, /* cpu_access */ + FALSE, /* do_not_block */ + "blit src"); + + /* + printf("surface copy from %u lvl %u to %u lvl %u: %u,%u,%u to %u,%u,%u %u x %u x %u\n", + src_tex->id, src_level, dst_tex->id, dst_level, + src_box->x, src_box->y, src_box->z, dstx, dsty, dstz, + src_box->width, src_box->height, src_box->depth); + */ + for (z = 0; z < src_box->depth; z++){ - llvmpipe_flush_resource(pipe, - dst, dst_level, dstz + z, - FALSE, /* read_only */ - TRUE, /* cpu_access */ - FALSE, /* do_not_block */ - "blit dest"); - - llvmpipe_flush_resource(pipe, - src, src_level, src_box->z + z, - TRUE, /* read_only */ - TRUE, /* cpu_access */ - FALSE, /* do_not_block */ - "blit src"); - - /* - printf("surface copy from %u lvl %u to %u lvl %u: %u,%u,%u to %u,%u,%u %u x %u x %u\n", - src_tex->id, src_level, dst_tex->id, dst_level, - src_box->x, src_box->y, src_box->z, dstx, dsty, dstz, - src_box->width, src_box->height, src_box->depth); - */ /* set src tiles to linear layout */ { @@ -148,27 +147,29 @@ lp_resource_copy(struct pipe_context *pipe, } } } + } - /* copy */ - { - const ubyte *src_linear_ptr - = llvmpipe_get_texture_image_address(src_tex, src_box->z + z, - src_level, - LP_TEX_LAYOUT_LINEAR); - ubyte *dst_linear_ptr - = llvmpipe_get_texture_image_address(dst_tex, dstz + z, - dst_level, - LP_TEX_LAYOUT_LINEAR); - - if (dst_linear_ptr && src_linear_ptr) { - util_copy_rect(dst_linear_ptr, format, - llvmpipe_resource_stride(&dst_tex->base, dst_level), - dstx, dsty, - width, height, - src_linear_ptr, - llvmpipe_resource_stride(&src_tex->base, src_level), - src_box->x, src_box->y); - } + /* copy */ + { + const ubyte *src_linear_ptr + = llvmpipe_get_texture_image_address(src_tex, src_box->z, + src_level, + LP_TEX_LAYOUT_LINEAR); + ubyte *dst_linear_ptr + = llvmpipe_get_texture_image_address(dst_tex, dstz, + dst_level, + LP_TEX_LAYOUT_LINEAR); + + if (dst_linear_ptr && src_linear_ptr) { + util_copy_box(dst_linear_ptr, format, + llvmpipe_resource_stride(&dst_tex->base, dst_level), + dst_tex->img_stride[dst_level], + dstx, dsty, 0, + width, height, depth, + src_linear_ptr, + llvmpipe_resource_stride(&src_tex->base, src_level), + src_tex->img_stride[src_level], + src_box->x, src_box->y, 0); } } } diff --git a/src/gallium/drivers/llvmpipe/lp_texture.c b/src/gallium/drivers/llvmpipe/lp_texture.c index ce756c52897..1c4f1dc20f6 100644 --- a/src/gallium/drivers/llvmpipe/lp_texture.c +++ b/src/gallium/drivers/llvmpipe/lp_texture.c @@ -655,7 +655,6 @@ llvmpipe_transfer_map( struct pipe_context *pipe, boolean do_not_block = !!(usage & PIPE_TRANSFER_DONTBLOCK); if (!llvmpipe_flush_resource(pipe, resource, level, - box->depth > 1 ? -1 : box->z, read_only, TRUE, /* cpu_access */ do_not_block, @@ -757,7 +756,7 @@ llvmpipe_transfer_unmap(struct pipe_context *pipe, unsigned int llvmpipe_is_resource_referenced( struct pipe_context *pipe, struct pipe_resource *presource, - unsigned level, int layer) + unsigned level) { struct llvmpipe_context *llvmpipe = llvmpipe_context( pipe ); diff --git a/src/gallium/drivers/llvmpipe/lp_texture.h b/src/gallium/drivers/llvmpipe/lp_texture.h index 97a5547bd89..172228dc3fb 100644 --- a/src/gallium/drivers/llvmpipe/lp_texture.h +++ b/src/gallium/drivers/llvmpipe/lp_texture.h @@ -242,7 +242,7 @@ llvmpipe_init_context_texture_funcs(struct pipe_context *pipe); unsigned int llvmpipe_is_resource_referenced( struct pipe_context *pipe, struct pipe_resource *presource, - unsigned level, int layer); + unsigned level); unsigned llvmpipe_get_format_alignment(enum pipe_format format);