summaryrefslogtreecommitdiffstats
path: root/src/gallium/auxiliary/util
diff options
context:
space:
mode:
authorAdam Jackson <ajax@redhat.com>2013-06-24 09:48:56 -0400
committerAdam Jackson <ajax@redhat.com>2013-06-24 09:48:56 -0400
commit2151d893fbd4a4be092098170e2fbca8c35797a5 (patch)
tree88af00d0b64d08bf04d33f972709db32aecf884d /src/gallium/auxiliary/util
parentd282f4ea9b99e4eefec8ce0664cdf49d53d7b052 (diff)
downloadexternal_mesa3d-2151d893fbd4a4be092098170e2fbca8c35797a5.zip
external_mesa3d-2151d893fbd4a4be092098170e2fbca8c35797a5.tar.gz
external_mesa3d-2151d893fbd4a4be092098170e2fbca8c35797a5.tar.bz2
gallium: Fix llvmpipe on big-endian machines
Squashed commit of the following: commit 0857a7e105bfcbc4d1431b2cc56612094c747ca3 Author: Richard Sandiford <r.sandiford@uk.ibm.com> Date: Tue Jun 18 12:25:07 2013 -0400 gallivm: Fix lp_build_rgba8_to_fi32_soa for big endian Reviewed-by: Adam Jackson <ajax@redhat.com> Signed-off-by: Richard Sandiford <r.sandiford@uk.ibm.com> commit 0d65131649a8aa140e2db228ba779d685c4333e3 Author: Richard Sandiford <r.sandiford@uk.ibm.com> Date: Tue Jun 18 12:25:07 2013 -0400 gallivm: Fix big-endian machines This adds a bit-shift count to the format table, and adds the concept of vector or bitwise alignment on gathers. Reviewed-by: Adam Jackson <ajax@redhat.com> Signed-off-by: Richard Sandiford <r.sandiford@uk.ibm.com> commit 9740bda9b7dc894b629ed38be9b51059ce90818f Author: Richard Sandiford <r.sandiford@uk.ibm.com> Date: Tue Jun 18 12:25:07 2013 -0400 llvmpipe: Fix convert_to_blend_type on big-endian Reviewed-by: Adam Jackson <ajax@redhat.com> Signed-off-by: Richard Sandiford <r.sandiford@uk.ibm.com> commit ae037c2de0f029e4e99371c0de25560484f0d8df Author: Richard Sandiford <r.sandiford@uk.ibm.com> Date: Tue Jun 18 12:25:06 2013 -0400 util: Convert color pack to packed formats This fixes them on big-endian. Reviewed-by: Adam Jackson <ajax@redhat.com> Signed-off-by: Richard Sandiford <r.sandiford@uk.ibm.com> commit 5b05ac0c89ae092ea8ba5bba9f739708d7396b5c Author: Richard Sandiford <r.sandiford@uk.ibm.com> Date: Tue Jun 18 12:25:06 2013 -0400 graw-xlib: Convert to packed formats Reviewed-by: Adam Jackson <ajax@redhat.com> Signed-off-by: Richard Sandiford <r.sandiford@uk.ibm.com> commit 51396e7d098cb6ff794391cf11afe4dbf86dbea0 Author: Richard Sandiford <r.sandiford@uk.ibm.com> Date: Tue Jun 18 12:25:06 2013 -0400 format: Convert to packed formats Reviewed-by: Adam Jackson <ajax@redhat.com> Signed-off-by: Richard Sandiford <r.sandiford@uk.ibm.com> commit 417b60bc66eb450e68a92ab0e47f76e292b385e6 Author: Adam Jackson <ajax@redhat.com> Date: Tue Jun 18 12:25:06 2013 -0400 st/dri: Convert to packed formats Reviewed-by: Adam Jackson <ajax@redhat.com> Signed-off-by: Richard Sandiford <r.sandiford@uk.ibm.com> commit 0934b2e022a5e0847d312c40734e2b44cac52fd8 Author: Richard Sandiford <r.sandiford@uk.ibm.com> Date: Tue Jun 18 12:25:06 2013 -0400 st/xlib: Convert to packed formats Reviewed-by: Adam Jackson <ajax@redhat.com> Signed-off-by: Richard Sandiford <r.sandiford@uk.ibm.com> commit a307ea3c3716a706963acce7966b5e405ba11db9 Author: Richard Sandiford <r.sandiford@uk.ibm.com> Date: Tue Jun 18 12:25:06 2013 -0400 gbm: Convert to packed formats Reviewed-by: Adam Jackson <ajax@redhat.com> Signed-off-by: Richard Sandiford <r.sandiford@uk.ibm.com> commit 53eebdd253e1960a645ea278f31d7ef6a6cf4aeb Author: Richard Sandiford <r.sandiford@uk.ibm.com> Date: Tue Jun 18 12:25:06 2013 -0400 tests: Convert to packed formats Reviewed-by: Adam Jackson <ajax@redhat.com> Signed-off-by: Richard Sandiford <r.sandiford@uk.ibm.com> commit 2f77fe3ee524945eacd546efcac34f7799fb3124 Author: Adam Jackson <ajax@redhat.com> Date: Tue Jun 18 13:07:37 2013 -0400 gallium: Document packed formats Signed-off-by: Adam Jackson <ajax@redhat.com> commit 1f1017159ce951f922210a430de9229f91f62714 Author: Richard Sandiford <r.sandiford@uk.ibm.com> Date: Tue Jun 18 12:25:06 2013 -0400 gallium: Introduce 32-bit packed format names These are for interacting with buffers natively described in terms of bit shifts, like X11 visuals: uint32_t xyzw8888 = (x << 0) | (y << 8) | (z << 16) | (w << 24); Define these in terms of (endian-dependent) aliases to the array-style format names. Reviewed-by: Adam Jackson <ajax@redhat.com> Signed-off-by: Richard Sandiford <r.sandiford@uk.ibm.com> commit 6cc7ab1ee66ed668da78c1d951dfd7782b4e786a Author: Adam Jackson <ajax@redhat.com> Date: Mon Jun 3 12:10:32 2013 -0400 gallium: Document format name conventions v2: - Fix a channel name thinko (Michel Dänzer) - Elaborate on SCALED versus INT - Add links to DirectX and FOURCC docs Signed-off-by: Adam Jackson <ajax@redhat.com> commit df4d269e7fb62051a3c029b84147465001e5776e Author: Adam Jackson <ajax@redhat.com> Date: Tue Jun 18 12:25:06 2013 -0400 gallivm: Remove all notion of byte-swapping Signed-off-by: Adam Jackson <ajax@redhat.com> Signed-off-by: Adam Jackson <ajax@redhat.com>
Diffstat (limited to 'src/gallium/auxiliary/util')
-rw-r--r--src/gallium/auxiliary/util/u_format.h25
-rw-r--r--src/gallium/auxiliary/util/u_format_pack.py29
-rwxr-xr-xsrc/gallium/auxiliary/util/u_format_parse.py10
-rwxr-xr-xsrc/gallium/auxiliary/util/u_format_table.py4
-rw-r--r--src/gallium/auxiliary/util/u_pack_color.h36
5 files changed, 56 insertions, 48 deletions
diff --git a/src/gallium/auxiliary/util/u_format.h b/src/gallium/auxiliary/util/u_format.h
index 4cace6a..9774a2b 100644
--- a/src/gallium/auxiliary/util/u_format.h
+++ b/src/gallium/auxiliary/util/u_format.h
@@ -133,6 +133,7 @@ struct util_format_channel_description
unsigned normalized:1;
unsigned pure_integer:1;
unsigned size:9; /**< bits per channel */
+ unsigned shift:16; /** number of bits from lsb */
};
@@ -179,9 +180,31 @@ struct util_format_description
unsigned is_mixed:1;
/**
- * Input channel description.
+ * Input channel description, in the order XYZW.
*
* Only valid for UTIL_FORMAT_LAYOUT_PLAIN formats.
+ *
+ * If each channel is accessed as an individual N-byte value, X is always
+ * at the lowest address in memory, Y is always next, and so on. For all
+ * currently-defined formats, the N-byte value has native endianness.
+ *
+ * If instead a group of channels is accessed as a single N-byte value,
+ * the order of the channels within that value depends on endianness.
+ * For big-endian targets, X is the most significant subvalue,
+ * otherwise it is the least significant one.
+ *
+ * For example, if X is 8 bits and Y is 24 bits, the memory order is:
+ *
+ * 0 1 2 3
+ * little-endian: X Yl Ym Yu (l = lower, m = middle, u = upper)
+ * big-endian: X Yu Ym Yl
+ *
+ * If X is 5 bits, Y is 5 bits, Z is 5 bits and W is 1 bit, the layout is:
+ *
+ * 0 1
+ * msb lsb msb lsb
+ * little-endian: YYYXXXXX WZZZZZYY
+ * big-endian: XXXXXYYY YYZZZZZW
*/
struct util_format_channel_description channel[4];
diff --git a/src/gallium/auxiliary/util/u_format_pack.py b/src/gallium/auxiliary/util/u_format_pack.py
index 565d059..d1f68c8 100644
--- a/src/gallium/auxiliary/util/u_format_pack.py
+++ b/src/gallium/auxiliary/util/u_format_pack.py
@@ -99,15 +99,6 @@ def generate_format_type(format):
print
-def bswap_format(format):
- '''Generate a structure that describes the format.'''
-
- if format.is_bitmask() and not format.is_array() and format.block_size() > 8:
- print '#ifdef PIPE_ARCH_BIG_ENDIAN'
- print ' pixel.value = util_bswap%u(pixel.value);' % format.block_size()
- print '#endif'
-
-
def is_format_supported(format):
'''Determines whether we actually have the plumbing necessary to generate the
to read/write to/from this format.'''
@@ -423,16 +414,11 @@ def generate_unpack_kernel(format, dst_channel, dst_native_type):
elif src_channel.type == SIGNED:
print ' int%u_t %s;' % (depth, src_channel.name)
- if depth > 8:
- print '#ifdef PIPE_ARCH_BIG_ENDIAN'
- print ' value = util_bswap%u(value);' % depth
- print '#endif'
-
# Compute the intermediate unshifted values
- shift = 0
for i in range(format.nr_channels()):
src_channel = format.channels[i]
value = 'value'
+ shift = src_channel.shift
if src_channel.type == UNSIGNED:
if shift:
value = '%s >> %u' % (value, shift)
@@ -455,8 +441,6 @@ def generate_unpack_kernel(format, dst_channel, dst_native_type):
if value is not None:
print ' %s = %s;' % (src_channel.name, value)
- shift += src_channel.size
-
# Convert, swizzle, and store final values
for i in range(4):
swizzle = format.swizzles[i]
@@ -484,7 +468,6 @@ def generate_unpack_kernel(format, dst_channel, dst_native_type):
else:
print ' union util_format_%s pixel;' % format.short_name()
print ' memcpy(&pixel, src, sizeof pixel);'
- bswap_format(format)
for i in range(4):
swizzle = format.swizzles[i]
@@ -525,9 +508,9 @@ def generate_pack_kernel(format, src_channel, src_native_type):
depth = format.block_size()
print ' uint%u_t value = 0;' % depth
- shift = 0
for i in range(4):
dst_channel = format.channels[i]
+ shift = dst_channel.shift
if inv_swizzle[i] is not None:
value ='src[%u]' % inv_swizzle[i]
dst_colorspace = format.colorspace
@@ -551,13 +534,6 @@ def generate_pack_kernel(format, src_channel, src_native_type):
if value is not None:
print ' value |= %s;' % (value)
- shift += dst_channel.size
-
- if depth > 8:
- print '#ifdef PIPE_ARCH_BIG_ENDIAN'
- print ' value = util_bswap%u(value);' % depth
- print '#endif'
-
print ' *(uint%u_t *)dst = value;' % depth
else:
@@ -579,7 +555,6 @@ def generate_pack_kernel(format, src_channel, src_native_type):
dst_colorspace = dst_colorspace)
print ' pixel.chan.%s = %s;' % (dst_channel.name, value)
- bswap_format(format)
print ' memcpy(dst, &pixel, sizeof pixel);'
diff --git a/src/gallium/auxiliary/util/u_format_parse.py b/src/gallium/auxiliary/util/u_format_parse.py
index 07052b9..e202099 100755
--- a/src/gallium/auxiliary/util/u_format_parse.py
+++ b/src/gallium/auxiliary/util/u_format_parse.py
@@ -30,6 +30,8 @@
'''
+import sys
+
VOID, UNSIGNED, SIGNED, FIXED, FLOAT = range(5)
SWIZZLE_X, SWIZZLE_Y, SWIZZLE_Z, SWIZZLE_W, SWIZZLE_0, SWIZZLE_1, SWIZZLE_NONE, = range(7)
@@ -42,6 +44,9 @@ YUV = 'yuv'
ZS = 'zs'
+# Not cross-compiler friendly
+is_big_endian = sys.byteorder == 'big'
+
def is_pot(x):
return (x & (x - 1)) == 0
@@ -307,6 +312,11 @@ def parse(filename):
channel = Channel(type, norm, pure, size, names[i])
channels.append(channel)
+ shift = 0
+ for channel in channels[3::-1] if is_big_endian else channels:
+ channel.shift = shift
+ shift += channel.size
+
format = Format(name, layout, block_width, block_height, channels, swizzles, colorspace)
formats.append(format)
return formats
diff --git a/src/gallium/auxiliary/util/u_format_table.py b/src/gallium/auxiliary/util/u_format_table.py
index 8edb505..9d44cf3 100755
--- a/src/gallium/auxiliary/util/u_format_table.py
+++ b/src/gallium/auxiliary/util/u_format_table.py
@@ -114,9 +114,9 @@ def write_format_table(formats):
else:
sep = ""
if channel.size:
- print " {%s, %s, %s, %u}%s\t/* %s = %s */" % (type_map[channel.type], bool_map(channel.norm), bool_map(channel.pure), channel.size, sep, "xyzw"[i], channel.name)
+ print " {%s, %s, %s, %u, %u}%s\t/* %s = %s */" % (type_map[channel.type], bool_map(channel.norm), bool_map(channel.pure), channel.size, channel.shift, sep, "xyzw"[i], channel.name)
else:
- print " {0, 0, 0, 0}%s" % (sep,)
+ print " {0, 0, 0, 0, 0}%s" % (sep,)
print " },"
print " {"
for i in range(4):
diff --git a/src/gallium/auxiliary/util/u_pack_color.h b/src/gallium/auxiliary/util/u_pack_color.h
index 1f6a56a..102ad60 100644
--- a/src/gallium/auxiliary/util/u_pack_color.h
+++ b/src/gallium/auxiliary/util/u_pack_color.h
@@ -65,32 +65,32 @@ util_pack_color_ub(ubyte r, ubyte g, ubyte b, ubyte a,
enum pipe_format format, union util_color *uc)
{
switch (format) {
- case PIPE_FORMAT_A8B8G8R8_UNORM:
+ case PIPE_FORMAT_ABGR8888_UNORM:
{
uc->ui = (r << 24) | (g << 16) | (b << 8) | a;
}
return;
- case PIPE_FORMAT_X8B8G8R8_UNORM:
+ case PIPE_FORMAT_XBGR8888_UNORM:
{
uc->ui = (r << 24) | (g << 16) | (b << 8) | 0xff;
}
return;
- case PIPE_FORMAT_B8G8R8A8_UNORM:
+ case PIPE_FORMAT_BGRA8888_UNORM:
{
uc->ui = (a << 24) | (r << 16) | (g << 8) | b;
}
return;
- case PIPE_FORMAT_B8G8R8X8_UNORM:
+ case PIPE_FORMAT_BGRX8888_UNORM:
{
uc->ui = (0xff << 24) | (r << 16) | (g << 8) | b;
}
return;
- case PIPE_FORMAT_A8R8G8B8_UNORM:
+ case PIPE_FORMAT_ARGB8888_UNORM:
{
uc->ui = (b << 24) | (g << 16) | (r << 8) | a;
}
return;
- case PIPE_FORMAT_X8R8G8B8_UNORM:
+ case PIPE_FORMAT_XRGB8888_UNORM:
{
uc->ui = (b << 24) | (g << 16) | (r << 8) | 0xff;
}
@@ -166,7 +166,7 @@ util_unpack_color_ub(enum pipe_format format, union util_color *uc,
ubyte *r, ubyte *g, ubyte *b, ubyte *a)
{
switch (format) {
- case PIPE_FORMAT_A8B8G8R8_UNORM:
+ case PIPE_FORMAT_ABGR8888_UNORM:
{
uint p = uc->ui;
*r = (ubyte) ((p >> 24) & 0xff);
@@ -175,7 +175,7 @@ util_unpack_color_ub(enum pipe_format format, union util_color *uc,
*a = (ubyte) ((p >> 0) & 0xff);
}
return;
- case PIPE_FORMAT_X8B8G8R8_UNORM:
+ case PIPE_FORMAT_XBGR8888_UNORM:
{
uint p = uc->ui;
*r = (ubyte) ((p >> 24) & 0xff);
@@ -184,7 +184,7 @@ util_unpack_color_ub(enum pipe_format format, union util_color *uc,
*a = (ubyte) 0xff;
}
return;
- case PIPE_FORMAT_B8G8R8A8_UNORM:
+ case PIPE_FORMAT_BGRA8888_UNORM:
{
uint p = uc->ui;
*r = (ubyte) ((p >> 16) & 0xff);
@@ -193,7 +193,7 @@ util_unpack_color_ub(enum pipe_format format, union util_color *uc,
*a = (ubyte) ((p >> 24) & 0xff);
}
return;
- case PIPE_FORMAT_B8G8R8X8_UNORM:
+ case PIPE_FORMAT_BGRX8888_UNORM:
{
uint p = uc->ui;
*r = (ubyte) ((p >> 16) & 0xff);
@@ -202,7 +202,7 @@ util_unpack_color_ub(enum pipe_format format, union util_color *uc,
*a = (ubyte) 0xff;
}
return;
- case PIPE_FORMAT_A8R8G8B8_UNORM:
+ case PIPE_FORMAT_ARGB8888_UNORM:
{
uint p = uc->ui;
*r = (ubyte) ((p >> 8) & 0xff);
@@ -211,7 +211,7 @@ util_unpack_color_ub(enum pipe_format format, union util_color *uc,
*a = (ubyte) ((p >> 0) & 0xff);
}
return;
- case PIPE_FORMAT_X8R8G8B8_UNORM:
+ case PIPE_FORMAT_XRGB8888_UNORM:
{
uint p = uc->ui;
*r = (ubyte) ((p >> 8) & 0xff);
@@ -350,32 +350,32 @@ util_pack_color(const float rgba[4], enum pipe_format format, union util_color *
}
switch (format) {
- case PIPE_FORMAT_A8B8G8R8_UNORM:
+ case PIPE_FORMAT_ABGR8888_UNORM:
{
uc->ui = (r << 24) | (g << 16) | (b << 8) | a;
}
return;
- case PIPE_FORMAT_X8B8G8R8_UNORM:
+ case PIPE_FORMAT_XBGR8888_UNORM:
{
uc->ui = (r << 24) | (g << 16) | (b << 8) | 0xff;
}
return;
- case PIPE_FORMAT_B8G8R8A8_UNORM:
+ case PIPE_FORMAT_BGRA8888_UNORM:
{
uc->ui = (a << 24) | (r << 16) | (g << 8) | b;
}
return;
- case PIPE_FORMAT_B8G8R8X8_UNORM:
+ case PIPE_FORMAT_BGRX8888_UNORM:
{
uc->ui = (0xff << 24) | (r << 16) | (g << 8) | b;
}
return;
- case PIPE_FORMAT_A8R8G8B8_UNORM:
+ case PIPE_FORMAT_ARGB8888_UNORM:
{
uc->ui = (b << 24) | (g << 16) | (r << 8) | a;
}
return;
- case PIPE_FORMAT_X8R8G8B8_UNORM:
+ case PIPE_FORMAT_XRGB8888_UNORM:
{
uc->ui = (b << 24) | (g << 16) | (r << 8) | 0xff;
}