diff --git a/src/gallium/drivers/panfrost/pan_blit.c b/src/gallium/drivers/panfrost/pan_blit.c index 51ebbec3a62..1297ea8b253 100644 --- a/src/gallium/drivers/panfrost/pan_blit.c +++ b/src/gallium/drivers/panfrost/pan_blit.c @@ -31,12 +31,10 @@ #include "pan_util.h" #include "util/format/u_format.h" -static void -panfrost_blitter_save( - struct panfrost_context *ctx, - struct blitter_context *blitter, - bool render_cond) +void +panfrost_blitter_save(struct panfrost_context *ctx, bool render_cond) { + struct blitter_context *blitter = ctx->blitter; util_blitter_save_vertex_buffer_slot(blitter, ctx->vertex_buffers); util_blitter_save_vertex_elements(blitter, ctx->vertex); @@ -82,6 +80,6 @@ panfrost_blit(struct pipe_context *pipe, if (!util_blitter_is_blit_supported(ctx->blitter, info)) unreachable("Unsupported blit\n"); - panfrost_blitter_save(ctx, ctx->blitter, info->render_condition_enable); + panfrost_blitter_save(ctx, info->render_condition_enable); util_blitter_blit(ctx->blitter, info); } diff --git a/src/gallium/drivers/panfrost/pan_context.c b/src/gallium/drivers/panfrost/pan_context.c index c051679d09f..d17455aa908 100644 --- a/src/gallium/drivers/panfrost/pan_context.c +++ b/src/gallium/drivers/panfrost/pan_context.c @@ -62,18 +62,26 @@ panfrost_clear( double depth, unsigned stencil) { struct panfrost_context *ctx = pan_context(pipe); + struct panfrost_batch *batch = panfrost_get_batch_for_fbo(ctx); if (!panfrost_render_condition_check(ctx)) return; - /* 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 jobs. - */ - struct panfrost_batch *batch = panfrost_get_fresh_batch_for_fbo(ctx, "Slow clear"); - panfrost_batch_clear(batch, buffers, color, depth, stencil); + /* At the start of the batch, we can clear for free */ + if (!batch->scoreboard.first_job) { + panfrost_batch_clear(batch, buffers, color, depth, stencil); + return; + } + + /* Once there is content, clear with a fullscreen quad */ + panfrost_blitter_save(ctx, false /* render condition */); + + util_blitter_clear(ctx->blitter, + ctx->pipe_framebuffer.width, + ctx->pipe_framebuffer.height, + util_framebuffer_get_num_layers(&ctx->pipe_framebuffer), + buffers, color, depth, stencil, + util_framebuffer_get_num_samples(&ctx->pipe_framebuffer) > 1); } bool diff --git a/src/gallium/drivers/panfrost/pan_resource.h b/src/gallium/drivers/panfrost/pan_resource.h index beeb233fccc..c5c14f5c88b 100644 --- a/src/gallium/drivers/panfrost/pan_resource.h +++ b/src/gallium/drivers/panfrost/pan_resource.h @@ -124,6 +124,9 @@ void panfrost_resource_context_init(struct pipe_context *pctx); /* Blitting */ +void +panfrost_blitter_save(struct panfrost_context *ctx, bool render_cond); + void panfrost_blit(struct pipe_context *pipe, const struct pipe_blit_info *info);