summaryrefslogtreecommitdiff
path: root/src/mesa
diff options
context:
space:
mode:
Diffstat (limited to 'src/mesa')
-rw-r--r--src/mesa/drivers/dri/r200/Makefile3
l---------src/mesa/drivers/dri/r200/radeon_tile.c1
l---------src/mesa/drivers/dri/r200/radeon_tile.h1
-rw-r--r--src/mesa/drivers/dri/r300/Makefile3
l---------src/mesa/drivers/dri/r300/radeon_tile.c1
l---------src/mesa/drivers/dri/r300/radeon_tile.h1
-rw-r--r--src/mesa/drivers/dri/r600/Makefile3
l---------src/mesa/drivers/dri/r600/radeon_tile.c1
l---------src/mesa/drivers/dri/r600/radeon_tile.h1
-rw-r--r--src/mesa/drivers/dri/radeon/Makefile3
-rw-r--r--src/mesa/drivers/dri/radeon/radeon_tile.c246
-rw-r--r--src/mesa/drivers/dri/radeon/radeon_tile.h32
12 files changed, 292 insertions, 4 deletions
diff --git a/src/mesa/drivers/dri/r200/Makefile b/src/mesa/drivers/dri/r200/Makefile
index 2e86e8b941..d91e5482e9 100644
--- a/src/mesa/drivers/dri/r200/Makefile
+++ b/src/mesa/drivers/dri/r200/Makefile
@@ -24,7 +24,8 @@ RADEON_COMMON_SOURCES = \
radeon_queryobj.c \
radeon_span.c \
radeon_texture.c \
- radeon_tex_copy.c
+ radeon_tex_copy.c \
+ radeon_tile.c
DRIVER_SOURCES = r200_context.c \
r200_ioctl.c \
diff --git a/src/mesa/drivers/dri/r200/radeon_tile.c b/src/mesa/drivers/dri/r200/radeon_tile.c
new file mode 120000
index 0000000000..d4bfe27da6
--- /dev/null
+++ b/src/mesa/drivers/dri/r200/radeon_tile.c
@@ -0,0 +1 @@
+../radeon/radeon_tile.c \ No newline at end of file
diff --git a/src/mesa/drivers/dri/r200/radeon_tile.h b/src/mesa/drivers/dri/r200/radeon_tile.h
new file mode 120000
index 0000000000..31074c581e
--- /dev/null
+++ b/src/mesa/drivers/dri/r200/radeon_tile.h
@@ -0,0 +1 @@
+../radeon/radeon_tile.h \ No newline at end of file
diff --git a/src/mesa/drivers/dri/r300/Makefile b/src/mesa/drivers/dri/r300/Makefile
index 08934fc996..730d801bb0 100644
--- a/src/mesa/drivers/dri/r300/Makefile
+++ b/src/mesa/drivers/dri/r300/Makefile
@@ -34,7 +34,8 @@ RADEON_COMMON_SOURCES = \
radeon_span.c \
radeon_queryobj.c \
radeon_texture.c \
- radeon_tex_copy.c
+ radeon_tex_copy.c \
+ radeon_tile.c
DRIVER_SOURCES = \
radeon_screen.c \
diff --git a/src/mesa/drivers/dri/r300/radeon_tile.c b/src/mesa/drivers/dri/r300/radeon_tile.c
new file mode 120000
index 0000000000..d4bfe27da6
--- /dev/null
+++ b/src/mesa/drivers/dri/r300/radeon_tile.c
@@ -0,0 +1 @@
+../radeon/radeon_tile.c \ No newline at end of file
diff --git a/src/mesa/drivers/dri/r300/radeon_tile.h b/src/mesa/drivers/dri/r300/radeon_tile.h
new file mode 120000
index 0000000000..31074c581e
--- /dev/null
+++ b/src/mesa/drivers/dri/r300/radeon_tile.h
@@ -0,0 +1 @@
+../radeon/radeon_tile.h \ No newline at end of file
diff --git a/src/mesa/drivers/dri/r600/Makefile b/src/mesa/drivers/dri/r600/Makefile
index 2478b12658..b6d1c5f459 100644
--- a/src/mesa/drivers/dri/r600/Makefile
+++ b/src/mesa/drivers/dri/r600/Makefile
@@ -34,7 +34,8 @@ RADEON_COMMON_SOURCES = \
radeon_span.c \
radeon_texture.c \
radeon_queryobj.c \
- radeon_tex_copy.c
+ radeon_tex_copy.c \
+ radeon_tile.c
DRIVER_SOURCES = \
radeon_screen.c \
diff --git a/src/mesa/drivers/dri/r600/radeon_tile.c b/src/mesa/drivers/dri/r600/radeon_tile.c
new file mode 120000
index 0000000000..d4bfe27da6
--- /dev/null
+++ b/src/mesa/drivers/dri/r600/radeon_tile.c
@@ -0,0 +1 @@
+../radeon/radeon_tile.c \ No newline at end of file
diff --git a/src/mesa/drivers/dri/r600/radeon_tile.h b/src/mesa/drivers/dri/r600/radeon_tile.h
new file mode 120000
index 0000000000..31074c581e
--- /dev/null
+++ b/src/mesa/drivers/dri/r600/radeon_tile.h
@@ -0,0 +1 @@
+../radeon/radeon_tile.h \ No newline at end of file
diff --git a/src/mesa/drivers/dri/radeon/Makefile b/src/mesa/drivers/dri/radeon/Makefile
index fc6d1c8e89..f7e8059c4f 100644
--- a/src/mesa/drivers/dri/radeon/Makefile
+++ b/src/mesa/drivers/dri/radeon/Makefile
@@ -25,7 +25,8 @@ RADEON_COMMON_SOURCES = \
radeon_queryobj.c \
radeon_span.c \
radeon_texture.c \
- radeon_tex_copy.c
+ radeon_tex_copy.c \
+ radeon_tile.c
DRIVER_SOURCES = \
radeon_context.c \
diff --git a/src/mesa/drivers/dri/radeon/radeon_tile.c b/src/mesa/drivers/dri/radeon/radeon_tile.c
new file mode 100644
index 0000000000..56f2fc46d9
--- /dev/null
+++ b/src/mesa/drivers/dri/radeon/radeon_tile.c
@@ -0,0 +1,246 @@
+/*
+ * Copyright (C) 2010 Maciej Cencora <m.cencora@gmail.com>
+ *
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial
+ * portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
+ * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+ * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ */
+
+#include "radeon_tile.h"
+
+#include <stdint.h>
+#include <string.h>
+
+#include <main/macros.h>
+
+#define MICRO_TILE_SIZE 32
+
+static void micro_tile_8_x_4_8bit(const void * const src, unsigned src_pitch,
+ void * const dst, unsigned dst_pitch,
+ unsigned width, unsigned height)
+{
+ unsigned row; /* current source row */
+ unsigned col; /* current source column */
+ unsigned k; /* number of processed tiles */
+ const unsigned tile_width = 8, tile_height = 4;
+ const unsigned tiles_in_row = (width + (tile_width - 1)) / tile_width;
+
+ k = 0;
+ for (row = 0; row < height; row += tile_height)
+ {
+ for (col = 0; col < width; col += tile_width, ++k)
+ {
+ uint8_t *src2 = (uint8_t *)src + src_pitch * row + col;
+ uint8_t *dst2 = (uint8_t *)dst + row * dst_pitch +
+ (k % tiles_in_row) * MICRO_TILE_SIZE / sizeof(uint8_t);
+ unsigned j;
+
+ for (j = 0; j < MIN2(tile_height, height - row); ++j)
+ {
+ unsigned columns = MIN2(tile_width, width - col);
+ memcpy(dst2, src2, columns * sizeof(uint8_t));
+ dst2 += tile_width;
+ src2 += src_pitch;
+ }
+ }
+ }
+}
+
+static void micro_tile_4_x_4_16bit(const void * const src, unsigned src_pitch,
+ void * const dst, unsigned dst_pitch,
+ unsigned width, unsigned height)
+{
+ unsigned row; /* current source row */
+ unsigned col; /* current source column */
+ unsigned k; /* number of processed tiles */
+ const unsigned tile_width = 4, tile_height = 4;
+ const unsigned tiles_in_row = (width + (tile_width - 1)) / tile_width;
+
+ k = 0;
+ for (row = 0; row < height; row += tile_height)
+ {
+ for (col = 0; col < width; col += tile_width, ++k)
+ {
+ uint16_t *src2 = (uint16_t *)src + src_pitch * row + col;
+ uint16_t *dst2 = (uint16_t *)dst + row * dst_pitch +
+ (k % tiles_in_row) * MICRO_TILE_SIZE / sizeof(uint16_t);
+ unsigned j;
+
+ for (j = 0; j < MIN2(tile_height, height - row); ++j)
+ {
+ unsigned columns = MIN2(tile_width, width - col);
+ memcpy(dst2, src2, columns * sizeof(uint16_t));
+ dst2 += tile_width;
+ src2 += src_pitch;
+ }
+ }
+ }
+}
+
+static void micro_tile_8_x_2_16bit(const void * const src, unsigned src_pitch,
+ void * const dst, unsigned dst_pitch,
+ unsigned width, unsigned height)
+{
+ unsigned row; /* current source row */
+ unsigned col; /* current source column */
+ unsigned k; /* number of processed tiles */
+ const unsigned tile_width = 8, tile_height = 2;
+ const unsigned tiles_in_row = (width + (tile_width - 1)) / tile_width;
+
+ k = 0;
+ for (row = 0; row < height; row += tile_height)
+ {
+ for (col = 0; col < width; col += tile_width, ++k)
+ {
+ uint16_t *src2 = (uint16_t *)src + src_pitch * row + col;
+ uint16_t *dst2 = (uint16_t *)dst + row * dst_pitch +
+ (k % tiles_in_row) * MICRO_TILE_SIZE / sizeof(uint16_t);
+ unsigned j;
+
+ for (j = 0; j < MIN2(tile_height, height - row); ++j)
+ {
+ unsigned columns = MIN2(tile_width, width - col);
+ memcpy(dst2, src2, columns * sizeof(uint16_t));
+ dst2 += tile_width;
+ src2 += src_pitch;
+ }
+ }
+ }
+}
+
+static void micro_tile_4_x_2_32bit(const void * const src, unsigned src_pitch,
+ void * const dst, unsigned dst_pitch,
+ unsigned width, unsigned height)
+{
+ unsigned row; /* current source row */
+ unsigned col; /* current source column */
+ unsigned k; /* number of processed tiles */
+ const unsigned tile_width = 4, tile_height = 2;
+ const unsigned tiles_in_row = (width + (tile_width - 1)) / tile_width;
+
+ k = 0;
+ for (row = 0; row < height; row += tile_height)
+ {
+ for (col = 0; col < width; col += tile_width, ++k)
+ {
+ uint32_t *src2 = (uint32_t *)src + src_pitch * row + col;
+ uint32_t *dst2 = (uint32_t *)dst + row * dst_pitch +
+ (k % tiles_in_row) * MICRO_TILE_SIZE / sizeof(uint32_t);
+ unsigned j;
+
+ for (j = 0; j < MIN2(tile_height, height - row); ++j)
+ {
+ unsigned columns = MIN2(tile_width, width - col);
+ memcpy(dst2, src2, columns * sizeof(uint32_t));
+ dst2 += tile_width;
+ src2 += src_pitch;
+ }
+ }
+ }
+}
+
+static void micro_tile_2_x_2_64bit(const void * const src, unsigned src_pitch,
+ void * const dst, unsigned dst_pitch,
+ unsigned width, unsigned height)
+{
+ unsigned row; /* current source row */
+ unsigned col; /* current source column */
+ unsigned k; /* number of processed tiles */
+ const unsigned tile_width = 2, tile_height = 2;
+ const unsigned tiles_in_row = (width + (tile_width - 1)) / tile_width;
+
+ k = 0;
+ for (row = 0; row < height; row += tile_height)
+ {
+ for (col = 0; col < width; col += tile_width, ++k)
+ {
+ uint64_t *src2 = (uint64_t *)src + src_pitch * row + col;
+ uint64_t *dst2 = (uint64_t *)dst + row * dst_pitch +
+ (k % tiles_in_row) * MICRO_TILE_SIZE / sizeof(uint64_t);
+ unsigned j;
+
+ for (j = 0; j < MIN2(tile_height, height - row); ++j)
+ {
+ unsigned columns = MIN2(tile_width, width - col);
+ memcpy(dst2, src2, columns * sizeof(uint64_t));
+ dst2 += tile_width;
+ src2 += src_pitch;
+ }
+ }
+ }
+}
+
+static void micro_tile_1_x_1_128bit(const void * src, unsigned src_pitch,
+ void * dst, unsigned dst_pitch,
+ unsigned width, unsigned height)
+{
+ unsigned i, j;
+ const unsigned elem_size = 16; /* sizeof(uint128_t) */
+
+ for (j = 0; j < height; ++j)
+ {
+ for (i = 0; i < width; ++i)
+ {
+ memcpy(dst, src, width * elem_size);
+ dst += dst_pitch * elem_size;
+ src += src_pitch * elem_size;
+ }
+ }
+}
+
+void tile_image(const void * src, unsigned src_pitch,
+ void *dst, unsigned dst_pitch,
+ gl_format format, unsigned width, unsigned height)
+{
+ assert(src_pitch >= width);
+ assert(dst_pitch >= width);
+ assert(dst_pitch * _mesa_get_format_bytes(format) % MICRO_TILE_SIZE == 0);
+
+ switch (_mesa_get_format_bytes(format))
+ {
+ case 16:
+ micro_tile_1_x_1_128bit(src, src_pitch, dst, dst_pitch, width, height);
+ break;
+ case 8:
+ micro_tile_2_x_2_64bit(src, src_pitch, dst, dst_pitch, width, height);
+ break;
+ case 4:
+ micro_tile_4_x_2_32bit(src, src_pitch, dst, dst_pitch, width, height);
+ break;
+ case 2:
+ if (_mesa_get_format_bits(format, GL_DEPTH_BITS))
+ {
+ micro_tile_4_x_4_16bit(src, src_pitch, dst, dst_pitch, width, height);
+ }
+ else
+ {
+ micro_tile_8_x_2_16bit(src, src_pitch, dst, dst_pitch, width, height);
+ }
+ break;
+ case 1:
+ micro_tile_8_x_4_8bit(src, src_pitch, dst, dst_pitch, width, height);
+ break;
+ default:
+ assert(0);
+ break;
+ }
+} \ No newline at end of file
diff --git a/src/mesa/drivers/dri/radeon/radeon_tile.h b/src/mesa/drivers/dri/radeon/radeon_tile.h
new file mode 100644
index 0000000000..4985e55204
--- /dev/null
+++ b/src/mesa/drivers/dri/radeon/radeon_tile.h
@@ -0,0 +1,32 @@
+/*
+ * Copyright (C) 2010 Maciej Cencora <m.cencora@gmail.com>
+ *
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial
+ * portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
+ * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+ * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ */
+
+#include <main/formats.h>
+
+void tile_image(const void * src, unsigned src_pitch,
+ void *dst, unsigned dst_pitch,
+ gl_format format, unsigned width, unsigned height);