Reviewed-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/18634>
radv_get_dcc_channel_type(const struct util_format_description *desc, enum dcc_channel_type *type,
unsigned *size)
{
- int i;
-
- /* Find the first non-void channel. */
- for (i = 0; i < desc->nr_channels; i++)
- if (desc->channel[i].type != UTIL_FORMAT_TYPE_VOID)
- break;
- if (i == desc->nr_channels) {
+ int i = util_format_get_first_non_void_channel(desc->format);
+ if (i == -1) {
*type = dcc_channel_incompatible;
return;
}
const struct util_format_description *desc = vk_format_description(format);
*hw_fmt = radv_translate_colorformat(format);
- int firstchan;
- for (firstchan = 0; firstchan < 4; firstchan++) {
- if (desc->channel[firstchan].type != UTIL_FORMAT_TYPE_VOID) {
- break;
- }
- }
- if (firstchan == 4 || desc->channel[firstchan].type == UTIL_FORMAT_TYPE_FLOAT) {
+ int firstchan = vk_format_get_first_non_void_channel(format);
+ if (firstchan == -1 || desc->channel[firstchan].type == UTIL_FORMAT_TYPE_FLOAT) {
*hw_type = V_028C70_NUMBER_FLOAT;
} else {
*hw_type = V_028C70_NUMBER_UNORM;