Mesa (staging/22.0): panfrost: Process scissor state earlier

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Fri Apr 1 16:17:36 UTC 2022


Module: Mesa
Branch: staging/22.0
Commit: 4747777f369fed17eda4cd06c95725523be34ffe
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=4747777f369fed17eda4cd06c95725523be34ffe

Author: Alyssa Rosenzweig <alyssa at collabora.com>
Date:   Sat Jan 15 10:29:11 2022 -0500

panfrost: Process scissor state earlier

Otherwise, if batch->scissor_culls_everything is set for a single draw,
every draw after it in the batch will be skipped because the new
scissor/viewport state will never be processed. Process scissor state
early in draw_vbo to fix this interaction.

We do need to be careful: setting something on the batch can only happen when
we've decided on a batch. If we have to select a fresh batch due to too many
draws, that must happen first. This is pretty clear in the code but worth noting
for the diff.

Signed-off-by: Alyssa Rosenzweig <alyssa at collabora.com>
Reported-by: Icecream95 <ixn at disroot.org>
Reviewed-by: Icecream95 <ixn at disroot.org>
Fixes: 79356b2e ("panfrost: Skip rasterizer discard draws without side effects")
Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/5839
Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/6136
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15365>
(cherry picked from commit d2fb6879a2934de03323b9c72b2f4987b2bc38d9)

---

 .pick_status.json                            |  2 +-
 src/gallium/drivers/panfrost/pan_cmdstream.c | 22 +++++++++++++---------
 src/panfrost/ci/panfrost-g52-fails.txt       |  1 -
 3 files changed, 14 insertions(+), 11 deletions(-)

diff --git a/.pick_status.json b/.pick_status.json
index 8ebf9976a0f..d69bbf913c8 100644
--- a/.pick_status.json
+++ b/.pick_status.json
@@ -2324,7 +2324,7 @@
         "description": "panfrost: Process scissor state earlier",
         "nominated": true,
         "nomination_type": 1,
-        "resolution": 5,
+        "resolution": 1,
         "because_sha": "79356b2e5f1762aeaaa81cc148cd5b469a47713d"
     },
     {
diff --git a/src/gallium/drivers/panfrost/pan_cmdstream.c b/src/gallium/drivers/panfrost/pan_cmdstream.c
index 8b36aae8b21..e55ff5c8f78 100644
--- a/src/gallium/drivers/panfrost/pan_cmdstream.c
+++ b/src/gallium/drivers/panfrost/pan_cmdstream.c
@@ -2628,9 +2628,6 @@ panfrost_update_state_3d(struct panfrost_batch *batch)
 {
         unsigned dirty = batch->ctx->dirty;
 
-        if (dirty & (PAN_DIRTY_VIEWPORT | PAN_DIRTY_SCISSOR))
-                batch->viewport = panfrost_emit_viewport(batch);
-
         if (dirty & PAN_DIRTY_TLS_SIZE)
                 panfrost_batch_adjust_stack_size(batch);
 }
@@ -3133,6 +3130,19 @@ panfrost_draw_vbo(struct pipe_context *pipe,
         /* Do some common setup */
         struct panfrost_batch *batch = panfrost_get_batch_for_fbo(ctx);
 
+        /* Don't add too many jobs to a single batch. Hardware has a hard limit
+         * of 65536 jobs, but we choose a smaller soft limit (arbitrary) to
+         * avoid the risk of timeouts. This might not be a good idea. */
+        if (unlikely(batch->scoreboard.job_index > 10000))
+                batch = panfrost_get_fresh_batch_for_fbo(ctx, "Too many draws");
+
+        /* panfrost_batch_skip_rasterization reads
+         * batch->scissor_culls_everything, which is set by
+         * panfrost_emit_viewport, so call that first.
+         */
+        if (ctx->dirty & (PAN_DIRTY_VIEWPORT | PAN_DIRTY_SCISSOR))
+                batch->viewport = panfrost_emit_viewport(batch);
+
         /* If rasterization discard is enabled but the vertex shader does not
          * have side effects (including transform feedback), skip the draw
          * altogether. This is always an optimization. Additionally, this is
@@ -3149,12 +3159,6 @@ panfrost_draw_vbo(struct pipe_context *pipe,
                         return;
         }
 
-        /* Don't add too many jobs to a single batch. Hardware has a hard limit
-         * of 65536 jobs, but we choose a smaller soft limit (arbitrary) to
-         * avoid the risk of timeouts. This might not be a good idea. */
-        if (unlikely(batch->scoreboard.job_index > 10000))
-                batch = panfrost_get_fresh_batch_for_fbo(ctx, "Too many draws");
-
         unsigned zs_draws = ctx->depth_stencil->draws;
         batch->draws |= zs_draws;
         batch->resolve |= zs_draws;
diff --git a/src/panfrost/ci/panfrost-g52-fails.txt b/src/panfrost/ci/panfrost-g52-fails.txt
index 60df76e709f..11113beaabb 100644
--- a/src/panfrost/ci/panfrost-g52-fails.txt
+++ b/src/panfrost/ci/panfrost-g52-fails.txt
@@ -593,7 +593,6 @@ spec@!opengl 2.1 at pbo@test_polygon_stip,Fail
 spec@!opengl 2.1 at polygon-stipple-fs,Fail
 spec@!opengl 3.0 at gl-3.0-vertexattribipointer,Fail
 spec@!opengl 3.0 at required-texture-attachment-formats,Fail
-spec@!opengl 3.0 at viewport-clamp,Crash
 spec@!opengl 3.1 at primitive-restart-xfb flush,Fail
 spec@!opengl 3.1 at primitive-restart-xfb generated,Fail
 spec@!opengl 3.1 at primitive-restart-xfb written,Fail



More information about the mesa-commit mailing list