[Mesa-dev] [PATCH 05/28] r100: Use preprocessor to select big vs little endian paths

Dylan Baker dylan at pnwbakers.com
Fri Nov 9 18:39:58 UTC 2018


---
 src/mesa/drivers/dri/radeon/radeon_blit.c    | 49 ++++++++------------
 src/mesa/drivers/dri/radeon/radeon_screen.c  | 21 +++++++--
 src/mesa/drivers/dri/radeon/radeon_texture.c | 31 ++++++-------
 3 files changed, 53 insertions(+), 48 deletions(-)

diff --git a/src/mesa/drivers/dri/radeon/radeon_blit.c b/src/mesa/drivers/dri/radeon/radeon_blit.c
index 0b0f06f0edb..de2baee76c1 100644
--- a/src/mesa/drivers/dri/radeon/radeon_blit.c
+++ b/src/mesa/drivers/dri/radeon/radeon_blit.c
@@ -42,35 +42,26 @@ static inline uint32_t cmdpacket0(struct radeon_screen *rscrn,
 unsigned r100_check_blit(mesa_format mesa_format, uint32_t dst_pitch)
 {
     /* XXX others?  */
-    if (_mesa_little_endian()) {
-	switch (mesa_format) {
-	case MESA_FORMAT_B8G8R8A8_UNORM:
-	case MESA_FORMAT_B8G8R8X8_UNORM:
-	case MESA_FORMAT_B5G6R5_UNORM:
-	case MESA_FORMAT_B4G4R4A4_UNORM:
-	case MESA_FORMAT_B5G5R5A1_UNORM:
-	case MESA_FORMAT_A_UNORM8:
-	case MESA_FORMAT_L_UNORM8:
-	case MESA_FORMAT_I_UNORM8:
-	    break;
-	default:
-	    return 0;
-	}
-    }
-    else {
-	switch (mesa_format) {
-	case MESA_FORMAT_A8R8G8B8_UNORM:
-	case MESA_FORMAT_X8R8G8B8_UNORM:
-	case MESA_FORMAT_R5G6B5_UNORM:
-	case MESA_FORMAT_A4R4G4B4_UNORM:
-	case MESA_FORMAT_A1R5G5B5_UNORM:
-	case MESA_FORMAT_A_UNORM8:
-	case MESA_FORMAT_L_UNORM8:
-	case MESA_FORMAT_I_UNORM8:
-	    break;
-	default:
-	    return 0;
-	}
+    switch (mesa_format) {
+#ifdef PIPE_ARCH_LITTLE_ENDIAN
+    case MESA_FORMAT_B8G8R8A8_UNORM:
+    case MESA_FORMAT_B8G8R8X8_UNORM:
+    case MESA_FORMAT_B5G6R5_UNORM:
+    case MESA_FORMAT_B4G4R4A4_UNORM:
+    case MESA_FORMAT_B5G5R5A1_UNORM:
+#else
+    case MESA_FORMAT_A8R8G8B8_UNORM:
+    case MESA_FORMAT_X8R8G8B8_UNORM:
+    case MESA_FORMAT_R5G6B5_UNORM:
+    case MESA_FORMAT_A4R4G4B4_UNORM:
+    case MESA_FORMAT_A1R5G5B5_UNORM:
+#endif
+    case MESA_FORMAT_A_UNORM8:
+    case MESA_FORMAT_L_UNORM8:
+    case MESA_FORMAT_I_UNORM8:
+        break;
+    default:
+        return 0;
     }
 
     /* Rendering to small buffer doesn't work.
diff --git a/src/mesa/drivers/dri/radeon/radeon_screen.c b/src/mesa/drivers/dri/radeon/radeon_screen.c
index 6345f2ce661..9e7887de769 100644
--- a/src/mesa/drivers/dri/radeon/radeon_screen.c
+++ b/src/mesa/drivers/dri/radeon/radeon_screen.c
@@ -696,11 +696,26 @@ radeonCreateBuffer( __DRIscreen *driScrnPriv,
     _mesa_initialize_window_framebuffer(&rfb->base, mesaVis);
 
     if (mesaVis->redBits == 5)
-        rgbFormat = _mesa_little_endian() ? MESA_FORMAT_B5G6R5_UNORM : MESA_FORMAT_R5G6B5_UNORM;
+        rgbFormat =
+#ifdef PIPE_ARCH_LITTLE_ENDIAN
+           MESA_FORMAT_B5G6R5_UNORM;
+#else
+           MESA_FORMAT_R5G6B5_UNORM;
+#endif
     else if (mesaVis->alphaBits == 0)
-        rgbFormat = _mesa_little_endian() ? MESA_FORMAT_B8G8R8X8_UNORM : MESA_FORMAT_X8R8G8B8_UNORM;
+        rgbFormat =
+#ifdef PIPE_ARCH_LITTLE_ENDIAN
+           MESA_FORMAT_B8G8R8X8_UNORM;
+#else
+           MESA_FORMAT_X8R8G8B8_UNORM;
+#endif
     else
-        rgbFormat = _mesa_little_endian() ? MESA_FORMAT_B8G8R8A8_UNORM : MESA_FORMAT_A8R8G8B8_UNORM;
+        rgbFormat = 
+#ifdef PIPE_ARCH_LITTLE_ENDIAN
+           MESA_FORMAT_B8G8R8A8_UNORM;
+#else
+           MESA_FORMAT_A8R8G8B8_UNORM;
+#endif
 
     /* front color renderbuffer */
     rfb->color_rb[0] = radeon_create_renderbuffer(rgbFormat, driDrawPriv);
diff --git a/src/mesa/drivers/dri/radeon/radeon_texture.c b/src/mesa/drivers/dri/radeon/radeon_texture.c
index 6639c7ed65e..f7f2adedd89 100644
--- a/src/mesa/drivers/dri/radeon/radeon_texture.c
+++ b/src/mesa/drivers/dri/radeon/radeon_texture.c
@@ -603,22 +603,21 @@ mesa_format _radeon_texformat_al88 = MESA_FORMAT_NONE;
 static void
 radeonInitTextureFormats(void)
 {
-   if (_mesa_little_endian()) {
-      _radeon_texformat_rgba8888	= MESA_FORMAT_A8B8G8R8_UNORM;
-      _radeon_texformat_argb8888	= MESA_FORMAT_B8G8R8A8_UNORM;
-      _radeon_texformat_rgb565		= MESA_FORMAT_B5G6R5_UNORM;
-      _radeon_texformat_argb4444	= MESA_FORMAT_B4G4R4A4_UNORM;
-      _radeon_texformat_argb1555	= MESA_FORMAT_B5G5R5A1_UNORM;
-      _radeon_texformat_al88		= MESA_FORMAT_L8A8_UNORM;
-   }
-   else {
-      _radeon_texformat_rgba8888	= MESA_FORMAT_R8G8B8A8_UNORM;
-      _radeon_texformat_argb8888	= MESA_FORMAT_A8R8G8B8_UNORM;
-      _radeon_texformat_rgb565		= MESA_FORMAT_R5G6B5_UNORM;
-      _radeon_texformat_argb4444	= MESA_FORMAT_A4R4G4B4_UNORM;
-      _radeon_texformat_argb1555	= MESA_FORMAT_A1R5G5B5_UNORM;
-      _radeon_texformat_al88		= MESA_FORMAT_A8L8_UNORM;
-   }
+#ifdef PIPE_ARCH_LITTLE_ENDIAN
+   _radeon_texformat_rgba8888	= MESA_FORMAT_A8B8G8R8_UNORM;
+   _radeon_texformat_argb8888	= MESA_FORMAT_B8G8R8A8_UNORM;
+   _radeon_texformat_rgb565		= MESA_FORMAT_B5G6R5_UNORM;
+   _radeon_texformat_argb4444	= MESA_FORMAT_B4G4R4A4_UNORM;
+   _radeon_texformat_argb1555	= MESA_FORMAT_B5G5R5A1_UNORM;
+   _radeon_texformat_al88		= MESA_FORMAT_L8A8_UNORM;
+#else
+   _radeon_texformat_rgba8888	= MESA_FORMAT_R8G8B8A8_UNORM;
+   _radeon_texformat_argb8888	= MESA_FORMAT_A8R8G8B8_UNORM;
+   _radeon_texformat_rgb565		= MESA_FORMAT_R5G6B5_UNORM;
+   _radeon_texformat_argb4444	= MESA_FORMAT_A4R4G4B4_UNORM;
+   _radeon_texformat_argb1555	= MESA_FORMAT_A1R5G5B5_UNORM;
+   _radeon_texformat_al88		= MESA_FORMAT_A8L8_UNORM;
+#endif
 }
 
 void
-- 
2.19.1



More information about the mesa-dev mailing list