diff options
author | Matt Turner <[email protected]> | 2015-02-20 19:46:21 -0800 |
---|---|---|
committer | Matt Turner <[email protected]> | 2015-02-23 10:41:22 -0800 |
commit | 14ded5ee61b2dfc23878c4a6f38021b15bd0a2fc (patch) | |
tree | c18fe35996ccfe416e558683075479876537830d /src/gallium/auxiliary/translate/translate_generic.c | |
parent | 3492e88090d2d0c0bfbc934963b8772b45fc8880 (diff) |
gallium: Use util_cpu_to_le{16,32} in many more places.
... and util_le{16,32}_to_cpu. I think I've used the right ones for
describing the actual operation performed (even though they're both just
"byte-swap this if I'm on big-endian").
The Linux Kernel has typedefs __le32/__be32 and friends that static
analysis tools can use to check that byte-orderings are correct. It
might be interesting to apply that here as well.
Reviewed-by: Eric Anholt <[email protected]>
Reviewed-by: Jose Fonseca <[email protected]>
Diffstat (limited to 'src/gallium/auxiliary/translate/translate_generic.c')
-rw-r--r-- | src/gallium/auxiliary/translate/translate_generic.c | 40 |
1 files changed, 8 insertions, 32 deletions
diff --git a/src/gallium/auxiliary/translate/translate_generic.c b/src/gallium/auxiliary/translate/translate_generic.c index 26b87c5af1c..45eb63231e3 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 |