diff options
author | Boris Brezillon <[email protected]> | 2019-09-19 15:52:02 +0200 |
---|---|---|
committer | Boris Brezillon <[email protected]> | 2019-10-08 10:07:54 +0200 |
commit | c138ca80d2390ce0d0fe640bc74aab2d2d0cb80d (patch) | |
tree | 66f196d239cdeb54e2342e46b5f4ed301570a42b /src/gallium/drivers/panfrost | |
parent | 016c19bc895ffaa85954aa864a9de969261f9922 (diff) |
panfrost: Make sure a clear does not re-use a pre-existing batch
glClear()s are expected to be the first thing GL apps do before drawing
new things. If there's already an existing batch targetting the same
FBO that has draws attached to it, we should make sure the new clear
gets a new batch assigned to guaranteed that the FB content is actually
cleared with the requested color/depth/stencil values.
We create a panfrost_get_fresh_batch_for_fbo() helper for that and
call it from panfrost_clear().
Signed-off-by: Boris Brezillon <[email protected]>
Reviewed-by: Alyssa Rosenzweig <[email protected]>
Diffstat (limited to 'src/gallium/drivers/panfrost')
-rw-r--r-- | src/gallium/drivers/panfrost/pan_context.c | 9 | ||||
-rw-r--r-- | src/gallium/drivers/panfrost/pan_job.c | 21 | ||||
-rw-r--r-- | src/gallium/drivers/panfrost/pan_job.h | 3 |
3 files changed, 32 insertions, 1 deletions
diff --git a/src/gallium/drivers/panfrost/pan_context.c b/src/gallium/drivers/panfrost/pan_context.c index a8fda5dcee6..b8edf302803 100644 --- a/src/gallium/drivers/panfrost/pan_context.c +++ b/src/gallium/drivers/panfrost/pan_context.c @@ -162,7 +162,14 @@ panfrost_clear( double depth, unsigned stencil) { struct panfrost_context *ctx = pan_context(pipe); - struct panfrost_batch *batch = panfrost_get_batch_for_fbo(ctx); + + /* TODO: panfrost_get_fresh_batch_for_fbo() instantiates a new batch if + * the existing batch targeting this FBO has draws. We could probably + * avoid that by replacing plain clears by quad-draws with a specific + * color/depth/stencil value, thus avoiding the generation of extra + * fragment/set_value jobs. + */ + struct panfrost_batch *batch = panfrost_get_fresh_batch_for_fbo(ctx); panfrost_batch_add_fbo_bos(batch); panfrost_batch_clear(batch, buffers, color, depth, stencil); diff --git a/src/gallium/drivers/panfrost/pan_job.c b/src/gallium/drivers/panfrost/pan_job.c index a56f4044fda..ae482a9a7a6 100644 --- a/src/gallium/drivers/panfrost/pan_job.c +++ b/src/gallium/drivers/panfrost/pan_job.c @@ -293,6 +293,27 @@ panfrost_get_batch_for_fbo(struct panfrost_context *ctx) return batch; } +struct panfrost_batch * +panfrost_get_fresh_batch_for_fbo(struct panfrost_context *ctx) +{ + struct panfrost_batch *batch; + + batch = panfrost_get_batch(ctx, &ctx->pipe_framebuffer); + + /* The batch has no draw/clear queued, let's return it directly. + * Note that it's perfectly fine to re-use a batch with an + * existing clear, we'll just update it with the new clear request. + */ + if (!batch->last_job.gpu) + return batch; + + /* Otherwise, we need to freeze the existing one and instantiate a new + * one. + */ + panfrost_freeze_batch(batch); + return panfrost_get_batch(ctx, &ctx->pipe_framebuffer); +} + static bool panfrost_batch_fence_is_signaled(struct panfrost_batch_fence *fence) { diff --git a/src/gallium/drivers/panfrost/pan_job.h b/src/gallium/drivers/panfrost/pan_job.h index 25905b51673..1da5d57aec1 100644 --- a/src/gallium/drivers/panfrost/pan_job.h +++ b/src/gallium/drivers/panfrost/pan_job.h @@ -169,6 +169,9 @@ panfrost_batch_fence_reference(struct panfrost_batch_fence *batch); struct panfrost_batch * panfrost_get_batch_for_fbo(struct panfrost_context *ctx); +struct panfrost_batch * +panfrost_get_fresh_batch_for_fbo(struct panfrost_context *ctx); + void panfrost_batch_init(struct panfrost_context *ctx); |