llvmpipe: get rid of llvmpipe_get_texture_tile_linear
authorRoland Scheidegger <sroland@vmware.com>
Tue, 1 Jul 2014 13:37:56 +0000 (15:37 +0200)
committerRoland Scheidegger <sroland@vmware.com>
Tue, 1 Jul 2014 23:55:59 +0000 (01:55 +0200)
Because the layout is always linear this didn't really do much any longer -
at some point this triggered per-tile swizzled->linear conversion. The x/y
coords were ignored too.
Apart from triggering conversion, this also invoked alloc_image_data(), which
could only actually trigger mapping of display target resources. So, instead
just call resource_map in the callers (which also gives the ability to unmap
again). Note that mapping/unmapping of display target resources still isn't
really all that clean (map/unmap may be unmatched, and all such mappings use
the same pointer thus usage flags are a lie).

Reviewed-by: Brian Paul <brianp@vmware.com>
src/gallium/drivers/llvmpipe/lp_surface.c
src/gallium/drivers/llvmpipe/lp_texture.c
src/gallium/drivers/llvmpipe/lp_texture.h

index 09ca39dd357a8a890aed75e967fbc2731ad2b3e7..08f968f7f0a4d86c36dfe501c009b7c62f949211 100644 (file)
 #include "lp_query.h"
 
 
-/**
- * Adjust x, y, width, height to lie on tile bounds.
- */
-static void
-adjust_to_tile_bounds(unsigned x, unsigned y, unsigned width, unsigned height,
-                      unsigned *x_tile, unsigned *y_tile,
-                      unsigned *w_tile, unsigned *h_tile)
-{
-   *x_tile = x & ~(TILE_SIZE - 1);
-   *y_tile = y & ~(TILE_SIZE - 1);
-   *w_tile = ((x + width + TILE_SIZE - 1) & ~(TILE_SIZE - 1)) - *x_tile;
-   *h_tile = ((y + height + TILE_SIZE - 1) & ~(TILE_SIZE - 1)) - *y_tile;
-}
-
-
-
 static void
 lp_resource_copy(struct pipe_context *pipe,
                  struct pipe_resource *dst, unsigned dst_level,
@@ -64,7 +48,6 @@ lp_resource_copy(struct pipe_context *pipe,
    unsigned width = src_box->width;
    unsigned height = src_box->height;
    unsigned depth = src_box->depth;
-   unsigned z;
 
    llvmpipe_flush_resource(pipe,
                            dst, dst_level,
@@ -94,61 +77,16 @@ lp_resource_copy(struct pipe_context *pipe,
           src_box->width, src_box->height, src_box->depth);
    */
 
-   for (z = 0; z < src_box->depth; z++){
-
-      /* set src tiles to linear layout */
-      {
-         unsigned tx, ty, tw, th;
-         unsigned x, y;
+   /* make sure display target resources (which cannot have levels/layers) are mapped */
+   if (src_tex->dt)
+      (void) llvmpipe_resource_map(src, src_level, 0, LP_TEX_USAGE_READ);
+   if (dst_tex->dt)
+      /*
+       * Could set this to WRITE_ALL if complete dst is covered but it gets
+       * ignored anyway.
+       */
+      (void) llvmpipe_resource_map(dst, dst_level, 0, LP_TEX_USAGE_READ_WRITE);
 
-         adjust_to_tile_bounds(src_box->x, src_box->y, width, height,
-                               &tx, &ty, &tw, &th);
-
-         for (y = 0; y < th; y += TILE_SIZE) {
-            for (x = 0; x < tw; x += TILE_SIZE) {
-               (void) llvmpipe_get_texture_tile_linear(src_tex,
-                                                       src_box->z + z, src_level,
-                                                       LP_TEX_USAGE_READ,
-                                                       tx + x, ty + y);
-            }
-         }
-      }
-
-      /* set dst tiles to linear layout */
-      {
-         unsigned tx, ty, tw, th;
-         unsigned x, y;
-         enum lp_texture_usage usage;
-
-         adjust_to_tile_bounds(dstx, dsty, width, height, &tx, &ty, &tw, &th);
-
-         for (y = 0; y < th; y += TILE_SIZE) {
-            boolean contained_y = ty + y >= dsty &&
-                                  ty + y + TILE_SIZE <= dsty + height ?
-                                  TRUE : FALSE;
-
-            for (x = 0; x < tw; x += TILE_SIZE) {
-               boolean contained_x = tx + x >= dstx &&
-                                     tx + x + TILE_SIZE <= dstx + width ?
-                                     TRUE : FALSE;
-
-               /*
-                * Set the usage mode to WRITE_ALL for the tiles which are
-                * completely contained by the dest rectangle.
-                */
-               if (contained_y && contained_x)
-                  usage = LP_TEX_USAGE_WRITE_ALL;
-               else
-                  usage = LP_TEX_USAGE_READ_WRITE;
-
-               (void) llvmpipe_get_texture_tile_linear(dst_tex,
-                                                       dstz + z, dst_level,
-                                                       usage,
-                                                       tx + x, ty + y);
-            }
-         }
-      }
-   }
 
    /* copy */
    {
@@ -171,6 +109,12 @@ lp_resource_copy(struct pipe_context *pipe,
                        src_box->x, src_box->y, 0);
       }
    }
+
+   if (src_tex->dt)
+      llvmpipe_resource_unmap(src, 0, 0);
+   if (dst_tex->dt)
+      llvmpipe_resource_unmap(dst, 0, 0);
+
 }
 
 
index 3cb421cd82378fa7959a05076671c42a9306c5c5..c07bd21bf12b284bb1314f0c9a57fa8ce96fc929 100644 (file)
@@ -735,6 +735,8 @@ llvmpipe_get_texture_image_address(struct llvmpipe_resource *lpr,
 {
    unsigned offset;
 
+   assert(llvmpipe_resource_is_texture(&lpr->base));
+
    offset = lpr->mip_offsets[level];
 
    if (face_slice > 0)
@@ -787,36 +789,6 @@ alloc_image_data(struct llvmpipe_resource *lpr)
 }
 
 
-/**
- * Get pointer to a linear image (not the tile!) at tile (x,y).
- * \return pointer to start of image/face (not the tile)
- */
-ubyte *
-llvmpipe_get_texture_tile_linear(struct llvmpipe_resource *lpr,
-                                 unsigned face_slice, unsigned level,
-                                 enum lp_texture_usage usage,
-                                 unsigned x, unsigned y)
-{
-   uint8_t *linear_image;
-
-   assert(llvmpipe_resource_is_texture(&lpr->base));
-   assert(x % TILE_SIZE == 0);
-   assert(y % TILE_SIZE == 0);
-
-   if (!lpr->tex_data) {
-      /* allocate memory for the linear image now */
-      /* XXX should probably not do that here? */
-      alloc_image_data(lpr);
-   }
-   assert(lpr->tex_data);
-
-   /* compute address of the slice/face of the image that contains the tile */
-   linear_image = llvmpipe_get_texture_image_address(lpr, face_slice, level);
-
-   return linear_image;
-}
-
-
 /**
  * Return size of resource in bytes
  */
index b1632268ea309729e55ef7e788b8afa33214ba0d..34c3f604066c3c81f7c92950e2c2d894c567e02c 100644 (file)
@@ -217,12 +217,6 @@ ubyte *
 llvmpipe_get_texture_image_address(struct llvmpipe_resource *lpr,
                                    unsigned face_slice, unsigned level);
 
-ubyte *
-llvmpipe_get_texture_tile_linear(struct llvmpipe_resource *lpr,
-                                 unsigned face_slice, unsigned level,
-                                 enum lp_texture_usage usage,
-                                 unsigned x, unsigned y);
-
 
 extern void
 llvmpipe_print_resources(void);