From ccfcf3287326b924d745d7915b0cb471f4c8e24e Mon Sep 17 00:00:00 2001 From: =?utf8?q?Marek=20Ol=C5=A1=C3=A1k?= Date: Wed, 19 Dec 2012 23:06:51 +0100 Subject: [PATCH] gallium/u_blitter: unify some parameters into a dstbox parameter in blit_generic Reviewed-by: Brian Paul --- src/gallium/auxiliary/util/u_blitter.c | 31 ++++++++++++++++++------------- src/gallium/auxiliary/util/u_blitter.h | 14 +++++++------- src/gallium/drivers/r300/r300_blit.c | 14 ++++++++------ src/gallium/drivers/r600/r600_blit.c | 8 +++++--- 4 files changed, 38 insertions(+), 29 deletions(-) diff --git a/src/gallium/auxiliary/util/u_blitter.c b/src/gallium/auxiliary/util/u_blitter.c index b6eca3e..8ce1e50 100644 --- a/src/gallium/auxiliary/util/u_blitter.c +++ b/src/gallium/auxiliary/util/u_blitter.c @@ -1175,10 +1175,14 @@ void util_blitter_copy_texture(struct blitter_context *blitter, struct pipe_context *pipe = ctx->base.pipe; struct pipe_surface *dst_view, dst_templ; struct pipe_sampler_view src_templ, *src_view; + struct pipe_box dstbox; assert(dst && src); assert(src->target < PIPE_MAX_TEXTURE_TYPES); + u_box_3d(dstx, dsty, dstz, abs(srcbox->width), abs(srcbox->height), + abs(srcbox->depth), &dstbox); + /* Initialize the surface. */ util_blitter_default_dst_texture(&dst_templ, dst, dst_level, dstz); dst_view = pipe->create_surface(pipe, dst, &dst_templ); @@ -1188,8 +1192,7 @@ void util_blitter_copy_texture(struct blitter_context *blitter, src_view = pipe->create_sampler_view(pipe, src, &src_templ); /* Copy. */ - util_blitter_blit_generic(blitter, dst_view, dstx, dsty, - abs(srcbox->width), abs(srcbox->height), + util_blitter_blit_generic(blitter, dst_view, &dstbox, src_view, srcbox, src->width0, src->height0, mask, PIPE_TEX_FILTER_NEAREST, NULL, copy_all_samples); @@ -1200,8 +1203,7 @@ void util_blitter_copy_texture(struct blitter_context *blitter, void util_blitter_blit_generic(struct blitter_context *blitter, struct pipe_surface *dst, - int dstx, int dsty, - unsigned dst_width, unsigned dst_height, + const struct pipe_box *dstbox, struct pipe_sampler_view *src, const struct pipe_box *srcbox, unsigned src_width0, unsigned src_height0, @@ -1293,7 +1295,8 @@ void util_blitter_blit_generic(struct blitter_context *blitter, if (filter == PIPE_TEX_FILTER_LINEAR && !blit_depth && !blit_stencil && src->texture->nr_samples <= 1 && - (dst_width != abs(srcbox->width) || dst_height != abs(srcbox->height))) { + (dstbox->width != abs(srcbox->width) || + dstbox->height != abs(srcbox->height))) { sampler_state = ctx->sampler_state_linear; } else { sampler_state = ctx->sampler_state; @@ -1364,8 +1367,9 @@ void util_blitter_blit_generic(struct blitter_context *blitter, /* Draw. */ pipe->set_sample_mask(pipe, ~0); - blitter->draw_rectangle(blitter, dstx, dsty, - dstx+dst_width, dsty+dst_height, 0, + blitter->draw_rectangle(blitter, dstbox->x, dstbox->y, + dstbox->x + dstbox->width, + dstbox->y + dstbox->height, 0, UTIL_BLITTER_ATTRIB_TEXCOORD, &coord); } else { /* Draw the quad with the generic codepath. */ @@ -1381,8 +1385,9 @@ void util_blitter_blit_generic(struct blitter_context *blitter, i, srcbox->x, srcbox->y, srcbox->x + srcbox->width, srcbox->y + srcbox->height); - blitter_draw(ctx, dstx, dsty, - dstx+dst_width, dsty+dst_height, 0); + blitter_draw(ctx, dstbox->x, dstbox->y, + dstbox->x + dstbox->width, + dstbox->y + dstbox->height, 0); } } else { pipe->set_sample_mask(pipe, ~0); @@ -1390,7 +1395,9 @@ void util_blitter_blit_generic(struct blitter_context *blitter, srcbox->x, srcbox->y, srcbox->x + srcbox->width, srcbox->y + srcbox->height); - blitter_draw(ctx, dstx, dsty, dstx+dst_width, dsty+dst_height, 0); + blitter_draw(ctx, dstbox->x, dstbox->y, + dstbox->x + dstbox->width, + dstbox->y + dstbox->height, 0); } } @@ -1428,9 +1435,7 @@ util_blitter_blit(struct blitter_context *blitter, src_view = pipe->create_sampler_view(pipe, src, &src_templ); /* Copy. */ - util_blitter_blit_generic(blitter, dst_view, - info->dst.box.x, info->dst.box.y, - info->dst.box.width, info->dst.box.height, + util_blitter_blit_generic(blitter, dst_view, &info->dst.box, src_view, &info->src.box, src->width0, src->height0, info->mask, info->filter, info->scissor_enable ? &info->scissor : NULL, TRUE); diff --git a/src/gallium/auxiliary/util/u_blitter.h b/src/gallium/auxiliary/util/u_blitter.h index 162f436..df8927b 100644 --- a/src/gallium/auxiliary/util/u_blitter.h +++ b/src/gallium/auxiliary/util/u_blitter.h @@ -217,14 +217,15 @@ void util_blitter_copy_texture(struct blitter_context *blitter, boolean copy_all_samples); /** - * Same as util_blitter_copy_texture with the capabilities of util_blitter_blit, - * but dst and src are pipe_surface and pipe_sampler_view, respectively. - * The mipmap level and dstz are part of the views. + * This is a generic implementation of pipe->blit, which accepts + * sampler/surface views instead of resources. + * + * The layer and mipmap level are specified by the views. * * Drivers can use this to change resource properties (like format, width, * height) by changing how the views interpret them, instead of changing - * pipe_resource directly. This is usually needed to accelerate copying of - * compressed formats. + * pipe_resource directly. This is used to blit resources of formats which + * are not renderable. * * src_width0 and src_height0 are sampler_view-private properties that * override pipe_resource. The blitter uses them for computation of texture @@ -236,8 +237,7 @@ void util_blitter_copy_texture(struct blitter_context *blitter, */ void util_blitter_blit_generic(struct blitter_context *blitter, struct pipe_surface *dst, - int dstx, int dsty, - unsigned dst_width, unsigned dst_height, + const struct pipe_box *dstbox, struct pipe_sampler_view *src, const struct pipe_box *srcbox, unsigned src_width0, unsigned src_height0, diff --git a/src/gallium/drivers/r300/r300_blit.c b/src/gallium/drivers/r300/r300_blit.c index 70b81e6..9fff370 100644 --- a/src/gallium/drivers/r300/r300_blit.c +++ b/src/gallium/drivers/r300/r300_blit.c @@ -466,7 +466,7 @@ static void r300_resource_copy_region(struct pipe_context *pipe, unsigned dst_width0 = r300_resource(dst)->tex.width0; unsigned dst_height0 = r300_resource(dst)->tex.height0; unsigned layout; - struct pipe_box box; + struct pipe_box box, dstbox; struct pipe_sampler_view src_templ, *src_view; struct pipe_surface dst_templ, *dst_view; @@ -581,12 +581,14 @@ static void r300_resource_copy_region(struct pipe_context *pipe, dst_view = r300_create_surface_custom(pipe, dst, &dst_templ, dst_width0, dst_height0); src_view = r300_create_sampler_view_custom(pipe, src, &src_templ, src_width0, src_height0); + u_box_3d(dstx, dsty, dstz, abs(src_box->width), abs(src_box->height), + abs(src_box->depth), &dstbox); + r300_blitter_begin(r300, R300_COPY); - util_blitter_blit_generic(r300->blitter, dst_view, dstx, dsty, - abs(src_box->width), abs(src_box->height), - src_view, src_box, - src_width0, src_height0, PIPE_MASK_RGBAZS, - PIPE_TEX_FILTER_NEAREST, NULL, FALSE); + util_blitter_blit_generic(r300->blitter, dst_view, &dstbox, + src_view, src_box, src_width0, src_height0, + PIPE_MASK_RGBAZS, PIPE_TEX_FILTER_NEAREST, NULL, + FALSE); r300_blitter_end(r300); pipe_surface_reference(&dst_view, NULL); diff --git a/src/gallium/drivers/r600/r600_blit.c b/src/gallium/drivers/r600/r600_blit.c index b4e9136..b348aa7 100644 --- a/src/gallium/drivers/r600/r600_blit.c +++ b/src/gallium/drivers/r600/r600_blit.c @@ -544,7 +544,7 @@ static void r600_resource_copy_region(struct pipe_context *ctx, struct pipe_surface *dst_view, dst_templ; struct pipe_sampler_view src_templ, *src_view; unsigned dst_width, dst_height, src_width0, src_height0, src_widthFL, src_heightFL; - struct pipe_box sbox; + struct pipe_box sbox, dstbox; bool copy_all_samples; /* Handle buffers first. */ @@ -647,10 +647,12 @@ static void r600_resource_copy_region(struct pipe_context *ctx, copy_all_samples = rctx->screen->msaa_texture_support != MSAA_TEXTURE_SAMPLE_ZERO; + u_box_3d(dstx, dsty, dstz, abs(src_box->width), abs(src_box->height), + abs(src_box->depth), &dstbox); + /* Copy. */ r600_blitter_begin(ctx, R600_COPY_TEXTURE); - util_blitter_blit_generic(rctx->blitter, dst_view, dstx, dsty, - abs(src_box->width), abs(src_box->height), + util_blitter_blit_generic(rctx->blitter, dst_view, &dstbox, src_view, src_box, src_width0, src_height0, PIPE_MASK_RGBAZS, PIPE_TEX_FILTER_NEAREST, NULL, copy_all_samples); -- 2.7.4