From e689b342febbecd4ab225f1da17e687e51db67d5 Mon Sep 17 00:00:00 2001 From: Christian Gmeiner Date: Mon, 18 Aug 2025 13:53:04 +0200 Subject: [PATCH] etnaviv: Optimize sampler view iteration with u_foreach_bit(..) Replace loop over all PIPE_MAX_SAMPLERS with u_foreach_bit(..) to iterate only over active sampler views. This avoids unnecessary iterations. Improves drawoverhead test 1 performance by ~10%. Signed-off-by: Christian Gmeiner Reviewed-by: Lucas Stach Part-of: --- src/gallium/drivers/etnaviv/etnaviv_context.c | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/src/gallium/drivers/etnaviv/etnaviv_context.c b/src/gallium/drivers/etnaviv/etnaviv_context.c index 844b60effa4..93abb995365 100644 --- a/src/gallium/drivers/etnaviv/etnaviv_context.c +++ b/src/gallium/drivers/etnaviv/etnaviv_context.c @@ -364,17 +364,15 @@ etna_draw_vbo(struct pipe_context *pctx, const struct pipe_draw_info *info, } /* Mark textures as being read */ - for (i = 0; i < PIPE_MAX_SAMPLERS; i++) { - if (ctx->sampler_view[i]) { - if (ctx->dirty & ETNA_DIRTY_SAMPLER_VIEWS) - resource_read(ctx, ctx->sampler_view[i]->texture); + u_foreach_bit(i, ctx->active_sampler_views) { + if (ctx->dirty & ETNA_DIRTY_SAMPLER_VIEWS) + resource_read(ctx, ctx->sampler_view[i]->texture); - /* if texture was modified since the last update, - * we need to clear the texture cache and possibly - * resolve/update ts - */ - etna_update_sampler_source(ctx->sampler_view[i], i); - } + /* if texture was modified since the last update, + * we need to clear the texture cache and possibly + * resolve/update ts + */ + etna_update_sampler_source(ctx->sampler_view[i], i); } if (indirect) {