summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/gallium/auxiliary/translate/translate_generic.c40
-rw-r--r--src/gallium/auxiliary/util/u_format_other.c80
-rw-r--r--src/gallium/auxiliary/util/u_format_yuv.c192
-rw-r--r--src/gallium/auxiliary/util/u_format_zs.c160
-rw-r--r--src/gallium/auxiliary/vl/vl_vlc.h6
5 files changed, 88 insertions, 390 deletions
diff --git a/src/gallium/auxiliary/translate/translate_generic.c b/src/gallium/auxiliary/translate/translate_generic.c
index 26b87c5..45eb632 100644
--- a/src/gallium/auxiliary/translate/translate_generic.c
+++ b/src/gallium/auxiliary/translate/translate_generic.c
@@ -266,10 +266,7 @@ emit_B10G10R10A2_UNORM( const void *attrib, void *ptr )
value |= (((uint32_t)(CLAMP(src[1], 0, 1) * 0x3ff)) & 0x3ff) << 10;
value |= (((uint32_t)(CLAMP(src[0], 0, 1) * 0x3ff)) & 0x3ff) << 20;
value |= ((uint32_t)(CLAMP(src[3], 0, 1) * 0x3)) << 30;
-#ifdef PIPE_ARCH_BIG_ENDIAN
- value = util_bswap32(value);
-#endif
- *(uint32_t *)attrib = value;
+ *(uint32_t *)attrib = util_le32_to_cpu(value);
}
static void
@@ -281,10 +278,7 @@ emit_B10G10R10A2_USCALED( const void *attrib, void *ptr )
value |= (((uint32_t)CLAMP(src[1], 0, 1023)) & 0x3ff) << 10;
value |= (((uint32_t)CLAMP(src[0], 0, 1023)) & 0x3ff) << 20;
value |= ((uint32_t)CLAMP(src[3], 0, 3)) << 30;
-#ifdef PIPE_ARCH_BIG_ENDIAN
- value = util_bswap32(value);
-#endif
- *(uint32_t *)attrib = value;
+ *(uint32_t *)attrib = util_le32_to_cpu(value);
}
static void
@@ -296,10 +290,7 @@ emit_B10G10R10A2_SNORM( const void *attrib, void *ptr )
value |= (uint32_t)((((uint32_t)(CLAMP(src[1], -1, 1) * 0x1ff)) & 0x3ff) << 10) ;
value |= (uint32_t)((((uint32_t)(CLAMP(src[0], -1, 1) * 0x1ff)) & 0x3ff) << 20) ;
value |= (uint32_t)(((uint32_t)(CLAMP(src[3], -1, 1) * 0x1)) << 30) ;
-#ifdef PIPE_ARCH_BIG_ENDIAN
- value = util_bswap32(value);
-#endif
- *(uint32_t *)attrib = value;
+ *(uint32_t *)attrib = util_le32_to_cpu(value);
}
static void
@@ -311,10 +302,7 @@ emit_B10G10R10A2_SSCALED( const void *attrib, void *ptr )
value |= (uint32_t)((((uint32_t)CLAMP(src[1], -512, 511)) & 0x3ff) << 10) ;
value |= (uint32_t)((((uint32_t)CLAMP(src[0], -512, 511)) & 0x3ff) << 20) ;
value |= (uint32_t)(((uint32_t)CLAMP(src[3], -2, 1)) << 30) ;
-#ifdef PIPE_ARCH_BIG_ENDIAN
- value = util_bswap32(value);
-#endif
- *(uint32_t *)attrib = value;
+ *(uint32_t *)attrib = util_le32_to_cpu(value);
}
static void
@@ -326,10 +314,7 @@ emit_R10G10B10A2_UNORM( const void *attrib, void *ptr )
value |= (((uint32_t)(CLAMP(src[1], 0, 1) * 0x3ff)) & 0x3ff) << 10;
value |= (((uint32_t)(CLAMP(src[2], 0, 1) * 0x3ff)) & 0x3ff) << 20;
value |= ((uint32_t)(CLAMP(src[3], 0, 1) * 0x3)) << 30;
-#ifdef PIPE_ARCH_BIG_ENDIAN
- value = util_bswap32(value);
-#endif
- *(uint32_t *)attrib = value;
+ *(uint32_t *)attrib = util_le32_to_cpu(value);
}
static void
@@ -341,10 +326,7 @@ emit_R10G10B10A2_USCALED( const void *attrib, void *ptr )
value |= (((uint32_t)CLAMP(src[1], 0, 1023)) & 0x3ff) << 10;
value |= (((uint32_t)CLAMP(src[2], 0, 1023)) & 0x3ff) << 20;
value |= ((uint32_t)CLAMP(src[3], 0, 3)) << 30;
-#ifdef PIPE_ARCH_BIG_ENDIAN
- value = util_bswap32(value);
-#endif
- *(uint32_t *)attrib = value;
+ *(uint32_t *)attrib = util_le32_to_cpu(value);
}
static void
@@ -356,10 +338,7 @@ emit_R10G10B10A2_SNORM( const void *attrib, void *ptr )
value |= (uint32_t)((((uint32_t)(CLAMP(src[1], -1, 1) * 0x1ff)) & 0x3ff) << 10) ;
value |= (uint32_t)((((uint32_t)(CLAMP(src[2], -1, 1) * 0x1ff)) & 0x3ff) << 20) ;
value |= (uint32_t)(((uint32_t)(CLAMP(src[3], -1, 1) * 0x1)) << 30) ;
-#ifdef PIPE_ARCH_BIG_ENDIAN
- value = util_bswap32(value);
-#endif
- *(uint32_t *)attrib = value;
+ *(uint32_t *)attrib = util_le32_to_cpu(value);
}
static void
@@ -371,10 +350,7 @@ emit_R10G10B10A2_SSCALED( const void *attrib, void *ptr)
value |= (uint32_t)((((uint32_t)CLAMP(src[1], -512, 511)) & 0x3ff) << 10) ;
value |= (uint32_t)((((uint32_t)CLAMP(src[2], -512, 511)) & 0x3ff) << 20) ;
value |= (uint32_t)(((uint32_t)CLAMP(src[3], -2, 1)) << 30) ;
-#ifdef PIPE_ARCH_BIG_ENDIAN
- value = util_bswap32(value);
-#endif
- *(uint32_t *)attrib = value;
+ *(uint32_t *)attrib = util_le32_to_cpu(value);
}
static void
diff --git a/src/gallium/auxiliary/util/u_format_other.c b/src/gallium/auxiliary/util/u_format_other.c
index 85001c1..20752d4 100644
--- a/src/gallium/auxiliary/util/u_format_other.c
+++ b/src/gallium/auxiliary/util/u_format_other.c
@@ -42,10 +42,7 @@ util_format_r9g9b9e5_float_unpack_rgba_float(float *dst_row, unsigned dst_stride
float *dst = dst_row;
const uint8_t *src = src_row;
for(x = 0; x < width; x += 1) {
- uint32_t value = *(const uint32_t *)src;
-#ifdef PIPE_ARCH_BIG_ENDIAN
- value = util_bswap32(value);
-#endif
+ uint32_t value = util_cpu_to_le32(*(const uint32_t *)src);
rgb9e5_to_float3(value, dst);
dst[3] = 1; /* a */
src += 4;
@@ -66,10 +63,7 @@ util_format_r9g9b9e5_float_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride
const float *src = src_row;
uint8_t *dst = dst_row;
for(x = 0; x < width; x += 1) {
- uint32_t value = float3_to_rgb9e5(src);
-#ifdef PIPE_ARCH_BIG_ENDIAN
- value = util_bswap32(value);
-#endif
+ uint32_t value = util_cpu_to_le32(float3_to_rgb9e5(src));
*(uint32_t *)dst = value;
src += 4;
dst += 4;
@@ -83,10 +77,7 @@ void
util_format_r9g9b9e5_float_fetch_rgba_float(float *dst, const uint8_t *src,
unsigned i, unsigned j)
{
- uint32_t value = *(const uint32_t *)src;
-#ifdef PIPE_ARCH_BIG_ENDIAN
- value = util_bswap32(value);
-#endif
+ uint32_t value = util_cpu_to_le32(*(const uint32_t *)src);
rgb9e5_to_float3(value, dst);
dst[3] = 1; /* a */
}
@@ -103,10 +94,7 @@ util_format_r9g9b9e5_float_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_str
uint8_t *dst = dst_row;
const uint8_t *src = src_row;
for(x = 0; x < width; x += 1) {
- uint32_t value = *(const uint32_t *)src;
-#ifdef PIPE_ARCH_BIG_ENDIAN
- value = util_bswap32(value);
-#endif
+ uint32_t value = util_cpu_to_le32(*(const uint32_t *)src);
rgb9e5_to_float3(value, p);
dst[0] = float_to_ubyte(p[0]); /* r */
dst[1] = float_to_ubyte(p[1]); /* g */
@@ -136,10 +124,7 @@ util_format_r9g9b9e5_float_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_strid
p[0] = ubyte_to_float(src[0]);
p[1] = ubyte_to_float(src[1]);
p[2] = ubyte_to_float(src[2]);
- value = float3_to_rgb9e5(p);
-#ifdef PIPE_ARCH_BIG_ENDIAN
- value = util_bswap32(value);
-#endif
+ value = util_cpu_to_le32(float3_to_rgb9e5(p));
*(uint32_t *)dst = value;
src += 4;
dst += 4;
@@ -160,10 +145,7 @@ util_format_r11g11b10_float_unpack_rgba_float(float *dst_row, unsigned dst_strid
float *dst = dst_row;
const uint8_t *src = src_row;
for(x = 0; x < width; x += 1) {
- uint32_t value = *(const uint32_t *)src;
-#ifdef PIPE_ARCH_BIG_ENDIAN
- value = util_bswap32(value);
-#endif
+ uint32_t value = util_cpu_to_le32(*(const uint32_t *)src);
r11g11b10f_to_float3(value, dst);
dst[3] = 1; /* a */
src += 4;
@@ -184,10 +166,7 @@ util_format_r11g11b10_float_pack_rgba_float(uint8_t *dst_row, unsigned dst_strid
const float *src = src_row;
uint8_t *dst = dst_row;
for(x = 0; x < width; x += 1) {
- uint32_t value = float3_to_r11g11b10f(src);
-#ifdef PIPE_ARCH_BIG_ENDIAN
- value = util_bswap32(value);
-#endif
+ uint32_t value = util_cpu_to_le32(float3_to_r11g11b10f(src));
*(uint32_t *)dst = value;
src += 4;
dst += 4;
@@ -201,10 +180,7 @@ void
util_format_r11g11b10_float_fetch_rgba_float(float *dst, const uint8_t *src,
unsigned i, unsigned j)
{
- uint32_t value = *(const uint32_t *)src;
-#ifdef PIPE_ARCH_BIG_ENDIAN
- value = util_bswap32(value);
-#endif
+ uint32_t value = util_cpu_to_le32(*(const uint32_t *)src);
r11g11b10f_to_float3(value, dst);
dst[3] = 1; /* a */
}
@@ -221,10 +197,7 @@ util_format_r11g11b10_float_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_st
uint8_t *dst = dst_row;
const uint8_t *src = src_row;
for(x = 0; x < width; x += 1) {
- uint32_t value = *(const uint32_t *)src;
-#ifdef PIPE_ARCH_BIG_ENDIAN
- value = util_bswap32(value);
-#endif
+ uint32_t value = util_cpu_to_le32(*(const uint32_t *)src);
r11g11b10f_to_float3(value, p);
dst[0] = float_to_ubyte(p[0]); /* r */
dst[1] = float_to_ubyte(p[1]); /* g */
@@ -254,10 +227,7 @@ util_format_r11g11b10_float_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stri
p[0] = ubyte_to_float(src[0]);
p[1] = ubyte_to_float(src[1]);
p[2] = ubyte_to_float(src[2]);
- value = float3_to_r11g11b10f(p);
-#ifdef PIPE_ARCH_BIG_ENDIAN
- value = util_bswap32(value);
-#endif
+ value = util_cpu_to_le32(float3_to_r11g11b10f(p));
*(uint32_t *)dst = value;
src += 4;
dst += 4;
@@ -338,13 +308,9 @@ util_format_r8g8bx_snorm_unpack_rgba_float(float *dst_row, unsigned dst_stride,
float *dst = dst_row;
const uint16_t *src = (const uint16_t *)src_row;
for(x = 0; x < width; x += 1) {
- uint16_t value = *src++;
+ uint16_t value = util_cpu_to_le16(*src++);
int16_t r, g;
-#ifdef PIPE_ARCH_BIG_ENDIAN
- value = util_bswap16(value);
-#endif
-
r = ((int16_t)(value << 8)) >> 8;
g = ((int16_t)(value << 0)) >> 8;
@@ -370,13 +336,9 @@ util_format_r8g8bx_snorm_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_strid
uint8_t *dst = dst_row;
const uint16_t *src = (const uint16_t *)src_row;
for(x = 0; x < width; x += 1) {
- uint16_t value = *src++;
+ uint16_t value = util_cpu_to_le16(*src++);
int16_t r, g;
-#ifdef PIPE_ARCH_BIG_ENDIAN
- value = util_bswap16(value);
-#endif
-
r = ((int16_t)(value << 8)) >> 8;
g = ((int16_t)(value << 0)) >> 8;
@@ -407,11 +369,7 @@ util_format_r8g8bx_snorm_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride,
value |= (uint16_t)(((int8_t)(CLAMP(src[0], -1, 1) * 0x7f)) & 0xff) ;
value |= (uint16_t)((((int8_t)(CLAMP(src[1], -1, 1) * 0x7f)) & 0xff) << 8) ;
-#ifdef PIPE_ARCH_BIG_ENDIAN
- value = util_bswap16(value);
-#endif
-
- *dst++ = value;
+ *dst++ = util_le16_to_cpu(value);
src += 4;
}
@@ -437,11 +395,7 @@ util_format_r8g8bx_snorm_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride,
value |= src[0] >> 1;
value |= (src[1] >> 1) << 8;
-#ifdef PIPE_ARCH_BIG_ENDIAN
- value = util_bswap16(value);
-#endif
-
- *dst++ = value;
+ *dst++ = util_le16_to_cpu(value);
src += 4;
}
@@ -455,13 +409,9 @@ void
util_format_r8g8bx_snorm_fetch_rgba_float(float *dst, const uint8_t *src,
unsigned i, unsigned j)
{
- uint16_t value = *(const uint16_t *)src;
+ uint16_t value = util_cpu_to_le16(*(const uint16_t *)src);
int16_t r, g;
-#ifdef PIPE_ARCH_BIG_ENDIAN
- value = util_bswap16(value);
-#endif
-
r = ((int16_t)(value << 8)) >> 8;
g = ((int16_t)(value << 0)) >> 8;
diff --git a/src/gallium/auxiliary/util/u_format_yuv.c b/src/gallium/auxiliary/util/u_format_yuv.c
index 891d99c..16ed8af 100644
--- a/src/gallium/auxiliary/util/u_format_yuv.c
+++ b/src/gallium/auxiliary/util/u_format_yuv.c
@@ -52,11 +52,7 @@ util_format_r8g8_b8g8_unorm_unpack_rgba_float(float *dst_row, unsigned dst_strid
float r, g0, g1, b;
for (x = 0; x + 1 < width; x += 2) {
- value = *src++;
-
-#ifdef PIPE_ARCH_BIG_ENDIAN
- value = util_bswap32(value);
-#endif
+ value = util_cpu_to_le32(*src++);
r = ubyte_to_float((value >> 0) & 0xff);
g0 = ubyte_to_float((value >> 8) & 0xff);
@@ -77,11 +73,7 @@ util_format_r8g8_b8g8_unorm_unpack_rgba_float(float *dst_row, unsigned dst_strid
}
if (x < width) {
- value = *src;
-
-#ifdef PIPE_ARCH_BIG_ENDIAN
- value = util_bswap32(value);
-#endif
+ value = util_cpu_to_le32(*src);
r = ubyte_to_float((value >> 0) & 0xff);
g0 = ubyte_to_float((value >> 8) & 0xff);
@@ -114,11 +106,7 @@ util_format_r8g8_b8g8_unorm_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_st
uint8_t r, g0, g1, b;
for (x = 0; x + 1 < width; x += 2) {
- value = *src++;
-
-#ifdef PIPE_ARCH_BIG_ENDIAN
- value = util_bswap32(value);
-#endif
+ value = util_cpu_to_le32(*src++);
r = (value >> 0) & 0xff;
g0 = (value >> 8) & 0xff;
@@ -139,11 +127,7 @@ util_format_r8g8_b8g8_unorm_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_st
}
if (x < width) {
- value = *src;
-
-#ifdef PIPE_ARCH_BIG_ENDIAN
- value = util_bswap32(value);
-#endif
+ value = util_cpu_to_le32(*src);
r = (value >> 0) & 0xff;
g0 = (value >> 8) & 0xff;
@@ -186,11 +170,7 @@ util_format_r8g8_b8g8_unorm_pack_rgba_float(uint8_t *dst_row, unsigned dst_strid
value |= float_to_ubyte(b) << 16;
value |= float_to_ubyte(g1) << 24;
-#ifdef PIPE_ARCH_BIG_ENDIAN
- value = util_bswap32(value);
-#endif
-
- *dst++ = value;
+ *dst++ = util_le32_to_cpu(value);
src += 8;
}
@@ -206,11 +186,7 @@ util_format_r8g8_b8g8_unorm_pack_rgba_float(uint8_t *dst_row, unsigned dst_strid
value |= float_to_ubyte(b) << 16;
value |= float_to_ubyte(g1) << 24;
-#ifdef PIPE_ARCH_BIG_ENDIAN
- value = util_bswap32(value);
-#endif
-
- *dst = value;
+ *dst = util_le32_to_cpu(value);
}
dst_row += dst_stride/sizeof(*dst_row);
@@ -243,11 +219,7 @@ util_format_r8g8_b8g8_unorm_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stri
value |= b << 16;
value |= g1 << 24;
-#ifdef PIPE_ARCH_BIG_ENDIAN
- value = util_bswap32(value);
-#endif
-
- *dst++ = value;
+ *dst++ = util_le32_to_cpu(value);
src += 8;
}
@@ -263,11 +235,7 @@ util_format_r8g8_b8g8_unorm_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stri
value |= b << 16;
value |= g1 << 24;
-#ifdef PIPE_ARCH_BIG_ENDIAN
- value = util_bswap32(value);
-#endif
-
- *dst = value;
+ *dst = util_le32_to_cpu(value);
}
dst_row += dst_stride/sizeof(*dst_row);
@@ -304,11 +272,7 @@ util_format_g8r8_g8b8_unorm_unpack_rgba_float(float *dst_row, unsigned dst_strid
float r, g0, g1, b;
for (x = 0; x + 1 < width; x += 2) {
- value = *src++;
-
-#ifdef PIPE_ARCH_BIG_ENDIAN
- value = util_bswap32(value);
-#endif
+ value = util_cpu_to_le32(*src++);
g0 = ubyte_to_float((value >> 0) & 0xff);
r = ubyte_to_float((value >> 8) & 0xff);
@@ -329,11 +293,7 @@ util_format_g8r8_g8b8_unorm_unpack_rgba_float(float *dst_row, unsigned dst_strid
}
if (x < width) {
- value = *src;
-
-#ifdef PIPE_ARCH_BIG_ENDIAN
- value = util_bswap32(value);
-#endif
+ value = util_cpu_to_le32(*src);
g0 = ubyte_to_float((value >> 0) & 0xff);
r = ubyte_to_float((value >> 8) & 0xff);
@@ -366,11 +326,7 @@ util_format_g8r8_g8b8_unorm_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_st
uint8_t r, g0, g1, b;
for (x = 0; x + 1 < width; x += 2) {
- value = *src++;
-
-#ifdef PIPE_ARCH_BIG_ENDIAN
- value = util_bswap32(value);
-#endif
+ value = util_cpu_to_le32(*src++);
g0 = (value >> 0) & 0xff;
r = (value >> 8) & 0xff;
@@ -391,11 +347,7 @@ util_format_g8r8_g8b8_unorm_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_st
}
if (x < width) {
- value = *src;
-
-#ifdef PIPE_ARCH_BIG_ENDIAN
- value = util_bswap32(value);
-#endif
+ value = util_cpu_to_le32(*src);
g0 = (value >> 0) & 0xff;
r = (value >> 8) & 0xff;
@@ -438,11 +390,7 @@ util_format_g8r8_g8b8_unorm_pack_rgba_float(uint8_t *dst_row, unsigned dst_strid
value |= float_to_ubyte(g1) << 16;
value |= float_to_ubyte(b) << 24;
-#ifdef PIPE_ARCH_BIG_ENDIAN
- value = util_bswap32(value);
-#endif
-
- *dst++ = value;
+ *dst++ = util_le32_to_cpu(value);
src += 8;
}
@@ -458,11 +406,7 @@ util_format_g8r8_g8b8_unorm_pack_rgba_float(uint8_t *dst_row, unsigned dst_strid
value |= float_to_ubyte(g1) << 16;
value |= float_to_ubyte(b) << 24;
-#ifdef PIPE_ARCH_BIG_ENDIAN
- value = util_bswap32(value);
-#endif
-
- *dst = value;
+ *dst = util_le32_to_cpu(value);
}
dst_row += dst_stride/sizeof(*dst_row);
@@ -495,11 +439,7 @@ util_format_g8r8_g8b8_unorm_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stri
value |= g1 << 16;
value |= b << 24;
-#ifdef PIPE_ARCH_BIG_ENDIAN
- value = util_bswap32(value);
-#endif
-
- *dst++ = value;
+ *dst++ = util_le32_to_cpu(value);
src += 8;
}
@@ -515,11 +455,7 @@ util_format_g8r8_g8b8_unorm_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stri
value |= g1 << 16;
value |= b << 24;
-#ifdef PIPE_ARCH_BIG_ENDIAN
- value = util_bswap32(value);
-#endif
-
- *dst = value;
+ *dst = util_le32_to_cpu(value);
}
dst_row += dst_stride/sizeof(*dst_row);
@@ -556,11 +492,7 @@ util_format_uyvy_unpack_rgba_float(float *dst_row, unsigned dst_stride,
uint8_t y0, y1, u, v;
for (x = 0; x + 1 < width; x += 2) {
- value = *src++;
-
-#ifdef PIPE_ARCH_BIG_ENDIAN
- value = util_bswap32(value);
-#endif
+ value = util_cpu_to_le32(*src++);
u = (value >> 0) & 0xff;
y0 = (value >> 8) & 0xff;
@@ -577,11 +509,7 @@ util_format_uyvy_unpack_rgba_float(float *dst_row, unsigned dst_stride,
}
if (x < width) {
- value = *src;
-
-#ifdef PIPE_ARCH_BIG_ENDIAN
- value = util_bswap32(value);
-#endif
+ value = util_cpu_to_le32(*src);
u = (value >> 0) & 0xff;
y0 = (value >> 8) & 0xff;
@@ -612,11 +540,7 @@ util_format_uyvy_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride,
uint8_t y0, y1, u, v;
for (x = 0; x + 1 < width; x += 2) {
- value = *src++;
-
-#ifdef PIPE_ARCH_BIG_ENDIAN
- value = util_bswap32(value);
-#endif
+ value = util_cpu_to_le32(*src++);
u = (value >> 0) & 0xff;
y0 = (value >> 8) & 0xff;
@@ -633,11 +557,7 @@ util_format_uyvy_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride,
}
if (x < width) {
- value = *src;
-
-#ifdef PIPE_ARCH_BIG_ENDIAN
- value = util_bswap32(value);
-#endif
+ value = util_cpu_to_le32(*src);
u = (value >> 0) & 0xff;
y0 = (value >> 8) & 0xff;
@@ -683,11 +603,7 @@ util_format_uyvy_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride,
value |= v << 16;
value |= y1 << 24;
-#ifdef PIPE_ARCH_BIG_ENDIAN
- value = util_bswap32(value);
-#endif
-
- *dst++ = value;
+ *dst++ = util_le32_to_cpu(value);
src += 8;
}
@@ -702,11 +618,7 @@ util_format_uyvy_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride,
value |= v << 16;
value |= y1 << 24;
-#ifdef PIPE_ARCH_BIG_ENDIAN
- value = util_bswap32(value);
-#endif
-
- *dst = value;
+ *dst = util_le32_to_cpu(value);
}
dst_row += dst_stride/sizeof(*dst_row);
@@ -744,11 +656,7 @@ util_format_uyvy_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride,
value |= v << 16;
value |= y1 << 24;
-#ifdef PIPE_ARCH_BIG_ENDIAN
- value = util_bswap32(value);
-#endif
-
- *dst++ = value;
+ *dst++ = util_le32_to_cpu(value);
src += 8;
}
@@ -763,11 +671,7 @@ util_format_uyvy_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride,
value |= v << 16;
value |= y1 << 24;
-#ifdef PIPE_ARCH_BIG_ENDIAN
- value = util_bswap32(value);
-#endif
-
- *dst = value;
+ *dst = util_le32_to_cpu(value);
}
dst_row += dst_stride/sizeof(*dst_row);
@@ -809,11 +713,7 @@ util_format_yuyv_unpack_rgba_float(float *dst_row, unsigned dst_stride,
uint8_t y0, y1, u, v;
for (x = 0; x + 1 < width; x += 2) {
- value = *src++;
-
-#ifdef PIPE_ARCH_BIG_ENDIAN
- value = util_bswap32(value);
-#endif
+ value = util_cpu_to_le32(*src++);
y0 = (value >> 0) & 0xff;
u = (value >> 8) & 0xff;
@@ -830,11 +730,7 @@ util_format_yuyv_unpack_rgba_float(float *dst_row, unsigned dst_stride,
}
if (x < width) {
- value = *src;
-
-#ifdef PIPE_ARCH_BIG_ENDIAN
- value = util_bswap32(value);
-#endif
+ value = util_cpu_to_le32(*src);
y0 = (value >> 0) & 0xff;
u = (value >> 8) & 0xff;
@@ -865,11 +761,7 @@ util_format_yuyv_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride,
uint8_t y0, y1, u, v;
for (x = 0; x + 1 < width; x += 2) {
- value = *src++;
-
-#ifdef PIPE_ARCH_BIG_ENDIAN
- value = util_bswap32(value);
-#endif
+ value = util_cpu_to_le32(*src++);
y0 = (value >> 0) & 0xff;
u = (value >> 8) & 0xff;
@@ -886,11 +778,7 @@ util_format_yuyv_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride,
}
if (x < width) {
- value = *src;
-
-#ifdef PIPE_ARCH_BIG_ENDIAN
- value = util_bswap32(value);
-#endif
+ value = util_cpu_to_le32(*src);
y0 = (value >> 0) & 0xff;
u = (value >> 8) & 0xff;
@@ -936,11 +824,7 @@ util_format_yuyv_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride,
value |= y1 << 16;
value |= v << 24;
-#ifdef PIPE_ARCH_BIG_ENDIAN
- value = util_bswap32(value);
-#endif
-
- *dst++ = value;
+ *dst++ = util_le32_to_cpu(value);
src += 8;
}
@@ -955,11 +839,7 @@ util_format_yuyv_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride,
value |= y1 << 16;
value |= v << 24;
-#ifdef PIPE_ARCH_BIG_ENDIAN
- value = util_bswap32(value);
-#endif
-
- *dst = value;
+ *dst = util_le32_to_cpu(value);
}
dst_row += dst_stride/sizeof(*dst_row);
@@ -997,11 +877,7 @@ util_format_yuyv_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride,
value |= y1 << 16;
value |= v << 24;
-#ifdef PIPE_ARCH_BIG_ENDIAN
- value = util_bswap32(value);
-#endif
-
- *dst++ = value;
+ *dst++ = util_le32_to_cpu(value);
src += 8;
}
@@ -1016,11 +892,7 @@ util_format_yuyv_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride,
value |= y1 << 16;
value |= v << 24;
-#ifdef PIPE_ARCH_BIG_ENDIAN
- value = util_bswap32(value);
-#endif
-
- *dst = value;
+ *dst = util_le32_to_cpu(value);
}
dst_row += dst_stride/sizeof(*dst_row);
diff --git a/src/gallium/auxiliary/util/u_format_zs.c b/src/gallium/auxiliary/util/u_format_zs.c
index ed45c52..f1ed32f 100644
--- a/src/gallium/auxiliary/util/u_format_zs.c
+++ b/src/gallium/auxiliary/util/u_format_zs.c
@@ -147,10 +147,7 @@ util_format_z16_unorm_unpack_z_float(float *dst_row, unsigned dst_stride,
float *dst = dst_row;
const uint16_t *src = (const uint16_t *)src_row;
for(x = 0; x < width; ++x) {
- uint16_t value = *src++;
-#ifdef PIPE_ARCH_BIG_ENDIAN
- value = util_bswap16(value);
-#endif
+ uint16_t value = util_cpu_to_le16(*src++);
*dst++ = z16_unorm_to_z32_float(value);
}
src_row += src_stride/sizeof(*src_row);
@@ -170,10 +167,7 @@ util_format_z16_unorm_pack_z_float(uint8_t *dst_row, unsigned dst_stride,
for(x = 0; x < width; ++x) {
uint16_t value;
value = z32_float_to_z16_unorm(*src++);
-#ifdef PIPE_ARCH_BIG_ENDIAN
- value = util_bswap16(value);
-#endif
- *dst++ = value;
+ *dst++ = util_le16_to_cpu(value);
}
dst_row += dst_stride/sizeof(*dst_row);
src_row += src_stride/sizeof(*src_row);
@@ -190,10 +184,7 @@ util_format_z16_unorm_unpack_z_32unorm(uint32_t *dst_row, unsigned dst_stride,
uint32_t *dst = dst_row;
const uint16_t *src = (const uint16_t *)src_row;
for(x = 0; x < width; ++x) {
- uint16_t value = *src++;
-#ifdef PIPE_ARCH_BIG_ENDIAN
- value = util_bswap16(value);
-#endif
+ uint16_t value = util_cpu_to_le16(*src++);
*dst++ = z16_unorm_to_z32_unorm(value);
}
src_row += src_stride/sizeof(*src_row);
@@ -213,10 +204,7 @@ util_format_z16_unorm_pack_z_32unorm(uint8_t *dst_row, unsigned dst_stride,
for(x = 0; x < width; ++x) {
uint16_t value;
value = z32_unorm_to_z16_unorm(*src++);
-#ifdef PIPE_ARCH_BIG_ENDIAN
- value = util_bswap16(value);
-#endif
- *dst++ = value;
+ *dst++ = util_le16_to_cpu(value);
}
dst_row += dst_stride/sizeof(*dst_row);
src_row += src_stride/sizeof(*src_row);
@@ -233,10 +221,7 @@ util_format_z32_unorm_unpack_z_float(float *dst_row, unsigned dst_stride,
float *dst = dst_row;
const uint32_t *src = (const uint32_t *)src_row;
for(x = 0; x < width; ++x) {
- uint32_t value = *src++;
-#ifdef PIPE_ARCH_BIG_ENDIAN
- value = util_bswap32(value);
-#endif
+ uint32_t value = util_cpu_to_le32(*src++);
*dst++ = z32_unorm_to_z32_float(value);
}
src_row += src_stride/sizeof(*src_row);
@@ -256,10 +241,7 @@ util_format_z32_unorm_pack_z_float(uint8_t *dst_row, unsigned dst_stride,
for(x = 0; x < width; ++x) {
uint32_t value;
value = z32_float_to_z32_unorm(*src++);
-#ifdef PIPE_ARCH_BIG_ENDIAN
- value = util_bswap32(value);
-#endif
- *dst++ = value;
+ *dst++ = util_le32_to_cpu(value);
}
dst_row += dst_stride/sizeof(*dst_row);
src_row += src_stride/sizeof(*src_row);
@@ -362,10 +344,7 @@ util_format_z24_unorm_s8_uint_unpack_z_float(float *dst_row, unsigned dst_stride
float *dst = dst_row;
const uint32_t *src = (const uint32_t *)src_row;
for(x = 0; x < width; ++x) {
- uint32_t value = *src++;
-#ifdef PIPE_ARCH_BIG_ENDIAN
- value = util_bswap32(value);
-#endif
+ uint32_t value = util_cpu_to_le32(*src++);
*dst++ = z24_unorm_to_z32_float(value & 0xffffff);
}
src_row += src_stride/sizeof(*src_row);
@@ -383,16 +362,10 @@ util_format_z24_unorm_s8_uint_pack_z_float(uint8_t *dst_row, unsigned dst_stride
const float *src = src_row;
uint32_t *dst = (uint32_t *)dst_row;
for(x = 0; x < width; ++x) {
- uint32_t value = *dst;
-#ifdef PIPE_ARCH_BIG_ENDIAN
- value = util_bswap32(value);
-#endif
+ uint32_t value = util_le32_to_cpu(*dst);
value &= 0xff000000;
value |= z32_float_to_z24_unorm(*src++);
-#ifdef PIPE_ARCH_BIG_ENDIAN
- value = util_bswap32(value);
-#endif
- *dst++ = value;
+ *dst++ = util_cpu_to_le32(value);
}
dst_row += dst_stride/sizeof(*dst_row);
src_row += src_stride/sizeof(*src_row);
@@ -409,10 +382,7 @@ util_format_z24_unorm_s8_uint_unpack_z_32unorm(uint32_t *dst_row, unsigned dst_s
uint32_t *dst = dst_row;
const uint32_t *src = (const uint32_t *)src_row;
for(x = 0; x < width; ++x) {
- uint32_t value = *src++;
-#ifdef PIPE_ARCH_BIG_ENDIAN
- value = util_bswap32(value);
-#endif
+ uint32_t value = util_cpu_to_le32(*src++);
*dst++ = z24_unorm_to_z32_unorm(value & 0xffffff);
}
src_row += src_stride/sizeof(*src_row);
@@ -430,16 +400,10 @@ util_format_z24_unorm_s8_uint_pack_z_32unorm(uint8_t *dst_row, unsigned dst_stri
const uint32_t *src = src_row;
uint32_t *dst = (uint32_t *)dst_row;
for(x = 0; x < width; ++x) {
- uint32_t value= *dst;
-#ifdef PIPE_ARCH_BIG_ENDIAN
- value = util_bswap32(value);
-#endif
+ uint32_t value = util_le32_to_cpu(*dst);
value &= 0xff000000;
value |= z32_unorm_to_z24_unorm(*src++);
-#ifdef PIPE_ARCH_BIG_ENDIAN
- value = util_bswap32(value);
-#endif
- *dst++ = value;
+ *dst++ = util_cpu_to_le32(value);
}
dst_row += dst_stride/sizeof(*dst_row);
src_row += src_stride/sizeof(*src_row);
@@ -456,10 +420,7 @@ util_format_z24_unorm_s8_uint_unpack_s_8uint(uint8_t *dst_row, unsigned dst_stri
uint8_t *dst = dst_row;
const uint32_t *src = (const uint32_t *)src_row;
for(x = 0; x < width; ++x) {
- uint32_t value = *src++;
-#ifdef PIPE_ARCH_BIG_ENDIAN
- value = util_bswap32(value);
-#endif
+ uint32_t value = util_cpu_to_le32(*src++);
*dst++ = value >> 24;
}
src_row += src_stride/sizeof(*src_row);
@@ -477,16 +438,10 @@ util_format_z24_unorm_s8_uint_pack_s_8uint(uint8_t *dst_row, unsigned dst_stride
const uint8_t *src = src_row;
uint32_t *dst = (uint32_t *)dst_row;
for(x = 0; x < width; ++x) {
- uint32_t value = *dst;
-#ifdef PIPE_ARCH_BIG_ENDIAN
- value = util_bswap32(value);
-#endif
+ uint32_t value = util_le32_to_cpu(*dst);
value &= 0x00ffffff;
value |= *src++ << 24;
-#ifdef PIPE_ARCH_BIG_ENDIAN
- value = util_bswap32(value);
-#endif
- *dst++ = value;
+ *dst++ = util_cpu_to_le32(value);
}
dst_row += dst_stride/sizeof(*dst_row);
src_row += src_stride/sizeof(*src_row);
@@ -503,10 +458,7 @@ util_format_s8_uint_z24_unorm_unpack_z_float(float *dst_row, unsigned dst_stride
float *dst = dst_row;
const uint32_t *src = (const uint32_t *)src_row;
for(x = 0; x < width; ++x) {
- uint32_t value = *src++;
-#ifdef PIPE_ARCH_BIG_ENDIAN
- value = util_bswap32(value);
-#endif
+ uint32_t value = util_cpu_to_le32(*src++);
*dst++ = z24_unorm_to_z32_float(value >> 8);
}
src_row += src_stride/sizeof(*src_row);
@@ -524,16 +476,10 @@ util_format_s8_uint_z24_unorm_pack_z_float(uint8_t *dst_row, unsigned dst_stride
const float *src = src_row;
uint32_t *dst = (uint32_t *)dst_row;
for(x = 0; x < width; ++x) {
- uint32_t value = *dst;
-#ifdef PIPE_ARCH_BIG_ENDIAN
- value = util_bswap32(value);
-#endif
+ uint32_t value = util_le32_to_cpu(*dst);
value &= 0x000000ff;
value |= z32_float_to_z24_unorm(*src++) << 8;
-#ifdef PIPE_ARCH_BIG_ENDIAN
- value = util_bswap32(value);
-#endif
- *dst++ = value;
+ *dst++ = util_cpu_to_le32(value);
}
dst_row += dst_stride/sizeof(*dst_row);
src_row += src_stride/sizeof(*src_row);
@@ -550,10 +496,7 @@ util_format_s8_uint_z24_unorm_unpack_z_32unorm(uint32_t *dst_row, unsigned dst_s
uint32_t *dst = dst_row;
const uint32_t *src = (const uint32_t *)src_row;
for(x = 0; x < width; ++x) {
- uint32_t value = *src++;
-#ifdef PIPE_ARCH_BIG_ENDIAN
- value = util_bswap32(value);
-#endif
+ uint32_t value = util_cpu_to_le32(*src++);
*dst++ = z24_unorm_to_z32_unorm(value >> 8);
}
src_row += src_stride/sizeof(*src_row);
@@ -571,16 +514,10 @@ util_format_s8_uint_z24_unorm_pack_z_32unorm(uint8_t *dst_row, unsigned dst_stri
const uint32_t *src = src_row;
uint32_t *dst = (uint32_t *)dst_row;
for(x = 0; x < width; ++x) {
- uint32_t value = *dst;
-#ifdef PIPE_ARCH_BIG_ENDIAN
- value = util_bswap32(value);
-#endif
+ uint32_t value = util_le32_to_cpu(*dst);
value &= 0x000000ff;
value |= *src++ & 0xffffff00;
-#ifdef PIPE_ARCH_BIG_ENDIAN
- value = util_bswap32(value);
-#endif
- *dst++ = value;
+ *dst++ = util_cpu_to_le32(value);
}
dst_row += dst_stride/sizeof(*dst_row);
src_row += src_stride/sizeof(*src_row);
@@ -597,10 +534,7 @@ util_format_s8_uint_z24_unorm_unpack_s_8uint(uint8_t *dst_row, unsigned dst_stri
uint8_t *dst = dst_row;
const uint32_t *src = (const uint32_t *)src_row;
for(x = 0; x < width; ++x) {
- uint32_t value = *src++;
-#ifdef PIPE_ARCH_BIG_ENDIAN
- value = util_bswap32(value);
-#endif
+ uint32_t value = util_cpu_to_le32(*src++);
*dst++ = value & 0xff;
}
src_row += src_stride/sizeof(*src_row);
@@ -618,16 +552,10 @@ util_format_s8_uint_z24_unorm_pack_s_8uint(uint8_t *dst_row, unsigned dst_stride
const uint8_t *src = src_row;
uint32_t *dst = (uint32_t *)dst_row;
for(x = 0; x < width; ++x) {
- uint32_t value = *dst;
-#ifdef PIPE_ARCH_BIG_ENDIAN
- value = util_bswap32(value);
-#endif
+ uint32_t value = util_le32_to_cpu(*dst);
value &= 0xffffff00;
value |= *src++;
-#ifdef PIPE_ARCH_BIG_ENDIAN
- value = util_bswap32(value);
-#endif
- *dst++ = value;
+ *dst++ = util_cpu_to_le32(value);
}
dst_row += dst_stride/sizeof(*dst_row);
src_row += src_stride/sizeof(*src_row);
@@ -644,10 +572,7 @@ util_format_z24x8_unorm_unpack_z_float(float *dst_row, unsigned dst_stride,
float *dst = dst_row;
const uint32_t *src = (const uint32_t *)src_row;
for(x = 0; x < width; ++x) {
- uint32_t value = *src++;
-#ifdef PIPE_ARCH_BIG_ENDIAN
- value = util_bswap32(value);
-#endif
+ uint32_t value = util_cpu_to_le32(*src++);
*dst++ = z24_unorm_to_z32_float(value & 0xffffff);
}
src_row += src_stride/sizeof(*src_row);
@@ -667,10 +592,7 @@ util_format_z24x8_unorm_pack_z_float(uint8_t *dst_row, unsigned dst_stride,
for(x = 0; x < width; ++x) {
uint32_t value;
value = z32_float_to_z24_unorm(*src++);
-#ifdef PIPE_ARCH_BIG_ENDIAN
- value = util_bswap32(value);
-#endif
- *dst++ = value;
+ *dst++ = util_le32_to_cpu(value);
}
dst_row += dst_stride/sizeof(*dst_row);
src_row += src_stride/sizeof(*src_row);
@@ -687,10 +609,7 @@ util_format_z24x8_unorm_unpack_z_32unorm(uint32_t *dst_row, unsigned dst_stride,
uint32_t *dst = dst_row;
const uint32_t *src = (const uint32_t *)src_row;
for(x = 0; x < width; ++x) {
- uint32_t value = *src++;
-#ifdef PIPE_ARCH_BIG_ENDIAN
- value = util_bswap32(value);
-#endif
+ uint32_t value = util_cpu_to_le32(*src++);
*dst++ = z24_unorm_to_z32_unorm(value & 0xffffff);
}
src_row += src_stride/sizeof(*src_row);
@@ -710,10 +629,7 @@ util_format_z24x8_unorm_pack_z_32unorm(uint8_t *dst_row, unsigned dst_stride,
for(x = 0; x < width; ++x) {
uint32_t value;
value = z32_unorm_to_z24_unorm(*src++);
-#ifdef PIPE_ARCH_BIG_ENDIAN
- value = util_bswap32(value);
-#endif
- *dst++ = value;
+ *dst++ = util_cpu_to_le32(value);
}
dst_row += dst_stride/sizeof(*dst_row);
src_row += src_stride/sizeof(*src_row);
@@ -730,10 +646,7 @@ util_format_x8z24_unorm_unpack_z_float(float *dst_row, unsigned dst_stride,
float *dst = dst_row;
const uint32_t *src = (uint32_t *)src_row;
for(x = 0; x < width; ++x) {
- uint32_t value = *src++;
-#ifdef PIPE_ARCH_BIG_ENDIAN
- value = util_bswap32(value);
-#endif
+ uint32_t value = util_cpu_to_le32(*src++);
*dst++ = z24_unorm_to_z32_float(value >> 8);
}
src_row += src_stride/sizeof(*src_row);
@@ -753,10 +666,7 @@ util_format_x8z24_unorm_pack_z_float(uint8_t *dst_row, unsigned dst_stride,
for(x = 0; x < width; ++x) {
uint32_t value;
value = z32_float_to_z24_unorm(*src++) << 8;
-#ifdef PIPE_ARCH_BIG_ENDIAN
- value = util_bswap32(value);
-#endif
- *dst++ = value;
+ *dst++ = util_cpu_to_le32(value);
}
dst_row += dst_stride/sizeof(*dst_row);
src_row += src_stride/sizeof(*src_row);
@@ -773,10 +683,7 @@ util_format_x8z24_unorm_unpack_z_32unorm(uint32_t *dst_row, unsigned dst_stride,
uint32_t *dst = dst_row;
const uint32_t *src = (const uint32_t *)src_row;
for(x = 0; x < width; ++x) {
- uint32_t value = *src++;
-#ifdef PIPE_ARCH_BIG_ENDIAN
- value = util_bswap32(value);
-#endif
+ uint32_t value = util_cpu_to_le32(*src++);
*dst++ = z24_unorm_to_z32_unorm(value >> 8);
}
src_row += src_stride/sizeof(*src_row);
@@ -796,10 +703,7 @@ util_format_x8z24_unorm_pack_z_32unorm(uint8_t *dst_row, unsigned dst_stride,
for(x = 0; x < width; ++x) {
uint32_t value;
value = z32_unorm_to_z24_unorm(*src++) << 8;
-#ifdef PIPE_ARCH_BIG_ENDIAN
- value = util_bswap32(value);
-#endif
- *dst++ = value;
+ *dst++ = util_cpu_to_le32(value);
}
dst_row += dst_stride/sizeof(*dst_row);
src_row += src_stride/sizeof(*src_row);
diff --git a/src/gallium/auxiliary/vl/vl_vlc.h b/src/gallium/auxiliary/vl/vl_vlc.h
index 2f90595..cad9989 100644
--- a/src/gallium/auxiliary/vl/vl_vlc.h
+++ b/src/gallium/auxiliary/vl/vl_vlc.h
@@ -149,11 +149,7 @@ vl_vlc_fillbits(struct vl_vlc *vlc)
} else if (bytes_left >= 4) {
/* enough bytes in buffer, read in a whole dword */
- uint64_t value = *(const uint32_t*)vlc->data;
-
-#ifndef PIPE_ARCH_BIG_ENDIAN
- value = util_bswap32(value);
-#endif
+ uint64_t value = util_cpu_to_le32(*(const uint32_t*)vlc->data);
vlc->buffer |= value << vlc->invalid_bits;
vlc->data += 4;