Module: Mesa Branch: main Commit: f8f0f1c5cb51511083c0d7bf48a0f079a4d71c8e URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=f8f0f1c5cb51511083c0d7bf48a0f079a4d71c8e
Author: Lucas Stach <[email protected]> Date: Fri Nov 18 18:23:37 2022 +0100 etnaviv: optimize render resource update Now that we track the age at the resource level we can optimize the render surface update by only copying the single level we are going to render to. Signed-off-by: Lucas Stach <[email protected]> Reviewed-by: Christian Gmeiner <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/19964> --- src/gallium/drivers/etnaviv/etnaviv_state.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/src/gallium/drivers/etnaviv/etnaviv_state.c b/src/gallium/drivers/etnaviv/etnaviv_state.c index 02e4eb577cd..3f06808250b 100644 --- a/src/gallium/drivers/etnaviv/etnaviv_state.c +++ b/src/gallium/drivers/etnaviv/etnaviv_state.c @@ -110,18 +110,23 @@ etna_set_constant_buffer(struct pipe_context *pctx, } static void -etna_update_render_resource(struct pipe_context *pctx, struct etna_resource *base) +etna_update_render_surface(struct pipe_context *pctx, struct etna_surface *surf) { + struct etna_resource *base = etna_resource(surf->prsc); struct etna_resource *to = base, *from = base; + unsigned level = surf->base.u.tex.level; - if (base->texture && etna_resource_newer(etna_resource(base->texture), base)) + if (base->texture && + etna_resource_level_newer(&etna_resource(base->texture)->levels[level], + surf->level)) from = etna_resource(base->texture); if (base->render) to = etna_resource(base->render); - if ((to != from) && etna_resource_older(to, from)) - etna_copy_resource(pctx, &to->base, &from->base, 0, base->base.last_level); + if ((to != from) && + etna_resource_level_older(&to->levels[level], &from->levels[level])) + etna_copy_resource(pctx, &to->base, &from->base, level, level); } static void @@ -149,7 +154,7 @@ etna_set_framebuffer_state(struct pipe_context *pctx, assert((res->layout & ETNA_LAYOUT_BIT_TILE) || VIV_FEATURE(screen, chipMinorFeatures2, LINEAR_PE)); - etna_update_render_resource(pctx, etna_resource(cbuf->prsc)); + etna_update_render_surface(pctx, cbuf); if (res->layout == ETNA_LAYOUT_LINEAR) target_linear = true; @@ -251,7 +256,7 @@ etna_set_framebuffer_state(struct pipe_context *pctx, struct etna_surface *zsbuf = etna_surface(fb->zsbuf); struct etna_resource *res = etna_resource(zsbuf->base.texture); - etna_update_render_resource(pctx, etna_resource(zsbuf->prsc)); + etna_update_render_surface(pctx, zsbuf); assert(res->layout &ETNA_LAYOUT_BIT_TILE); /* Cannot render to linear surfaces */
