panfrost: Remove scissor_culls_everything
authorAlyssa Rosenzweig <alyssa@collabora.com>
Mon, 7 Jun 2021 17:38:45 +0000 (13:38 -0400)
committerMarge Bot <eric+marge@anholt.net>
Thu, 10 Jun 2021 18:06:10 +0000 (18:06 +0000)
Based on a misunderstanding of how the scissor test works, and in
particular breaks transform feedback and SSBO writes from vertex
shaders.

Replace it with a moral equivalent to rasterizer_discard so vertex
shaders still run.

Signed-off-by: Alyssa Rosenzweig <alyssa@collabora.com>
Cc: mesa-stable
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11123>

src/gallium/drivers/panfrost/pan_cmdstream.c
src/gallium/drivers/panfrost/pan_context.c
src/gallium/drivers/panfrost/pan_job.h

index c2385ec..ac1bfa7 100644 (file)
@@ -767,6 +767,8 @@ panfrost_emit_viewport(struct panfrost_batch *batch)
         }
 
         panfrost_batch_union_scissor(batch, minx, miny, maxx, maxy);
+        batch->scissor_culls_everything = (minx >= maxx || miny >= maxy);
+
         return T.gpu;
 }
 
@@ -2356,7 +2358,7 @@ panfrost_emit_vertex_tiler_jobs(struct panfrost_batch *batch,
                                            batch->indirect_draw_job_id : 0,
                                            0, vertex_job, false);
 
-        if (ctx->rasterizer->base.rasterizer_discard)
+        if (ctx->rasterizer->base.rasterizer_discard || batch->scissor_culls_everything)
                 return;
 
         panfrost_add_job(&batch->pool, &batch->scoreboard,
index a0051f2..831ba1d 100644 (file)
@@ -154,19 +154,6 @@ pan_draw_mode(enum pipe_prim_type mode)
 
 #undef DEFINE_CASE
 
-static bool
-panfrost_scissor_culls_everything(struct panfrost_context *ctx)
-{
-        const struct pipe_scissor_state *ss = &ctx->scissor;
-
-        /* Check if we're scissoring at all */
-
-        if (!ctx->rasterizer->base.scissor)
-                return false;
-
-        return (ss->minx == ss->maxx) || (ss->miny == ss->maxy);
-}
-
 /* Count generated primitives (when there is no geom/tess shaders) for
  * transform feedback */
 
@@ -740,13 +727,6 @@ panfrost_draw_vbo(struct pipe_context *pipe,
         struct panfrost_context *ctx = pan_context(pipe);
         struct panfrost_device *dev = pan_device(pipe->screen);
 
-        /* First of all, check the scissor to see if anything is drawn at all.
-         * If it's not, we drop the draw (mostly a conformance issue;
-         * well-behaved apps shouldn't hit this) */
-
-        if (panfrost_scissor_culls_everything(ctx))
-                return;
-
         if (!panfrost_render_condition_check(ctx))
                 return;
 
index 1a6dc0b..ac92dfe 100644 (file)
@@ -76,6 +76,9 @@ struct panfrost_batch {
         unsigned minx, miny;
         unsigned maxx, maxy;
 
+        /* Acts as a rasterizer discard */
+        bool scissor_culls_everything;
+
         /* BOs referenced not in the pool */
         struct hash_table *bos;