summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRay Strode <rstrode@redhat.com>2017-08-23 16:32:42 -0400
committerAndres Gomez <agomez@igalia.com>2017-09-06 18:05:10 +0300
commita1bdc43dd203396647a03a50e64d67707d8322b5 (patch)
tree4574310b0a026d045bdc645fa49799044f8b753c
parentf4266d73b54d821a63c97a94d7494e7689e5dc5a (diff)
gallivm: correct channel shift logic on big endian
lp_build_fetch_rgba_soa fetches a texel from a texture. Part of that process involves first gathering the element together from memory into a packed format, and then breaking out the individual color channels into separate, parallel arrays. The code fails to account for endianess when reading the packed values. This commit attempts to correct the problem by reversing the order the packed values are read on big endian systems. Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=100613 Cc: "17.2" "17.1" <mesa-stable@lists.freedesktop.org> Signed-off-by: Ray Strode <rstrode@redhat.com> Reviewed-by: Roland Scheidegger <sroland@vmware.com> (cherry picked from commit 75cb6e36178b9474bbb59b76cbbcce2a67bf88d2)
-rw-r--r--src/gallium/auxiliary/gallivm/lp_bld_format_soa.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/gallium/auxiliary/gallivm/lp_bld_format_soa.c b/src/gallium/auxiliary/gallivm/lp_bld_format_soa.c
index 98eb694c1f6..22c19b10dbd 100644
--- a/src/gallium/auxiliary/gallivm/lp_bld_format_soa.c
+++ b/src/gallium/auxiliary/gallivm/lp_bld_format_soa.c
@@ -650,7 +650,13 @@ lp_build_fetch_rgba_soa(struct gallivm_state *gallivm,
for (i = 0; i < format_desc->nr_channels; i++) {
struct util_format_channel_description chan_desc = format_desc->channel[i];
unsigned blockbits = type.width;
- unsigned vec_nr = chan_desc.shift / type.width;
+ unsigned vec_nr;
+
+#ifdef PIPE_ARCH_BIG_ENDIAN
+ vec_nr = (format_desc->block.bits - (chan_desc.shift + chan_desc.size)) / type.width;
+#else
+ vec_nr = chan_desc.shift / type.width;
+#endif
chan_desc.shift %= type.width;
output[i] = lp_build_extract_soa_chan(&bld,