lima: implement invalidate_resource()
We don't need to resolve invalidated resources, so it should improve performance for applications that are doing this hint. Reviewed-by: Qiang Yu <yuq825@gmail.com> Signed-off-by: Vasily Khoruzhick <anarsoul@gmail.com> Tested-by: Marge Bot <https://gitlab.freedesktop.org/mesa/mesa/merge_requests/3476> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/merge_requests/3476>
This commit is contained in:
parent
bf830250a7
commit
60f9b45802
|
@ -104,6 +104,19 @@ lima_context_free_drm_ctx(struct lima_screen *screen, int id)
|
||||||
drmIoctl(screen->fd, DRM_IOCTL_LIMA_CTX_FREE, &req);
|
drmIoctl(screen->fd, DRM_IOCTL_LIMA_CTX_FREE, &req);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
lima_invalidate_resource(struct pipe_context *pctx, struct pipe_resource *prsc)
|
||||||
|
{
|
||||||
|
struct lima_context *ctx = lima_context(pctx);
|
||||||
|
|
||||||
|
if (ctx->framebuffer.base.zsbuf && (ctx->framebuffer.base.zsbuf->texture == prsc))
|
||||||
|
ctx->resolve &= ~(PIPE_CLEAR_DEPTH | PIPE_CLEAR_STENCIL);
|
||||||
|
|
||||||
|
if (ctx->framebuffer.base.nr_cbufs &&
|
||||||
|
(ctx->framebuffer.base.cbufs[0]->texture == prsc))
|
||||||
|
ctx->resolve &= ~PIPE_CLEAR_COLOR0;
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
lima_context_destroy(struct pipe_context *pctx)
|
lima_context_destroy(struct pipe_context *pctx)
|
||||||
{
|
{
|
||||||
|
@ -192,6 +205,7 @@ lima_context_create(struct pipe_screen *pscreen, void *priv, unsigned flags)
|
||||||
ctx->base.screen = pscreen;
|
ctx->base.screen = pscreen;
|
||||||
ctx->base.destroy = lima_context_destroy;
|
ctx->base.destroy = lima_context_destroy;
|
||||||
ctx->base.set_debug_callback = lima_set_debug_callback;
|
ctx->base.set_debug_callback = lima_set_debug_callback;
|
||||||
|
ctx->base.invalidate_resource = lima_invalidate_resource;
|
||||||
|
|
||||||
lima_resource_context_init(ctx);
|
lima_resource_context_init(ctx);
|
||||||
lima_fence_context_init(ctx);
|
lima_fence_context_init(ctx);
|
||||||
|
@ -273,15 +287,3 @@ lima_need_flush(struct lima_context *ctx, struct lima_bo *bo, bool write)
|
||||||
return lima_submit_has_bo(ctx->gp_submit, bo, write) ||
|
return lima_submit_has_bo(ctx->gp_submit, bo, write) ||
|
||||||
lima_submit_has_bo(ctx->pp_submit, bo, write);
|
lima_submit_has_bo(ctx->pp_submit, bo, write);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
|
||||||
lima_is_scanout(struct lima_context *ctx)
|
|
||||||
{
|
|
||||||
/* If there is no color buffer, it's an FBO */
|
|
||||||
if (!ctx->framebuffer.base.nr_cbufs)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
return ctx->framebuffer.base.cbufs[0]->texture->bind & PIPE_BIND_DISPLAY_TARGET ||
|
|
||||||
ctx->framebuffer.base.cbufs[0]->texture->bind & PIPE_BIND_SCANOUT ||
|
|
||||||
ctx->framebuffer.base.cbufs[0]->texture->bind & PIPE_BIND_SHARED;
|
|
||||||
}
|
|
||||||
|
|
|
@ -187,6 +187,8 @@ struct lima_context {
|
||||||
LIMA_CONTEXT_DIRTY_TEXTURES = (1 << 14),
|
LIMA_CONTEXT_DIRTY_TEXTURES = (1 << 14),
|
||||||
} dirty;
|
} dirty;
|
||||||
|
|
||||||
|
unsigned resolve;
|
||||||
|
|
||||||
struct u_upload_mgr *uploader;
|
struct u_upload_mgr *uploader;
|
||||||
struct blitter_context *blitter;
|
struct blitter_context *blitter;
|
||||||
|
|
||||||
|
|
|
@ -680,6 +680,8 @@ lima_clear(struct pipe_context *pctx, unsigned buffers,
|
||||||
|
|
||||||
lima_flush(ctx);
|
lima_flush(ctx);
|
||||||
|
|
||||||
|
ctx->resolve |= buffers;
|
||||||
|
|
||||||
/* no need to reload if cleared */
|
/* no need to reload if cleared */
|
||||||
if (ctx->framebuffer.base.nr_cbufs && (buffers & PIPE_CLEAR_COLOR0)) {
|
if (ctx->framebuffer.base.nr_cbufs && (buffers & PIPE_CLEAR_COLOR0)) {
|
||||||
struct lima_surface *surf = lima_surface(ctx->framebuffer.base.cbufs[0]);
|
struct lima_surface *surf = lima_surface(ctx->framebuffer.base.cbufs[0]);
|
||||||
|
@ -1525,6 +1527,17 @@ lima_draw_vbo_update(struct pipe_context *pctx,
|
||||||
ctx->gp_output = NULL;
|
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;
|
ctx->dirty = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1722,14 +1735,11 @@ lima_pack_pp_frame_reg(struct lima_context *ctx, uint32_t *frame_reg,
|
||||||
frame->blocking = (fb->shift_min << 28) | (fb->shift_h << 16) | fb->shift_w;
|
frame->blocking = (fb->shift_min << 28) | (fb->shift_h << 16) | fb->shift_w;
|
||||||
frame->foureight = 0x8888;
|
frame->foureight = 0x8888;
|
||||||
|
|
||||||
if (fb->base.nr_cbufs)
|
if (fb->base.nr_cbufs && (ctx->resolve & PIPE_CLEAR_COLOR0))
|
||||||
lima_pack_wb_cbuf_reg(ctx, wb_reg, wb_idx++);
|
lima_pack_wb_cbuf_reg(ctx, wb_reg, wb_idx++);
|
||||||
|
|
||||||
/* Mali4x0 can use on-tile buffer for depth/stencil, so to save some
|
if (fb->base.zsbuf &&
|
||||||
* memory bandwidth don't write depth/stencil back to memory if we're
|
(ctx->resolve & (PIPE_CLEAR_DEPTH | PIPE_CLEAR_STENCIL)))
|
||||||
* rendering to scanout
|
|
||||||
*/
|
|
||||||
if (!lima_is_scanout(ctx) && fb->base.zsbuf)
|
|
||||||
lima_pack_wb_zsbuf_reg(ctx, wb_reg, wb_idx++);
|
lima_pack_wb_zsbuf_reg(ctx, wb_reg, wb_idx++);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1886,6 +1896,8 @@ _lima_flush(struct lima_context *ctx, bool end_of_frame)
|
||||||
ctx->damage_rect.minx = ctx->damage_rect.miny = 0xffff;
|
ctx->damage_rect.minx = ctx->damage_rect.miny = 0xffff;
|
||||||
ctx->damage_rect.maxx = ctx->damage_rect.maxy = 0;
|
ctx->damage_rect.maxx = ctx->damage_rect.maxy = 0;
|
||||||
|
|
||||||
|
ctx->resolve = 0;
|
||||||
|
|
||||||
lima_dump_file_next();
|
lima_dump_file_next();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue