summaryrefslogtreecommitdiffstats
path: root/src/gallium/auxiliary/gallivm/lp_bld_swizzle.c
diff options
context:
space:
mode:
authorAdhemerval Zanella <azanella@linux.vnet.ibm.com>2012-11-22 13:48:45 -0600
committerJosé Fonseca <jfonseca@vmware.com>2012-11-29 11:54:18 +0000
commite25abacc1883f1b2e09c32230e35ffae7df5e61b (patch)
tree6afc27a9233c351b69d378f88e6da1952d785779 /src/gallium/auxiliary/gallivm/lp_bld_swizzle.c
parentb772d784b25771ff939e3c0c87fdf0d8053827be (diff)
downloadexternal_mesa3d-e25abacc1883f1b2e09c32230e35ffae7df5e61b.zip
external_mesa3d-e25abacc1883f1b2e09c32230e35ffae7df5e61b.tar.gz
external_mesa3d-e25abacc1883f1b2e09c32230e35ffae7df5e61b.tar.bz2
gallivm: Fix format manipulation for big-endian
This patch fixes various format manipulation for big-endian architectures. Reviewed-by: Roland Scheidegger <sroland@vmware.com> Reviewed-by: Jose Fonseca <jfonseca@vmware.com>
Diffstat (limited to 'src/gallium/auxiliary/gallivm/lp_bld_swizzle.c')
-rw-r--r--src/gallium/auxiliary/gallivm/lp_bld_swizzle.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/src/gallium/auxiliary/gallivm/lp_bld_swizzle.c b/src/gallium/auxiliary/gallivm/lp_bld_swizzle.c
index ae4033b..08d817a 100644
--- a/src/gallium/auxiliary/gallivm/lp_bld_swizzle.c
+++ b/src/gallium/auxiliary/gallivm/lp_bld_swizzle.c
@@ -431,10 +431,16 @@ lp_build_swizzle_aos(struct lp_build_context *bld,
*
* For example, this will convert BGRA to RGBA by doing
*
+ * Little endian:
* rgba = (bgra & 0x00ff0000) >> 16
* | (bgra & 0xff00ff00)
* | (bgra & 0x000000ff) << 16
*
+ * Big endian:A
+ * rgba = (bgra & 0x0000ff00) << 16
+ * | (bgra & 0x00ff00ff)
+ * | (bgra & 0xff000000) >> 16
+ *
* This is necessary not only for faster cause, but because X86 backend
* will refuse shuffles of <4 x i8> vectors
*/
@@ -479,7 +485,11 @@ lp_build_swizzle_aos(struct lp_build_context *bld,
/* FIXME: big endian */
if (swizzles[chan] < 4 &&
chan - swizzles[chan] == shift) {
+#ifdef PIPE_ARCH_LITTLE_ENDIAN
mask |= ((1ULL << type.width) - 1) << (swizzles[chan] * type.width);
+#else
+ mask |= ((1ULL << type.width) - 1) << (type4.width - type.width) >> (swizzles[chan] * type.width);
+#endif
}
}
@@ -492,11 +502,21 @@ lp_build_swizzle_aos(struct lp_build_context *bld,
masked = LLVMBuildAnd(builder, a,
lp_build_const_int_vec(bld->gallivm, type4, mask), "");
if (shift > 0) {
+#ifdef PIPE_ARCH_LITTLE_ENDIAN
shifted = LLVMBuildShl(builder, masked,
lp_build_const_int_vec(bld->gallivm, type4, shift*type.width), "");
+#else
+ shifted = LLVMBuildLShr(builder, masked,
+ lp_build_const_int_vec(bld->gallivm, type4, shift*type.width), "");
+#endif
} else if (shift < 0) {
+#ifdef PIPE_ARCH_LITTLE_ENDIAN
shifted = LLVMBuildLShr(builder, masked,
lp_build_const_int_vec(bld->gallivm, type4, -shift*type.width), "");
+#else
+ shifted = LLVMBuildShl(builder, masked,
+ lp_build_const_int_vec(bld->gallivm, type4, -shift*type.width), "");
+#endif
} else {
shifted = masked;
}