[Mesa-dev] [PATCH 2/2] panfrost: Enable AFBC on depth/stencil

Alyssa Rosenzweig alyssa.rosenzweig at collabora.com
Mon Jun 10 15:07:11 UTC 2019


This seems to be a performance win, but more rigorous testing is
necessary to figure out the exact circumstances when this is good/bad.
Incidentally, this fixes non-aligned ZS.

Signed-off-by: Alyssa Rosenzweig <alyssa.rosenzweig at collabora.com>
---
 src/gallium/drivers/panfrost/pan_afbc.c     |  4 +++-
 src/gallium/drivers/panfrost/pan_context.c  | 11 +++++++----
 src/gallium/drivers/panfrost/pan_resource.c |  6 ------
 3 files changed, 10 insertions(+), 11 deletions(-)

diff --git a/src/gallium/drivers/panfrost/pan_afbc.c b/src/gallium/drivers/panfrost/pan_afbc.c
index 83d93a14742..0bb9d2491c6 100644
--- a/src/gallium/drivers/panfrost/pan_afbc.c
+++ b/src/gallium/drivers/panfrost/pan_afbc.c
@@ -86,8 +86,10 @@ panfrost_format_supports_afbc(enum pipe_format format)
         if (util_format_is_rgba8_variant(desc))
                 return true;
 
+        if (format == PIPE_FORMAT_Z32_UNORM)
+                return true;
+
         /* TODO: AFBC of other formats */
-        /* TODO: AFBC of ZS */
 
         return false;
 }
diff --git a/src/gallium/drivers/panfrost/pan_context.c b/src/gallium/drivers/panfrost/pan_context.c
index 13bb4e1e74a..e20e8e8d592 100644
--- a/src/gallium/drivers/panfrost/pan_context.c
+++ b/src/gallium/drivers/panfrost/pan_context.c
@@ -2118,9 +2118,9 @@ panfrost_set_framebuffer_state(struct pipe_context *pctx,
 
                 struct panfrost_resource *tex = ((struct panfrost_resource *) ctx->pipe_framebuffer.cbufs[i]->texture);
                 enum pipe_format format = ctx->pipe_framebuffer.cbufs[i]->format;
-                bool is_scanout = panfrost_is_scanout(ctx);
 
                 bool can_afbc = panfrost_format_supports_afbc(format);
+                bool is_scanout = panfrost_is_scanout(ctx);
 
                 if (!is_scanout && tex->bo->layout != PAN_AFBC && can_afbc)
                         panfrost_enable_afbc(ctx, tex, false);
@@ -2136,8 +2136,6 @@ panfrost_set_framebuffer_state(struct pipe_context *pctx,
                         pipe_surface_reference(&ctx->pipe_framebuffer.zsbuf, zb);
 
                         if (zb) {
-                                /* FBO has depth */
-
                                 if (ctx->require_sfbd)
                                         ctx->vt_framebuffer_sfbd = panfrost_emit_sfbd(ctx);
                                 else
@@ -2145,7 +2143,12 @@ panfrost_set_framebuffer_state(struct pipe_context *pctx,
 
                                 panfrost_attach_vt_framebuffer(ctx);
 
-                                /* Keep the depth FBO linear */
+                                struct panfrost_resource *tex = pan_resource(zb->texture);
+                                bool can_afbc = panfrost_format_supports_afbc(zb->format);
+                                bool is_scanout = panfrost_is_scanout(ctx);
+
+                                if (!is_scanout && tex->bo->layout != PAN_AFBC && can_afbc)
+                                        panfrost_enable_afbc(ctx, tex, true);
                         }
                 }
         }
diff --git a/src/gallium/drivers/panfrost/pan_resource.c b/src/gallium/drivers/panfrost/pan_resource.c
index 0c45e258b96..bcde38ae8b4 100644
--- a/src/gallium/drivers/panfrost/pan_resource.c
+++ b/src/gallium/drivers/panfrost/pan_resource.c
@@ -251,12 +251,6 @@ panfrost_create_bo(struct panfrost_screen *screen, const struct pipe_resource *t
         /* Tiling textures is almost always faster, unless we only use it once */
         bool should_tile = (template->usage != PIPE_USAGE_STREAM) && (template->bind & PIPE_BIND_SAMPLER_VIEW);
 
-        /* For unclear reasons, depth/stencil is faster linear than AFBC, so
-         * make sure it's linear */
-
-        if (template->bind & PIPE_BIND_DEPTH_STENCIL)
-                should_tile = false;
-
         /* Set the layout appropriately */
         bo->layout = should_tile ? PAN_TILED : PAN_LINEAR;
 
-- 
2.20.1



More information about the mesa-dev mailing list