mesa/main: replace uses of _mesa_little_endian with preprocessor
authorDylan Baker <dylan@pnwbakers.com>
Thu, 6 Sep 2018 22:14:24 +0000 (15:14 -0700)
committerDylan Baker <dylan@pnwbakers.com>
Tue, 5 Nov 2019 16:39:55 +0000 (16:39 +0000)
Reviewed-by: Eric Engestrom <eric@engestrom.ch>
src/mesa/main/format_utils.c
src/mesa/main/formats.c
src/mesa/main/texcompress_bptc.c
src/mesa/main/texcompress_fxt1.c
src/mesa/main/texcompress_s3tc.c
src/mesa/main/texstore.c

index 58a65adc4de5fde303c4f5b24bba72627995be45..f87cbdf11556cb53e0bde106558d17fc84646175 100644 (file)
@@ -652,8 +652,10 @@ _mesa_format_convert(void *void_dst, uint32_t dst_format, size_t dst_stride,
 }
 
 static const uint8_t map_identity[7] = { 0, 1, 2, 3, 4, 5, 6 };
+#if PIPE_ARCH_BIG_ENDIAN
 static const uint8_t map_3210[7] = { 3, 2, 1, 0, 4, 5, 6 };
 static const uint8_t map_1032[7] = { 1, 0, 3, 2, 4, 5, 6 };
+#endif
 
 /**
  * Describes a format as an array format, if possible
@@ -704,10 +706,18 @@ _mesa_format_to_array(mesa_format format, GLenum *type, int *num_components,
             endian = map_identity;
             break;
          case 2:
-            endian = _mesa_little_endian() ? map_identity : map_1032;
+#if PIPE_ARCH_LITTLE_ENDIAN
+            endian = map_identity;
+#else
+            endian = map_1032;
+#endif
             break;
          case 4:
-            endian = _mesa_little_endian() ? map_identity : map_3210;
+#if PIPE_ARCH_LITTLE_ENDIAN
+            endian = map_identity;
+#else
+            endian = map_3210;
+#endif
             break;
          default:
             endian = map_identity;
@@ -725,7 +735,11 @@ _mesa_format_to_array(mesa_format format, GLenum *type, int *num_components,
             endian = map_identity;
             break;
          case 2:
-            endian = _mesa_little_endian() ? map_identity : map_1032;
+#if PIPE_ARCH_LITTLE_ENDIAN
+            endian = map_identity;
+#else
+            endian = map_1032;
+#endif
             break;
          default:
             endian = map_identity;
index 7767249c19002f7bfce5a706edc2a62a2b2e4f71..325a1091ac9d801f6c1acbc05cc72ea3a9dbfc5a 100644 (file)
@@ -425,10 +425,11 @@ uint32_t
 _mesa_format_to_array_format(mesa_format format)
 {
    const struct mesa_format_info *info = _mesa_get_format_info(format);
-   if (info->ArrayFormat && !_mesa_little_endian() &&
-       info->Layout == MESA_FORMAT_LAYOUT_PACKED)
+#if PIPE_ARCH_BIG_ENDIAN
+   if (info->ArrayFormat && info->Layout == MESA_FORMAT_LAYOUT_PACKED)
       return _mesa_array_format_flip_channels(info->ArrayFormat);
    else
+#endif
       return info->ArrayFormat;
 }
 
@@ -467,11 +468,11 @@ format_array_format_table_init(void)
       if (!info->ArrayFormat)
          continue;
 
-      if (_mesa_little_endian()) {
+#if PIPE_ARCH_LITTLE_ENDIAN
          array_format = info->ArrayFormat;
-      } else {
+#else
          array_format = _mesa_array_format_flip_channels(info->ArrayFormat);
-      }
+#endif
 
       /* This can happen and does for some of the BGR formats.  Let's take
        * the first one in the list.
index 46279f144ff6d526334bb79c0828926c1c515bfc..d7f4ecf9abb66d19e12eb313c423bf3c6dd884c2 100644 (file)
@@ -142,8 +142,11 @@ _mesa_texstore_bptc_rgba_unorm(TEXSTORE_PARAMS)
       tempImageSlices[0] = (GLubyte *) tempImage;
       _mesa_texstore(ctx, dims,
                      baseInternalFormat,
-                     _mesa_little_endian() ? MESA_FORMAT_R8G8B8A8_UNORM
-                                           : MESA_FORMAT_A8B8G8R8_UNORM,
+#if PIPE_ARCH_LITTLE_ENDIAN
+                     MESA_FORMAT_R8G8B8A8_UNORM,
+#else
+                     MESA_FORMAT_A8B8G8R8_UNORM,
+#endif
                      rgbaRowStride, tempImageSlices,
                      srcWidth, srcHeight, srcDepth,
                      srcFormat, srcType, srcAddr,
index 19df6baf371984d1fefef37f2d1d0704a75888c6..6642fe7cf0ead3d7a55335a2df743f3869dd51e0 100644 (file)
@@ -132,8 +132,11 @@ _mesa_texstore_rgba_fxt1(TEXSTORE_PARAMS)
       tempImageSlices[0] = (GLubyte *) tempImage;
       _mesa_texstore(ctx, dims,
                      baseInternalFormat,
-                     _mesa_little_endian() ? MESA_FORMAT_R8G8B8A8_UNORM
-                                           : MESA_FORMAT_A8B8G8R8_UNORM,
+#if PIPE_ARCH_LITTLE_ENDIAN
+                     MESA_FORMAT_R8G8B8A8_UNORM,
+#else
+                     MESA_FORMAT_A8B8G8R8_UNORM,
+#endif
                      rgbaRowStride, tempImageSlices,
                      srcWidth, srcHeight, srcDepth,
                      srcFormat, srcType, srcAddr,
index 1c6cbba892a9c375ffbf399b4dec5f4ec01bbb37..3e4b9acd4c6a6ba3397d3b74d64243b32acd9cff 100644 (file)
@@ -121,8 +121,11 @@ _mesa_texstore_rgba_dxt1(TEXSTORE_PARAMS)
       tempImageSlices[0] = (GLubyte *) tempImage;
       _mesa_texstore(ctx, dims,
                      baseInternalFormat,
-                     _mesa_little_endian() ? MESA_FORMAT_R8G8B8A8_UNORM
-                                           : MESA_FORMAT_A8B8G8R8_UNORM,
+#if PIPE_ARCH_LITTLE_ENDIAN
+                     MESA_FORMAT_R8G8B8A8_UNORM,
+#else
+                     MESA_FORMAT_A8B8G8R8_UNORM,
+#endif
                      rgbaRowStride, tempImageSlices,
                      srcWidth, srcHeight, srcDepth,
                      srcFormat, srcType, srcAddr,
@@ -174,8 +177,11 @@ _mesa_texstore_rgba_dxt3(TEXSTORE_PARAMS)
       tempImageSlices[0] = (GLubyte *) tempImage;
       _mesa_texstore(ctx, dims,
                      baseInternalFormat,
-                     _mesa_little_endian() ? MESA_FORMAT_R8G8B8A8_UNORM
-                                           : MESA_FORMAT_A8B8G8R8_UNORM,
+#if PIPE_ARCH_LITTLE_ENDIAN
+                     MESA_FORMAT_R8G8B8A8_UNORM,
+#else
+                     MESA_FORMAT_A8B8G8R8_UNORM,
+#endif
                      rgbaRowStride, tempImageSlices,
                      srcWidth, srcHeight, srcDepth,
                      srcFormat, srcType, srcAddr,
@@ -226,8 +232,11 @@ _mesa_texstore_rgba_dxt5(TEXSTORE_PARAMS)
       tempImageSlices[0] = (GLubyte *) tempImage;
       _mesa_texstore(ctx, dims,
                      baseInternalFormat,
-                     _mesa_little_endian() ? MESA_FORMAT_R8G8B8A8_UNORM
-                                           : MESA_FORMAT_A8B8G8R8_UNORM,
+#if PIPE_ARCH_LITTLE_ENDIAN
+                     MESA_FORMAT_R8G8B8A8_UNORM,
+#else
+                     MESA_FORMAT_A8B8G8R8_UNORM,
+#endif
                      rgbaRowStride, tempImageSlices,
                      srcWidth, srcHeight, srcDepth,
                      srcFormat, srcType, srcAddr,
index 207695041a7110f6b8cfc6d052c59218ecab93d5..77c4bccbe072d2336a88f02cb7a22ef1b5a45539 100755 (executable)
@@ -280,8 +280,6 @@ _mesa_texstore_z16(TEXSTORE_PARAMS)
 static GLboolean
 _mesa_texstore_ycbcr(TEXSTORE_PARAMS)
 {
-   const GLboolean littleEndian = _mesa_little_endian();
-
    (void) ctx; (void) dims; (void) baseInternalFormat;
 
    assert((dstFormat == MESA_FORMAT_YCBCR) ||
@@ -305,7 +303,7 @@ _mesa_texstore_ycbcr(TEXSTORE_PARAMS)
    if (srcPacking->SwapBytes ^
        (srcType == GL_UNSIGNED_SHORT_8_8_REV_MESA) ^
        (dstFormat == MESA_FORMAT_YCBCR_REV) ^
-       !littleEndian) {
+       !PIPE_ARCH_LITTLE_ENDIAN) {
       GLint img, row;
       for (img = 0; img < srcDepth; img++) {
          GLubyte *dstRow = dstSlices[img];