panfrost: Allow testing if a specific batch is targeting a scanout FB
authorBoris Brezillon <boris.brezillon@collabora.com>
Sun, 1 Sep 2019 08:54:38 +0000 (10:54 +0200)
committerBoris Brezillon <boris.brezillon@collabora.com>
Fri, 13 Sep 2019 14:25:06 +0000 (16:25 +0200)
Rename panfrost_is_scanout() into panfrost_batch_is_scanout(), pass it
a batch instead of a context and move the code to pan_job.c.

With this in place, we can now test if a batch is targeting a scanout
FB even if this batch is not bound to the context.

Signed-off-by: Boris Brezillon <boris.brezillon@collabora.com>
Reviewed-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
src/gallium/drivers/panfrost/pan_context.c
src/gallium/drivers/panfrost/pan_context.h
src/gallium/drivers/panfrost/pan_job.c
src/gallium/drivers/panfrost/pan_job.h
src/gallium/drivers/panfrost/pan_mfbd.c

index 0fb4c2584e40aa93eedff2cdbdac0c38bfbbc037..35b36f501e2aa171c5b23fbd75b6bd9a0f8bdfe3 100644 (file)
@@ -151,24 +151,6 @@ panfrost_emit_mfbd(struct panfrost_context *ctx, unsigned vertex_count)
         return framebuffer;
 }
 
-/* Are we currently rendering to the screen (rather than an FBO)? */
-
-bool
-panfrost_is_scanout(struct panfrost_context *ctx)
-{
-        /* If there is no color buffer, it's an FBO */
-        if (ctx->pipe_framebuffer.nr_cbufs != 1)
-                return false;
-
-        /* If we're too early that no framebuffer was sent, it's scanout */
-        if (!ctx->pipe_framebuffer.cbufs[0])
-                return true;
-
-        return ctx->pipe_framebuffer.cbufs[0]->texture->bind & PIPE_BIND_DISPLAY_TARGET ||
-               ctx->pipe_framebuffer.cbufs[0]->texture->bind & PIPE_BIND_SCANOUT ||
-               ctx->pipe_framebuffer.cbufs[0]->texture->bind & PIPE_BIND_SHARED;
-}
-
 static void
 panfrost_clear(
         struct pipe_context *pipe,
@@ -2396,7 +2378,7 @@ panfrost_set_framebuffer_state(struct pipe_context *pctx,
          */
 
         struct panfrost_batch *batch = panfrost_get_batch_for_fbo(ctx);
-        bool is_scanout = panfrost_is_scanout(ctx);
+        bool is_scanout = panfrost_batch_is_scanout(batch);
         bool has_draws = batch->last_job.gpu;
 
         /* Bail out early when the current and new states are the same. */
index 586b6d854b6cd2ecd023a43435acea20bb7baa4e..02552ed23de2c55a5761a0c065f62b2f21e07887 100644 (file)
@@ -315,9 +315,6 @@ panfrost_flush(
         struct pipe_fence_handle **fence,
         unsigned flags);
 
-bool
-panfrost_is_scanout(struct panfrost_context *ctx);
-
 mali_ptr panfrost_sfbd_fragment(struct panfrost_context *ctx, bool has_draws);
 mali_ptr panfrost_mfbd_fragment(struct panfrost_context *ctx, bool has_draws);
 
index 0f8fe1a1b7ab01727c1828c7bec5884ebff56e07..3d64aa8e452380f64c0114cf38076e781b7d769a 100644 (file)
@@ -375,6 +375,24 @@ panfrost_batch_intersection_scissor(struct panfrost_batch *batch,
         batch->maxy = MIN2(batch->maxy, maxy);
 }
 
+/* Are we currently rendering to the screen (rather than an FBO)? */
+
+bool
+panfrost_batch_is_scanout(struct panfrost_batch *batch)
+{
+        /* If there is no color buffer, it's an FBO */
+        if (batch->key.nr_cbufs != 1)
+                return false;
+
+        /* If we're too early that no framebuffer was sent, it's scanout */
+        if (!batch->key.cbufs[0])
+                return true;
+
+        return batch->key.cbufs[0]->texture->bind & PIPE_BIND_DISPLAY_TARGET ||
+               batch->key.cbufs[0]->texture->bind & PIPE_BIND_SCANOUT ||
+               batch->key.cbufs[0]->texture->bind & PIPE_BIND_SHARED;
+}
+
 void
 panfrost_batch_init(struct panfrost_context *ctx)
 {
index a5347f8814e11737c73d27b89d62f52681913c71..cf0d93f2628fe123103a53b31254cf46b1f3d5c4 100644 (file)
@@ -189,4 +189,7 @@ panfrost_scoreboard_queue_fused_job_prepend(
 void
 panfrost_scoreboard_link_batch(struct panfrost_batch *batch);
 
+bool
+panfrost_batch_is_scanout(struct panfrost_batch *batch);
+
 #endif
index 3ad22f82c4abed5513d1d375c7c5a44a51a81027..8b1831c92083392f9bc5d7c5c70ecb6415b260e7 100644 (file)
@@ -454,9 +454,8 @@ panfrost_mfbd_fragment(struct panfrost_context *ctx, bool has_draws)
          * The exception is ReadPixels, but this is not supported on GLES so we
          * can safely ignore it. */
 
-        if (panfrost_is_scanout(ctx)) {
+        if (panfrost_batch_is_scanout(batch))
                 batch->requirements &= ~PAN_REQ_DEPTH_WRITE;
-        }
 
         /* Actualize the requirements */