iris: Add and use get_num_planes

This function counts the number of objects in a pipe_resource linked list.

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12795>
This commit is contained in:
Nanley Chery 2021-09-08 06:41:12 -07:00 committed by Marge Bot
parent a16d6bc179
commit 8510d17ff4

View file

@ -1198,6 +1198,16 @@ mod_plane_is_clear_color(uint64_t modifier, uint32_t plane)
}
}
static unsigned
get_num_planes(const struct pipe_resource *resource)
{
unsigned count = 0;
for (const struct pipe_resource *cur = resource; cur; cur = cur->next)
count++;
return count;
}
static struct pipe_resource *
iris_resource_from_handle(struct pipe_screen *pscreen,
const struct pipe_resource *templ,
@ -1425,10 +1435,7 @@ iris_resource_get_param(struct pipe_screen *pscreen,
res->mod_info->modifier,
res->external_format);
} else {
unsigned count = 0;
for (struct pipe_resource *cur = resource; cur; cur = cur->next)
count++;
*value = count;
*value = get_num_planes(&res->base.b);
}
return true;
case PIPE_RESOURCE_PARAM_STRIDE: