summaryrefslogtreecommitdiff
path: root/src/gallium/auxiliary/util/u_format_pack.py
diff options
context:
space:
mode:
Diffstat (limited to 'src/gallium/auxiliary/util/u_format_pack.py')
-rw-r--r--src/gallium/auxiliary/util/u_format_pack.py59
1 files changed, 25 insertions, 34 deletions
diff --git a/src/gallium/auxiliary/util/u_format_pack.py b/src/gallium/auxiliary/util/u_format_pack.py
index 06831d1e19..7c5fa9c00a 100644
--- a/src/gallium/auxiliary/util/u_format_pack.py
+++ b/src/gallium/auxiliary/util/u_format_pack.py
@@ -46,12 +46,21 @@ from u_format_parse import *
def generate_format_type(format):
'''Generate a structure that describes the format.'''
+ assert format.layout == PLAIN
+
print 'union util_format_%s {' % format.short_name()
- if format.is_bitmask() or format.short_name() == "r11g11b10_float":
+
+ if format.block_size() in (8, 16, 32, 64):
print ' uint%u_t value;' % (format.block_size(),)
+
+ use_bitfields = False
+ for channel in format.channels:
+ if channel.size % 8 or not is_pot(channel.size):
+ use_bitfields = True
+
print ' struct {'
for channel in format.channels:
- if (format.is_bitmask() or format.is_mixed()) and not format.is_array() or format.short_name() == "r11g11b10_float":
+ if use_bitfields:
if channel.type == VOID:
if channel.size:
print ' unsigned %s:%u;' % (channel.name, channel.size)
@@ -60,7 +69,9 @@ def generate_format_type(format):
elif channel.type in (SIGNED, FIXED):
print ' int %s:%u;' % (channel.name, channel.size)
elif channel.type == FLOAT:
- if channel.size == 32:
+ if channel.size == 64:
+ print ' double %s;' % (channel.name)
+ elif channel.size == 32:
print ' float %s;' % (channel.name)
else:
print ' unsigned %s:%u;' % (channel.name, channel.size)
@@ -116,10 +127,6 @@ def is_format_supported(format):
if channel.type == FLOAT and channel.size not in (16, 32, 64):
return False
- # We can only read a color from a depth/stencil format if the depth channel is present
- if format.colorspace == 'zs' and format.swizzles[0] == SWIZZLE_NONE:
- return False
-
return True
@@ -442,11 +449,6 @@ def generate_unpack_kernel(format, dst_channel, dst_native_type):
value = '0'
else:
assert False
- if format.colorspace == ZS:
- if i == 3:
- value = get_one(dst_channel)
- elif i >= 1:
- value = 'dst[0]'
print ' dst[%u] = %s; /* %s */' % (i, value, 'rgba'[i])
else:
@@ -475,11 +477,6 @@ def generate_unpack_kernel(format, dst_channel, dst_native_type):
value = '0'
else:
assert False
- if format.colorspace == ZS:
- if i == 3:
- value = get_one(dst_channel)
- elif i >= 1:
- value = 'dst[0]'
print ' dst[%u] = %s; /* %s */' % (i, value, 'rgba'[i])
@@ -511,11 +508,6 @@ def generate_pack_kernel(format, src_channel, src_native_type):
dst_channel, dst_native_type,
value,
dst_colorspace = dst_colorspace)
- if format.colorspace == ZS:
- if i == 3:
- value = get_one(dst_channel)
- elif i >= 1:
- value = '0'
if dst_channel.type in (UNSIGNED, SIGNED):
if shift + dst_channel.size < depth:
value = '(%s) & 0x%x' % (value, (1 << dst_channel.size) - 1)
@@ -555,11 +547,6 @@ def generate_pack_kernel(format, src_channel, src_native_type):
dst_channel, dst_native_type,
value,
dst_colorspace = dst_colorspace)
- if format.colorspace == ZS:
- if i == 3:
- value = get_one(dst_channel)
- elif i >= 1:
- value = '0'
print ' pixel.chan.%s = %s;' % (dst_channel.name, value)
bswap_format(format)
@@ -641,27 +628,30 @@ def generate_format_fetch(format, dst_channel, dst_native_type, dst_suffix):
def is_format_hand_written(format):
- return format.layout in ('s3tc', 'subsampled', 'other')
+ return format.layout in ('s3tc', 'subsampled', 'other') or format.colorspace == ZS
+
def generate(formats):
print
print '#include "pipe/p_compiler.h"'
print '#include "u_math.h"'
+ print '#include "u_half.h"'
print '#include "u_format.h"'
print '#include "u_format_other.h"'
print '#include "u_format_srgb.h"'
print '#include "u_format_yuv.h"'
- print '#include "u_half.h"'
+ print '#include "u_format_zs.h"'
print
for format in formats:
- if is_format_supported(format):
- generate_format_type(format)
-
if not is_format_hand_written(format):
+
+ if is_format_supported(format):
+ generate_format_type(format)
+
channel = Channel(FLOAT, False, 32)
native_type = 'float'
- suffix = 'float'
+ suffix = 'rgba_float'
generate_format_unpack(format, channel, native_type, suffix)
generate_format_pack(format, channel, native_type, suffix)
@@ -669,7 +659,8 @@ def generate(formats):
channel = Channel(UNSIGNED, True, 8)
native_type = 'uint8_t'
- suffix = '8unorm'
+ suffix = 'rgba_8unorm'
generate_format_unpack(format, channel, native_type, suffix)
generate_format_pack(format, channel, native_type, suffix)
+