gallium/u_blitter: unify some parameters into a dstbox parameter in blit_generic
authorMarek Olšák <maraeo@gmail.com>
Wed, 19 Dec 2012 22:06:51 +0000 (23:06 +0100)
committerMarek Olšák <maraeo@gmail.com>
Fri, 4 Jan 2013 13:05:43 +0000 (14:05 +0100)
Reviewed-by: Brian Paul <brianp@vmware.com>
src/gallium/auxiliary/util/u_blitter.c
src/gallium/auxiliary/util/u_blitter.h
src/gallium/drivers/r300/r300_blit.c
src/gallium/drivers/r600/r600_blit.c

index b6eca3e61305cd91a0a6fddf687e21b6949ed07a..8ce1e503855d3a53e4de5c0fced26c53e1928842 100644 (file)
@@ -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);
index 162f436de7918f647662fa8835ebcd317962d633..df8927b5b644cda160e1b472e6161cb9264e9e6a 100644 (file)
@@ -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,
index 70b81e64231a9e65a982205150c069371a14f8b7..9fff3700ed3f5dbc369e91d7e6744f2b4f1a0ca4 100644 (file)
@@ -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);
index b4e9136416c0b2af279a49bc951d35dff3baefde..b348aa728b0e4b21f3cde900f78d549d4459c898 100644 (file)
@@ -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);