softpipe: Use memory allocation macros.
[mesa.git] / src / gallium / drivers / softpipe / sp_tex_tile_cache.c
index e42015ad498099e0a5674081d368da7c28d28231..e589ee7c84100b8393a4f9392d2e98c2579b71ae 100644 (file)
@@ -251,6 +251,7 @@ sp_find_cached_tile_tex(struct softpipe_tex_tile_cache *tc,
           tc->tex_level != addr.bits.level ||
           tc->tex_z != addr.bits.z) {
          /* get new transfer (view into texture) */
+         unsigned width, height, layer;
 
          if (tc->tex_trans) {
             if (tc->tex_trans_map) {
@@ -262,14 +263,22 @@ sp_find_cached_tile_tex(struct softpipe_tex_tile_cache *tc,
             tc->tex_trans = NULL;
          }
 
+         width = u_minify(tc->texture->width0, addr.bits.level);
+         if (tc->texture->target == PIPE_TEXTURE_1D_ARRAY) {
+            height = tc->texture->array_size;
+            layer = 0;
+         }
+         else {
+            height = u_minify(tc->texture->height0, addr.bits.level);
+            layer = addr.bits.face + addr.bits.z;
+         }
+
          tc->tex_trans = 
             pipe_get_transfer(tc->pipe, tc->texture,
                               addr.bits.level,
-                              addr.bits.face + addr.bits.z,
+                              layer,
                               PIPE_TRANSFER_READ | PIPE_TRANSFER_UNSYNCHRONIZED,
-                              0, 0,
-                              u_minify(tc->texture->width0, addr.bits.level),
-                              u_minify(tc->texture->height0, addr.bits.level));
+                              0, 0, width, height);
 
          tc->tex_trans_map = tc->pipe->transfer_map(tc->pipe, tc->tex_trans);
 
@@ -278,22 +287,17 @@ sp_find_cached_tile_tex(struct softpipe_tex_tile_cache *tc,
          tc->tex_z = addr.bits.z;
       }
 
-      /* get tile from the transfer (view into texture)
-       * Note we're using the swizzle version of this fuction only because
-       * we need to pass the texture cache's format explicitly.
+      /* Get tile from the transfer (view into texture), explicitly passing
+       * the image format.
        */
-      pipe_get_tile_swizzle(tc->pipe,
-                           tc->tex_trans,
-                            addr.bits.x * TILE_SIZE, 
-                            addr.bits.y * TILE_SIZE,
-                            TILE_SIZE,
-                            TILE_SIZE,
-                            PIPE_SWIZZLE_RED,
-                            PIPE_SWIZZLE_GREEN,
-                            PIPE_SWIZZLE_BLUE,
-                            PIPE_SWIZZLE_ALPHA,
-                            tc->format,
-                            (float *) tile->data.color);
+      pipe_get_tile_rgba_format(tc->pipe,
+                                tc->tex_trans,
+                                addr.bits.x * TILE_SIZE, 
+                                addr.bits.y * TILE_SIZE,
+                                TILE_SIZE,
+                                TILE_SIZE,
+                                tc->format,
+                                (float *) tile->data.color);
 
       tile->addr = addr;
    }