aboutsummaryrefslogtreecommitdiff
path: root/mesalib/src/gallium/auxiliary/util/u_format_other.c
diff options
context:
space:
mode:
Diffstat (limited to 'mesalib/src/gallium/auxiliary/util/u_format_other.c')
-rw-r--r--mesalib/src/gallium/auxiliary/util/u_format_other.c80
1 files changed, 15 insertions, 65 deletions
diff --git a/mesalib/src/gallium/auxiliary/util/u_format_other.c b/mesalib/src/gallium/auxiliary/util/u_format_other.c
index 85001c14f..20752d469 100644
--- a/mesalib/src/gallium/auxiliary/util/u_format_other.c
+++ b/mesalib/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;