diff --git a/src/gallium/drivers/panfrost/pan_cmdstream.c b/src/gallium/drivers/panfrost/pan_cmdstream.c index 35fbb0af0fc..37b55719180 100644 --- a/src/gallium/drivers/panfrost/pan_cmdstream.c +++ b/src/gallium/drivers/panfrost/pan_cmdstream.c @@ -3087,6 +3087,10 @@ panfrost_emit_primitive(struct panfrost_context *ctx, { UNUSED struct pipe_rasterizer_state *rast = &ctx->rasterizer->base; + bool lines = (info->mode == PIPE_PRIM_LINES || + info->mode == PIPE_PRIM_LINE_LOOP || + info->mode == PIPE_PRIM_LINE_STRIP); + pan_pack(out, PRIMITIVE, cfg) { cfg.draw_mode = pan_draw_mode(info->mode); if (panfrost_writes_point_size(ctx)) @@ -3097,9 +3101,7 @@ panfrost_emit_primitive(struct panfrost_context *ctx, * be set to true and the provoking vertex is selected with * DRAW.flat_shading_vertex. */ - if (info->mode == PIPE_PRIM_LINES || - info->mode == PIPE_PRIM_LINE_LOOP || - info->mode == PIPE_PRIM_LINE_STRIP) + if (lines) cfg.first_provoking_vertex = true; else cfg.first_provoking_vertex = rast->flatshade_first; @@ -3113,7 +3115,10 @@ panfrost_emit_primitive(struct panfrost_context *ctx, cfg.job_task_split = 6; #else - cfg.allow_rotating_primitives = false; + struct panfrost_shader_state *fs = + panfrost_get_shader_state(ctx, PIPE_SHADER_FRAGMENT); + + cfg.allow_rotating_primitives = !(lines || fs->info.bifrost.uses_flat_shading); cfg.primitive_restart = info->primitive_restart; /* Non-fixed restart indices should have been lowered */ diff --git a/src/panfrost/bifrost/bifrost_compile.c b/src/panfrost/bifrost/bifrost_compile.c index 95a47d51abc..4ea115a15d3 100644 --- a/src/panfrost/bifrost/bifrost_compile.c +++ b/src/panfrost/bifrost/bifrost_compile.c @@ -547,6 +547,9 @@ bi_emit_load_vary(bi_builder *b, nir_intrinsic_instr *instr) */ if (b->shader->arch >= 9) src0 = bi_preload(b, 61); + + /* Gather info as we go */ + b->shader->info.bifrost->uses_flat_shading = true; } nir_src *offset = nir_get_io_offset_src(instr); diff --git a/src/panfrost/util/pan_ir.h b/src/panfrost/util/pan_ir.h index 19fcaa52a6a..c6a0d191dee 100644 --- a/src/panfrost/util/pan_ir.h +++ b/src/panfrost/util/pan_ir.h @@ -256,6 +256,12 @@ struct bifrost_shader_info { nir_alu_type blend_src1_type; bool wait_6, wait_7; struct bifrost_message_preload messages[2]; + + /* Whether any flat varyings are loaded. This may disable optimizations + * that change the provoking vertex, since that would load incorrect + * values for flat varyings. + */ + bool uses_flat_shading; }; struct midgard_shader_info {