asahi: Use util_blitter_clear

To avoid flush, use util_blitter_clear to clear with rectangles when
there is already content in the scene. This ~doubles the performance of
Inochi2D, which does frequent stencil clears in the middle of the screen
to implement masking.

Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/18380>
This commit is contained in:
Alyssa Rosenzweig 2022-06-16 23:29:18 -04:00 committed by Marge Bot
parent fb7860ed24
commit 279eaec278
3 changed files with 23 additions and 8 deletions

View file

@ -362,20 +362,33 @@ agx_clear(struct pipe_context *pctx, unsigned buffers, const struct pipe_scissor
{
struct agx_context *ctx = agx_context(pctx);
/* TODO: support partial clears */
if (ctx->batch->clear | ctx->batch->draw)
pctx->flush(pctx, NULL, 0);
unsigned fastclear = buffers & ~(ctx->batch->draw | ctx->batch->load);
unsigned slowclear = buffers & ~fastclear;
ctx->batch->clear |= buffers;
assert(scissor_state == NULL && "we don't support PIPE_CAP_CLEAR_SCISSORED");
if (buffers & PIPE_CLEAR_COLOR0)
/* Fast clears configure the batch */
if (fastclear & PIPE_CLEAR_COLOR0)
memcpy(ctx->batch->clear_color, color->f, sizeof(color->f));
if (buffers & PIPE_CLEAR_DEPTH)
if (fastclear & PIPE_CLEAR_DEPTH)
ctx->batch->clear_depth = depth;
if (buffers & PIPE_CLEAR_STENCIL)
if (fastclear & PIPE_CLEAR_STENCIL)
ctx->batch->clear_stencil = stencil;
/* Slow clears draw a fullscreen rectangle */
if (slowclear) {
agx_blitter_save(ctx, ctx->blitter, false /* render cond */);
util_blitter_clear(ctx->blitter, ctx->framebuffer.width,
ctx->framebuffer.height,
util_framebuffer_get_num_layers(&ctx->framebuffer),
slowclear, color, depth, stencil,
util_framebuffer_get_num_samples(&ctx->framebuffer) > 1);
}
ctx->batch->clear |= fastclear;
assert((ctx->batch->draw & slowclear) == slowclear);
}
@ -554,6 +567,7 @@ agx_flush(struct pipe_context *pctx,
agx_pool_init(&ctx->batch->pipeline_pool, dev, AGX_MEMORY_TYPE_CMDBUF_32, true);
ctx->batch->clear = 0;
ctx->batch->draw = 0;
ctx->batch->load = 0;
ctx->batch->encoder_current = ctx->batch->encoder->ptr.cpu;
ctx->batch->scissor.count = 0;
ctx->dirty = ~0;

View file

@ -1706,6 +1706,7 @@ agx_draw_vbo(struct pipe_context *pctx, const struct pipe_draw_info *info,
/* TODO: masks */
ctx->batch->draw |= ~0;
ctx->batch->load |= ~0;
/* TODO: Dirty track */
agx_update_vs(ctx);

View file

@ -98,7 +98,7 @@ struct agx_batch {
struct pipe_surface *zsbuf;
/* PIPE_CLEAR_* bitmask */
uint32_t clear, draw;
uint32_t clear, draw, load;
float clear_color[4];
double clear_depth;