Mesa (main): panfrost: Set allow_rotating_primitives

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Mon May 30 14:16:25 UTC 2022


Module: Mesa
Branch: main
Commit: 67f57213493c688691fda042caecf2f08823cf92
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=67f57213493c688691fda042caecf2f08823cf92

Author: Alyssa Rosenzweig <alyssa at collabora.com>
Date:   Fri May 27 09:06:31 2022 -0400

panfrost: Set allow_rotating_primitives

On Valhall, the driver should set this flag if the hardware may rotate
primitives. This happens if:

1. The rasterization of lines does not matter, AND
2. The provoking vertex does not matter.

The first condition we may satisfy by checking for LINES and the second by
checking for flat shading. Otherwise, we should set this flag to allow
optimizations. This may be more efficient for tiling.

Signed-off-by: Alyssa Rosenzweig <alyssa at collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16748>

---

 src/gallium/drivers/panfrost/pan_cmdstream.c | 13 +++++++++----
 src/panfrost/bifrost/bifrost_compile.c       |  3 +++
 src/panfrost/util/pan_ir.h                   |  6 ++++++
 3 files changed, 18 insertions(+), 4 deletions(-)

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 {



More information about the mesa-commit mailing list