From 0566fa2db46ac1d9ca8055cb9bff41ef452ac83d Mon Sep 17 00:00:00 2001 From: Alyssa Rosenzweig Date: Tue, 1 Jun 2021 19:14:06 -0400 Subject: [PATCH] panfrost: Use util_last_bit for images Probbaly more correct for hols in image_mask. Signed-off-by: Alyssa Rosenzweig Part-of: --- src/gallium/drivers/panfrost/pan_cmdstream.c | 4 ++-- src/panfrost/lib/pan_shader.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/gallium/drivers/panfrost/pan_cmdstream.c b/src/gallium/drivers/panfrost/pan_cmdstream.c index ef81a42fecd..3cd8a724dbe 100644 --- a/src/gallium/drivers/panfrost/pan_cmdstream.c +++ b/src/gallium/drivers/panfrost/pan_cmdstream.c @@ -1626,7 +1626,7 @@ panfrost_emit_vertex_data(struct panfrost_batch *batch, struct panfrost_shader_state *vs = panfrost_get_shader_state(ctx, PIPE_SHADER_VERTEX); bool instanced = ctx->indirect_draw || ctx->instance_count > 1; uint32_t image_mask = ctx->image_mask[PIPE_SHADER_VERTEX]; - unsigned nr_images = util_bitcount(image_mask); + unsigned nr_images = util_last_bit(image_mask); /* Worst case: everything is NPOT, which is only possible if instancing * is enabled. Otherwise single record is gauranteed. @@ -1795,7 +1795,7 @@ panfrost_emit_vertex_data(struct panfrost_batch *batch, k = ALIGN_POT(k, 2); emit_image_attribs(ctx, PIPE_SHADER_VERTEX, out + so->num_elements, k); emit_image_bufs(batch, PIPE_SHADER_VERTEX, bufs + k, k); - k += util_bitcount(ctx->image_mask[PIPE_SHADER_VERTEX]); + k += util_last_bit(ctx->image_mask[PIPE_SHADER_VERTEX]); /* We need an empty attrib buf to stop the prefetching on Bifrost */ if (pan_is_bifrost(dev)) diff --git a/src/panfrost/lib/pan_shader.c b/src/panfrost/lib/pan_shader.c index b4b30eee6ff..f8fa8ad8f51 100644 --- a/src/panfrost/lib/pan_shader.c +++ b/src/panfrost/lib/pan_shader.c @@ -270,7 +270,7 @@ pan_shader_compile(const struct panfrost_device *dev, else info->ubo_count = s->info.num_ubos; - info->attribute_count += util_bitcount(s->info.images_used); + info->attribute_count += util_last_bit(s->info.images_used); info->writes_global = s->info.writes_memory; info->sampler_count = info->texture_count = BITSET_LAST_BIT(s->info.textures_used);