panfrost: Simplify set_framebuffer_state
authorAlyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Thu, 18 Jul 2019 18:05:01 +0000 (11:05 -0700)
committerAlyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Thu, 18 Jul 2019 22:25:40 +0000 (15:25 -0700)
Most of the ad hoc logic is already in Gallium.

Signed-off-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
src/gallium/drivers/panfrost/pan_context.c

index 06943c22b449acd0910eb43022bb2915aa5e1a4c..68d74224d071ad25dbc1664cdb332a6c328e4103 100644 (file)
@@ -2377,45 +2377,19 @@ panfrost_set_framebuffer_state(struct pipe_context *pctx,
                 panfrost_flush(pctx, NULL, PIPE_FLUSH_END_OF_FRAME);
         }
 
-        ctx->pipe_framebuffer.nr_cbufs = fb->nr_cbufs;
-        ctx->pipe_framebuffer.samples = fb->samples;
-        ctx->pipe_framebuffer.layers = fb->layers;
-        ctx->pipe_framebuffer.width = fb->width;
-        ctx->pipe_framebuffer.height = fb->height;
+        util_copy_framebuffer_state(&ctx->pipe_framebuffer, fb);
 
-        struct pipe_surface *zb = fb->zsbuf;
-        bool needs_reattach = false;
+        /* Given that we're rendering, we'd love to have compression */
+        struct panfrost_screen *screen = pan_screen(ctx->base.screen);
 
-        for (int i = 0; i < PIPE_MAX_COLOR_BUFS; i++) {
-                struct pipe_surface *cb = i < fb->nr_cbufs ? fb->cbufs[i] : NULL;
+        panfrost_hint_afbc(screen, &ctx->pipe_framebuffer);
 
-                /* check if changing cbuf */
-                if (ctx->pipe_framebuffer.cbufs[i] == cb) continue;
-
-                /* assign new */
-                pipe_surface_reference(&ctx->pipe_framebuffer.cbufs[i], cb);
-
-                needs_reattach |= (cb != NULL);
-        }
-
-        if (ctx->pipe_framebuffer.zsbuf != zb) {
-                pipe_surface_reference(&ctx->pipe_framebuffer.zsbuf, zb);
-                needs_reattach |= (zb != NULL);
-        }
-
-        if (needs_reattach) {
-                /* Given that we're rendering, we'd love to have compression */
-                struct panfrost_screen *screen = pan_screen(ctx->base.screen);
-
-                panfrost_hint_afbc(screen, &ctx->pipe_framebuffer);
-
-                if (ctx->require_sfbd)
-                        ctx->vt_framebuffer_sfbd = panfrost_emit_sfbd(ctx, ~0);
-                else
-                        ctx->vt_framebuffer_mfbd = panfrost_emit_mfbd(ctx, ~0);
+        if (ctx->require_sfbd)
+                ctx->vt_framebuffer_sfbd = panfrost_emit_sfbd(ctx, ~0);
+        else
+                ctx->vt_framebuffer_mfbd = panfrost_emit_mfbd(ctx, ~0);
 
-                panfrost_attach_vt_framebuffer(ctx, false);
-        }
+        panfrost_attach_vt_framebuffer(ctx, false);
 }
 
 static void *