summaryrefslogtreecommitdiff
path: root/src/gallium/auxiliary/util/u_format_parse.py
diff options
context:
space:
mode:
Diffstat (limited to 'src/gallium/auxiliary/util/u_format_parse.py')
-rwxr-xr-xsrc/gallium/auxiliary/util/u_format_parse.py24
1 files changed, 17 insertions, 7 deletions
diff --git a/src/gallium/auxiliary/util/u_format_parse.py b/src/gallium/auxiliary/util/u_format_parse.py
index 250926418e..7076c676aa 100755
--- a/src/gallium/auxiliary/util/u_format_parse.py
+++ b/src/gallium/auxiliary/util/u_format_parse.py
@@ -73,18 +73,22 @@ class Channel:
'''Maximum representable number.'''
if self.type == FLOAT:
return VERY_LARGE
+ if self.type == FIXED:
+ return (1 << (self.size/2)) - 1
if self.norm:
return 1
if self.type == UNSIGNED:
return (1 << self.size) - 1
if self.type == SIGNED:
- return self.size - 1
+ return (1 << (self.size - 1)) - 1
assert False
def min(self):
'''Minimum representable number.'''
if self.type == FLOAT:
return -VERY_LARGE
+ if self.type == FIXED:
+ return -(1 << (self.size/2))
if self.type == UNSIGNED:
return 0
if self.norm:
@@ -134,6 +138,8 @@ class Format:
return nr_channels
def is_array(self):
+ if self.layout != PLAIN:
+ return False
ref_channel = self.channels[0]
for channel in self.channels[1:]:
if channel.size and (channel.size != ref_channel.size or channel.size % 8):
@@ -141,7 +147,11 @@ class Format:
return True
def is_mixed(self):
+ if self.layout != PLAIN:
+ return False
ref_channel = self.channels[0]
+ if ref_channel.type == VOID:
+ ref_channel = self.channels[1]
for channel in self.channels[1:]:
if channel.type != VOID:
if channel.type != ref_channel.type:
@@ -154,29 +164,29 @@ class Format:
return is_pot(self.block_size())
def is_int(self):
+ if self.layout != PLAIN:
+ return False
for channel in self.channels:
if channel.type not in (VOID, UNSIGNED, SIGNED):
return False
return True
def is_float(self):
+ if self.layout != PLAIN:
+ return False
for channel in self.channels:
if channel.type not in (VOID, FLOAT):
return False
return True
def is_bitmask(self):
- if self.block_size() > 32:
+ if self.layout != PLAIN:
return False
- if not self.is_pot():
+ if self.block_size() not in (8, 16, 32):
return False
for channel in self.channels:
- if not is_pot(channel.size):
- return True
if channel.type not in (VOID, UNSIGNED, SIGNED):
return False
- if channel.size >= 32:
- return False
return True
def inv_swizzles(self):