From e15fd6c36ee2614e006238bcf8121770602226ff Mon Sep 17 00:00:00 2001 From: Boris Brezillon Date: Fri, 27 Nov 2020 20:51:18 +0100 Subject: [PATCH] panfrost: Reload depth/stencil when they are read Signed-off-by: Boris Brezillon Reviewed-by: Alyssa Rosenzweig Part-of: --- src/gallium/drivers/panfrost/pan_cmdstream.c | 6 ++++++ src/gallium/drivers/panfrost/pan_job.c | 12 ++++++------ src/gallium/drivers/panfrost/pan_job.h | 3 +++ 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/src/gallium/drivers/panfrost/pan_cmdstream.c b/src/gallium/drivers/panfrost/pan_cmdstream.c index b72bf291156..996aba903f8 100644 --- a/src/gallium/drivers/panfrost/pan_cmdstream.c +++ b/src/gallium/drivers/panfrost/pan_cmdstream.c @@ -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; } diff --git a/src/gallium/drivers/panfrost/pan_job.c b/src/gallium/drivers/panfrost/pan_job.c index dedf66d11d6..dc5436a5454 100644 --- a/src/gallium/drivers/panfrost/pan_job.c +++ b/src/gallium/drivers/panfrost/pan_job.c @@ -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)) diff --git a/src/gallium/drivers/panfrost/pan_job.h b/src/gallium/drivers/panfrost/pan_job.h index 6a905ee062d..bdd9d121471 100644 --- a/src/gallium/drivers/panfrost/pan_job.h +++ b/src/gallium/drivers/panfrost/pan_job.h @@ -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