[Mesa-dev] [PATCH 5/8] util: Precompute channel shifts in u_format_parse.py
Richard Sandiford
rsandifo at linux.vnet.ibm.com
Tue Jun 11 08:16:08 PDT 2013
Store the shift value for a bitmask channel in the Channel object,
rather than working it out on the fly. This allows the shift to
depend on endianness.
There is no change to the generated u_format_table.c.
Signed-off-by: Richard Sandiford <rsandifo at linux.vnet.ibm.com>
---
src/gallium/auxiliary/util/u_format_pack.py | 8 ++------
src/gallium/auxiliary/util/u_format_parse.py | 5 +++++
2 files changed, 7 insertions(+), 6 deletions(-)
diff --git a/src/gallium/auxiliary/util/u_format_pack.py b/src/gallium/auxiliary/util/u_format_pack.py
index 84eef8c..b4db0d1 100644
--- a/src/gallium/auxiliary/util/u_format_pack.py
+++ b/src/gallium/auxiliary/util/u_format_pack.py
@@ -428,9 +428,9 @@ def generate_unpack_kernel(format, dst_channel, dst_native_type):
print '#endif'
# Compute the intermediate unshifted values
- shift = 0
for i in range(4):
src_channel = channels[i]
+ shift = src_channel.shift
value = 'value'
if src_channel.type == UNSIGNED:
if shift:
@@ -454,8 +454,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 = swizzles[i]
@@ -529,9 +527,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 = channels[i]
+ shift = dst_channel.shift
if inv_swizzle[i] is not None:
value ='src[%u]' % inv_swizzle[i]
dst_colorspace = format.colorspace
@@ -555,8 +553,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
diff --git a/src/gallium/auxiliary/util/u_format_parse.py b/src/gallium/auxiliary/util/u_format_parse.py
index 2553a5b..d60a0a2 100755
--- a/src/gallium/auxiliary/util/u_format_parse.py
+++ b/src/gallium/auxiliary/util/u_format_parse.py
@@ -337,6 +337,11 @@ def parse(filename):
swizzles = [_swizzle_parse_map[swizzle] for swizzle in fields[8]]
channels = _parse_channels(fields[4:8], layout, colorspace, swizzles)
+ shift = 0
+ for channel in channels:
+ channel.shift = shift
+ shift += channel.size
+
format = Format(name, layout, block_width, block_height, channels, swizzles, colorspace)
formats.append(format)
return formats
--
1.7.11.7
More information about the mesa-dev
mailing list