lima: add render target to submit by dirty buffer flags

No need to add un-touched buffer to submit.

Reviewed-by: Vasily Khoruzhick <anarsoul@gmail.com>
Signed-off-by: Qiang Yu <yuq825@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/merge_requests/3755>
This commit is contained in:
Qiang Yu 2020-02-07 17:07:51 +08:00 committed by Marge Bot
parent 32f1733972
commit 47200f5c8d
1 changed files with 27 additions and 22 deletions

View File

@ -633,20 +633,25 @@ lima_update_pp_stream(struct lima_context *ctx)
}
static void
lima_update_submit_wb(struct lima_context *ctx)
lima_update_submit_wb(struct lima_context *ctx, unsigned buffers)
{
if (lima_ctx_dirty(ctx))
return;
struct lima_context_framebuffer *fb = &ctx->framebuffer;
if (ctx->framebuffer.base.nr_cbufs) {
struct lima_resource *res = lima_resource(ctx->framebuffer.base.cbufs[0]->texture);
/* add to submit when the buffer is dirty and resolve is clear (not added before) */
if (fb->base.nr_cbufs && (buffers & PIPE_CLEAR_COLOR0) &&
!(ctx->resolve & PIPE_CLEAR_COLOR0)) {
struct lima_resource *res = lima_resource(fb->base.cbufs[0]->texture);
lima_submit_add_bo(ctx->pp_submit, res->bo, LIMA_SUBMIT_BO_WRITE);
}
if (ctx->framebuffer.base.zsbuf) {
struct lima_resource *res = lima_resource(ctx->framebuffer.base.zsbuf->texture);
/* add to submit when the buffer is dirty and resolve is clear (not added before) */
if (fb->base.zsbuf && (buffers & (PIPE_CLEAR_DEPTH | PIPE_CLEAR_STENCIL)) &&
!(ctx->resolve & (PIPE_CLEAR_DEPTH | PIPE_CLEAR_STENCIL))) {
struct lima_resource *res = lima_resource(fb->base.zsbuf->texture);
lima_submit_add_bo(ctx->pp_submit, res->bo, LIMA_SUBMIT_BO_WRITE);
}
ctx->resolve |= buffers;
}
static void
@ -685,9 +690,7 @@ lima_clear(struct pipe_context *pctx, unsigned buffers,
lima_flush(ctx);
lima_update_submit_wb(ctx);
ctx->resolve |= buffers;
lima_update_submit_wb(ctx, buffers);
/* no need to reload if cleared */
if (ctx->framebuffer.base.nr_cbufs && (buffers & PIPE_CLEAR_COLOR0)) {
@ -1511,8 +1514,21 @@ lima_draw_vbo_update(struct pipe_context *pctx,
const struct pipe_draw_info *info)
{
struct lima_context *ctx = lima_context(pctx);
struct lima_context_framebuffer *fb = &ctx->framebuffer;
unsigned buffers = 0;
lima_update_submit_wb(ctx);
if (fb->base.zsbuf) {
if (ctx->zsa->base.depth.enabled)
buffers |= PIPE_CLEAR_DEPTH;
if (ctx->zsa->base.stencil[0].enabled ||
ctx->zsa->base.stencil[1].enabled)
buffers |= PIPE_CLEAR_STENCIL;
}
if (fb->base.nr_cbufs)
buffers |= PIPE_CLEAR_COLOR0;
lima_update_submit_wb(ctx, buffers);
lima_update_gp_attribute_info(ctx, info);
@ -1546,17 +1562,6 @@ lima_draw_vbo_update(struct pipe_context *pctx,
ctx->gp_output = NULL;
}
if (ctx->framebuffer.base.zsbuf) {
if (ctx->zsa->base.depth.enabled)
ctx->resolve |= PIPE_CLEAR_DEPTH;
if (ctx->zsa->base.stencil[0].enabled ||
ctx->zsa->base.stencil[1].enabled)
ctx->resolve |= PIPE_CLEAR_STENCIL;
}
if (ctx->framebuffer.base.nr_cbufs)
ctx->resolve |= PIPE_CLEAR_COLOR0;
ctx->dirty = 0;
}