<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Sun, Apr 24, 2016 at 6:27 AM, Marek Olšák <span dir="ltr"><<a href="mailto:maraeo@gmail.com" target="_blank">maraeo@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">From: Marek Olšák <<a href="mailto:marek.olsak@amd.com">marek.olsak@amd.com</a>><br>
<br>
---<br>
src/gallium/drivers/r300/r300_reg.h | 20 +++++++----------<br>
src/gallium/drivers/r300/r300_texture.c | 38 ++++++++++++++++++++++++++++++---<br>
2 files changed, 43 insertions(+), 15 deletions(-)<br>
<br>
diff --git a/src/gallium/drivers/r300/r300_reg.h b/src/gallium/drivers/r300/r300_reg.h<br>
index 9c373c5..9c93b84 100644<br>
--- a/src/gallium/drivers/r300/r300_reg.h<br>
+++ b/src/gallium/drivers/r300/r300_reg.h<br>
@@ -1700,10 +1700,7 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.<br>
#define R300_TX_OFFSET_6 0x4558<br>
#define R300_TX_OFFSET_7 0x455C<br>
<br>
-# define R300_TXO_ENDIAN_NO_SWAP (0 << 0)<br>
-# define R300_TXO_ENDIAN_BYTE_SWAP (1 << 0)<br>
-# define R300_TXO_ENDIAN_WORD_SWAP (2 << 0)<br>
-# define R300_TXO_ENDIAN_HALFDW_SWAP (3 << 0)<br>
+# define R300_TXO_ENDIAN(x) ((x) << 0)<br>
# define R300_TXO_MACRO_TILE_LINEAR (0 << 2)<br>
# define R300_TXO_MACRO_TILE_TILED (1 << 2)<br>
# define R300_TXO_MACRO_TILE(x) ((x) << 2)<br>
@@ -2418,10 +2415,7 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.<br>
# define R300_COLOR_MICROTILE_ENABLE (1 << 17)<br>
# define R300_COLOR_MICROTILE_ENABLE_SQUARE (2 << 17) /* Only available in 16-bit */<br>
# define R300_COLOR_MICROTILE(x) ((x) << 17)<br>
-# define R300_COLOR_ENDIAN_NO_SWAP (0 << 19)<br>
-# define R300_COLOR_ENDIAN_WORD_SWAP (1 << 19)<br>
-# define R300_COLOR_ENDIAN_DWORD_SWAP (2 << 19)<br>
-# define R300_COLOR_ENDIAN_HALF_DWORD_SWAP (3 << 19)<br>
+# define R300_COLOR_ENDIAN(x) ((x) << 19)<br>
# define R500_COLOR_FORMAT_ARGB10101010 (0 << 21)<br>
# define R500_COLOR_FORMAT_UV1010 (1 << 21)<br>
# define R500_COLOR_FORMAT_CI8 (2 << 21) /* 2D only */<br>
@@ -2693,10 +2687,12 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.<br>
# define R300_DEPTHMICROTILE_TILED (1 << 17)<br>
# define R300_DEPTHMICROTILE_TILED_SQUARE (2 << 17)<br>
# define R300_DEPTHMICROTILE(x) ((x) << 17)<br>
-# define R300_DEPTHENDIAN_NO_SWAP (0 << 18)<br>
-# define R300_DEPTHENDIAN_WORD_SWAP (1 << 18)<br>
-# define R300_DEPTHENDIAN_DWORD_SWAP (2 << 18)<br>
-# define R300_DEPTHENDIAN_HALF_DWORD_SWAP (3 << 18)<br>
+# define R300_DEPTHENDIAN(x) ((x) << 19)<br></blockquote><div><br></div><div>Was this an intentional switch to << 19, or just a copy/paste type-o from the R300_COLOR_ENDIAN hunk above?<br><br></div><div>Not qualified to review this patch, but that looked odd as I was scanning it.<br></div><div><br></div><div>--Aaron<br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
+<br>
+#define R300_SURF_NO_SWAP 0<br>
+#define R300_SURF_WORD_SWAP 1<br>
+#define R300_SURF_DWORD_SWAP 2<br>
+#define R300_SURF_HALF_DWORD_SWAP 3<br>
<br>
/* Z Buffer Clear Value */<br>
#define R300_ZB_DEPTHCLEARVALUE 0x4f28<br>
diff --git a/src/gallium/drivers/r300/r300_texture.c b/src/gallium/drivers/r300/r300_texture.c<br>
index da51661..825d811 100644<br>
--- a/src/gallium/drivers/r300/r300_texture.c<br>
+++ b/src/gallium/drivers/r300/r300_texture.c<br>
@@ -837,6 +837,35 @@ boolean r300_is_sampler_format_supported(enum pipe_format format)<br>
return r300_translate_texformat(format, 0, TRUE, FALSE) != ~0;<br>
}<br>
<br>
+static unsigned r300_get_endian_swap(enum pipe_format format)<br>
+{<br>
+ const struct util_format_description *desc;<br>
+ unsigned swap_size;<br>
+<br>
+ if (PIPE_ENDIAN_NATIVE != PIPE_ENDIAN_BIG)<br>
+ return R300_SURF_NO_SWAP;<br>
+<br>
+ desc = util_format_description(format);<br>
+ if (!desc)<br>
+ return R300_SURF_NO_SWAP;<br>
+<br>
+ /* Compressed formats should be in the little endian format. */<br>
+ if (desc->block.width != 1 || desc->block.height != 1)<br>
+ return R300_SURF_NO_SWAP;<br>
+<br>
+ swap_size = desc->is_array ? desc->channel[0].size : desc->block.bits;<br>
+<br>
+ switch (swap_size) {<br>
+ default: /* shouldn't happen? */<br>
+ case 8:<br>
+ return R300_SURF_NO_SWAP;<br>
+ case 16:<br>
+ return R300_SURF_WORD_SWAP;<br>
+ case 32:<br>
+ return R300_SURF_DWORD_SWAP;<br>
+ }<br>
+}<br>
+<br>
void r300_texture_setup_format_state(struct r300_screen *screen,<br>
struct r300_resource *tex,<br>
enum pipe_format format,<br>
@@ -918,7 +947,8 @@ void r300_texture_setup_format_state(struct r300_screen *screen,<br>
}<br>
<br>
out->tile_config = R300_TXO_MACRO_TILE(desc->macrotile[level]) |<br>
- R300_TXO_MICRO_TILE(desc->microtile);<br>
+ R300_TXO_MICRO_TILE(desc->microtile) |<br>
+ R300_TXO_ENDIAN(r300_get_endian_swap(tex->b.b.format));<br>
}<br>
<br>
static void r300_texture_setup_fb_state(struct r300_surface *surf)<br>
@@ -933,7 +963,8 @@ static void r300_texture_setup_fb_state(struct r300_surface *surf)<br>
surf->pitch =<br>
stride |<br>
R300_DEPTHMACROTILE(tex->tex.macrotile[level]) |<br>
- R300_DEPTHMICROTILE(tex->tex.microtile);<br>
+ R300_DEPTHMICROTILE(tex->tex.microtile) |<br>
+ R300_DEPTHENDIAN(r300_get_endian_swap(tex->b.b.format));<br>
surf->format = r300_translate_zsformat(surf->base.format);<br>
surf->pitch_zmask = tex->tex.zmask_stride_in_pixels[level];<br>
surf->pitch_hiz = tex->tex.hiz_stride_in_pixels[level];<br>
@@ -944,7 +975,8 @@ static void r300_texture_setup_fb_state(struct r300_surface *surf)<br>
stride |<br>
r300_translate_colorformat(format) |<br>
R300_COLOR_TILE(tex->tex.macrotile[level]) |<br>
- R300_COLOR_MICROTILE(tex->tex.microtile);<br>
+ R300_COLOR_MICROTILE(tex->tex.microtile) |<br>
+ R300_COLOR_ENDIAN(r300_get_endian_swap(tex->b.b.format));<br>
surf->format = r300_translate_out_fmt(format);<br>
surf->colormask_swizzle =<br>
r300_translate_colormask_swizzle(format);<br>
<span class="HOEnZb"><font color="#888888">--<br>
2.5.0<br>
<br>
_______________________________________________<br>
mesa-dev mailing list<br>
<a href="mailto:mesa-dev@lists.freedesktop.org">mesa-dev@lists.freedesktop.org</a><br>
<a href="https://lists.freedesktop.org/mailman/listinfo/mesa-dev" rel="noreferrer" target="_blank">https://lists.freedesktop.org/mailman/listinfo/mesa-dev</a><br>
</font></span></blockquote></div><br></div></div>