diff options
author | Rob Clark <[email protected]> | 2018-12-11 11:13:49 -0500 |
---|---|---|
committer | Rob Clark <[email protected]> | 2018-12-13 15:51:01 -0500 |
commit | 532f8c0043142a32e1954950870bf8b84d288633 (patch) | |
tree | 711eff58066164e95aa34a99d51d02c0850d005d /src/gallium/auxiliary/util | |
parent | 85cd4df47f952414e47fc61a08a03fdf285af766 (diff) |
gallium/aux: add is_unorm() helper
We already had one for is_snorm() but not unorm.
Signed-off-by: Rob Clark <[email protected]>
Diffstat (limited to 'src/gallium/auxiliary/util')
-rw-r--r-- | src/gallium/auxiliary/util/u_format.c | 21 | ||||
-rw-r--r-- | src/gallium/auxiliary/util/u_format.h | 3 |
2 files changed, 24 insertions, 0 deletions
diff --git a/src/gallium/auxiliary/util/u_format.c b/src/gallium/auxiliary/util/u_format.c index e43a619313e..231e89017b4 100644 --- a/src/gallium/auxiliary/util/u_format.c +++ b/src/gallium/auxiliary/util/u_format.c @@ -169,6 +169,27 @@ util_format_is_snorm(enum pipe_format format) desc->channel[i].normalized; } +/** + * Returns true if all non-void channels are normalized unsigned. + */ +boolean +util_format_is_unorm(enum pipe_format format) +{ + const struct util_format_description *desc = util_format_description(format); + int i; + + if (desc->is_mixed) + return FALSE; + + i = util_format_get_first_non_void_channel(format); + if (i == -1) + return FALSE; + + return desc->channel[i].type == UTIL_FORMAT_TYPE_UNSIGNED && + !desc->channel[i].pure_integer && + desc->channel[i].normalized; +} + boolean util_format_is_snorm8(enum pipe_format format) { diff --git a/src/gallium/auxiliary/util/u_format.h b/src/gallium/auxiliary/util/u_format.h index 5bcfc1f1154..8dcc438a4a1 100644 --- a/src/gallium/auxiliary/util/u_format.h +++ b/src/gallium/auxiliary/util/u_format.h @@ -727,6 +727,9 @@ boolean util_format_is_snorm(enum pipe_format format); boolean +util_format_is_unorm(enum pipe_format format); + +boolean util_format_is_snorm8(enum pipe_format format); /** |