asahi: Skip draws if the scissor culls everything
authorAlyssa Rosenzweig <alyssa@rosenzweig.io>
Sun, 30 May 2021 19:58:25 +0000 (01:28 +0530)
committerMarge Bot <eric+marge@anholt.net>
Sun, 30 May 2021 23:32:01 +0000 (23:32 +0000)
We can't pack the scissor descriptor for these, and there would be no rendering
anyway, so detect this condition and skip the draw.

Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11084>

src/gallium/drivers/asahi/agx_state.c

index d1158e2..d11cddb 100644 (file)
@@ -1190,6 +1190,15 @@ agx_index_buffer_ptr(struct agx_batch *batch,
    }
 }
 
+static bool
+agx_scissor_culls_everything(struct agx_context *ctx)
+{
+        const struct pipe_scissor_state ss = ctx->scissor;
+
+        return ctx->rast->base.scissor &&
+               ((ss.minx == ss.maxx) || (ss.miny == ss.maxy));
+}
+
 static void
 agx_draw_vbo(struct pipe_context *pctx, const struct pipe_draw_info *info,
              unsigned drawid_offset,
@@ -1210,6 +1219,9 @@ agx_draw_vbo(struct pipe_context *pctx, const struct pipe_draw_info *info,
    struct agx_context *ctx = agx_context(pctx);
    struct agx_batch *batch = ctx->batch;
 
+   if (agx_scissor_culls_everything(ctx))
+          return;
+
    /* TODO: masks */
    ctx->batch->draw |= ~0;