llvmpipe: lp_resource_copy cleanup
authorRoland Scheidegger <sroland@vmware.com>
Tue, 19 Feb 2013 20:18:29 +0000 (21:18 +0100)
committerRoland Scheidegger <sroland@vmware.com>
Wed, 20 Feb 2013 18:37:30 +0000 (19:37 +0100)
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 <jfonseca@vmware.com>
src/gallium/drivers/llvmpipe/lp_flush.c
src/gallium/drivers/llvmpipe/lp_flush.h
src/gallium/drivers/llvmpipe/lp_surface.c
src/gallium/drivers/llvmpipe/lp_texture.c
src/gallium/drivers/llvmpipe/lp_texture.h

index 964b792b739e626942927664644179cb38922820..cbfe564a78176c2f79c74e9d8a3b158ca10bb0a6 100644 (file)
@@ -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)) {
index efff94c8c0cfe08c4cf1249e7f65a372aabfc44c..bc1e2a8ebcd5e5363cf093923f7cc2d6f59bdf90 100644 (file)
@@ -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,
index dbaed95d2d5430cc7032343608de7ec9b6f195e0..a83a9033c40b2aab6f502d294dcb36fb52600662 100644 (file)
@@ -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);
       }
    }
 }
index ce756c528976ae8fe64f0cada37efeed515ed1d2..1c4f1dc20f6344ee21e0a6253b7ac578989640d3 100644 (file)
@@ -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 );
 
index 97a5547bd895dd1338d3d2e9cacefb64da09b821..172228dc3fbe618aff91f9e814af2a140c38a720 100644 (file)
@@ -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);