From 8510d17ff4e293e9742a6366e01d871172d86e4d Mon Sep 17 00:00:00 2001 From: Nanley Chery Date: Wed, 8 Sep 2021 06:41:12 -0700 Subject: [PATCH] iris: Add and use get_num_planes This function counts the number of objects in a pipe_resource linked list. Reviewed-by: Kenneth Graunke Part-of: --- src/gallium/drivers/iris/iris_resource.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/gallium/drivers/iris/iris_resource.c b/src/gallium/drivers/iris/iris_resource.c index 5f1adbf0f77..b7cdf8f3731 100644 --- a/src/gallium/drivers/iris/iris_resource.c +++ b/src/gallium/drivers/iris/iris_resource.c @@ -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: