[Mesa-dev] [PATCH v3 14/25] panfrost: Move the fence creation in panfrost_flush()
Boris Brezillon
boris.brezillon at collabora.com
Thu Sep 5 19:41:39 UTC 2019
panfrost_flush() is about to be reworked to flush all pending batches,
but we want the fence to block on the last one. Let's move the fence
creation logic in panfrost_flush() to prepare for this situation.
Signed-off-by: Boris Brezillon <boris.brezillon at collabora.com>
---
src/gallium/drivers/panfrost/pan_context.c | 13 +++++++++----
src/gallium/drivers/panfrost/pan_context.h | 3 +++
src/gallium/drivers/panfrost/pan_drm.c | 11 ++---------
src/gallium/drivers/panfrost/pan_screen.h | 3 +--
4 files changed, 15 insertions(+), 15 deletions(-)
diff --git a/src/gallium/drivers/panfrost/pan_context.c b/src/gallium/drivers/panfrost/pan_context.c
index e34f5757b1cf..6552052b8cad 100644
--- a/src/gallium/drivers/panfrost/pan_context.c
+++ b/src/gallium/drivers/panfrost/pan_context.c
@@ -1308,7 +1308,6 @@ panfrost_queue_draw(struct panfrost_context *ctx)
static void
panfrost_submit_frame(struct panfrost_context *ctx, bool flush_immediate,
- struct pipe_fence_handle **fence,
struct panfrost_batch *batch)
{
panfrost_batch_submit(batch);
@@ -1316,14 +1315,14 @@ panfrost_submit_frame(struct panfrost_context *ctx, bool flush_immediate,
/* If visual, we can stall a frame */
if (!flush_immediate)
- panfrost_drm_force_flush_fragment(ctx, fence);
+ panfrost_drm_force_flush_fragment(ctx);
ctx->last_fragment_flushed = false;
ctx->last_batch = batch;
/* If readback, flush now (hurts the pipelined performance) */
if (flush_immediate)
- panfrost_drm_force_flush_fragment(ctx, fence);
+ panfrost_drm_force_flush_fragment(ctx);
}
static void
@@ -1452,7 +1451,13 @@ panfrost_flush(
bool flush_immediate = /*flags & PIPE_FLUSH_END_OF_FRAME*/true;
/* Submit the frame itself */
- panfrost_submit_frame(ctx, flush_immediate, fence, batch);
+ panfrost_submit_frame(ctx, flush_immediate, batch);
+
+ if (fence) {
+ struct panfrost_fence *f = panfrost_fence_create(ctx);
+ pipe->screen->fence_reference(pipe->screen, fence, NULL);
+ *fence = (struct pipe_fence_handle *)f;
+ }
/* Prepare for the next frame */
panfrost_invalidate_frame(ctx);
diff --git a/src/gallium/drivers/panfrost/pan_context.h b/src/gallium/drivers/panfrost/pan_context.h
index 02552ed23de2..6ad2cc81c781 100644
--- a/src/gallium/drivers/panfrost/pan_context.h
+++ b/src/gallium/drivers/panfrost/pan_context.h
@@ -297,6 +297,9 @@ pan_context(struct pipe_context *pcontext)
return (struct panfrost_context *) pcontext;
}
+struct panfrost_fence *
+panfrost_fence_create(struct panfrost_context *ctx);
+
struct pipe_context *
panfrost_create_context(struct pipe_screen *screen, void *priv, unsigned flags);
diff --git a/src/gallium/drivers/panfrost/pan_drm.c b/src/gallium/drivers/panfrost/pan_drm.c
index e4b75fad4078..47cec9f39fef 100644
--- a/src/gallium/drivers/panfrost/pan_drm.c
+++ b/src/gallium/drivers/panfrost/pan_drm.c
@@ -109,7 +109,7 @@ panfrost_drm_submit_vs_fs_batch(struct panfrost_batch *batch, bool has_draws)
return ret;
}
-static struct panfrost_fence *
+struct panfrost_fence *
panfrost_fence_create(struct panfrost_context *ctx)
{
struct pipe_context *gallium = (struct pipe_context *) ctx;
@@ -136,8 +136,7 @@ panfrost_fence_create(struct panfrost_context *ctx)
}
void
-panfrost_drm_force_flush_fragment(struct panfrost_context *ctx,
- struct pipe_fence_handle **fence)
+panfrost_drm_force_flush_fragment(struct panfrost_context *ctx)
{
struct pipe_context *gallium = (struct pipe_context *) ctx;
struct panfrost_screen *screen = pan_screen(gallium->screen);
@@ -149,12 +148,6 @@ panfrost_drm_force_flush_fragment(struct panfrost_context *ctx,
/* The job finished up, so we're safe to clean it up now */
panfrost_free_batch(ctx->last_batch);
}
-
- if (fence) {
- struct panfrost_fence *f = panfrost_fence_create(ctx);
- gallium->screen->fence_reference(gallium->screen, fence, NULL);
- *fence = (struct pipe_fence_handle *)f;
- }
}
unsigned
diff --git a/src/gallium/drivers/panfrost/pan_screen.h b/src/gallium/drivers/panfrost/pan_screen.h
index aab141a563c2..4acdd3572c9f 100644
--- a/src/gallium/drivers/panfrost/pan_screen.h
+++ b/src/gallium/drivers/panfrost/pan_screen.h
@@ -123,8 +123,7 @@ pan_screen(struct pipe_screen *p)
int
panfrost_drm_submit_vs_fs_batch(struct panfrost_batch *batch, bool has_draws);
void
-panfrost_drm_force_flush_fragment(struct panfrost_context *ctx,
- struct pipe_fence_handle **fence);
+panfrost_drm_force_flush_fragment(struct panfrost_context *ctx);
unsigned
panfrost_drm_query_gpu_version(struct panfrost_screen *screen);
int
--
2.21.0
More information about the mesa-dev
mailing list