[Mesa-dev] [PATCH] gallium/aux: add is_unorm() helper

Roland Scheidegger sroland at vmware.com
Tue Dec 11 22:56:42 UTC 2018


Am 11.12.18 um 22:21 schrieb Ilia Mirkin:
> So ... Z24 will end up with is_unorm() == true? [Just guessing --
> assume it doesn't hae is_mixed == true.]
Z24X8 would return true, but Z24S8 would return false. (If you didn't
want that I guess you could check for colorspace.)

> Also, does RGB10A2 have mixed
> set? If so, then it won't report unorm. Not 100% sure if is_mixed is
> only for norm + int mixing.
Not sure which RGB10A2 variant you're refering to but there's only one
weird one (for bump maps) which would have mixed set. All others I think
always have components with the same type, so the one with unorm should
return true...

FWIW I don't think the combination of normalized & pure_integer is
really possible, so an explicit check for !pure_integer seems redundant.
But shouldn't hurt I suppose (and of course is_snorm does it the same).

Roland




> On Tue, Dec 11, 2018 at 4:05 PM Rob Clark <robdclark at gmail.com> wrote:
>>
>> We already had one for is_snorm() but not unorm.
>>
>> Signed-off-by: Rob Clark <robdclark at gmail.com>
>> ---
>>  src/gallium/auxiliary/util/u_format.c | 21 +++++++++++++++++++++
>>  src/gallium/auxiliary/util/u_format.h |  3 +++
>>  2 files changed, 24 insertions(+)
>>
>> 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
>> @@ -726,6 +726,9 @@ util_format_is_pure_uint(enum pipe_format format);
>>  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);
>>
>> --
>> 2.19.2
>>
>> _______________________________________________
>> mesa-dev mailing list
>> mesa-dev at lists.freedesktop.org
>> https://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Flists.freedesktop.org%2Fmailman%2Flistinfo%2Fmesa-dev&data=02%7C01%7Csroland%40vmware.com%7C4aca1244e0024a40746508d65faea953%7Cb39138ca3cee4b4aa4d6cd83d9dd62f0%7C0%7C0%7C636801601117990736&sdata=5SfD%2BKxjb1guv08vn0GOyxCODeiehCLf0m%2BLAhEE%2BW8%3D&reserved=0
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> https://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Flists.freedesktop.org%2Fmailman%2Flistinfo%2Fmesa-dev&data=02%7C01%7Csroland%40vmware.com%7C4aca1244e0024a40746508d65faea953%7Cb39138ca3cee4b4aa4d6cd83d9dd62f0%7C0%7C0%7C636801601117990736&sdata=5SfD%2BKxjb1guv08vn0GOyxCODeiehCLf0m%2BLAhEE%2BW8%3D&reserved=0
> 



More information about the mesa-dev mailing list