freedreno/a5xx: fallback to slow-clear for z32
authorRob Clark <robdclark@gmail.com>
Mon, 15 May 2017 16:36:24 +0000 (12:36 -0400)
committerRob Clark <robdclark@gmail.com>
Tue, 16 May 2017 20:34:21 +0000 (16:34 -0400)
We probably *could* do this with blit path, but I think it would involve
clobbering settings from batch->gmem (see emit_zs()).

Signed-off-by: Rob Clark <robdclark@gmail.com>
src/gallium/drivers/freedreno/a2xx/fd2_draw.c
src/gallium/drivers/freedreno/a5xx/fd5_draw.c
src/gallium/drivers/freedreno/freedreno_context.h
src/gallium/drivers/freedreno/freedreno_draw.c

index f7915d66c1aa14f7321d8b5f91a43daa067e151e..8df1793a35f95792ec8f442ebb9296b50e352d19 100644 (file)
@@ -123,7 +123,7 @@ fd2_draw_vbo(struct fd_context *ctx, const struct pipe_draw_info *info,
 }
 
 
-static void
+static bool
 fd2_clear(struct fd_context *ctx, unsigned buffers,
                const union pipe_color_union *color, double depth, unsigned stencil)
 {
@@ -291,6 +291,8 @@ fd2_clear(struct fd_context *ctx, unsigned buffers,
 
        ctx->dirty_shader[PIPE_SHADER_VERTEX]   |= FD_DIRTY_SHADER_PROG;
        ctx->dirty_shader[PIPE_SHADER_FRAGMENT] |= FD_DIRTY_SHADER_PROG | FD_DIRTY_SHADER_CONST;
+
+       return true;
 }
 
 void
index cd315d4ac04d12ec841dd57dd0f5d92f226b7d52..bc5232a4c17b34138315d7c6993d4d24b9f8f504 100644 (file)
@@ -162,7 +162,19 @@ fd5_draw_vbo(struct fd_context *ctx, const struct pipe_draw_info *info,
        return true;
 }
 
-static void
+static bool is_z32(enum pipe_format format)
+{
+       switch (format) {
+       case PIPE_FORMAT_Z32_FLOAT_S8X24_UINT:
+       case PIPE_FORMAT_Z32_UNORM:
+       case PIPE_FORMAT_Z32_FLOAT:
+               return true;
+       default:
+               return false;
+       }
+}
+
+static bool
 fd5_clear(struct fd_context *ctx, unsigned buffers,
                const union pipe_color_union *color, double depth, unsigned stencil)
 {
@@ -170,6 +182,10 @@ fd5_clear(struct fd_context *ctx, unsigned buffers,
        struct pipe_framebuffer_state *pfb = &ctx->batch->framebuffer;
        struct pipe_scissor_state *scissor = fd_context_get_scissor(ctx);
 
+       if ((buffers & (PIPE_CLEAR_DEPTH | PIPE_CLEAR_STENCIL)) &&
+                       is_z32(pfb->zsbuf->format))
+               return false;
+
        /* TODO handle scissor.. or fallback to slow-clear? */
 
        ctx->batch->max_scissor.minx = MIN2(ctx->batch->max_scissor.minx, scissor->minx);
@@ -272,6 +288,8 @@ fd5_clear(struct fd_context *ctx, unsigned buffers,
        /* disable fast clear to not interfere w/ gmem->mem, etc.. */
        OUT_PKT4(ring, REG_A5XX_RB_CLEAR_CNTL, 1);
        OUT_RING(ring, 0x00000000);   /* RB_CLEAR_CNTL */
+
+       return true;
 }
 
 void
index 5c63a5ff9343e913ed0395db3273f3951fc21f68..4472afb83e1fca7b0835dfb5f9e42f7c5ff3a792 100644 (file)
@@ -297,7 +297,7 @@ struct fd_context {
        /* draw: */
        bool (*draw_vbo)(struct fd_context *ctx, const struct pipe_draw_info *info,
                          unsigned index_offset);
-       void (*clear)(struct fd_context *ctx, unsigned buffers,
+       bool (*clear)(struct fd_context *ctx, unsigned buffers,
                        const union pipe_color_union *color, double depth, unsigned stencil);
 
        /* compute: */
index 08cba77751061bcc2f5d2b6a79f40e0c41b53632..a4a19750a420dafa27a4313d07c2dc67f248e526 100644 (file)
@@ -384,17 +384,22 @@ fd_clear(struct pipe_context *pctx, unsigned buffers,
        /* if per-gen backend doesn't implement ctx->clear() generic
         * blitter clear:
         */
-       if (!ctx->clear) {
-               fd_blitter_clear(pctx, buffers, color, depth, stencil);
-               return;
-       }
+       bool fallback = true;
 
-       fd_batch_set_stage(batch, FD_STAGE_CLEAR);
+       if (ctx->clear) {
+               fd_batch_set_stage(batch, FD_STAGE_CLEAR);
 
-       ctx->clear(ctx, buffers, color, depth, stencil);
+               if (ctx->clear(ctx, buffers, color, depth, stencil)) {
+                       if (fd_mesa_debug & FD_DBG_DCLEAR)
+                               fd_context_all_dirty(ctx);
 
-       if (fd_mesa_debug & FD_DBG_DCLEAR)
-               fd_context_all_dirty(ctx);
+                       fallback = false;
+               }
+       }
+
+       if (fallback) {
+               fd_blitter_clear(pctx, buffers, color, depth, stencil);
+       }
 }
 
 static void