mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-05 03:08:05 +02:00
u_format: add inline helper to find first non void channel
This is used in a few places in drivers as well, also the integer support can use it as well. Signed-off-by: Dave Airlie <airlied@redhat.com>
This commit is contained in:
parent
b861479f83
commit
61285c6cfa
2 changed files with 22 additions and 8 deletions
|
|
@ -52,14 +52,8 @@ util_format_is_float(enum pipe_format format)
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
/* Find the first non-void channel. */
|
||||
for (i = 0; i < 4; i++) {
|
||||
if (desc->channel[i].type != UTIL_FORMAT_TYPE_VOID) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (i == 4) {
|
||||
i = util_format_get_first_non_void_channel(format);
|
||||
if (i == -1) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -806,6 +806,26 @@ util_format_get_nr_components(enum pipe_format format)
|
|||
return desc->nr_channels;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the index of the first non-void channel
|
||||
* -1 if no non-void channels
|
||||
*/
|
||||
static INLINE int
|
||||
util_format_get_first_non_void_channel(enum pipe_format format)
|
||||
{
|
||||
const struct util_format_description *desc = util_format_description(format);
|
||||
int i;
|
||||
|
||||
for (i = 0; i < 4; i++)
|
||||
if (desc->channel[i].type != UTIL_FORMAT_TYPE_VOID)
|
||||
break;
|
||||
|
||||
if (i == 4)
|
||||
return -1;
|
||||
|
||||
return i;
|
||||
}
|
||||
|
||||
/*
|
||||
* Format access functions.
|
||||
*/
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue