panfrost: Reload depth/stencil when they are read
authorBoris Brezillon <boris.brezillon@collabora.com>
Fri, 27 Nov 2020 19:51:18 +0000 (20:51 +0100)
committerMarge Bot <eric+marge@anholt.net>
Fri, 11 Dec 2020 09:47:38 +0000 (09:47 +0000)
Signed-off-by: Boris Brezillon <boris.brezillon@collabora.com>
Reviewed-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7922>

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

index b72bf29..996aba9 100644 (file)
@@ -604,6 +604,12 @@ panfrost_emit_frag_shader_meta(struct panfrost_batch *batch)
         else
                 batch->draws |= PIPE_CLEAR_COLOR0;
 
+        if (ctx->depth_stencil->base.depth.enabled)
+                batch->read |= PIPE_CLEAR_DEPTH;
+
+        if (ctx->depth_stencil->base.stencil[0].enabled)
+                batch->read |= PIPE_CLEAR_STENCIL;
+
         return xfer.gpu;
 }
 
index dedf66d..dc5436a 100644 (file)
@@ -893,17 +893,17 @@ panfrost_batch_draw_wallpaper(struct panfrost_batch *batch)
         /* Assume combined. If either depth or stencil is written, they will
          * both be written so we need to be careful for reloading */
 
-        unsigned draws = batch->draws;
+        unsigned reload = batch->draws | batch->read;
 
-        if (draws & PIPE_CLEAR_DEPTHSTENCIL)
-                draws |= PIPE_CLEAR_DEPTHSTENCIL;
+        if (reload & PIPE_CLEAR_DEPTHSTENCIL)
+                reload |= PIPE_CLEAR_DEPTHSTENCIL;
 
         /* Mask of buffers which need reload since they are not cleared and
          * they are drawn. (If they are cleared, reload is useless; if they are
-         * not drawn and also not cleared, we can generally omit the attachment
-         * at the framebuffer descriptor level */
+         * not drawn or read and also not cleared, we can generally omit the
+         * attachment at the framebuffer descriptor level */
 
-        unsigned reload = ~batch->clear & draws;
+        reload &= ~batch->clear;
 
         for (unsigned i = 0; i < batch->key.nr_cbufs; ++i) {
                 if (reload & (PIPE_CLEAR_COLOR0 << i)) 
index 6a905ee..bdd9d12 100644 (file)
@@ -64,6 +64,9 @@ struct panfrost_batch {
         /* Buffers drawn */
         unsigned draws;
 
+        /* Buffers read */
+        unsigned read;
+
         /* Packed clear values, indexed by both render target as well as word.
          * Essentially, a single pixel is packed, with some padding to bring it
          * up to a 32-bit interval; that pixel is then duplicated over to fill