From f167e2facf9ba91f2a754c7a812af21e95e5e628 Mon Sep 17 00:00:00 2001 From: Boris Brezillon Date: Wed, 15 Nov 2023 14:27:13 +0100 Subject: [PATCH] panfrost: Factor out the point-sprite shader update logic Not strictly needed for CSF, but anything we can do to make panfrost_direct_draw() shorter is good to take. Signed-off-by: Boris Brezillon Reviewed-by: Erik Faye-Lund Part-of: --- src/gallium/drivers/panfrost/pan_cmdstream.c | 32 ++++++++++++-------- 1 file changed, 20 insertions(+), 12 deletions(-) diff --git a/src/gallium/drivers/panfrost/pan_cmdstream.c b/src/gallium/drivers/panfrost/pan_cmdstream.c index dfd42843fc5..cecc3d27978 100644 --- a/src/gallium/drivers/panfrost/pan_cmdstream.c +++ b/src/gallium/drivers/panfrost/pan_cmdstream.c @@ -3557,6 +3557,25 @@ panfrost_increase_vertex_count(struct panfrost_batch *batch, uint32_t increment) batch->tiler_ctx.vertex_count = UINT32_MAX; } +/* + * If we change whether we're drawing points, or whether point sprites are + * enabled (specified in the rasterizer), we may need to rebind shaders + * accordingly. This implicitly covers the case of rebinding framebuffers, + * because all dirty flags are set there. + */ +static void +panfrost_update_point_sprite_shader(struct panfrost_context *ctx, + const struct pipe_draw_info *info) +{ + if ((ctx->dirty & PAN_DIRTY_RASTERIZER) || + ((ctx->active_prim == MESA_PRIM_POINTS) ^ + (info->mode == MESA_PRIM_POINTS))) { + + ctx->active_prim = info->mode; + panfrost_update_shader_variant(ctx, PIPE_SHADER_FRAGMENT); + } +} + static void panfrost_direct_draw(struct panfrost_batch *batch, const struct pipe_draw_info *info, unsigned drawid_offset, @@ -3567,18 +3586,7 @@ panfrost_direct_draw(struct panfrost_batch *batch, struct panfrost_context *ctx = batch->ctx; - /* If we change whether we're drawing points, or whether point sprites - * are enabled (specified in the rasterizer), we may need to rebind - * shaders accordingly. This implicitly covers the case of rebinding - * framebuffers, because all dirty flags are set there. - */ - if ((ctx->dirty & PAN_DIRTY_RASTERIZER) || - ((ctx->active_prim == MESA_PRIM_POINTS) ^ - (info->mode == MESA_PRIM_POINTS))) { - - ctx->active_prim = info->mode; - panfrost_update_shader_variant(ctx, PIPE_SHADER_FRAGMENT); - } + panfrost_update_point_sprite_shader(ctx, info); /* Take into account a negative bias */ ctx->vertex_count =