From ac5ba2dfadb46edb260be631f128e264c1711237 Mon Sep 17 00:00:00 2001 From: Alyssa Rosenzweig Date: Tue, 11 May 2021 15:39:21 -0400 Subject: [PATCH] panfrost: Implement framebuffer invalidation The strategy is lifted from Freedreno. The trick is to remove buffers from the resolve set, rather than add buffers to a discard set (as you would naively try). The latter is wrong -- draws after the glInvalidateFramebuffer() still need to be respected. glmark2 -btexture on-screen with sway on Mali T860 from 1393fps to 1998fps Signed-off-by: Alyssa Rosenzweig Closes: #2407 Reviewed-by: Boris Brezillon Part-of: --- src/gallium/drivers/panfrost/pan_resource.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/gallium/drivers/panfrost/pan_resource.c b/src/gallium/drivers/panfrost/pan_resource.c index 8f0155adf73..f43b5f864d3 100644 --- a/src/gallium/drivers/panfrost/pan_resource.c +++ b/src/gallium/drivers/panfrost/pan_resource.c @@ -1193,9 +1193,21 @@ panfrost_ptr_flush_region(struct pipe_context *pctx, } static void -panfrost_invalidate_resource(struct pipe_context *pctx, struct pipe_resource *prsc) +panfrost_invalidate_resource(struct pipe_context *pctx, struct pipe_resource *prsrc) { - /* TODO */ + struct panfrost_context *ctx = pan_context(pctx); + struct panfrost_batch *batch = panfrost_get_batch_for_fbo(ctx); + + /* Handle the glInvalidateFramebuffer case */ + if (batch->key.zsbuf && batch->key.zsbuf->texture == prsrc) + batch->resolve &= ~PIPE_CLEAR_DEPTHSTENCIL; + + for (unsigned i = 0; i < batch->key.nr_cbufs; ++i) { + struct pipe_surface *surf = batch->key.cbufs[i]; + + if (surf && surf->texture == prsrc) + batch->resolve &= ~(PIPE_CLEAR_COLOR0 << i); + } } static enum pipe_format