[Mesa-dev] [PATCH 09/10] r600g: use endian_format in color swapping functions

Oded Gabbay oded.gabbay at gmail.com
Mon Apr 11 14:34:12 UTC 2016


For some formats we need to take endian_format into account when
configuring swapping for color buffers.

Signed-off-by: Oded Gabbay <oded.gabbay at gmail.com>
---
 src/gallium/drivers/r600/r600_state_common.c |  5 ++++-
 src/gallium/drivers/radeon/r600_texture.c    | 11 ++++++++---
 2 files changed, 12 insertions(+), 4 deletions(-)

diff --git a/src/gallium/drivers/r600/r600_state_common.c b/src/gallium/drivers/r600/r600_state_common.c
index 9bccc6a..35c79f7 100644
--- a/src/gallium/drivers/r600/r600_state_common.c
+++ b/src/gallium/drivers/r600/r600_state_common.c
@@ -2684,7 +2684,10 @@ uint32_t r600_translate_colorformat(enum chip_class chip, enum pipe_format forma
 					return V_0280A0_COLOR_32_32;
 			}
 		} else if (HAS_SIZE(8,24,0,0)) {
-			return V_0280A0_COLOR_24_8;
+			if (format == PIPE_FORMAT_Z24_UNORM_S8_UINT || format == PIPE_FORMAT_Z24X8_UNORM)
+				return (endianformat == PIPE_ENDIAN_BIG ? V_0280A0_COLOR_8_24 : V_0280A0_COLOR_24_8);
+			else
+				return V_0280A0_COLOR_24_8;
 		} else if (HAS_SIZE(24,8,0,0)) {
 			return V_0280A0_COLOR_8_24;
 		}
diff --git a/src/gallium/drivers/radeon/r600_texture.c b/src/gallium/drivers/radeon/r600_texture.c
index 24354d3..358b762 100644
--- a/src/gallium/drivers/radeon/r600_texture.c
+++ b/src/gallium/drivers/radeon/r600_texture.c
@@ -1439,7 +1439,10 @@ unsigned r600_translate_colorswap(enum pipe_format format, enum pipe_endian endi
 		else if ((HAS_SWIZZLE(0,Y) && HAS_SWIZZLE(1,X)) ||
 			 (HAS_SWIZZLE(0,Y) && HAS_SWIZZLE(1,NONE)) ||
 		         (HAS_SWIZZLE(0,NONE) && HAS_SWIZZLE(1,X)))
-			return V_0280A0_SWAP_STD_REV; /* YX__ */
+			if (format == PIPE_FORMAT_Z24_UNORM_S8_UINT || format == PIPE_FORMAT_Z24X8_UNORM)
+				return (endianformat == PIPE_ENDIAN_BIG ? V_0280A0_SWAP_STD : V_0280A0_SWAP_STD_REV);
+			else
+				return V_0280A0_SWAP_STD_REV; /* YX__ */
 		else if (HAS_SWIZZLE(0,X) && HAS_SWIZZLE(3,Y))
 			return V_0280A0_SWAP_ALT; /* X__Y */
 		else if (HAS_SWIZZLE(0,Y) && HAS_SWIZZLE(3,X))
@@ -1447,7 +1450,8 @@ unsigned r600_translate_colorswap(enum pipe_format format, enum pipe_endian endi
 		break;
 	case 3:
 		if (HAS_SWIZZLE(0,X))
-			return V_0280A0_SWAP_STD; /* XYZ */
+			/* XYZ */
+			return (endianformat == PIPE_ENDIAN_BIG ? V_0280A0_SWAP_STD_REV : V_0280A0_SWAP_STD);
 		else if (HAS_SWIZZLE(0,Z))
 			return V_0280A0_SWAP_STD_REV; /* ZYX */
 		break;
@@ -1460,7 +1464,8 @@ unsigned r600_translate_colorswap(enum pipe_format format, enum pipe_endian endi
 		else if (HAS_SWIZZLE(1,Y) && HAS_SWIZZLE(2,X))
 			return V_0280A0_SWAP_ALT; /* ZYXW */
 		else if (HAS_SWIZZLE(1,Z) && HAS_SWIZZLE(2,W))
-			return V_0280A0_SWAP_ALT_REV; /* YZWX */
+			/* YZWX */
+			return (endianformat == PIPE_ENDIAN_BIG ? V_0280A0_SWAP_ALT : V_0280A0_SWAP_ALT_REV);
 		break;
 	}
 	return ~0U;
-- 
2.5.5



More information about the mesa-dev mailing list