panfrost: Flush scanout too
authorAlyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Fri, 14 Jun 2019 19:26:19 +0000 (12:26 -0700)
committerAlyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Mon, 17 Jun 2019 14:59:14 +0000 (07:59 -0700)
In a poorly coded app, the framebuffer can be partially drawn, an FBO
switched, switch back to the framebuffer and keep drawing, etc.
Reordering would fix this, but for now we need to just be careful about
flushing scanout too.

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

index bce57625163fae73e0016c304478b94afa35bc99..b6839e71ca15905ccd49f56f02f5023181597765 100644 (file)
@@ -2153,12 +2153,15 @@ panfrost_set_framebuffer_state(struct pipe_context *pctx,
 {
         struct panfrost_context *ctx = pan_context(pctx);
 
-        /* Flush when switching away from an FBO, but not if the framebuffer
+        /* Flush when switching framebuffers, but not if the framebuffer
          * state is being restored by u_blitter
          */
 
-        if (!panfrost_is_scanout(ctx) && !ctx->blitter->running) {
-                panfrost_flush(pctx, NULL, 0);
+        bool is_scanout = panfrost_is_scanout(ctx);
+        bool has_draws = ctx->draw_count > 0;
+
+        if (!ctx->blitter->running && (!is_scanout || has_draws)) {
+                panfrost_flush(pctx, NULL, PIPE_FLUSH_END_OF_FRAME);
         }
 
         ctx->pipe_framebuffer.nr_cbufs = fb->nr_cbufs;