gallivm,llvmpipe,draw: Support multiple constant buffers.
[mesa.git] / src / gallium / drivers / llvmpipe / lp_tile_image.c
index 0852150ba7216010573252dc86a219cd9d17fe52..3faf0181183d25c592e35d9af09dbf9b25066e33 100644 (file)
@@ -33,7 +33,8 @@
 
 
 #include "util/u_format.h"
-#include "lp_tile_soa.h"
+#include "util/u_memory.h"
+#include "lp_limits.h"
 #include "lp_tile_image.h"
 
 
@@ -122,14 +123,15 @@ tile_4_4_uint16(const uint16_t *src, uint16_t *dst, unsigned src_stride)
 
 /**
  * Convert a tiled image into a linear image.
- * \param src_stride  source row stride in bytes (bytes per row of tiles)
  * \param dst_stride  dest row stride in bytes
  */
 void
 lp_tiled_to_linear(const void *src, void *dst,
                    unsigned x, unsigned y,
                    unsigned width, unsigned height,
-                   enum pipe_format format, unsigned dst_stride)
+                   enum pipe_format format,
+                   unsigned dst_stride,
+                   unsigned tiles_per_row)
 {
    assert(x % TILE_SIZE == 0);
    assert(y % TILE_SIZE == 0);
@@ -187,27 +189,7 @@ lp_tiled_to_linear(const void *src, void *dst,
       }
    }
    else {
-      /* color image */
-      const uint bpp = 4;
-      const uint tile_w = TILE_SIZE, tile_h = TILE_SIZE;
-      const uint bytes_per_tile = tile_w * tile_h * bpp;
-      const uint src_stride = dst_stride * tile_w;
-      const uint tiles_per_row = src_stride / bytes_per_tile;
-      uint i, j;
-
-      for (j = 0; j < height; j += tile_h) {
-         for (i = 0; i < width; i += tile_w) {
-            uint ii = i + x, jj = j + y;
-            uint tile_offset = ((jj / tile_h) * tiles_per_row + ii / tile_w);
-            uint byte_offset = tile_offset * bytes_per_tile;
-            const uint8_t *src_tile = (uint8_t *) src + byte_offset;
-
-            lp_tile_write_4ub(format,
-                              src_tile,
-                              dst, dst_stride,
-                              ii, jj, tile_w, tile_h);
-         }
-      }
+      assert(0);
    }
 }
 
@@ -215,13 +197,14 @@ lp_tiled_to_linear(const void *src, void *dst,
 /**
  * Convert a linear image into a tiled image.
  * \param src_stride  source row stride in bytes
- * \param dst_stride  dest row stride in bytes (bytes per row of tiles)
  */
 void
 lp_linear_to_tiled(const void *src, void *dst,
                    unsigned x, unsigned y,
                    unsigned width, unsigned height,
-                   enum pipe_format format, unsigned src_stride)
+                   enum pipe_format format,
+                   unsigned src_stride,
+                   unsigned tiles_per_row)
 {
    assert(x % TILE_SIZE == 0);
    assert(y % TILE_SIZE == 0);
@@ -278,26 +261,7 @@ lp_linear_to_tiled(const void *src, void *dst,
       }
    }
    else {
-      const uint bpp = 4;
-      const uint tile_w = TILE_SIZE, tile_h = TILE_SIZE;
-      const uint bytes_per_tile = tile_w * tile_h * bpp;
-      const uint dst_stride = src_stride * tile_w;
-      const uint tiles_per_row = dst_stride / bytes_per_tile;
-      uint i, j;
-
-      for (j = 0; j < height; j += TILE_SIZE) {
-         for (i = 0; i < width; i += TILE_SIZE) {
-            uint ii = i + x, jj = j + y;
-            uint tile_offset = ((jj / tile_h) * tiles_per_row + ii / tile_w);
-            uint byte_offset = tile_offset * bytes_per_tile;
-            uint8_t *dst_tile = (uint8_t *) dst + byte_offset;
-
-            lp_tile_read_4ub(format,
-                             dst_tile,
-                             src, src_stride,
-                             ii, jj, tile_w, tile_h);
-         }
-      }
+      assert(0);
    }
 }
 
@@ -315,16 +279,16 @@ test_tiled_linear_conversion(void *data,
    unsigned wt = (width + TILE_SIZE - 1) / TILE_SIZE;
    unsigned ht = (height + TILE_SIZE - 1) / TILE_SIZE;
 
-   uint8_t *tiled = malloc(wt * ht * TILE_SIZE * TILE_SIZE * 4);
+   uint8_t *tiled = MALLOC(wt * ht * TILE_SIZE * TILE_SIZE * 4);
 
    /*unsigned tiled_stride = wt * TILE_SIZE * TILE_SIZE * 4;*/
 
    lp_linear_to_tiled(data, tiled, 0, 0, width, height, format,
-                      stride);
+                      stride, wt);
 
    lp_tiled_to_linear(tiled, data, 0, 0, width, height, format,
-                      stride);
+                      stride, wt);
 
-   free(tiled);
+   FREE(tiled);
 }