panfrost: clean up active_prim update

How we're updating active_prim is currently a bit convoluted, because we
update it from two different places: First, we update it right before
updating the shader-variant in the case of point-sprite changes, and
then later on we update it unconditionally.

But we're about to need to change this logic, because we also need to
deal with line-smooth lowering. So let's clean this up a tad first, by
moving both updates to the same function, and renaming it a bit. This
let's us cleanly update it in one place, and then react to the change.

While we're at it, let's replace the bitwise xor with a logical
not-equals, which makes this all logical operations.

Reviewed-by: Boris Brezillon <boris.brezillon@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/26904>
This commit is contained in:
Erik Faye-Lund 2024-01-17 09:55:21 +00:00 committed by Marge Bot
parent 6343e0bbd0
commit a3cbfb5bd9

View file

@ -2766,14 +2766,15 @@ panfrost_increase_vertex_count(struct panfrost_batch *batch, uint32_t increment)
* because all dirty flags are set there.
*/
static void
panfrost_update_point_sprite_shader(struct panfrost_context *ctx,
const struct pipe_draw_info *info)
panfrost_update_active_prim(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))) {
const enum mesa_prim prev_prim = ctx->active_prim;
ctx->active_prim = info->mode;
ctx->active_prim = info->mode;
if ((ctx->dirty & PAN_DIRTY_RASTERIZER) ||
((prev_prim == MESA_PRIM_POINTS) !=
(info->mode == MESA_PRIM_POINTS))) {
panfrost_update_shader_variant(ctx, PIPE_SHADER_FRAGMENT);
}
}
@ -2836,7 +2837,7 @@ panfrost_direct_draw(struct panfrost_batch *batch,
struct panfrost_context *ctx = batch->ctx;
panfrost_update_point_sprite_shader(ctx, info);
panfrost_update_active_prim(ctx, info);
/* Take into account a negative bias */
ctx->vertex_count =
@ -2844,7 +2845,6 @@ panfrost_direct_draw(struct panfrost_batch *batch,
ctx->instance_count = info->instance_count;
ctx->base_vertex = info->index_size ? draw->index_bias : 0;
ctx->base_instance = info->start_instance;
ctx->active_prim = info->mode;
ctx->drawid = drawid_offset;
struct panfrost_compiled_shader *vs = ctx->prog[PIPE_SHADER_VERTEX];