diff options
author | Eric Anholt <eric@anholt.net> | 2019-01-23 14:26:53 -0800 |
---|---|---|
committer | Eric Anholt <eric@anholt.net> | 2019-01-25 13:06:50 -0800 |
commit | 08f4a904b386f3535719dff4c224ea5cfccc92cd (patch) | |
tree | fe37c929c2488ac9857036c7ce49f2f11058c49f /src/gallium/auxiliary/util/u_format_parse.py | |
parent | 104c7883e777b3d5caca98ed96afc3c7c409d340 (diff) |
gallium: Make sure we return is_unorm/is_snorm for compressed formats.
The util helpers were looking for a non-void channels in a non-mixed
format and returning its snorm/unorm state. However, compressed formats
don't have non-void channels, so they always returned false. V3D wants to
use util_format_is_[su]norm for its border color clamping workarounds, so
fix the functions to return the right answer for these.
This now means that we ignore .is_mixed. I could retain the is_mixed
check, but it doesn't seem like a useful feature -- the only code I could
find that might care is freedreno's blit, which has some notes about how
things are wonky in this area anyway.
Reviewed-by: <Roland Scheidegger sroland@vmware.com>
Diffstat (limited to 'src/gallium/auxiliary/util/u_format_parse.py')
-rw-r--r-- | src/gallium/auxiliary/util/u_format_parse.py | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/src/gallium/auxiliary/util/u_format_parse.py b/src/gallium/auxiliary/util/u_format_parse.py index 48cc012cd2a..e8a6c92d119 100644 --- a/src/gallium/auxiliary/util/u_format_parse.py +++ b/src/gallium/auxiliary/util/u_format_parse.py @@ -187,6 +187,26 @@ class Format: return True return False + def is_compressed(self): + for channel in self.le_channels: + if channel.type != VOID: + return False + return True + + def is_unorm(self): + # Non-compressed formats all have unorm or srgb in their name. + for keyword in ['_UNORM', '_SRGB']: + if keyword in self.name: + return True + + # All the compressed formats in GLES3.2 and GL4.6 ("Table 8.14: Generic + # and specific compressed internal formats.") that aren't snorm for + # border colors are unorm, other than BPTC_*_FLOAT. + return self.is_compressed() and not ('FLOAT' in self.name or self.is_snorm()) + + def is_snorm(self): + return '_SNORM' in self.name + def is_pot(self): return is_pot(self.block_size()) |