diff options
author | Tomeu Vizoso <tomeu.vizoso@collabora.com> | 2018-12-17 09:56:00 +0100 |
---|---|---|
committer | Emil Velikov <emil.l.velikov@gmail.com> | 2019-01-30 17:33:50 +0000 |
commit | 5e8af9e609632f7062bf9dc81b44c6877a7d8ee4 (patch) | |
tree | ad301ab97f6c6320d34f36180250c59d548e5811 | |
parent | f072585522a137b3b01cb08d624f6e3f340e6583 (diff) |
etnaviv: Consolidate buffer references from framebuffers
We were leaking surfaces because the references taken in
etna_set_framebuffer_state weren't being released on context destroy.
Instead of just directly releasing those references in
etna_context_destroy, use the util_copy_framebuffer_state helper.
Take the chance to remove the duplicated buffer references in
compiled_framebuffer_state to avoid confusion.
The leak can be reproduced with a client that continuously creates and
destroys contexts.
Signed-off-by: Tomeu Vizoso <tomeu.vizoso@collabora.com>
Reported-by: Sjoerd Simons <sjoerd.simons@collabora.co.uk>
Reviewed-by: Christian Gmeiner <christian.gmeiner@gmail.com>
(cherry picked from commit bf1dfcc3e8120400c9a78d03dd914a786728b5f7)
[Emil: resolve trivial conflict - dummy_rt does not exist in branch]
Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
Conflicts:
src/gallium/drivers/etnaviv/etnaviv_context.c
-rw-r--r-- | src/gallium/drivers/etnaviv/etnaviv_context.c | 10 | ||||
-rw-r--r-- | src/gallium/drivers/etnaviv/etnaviv_internal.h | 1 | ||||
-rw-r--r-- | src/gallium/drivers/etnaviv/etnaviv_state.c | 8 |
3 files changed, 9 insertions, 10 deletions
diff --git a/src/gallium/drivers/etnaviv/etnaviv_context.c b/src/gallium/drivers/etnaviv/etnaviv_context.c index 3038d210e10..303dff583aa 100644 --- a/src/gallium/drivers/etnaviv/etnaviv_context.c +++ b/src/gallium/drivers/etnaviv/etnaviv_context.c @@ -60,6 +60,8 @@ etna_context_destroy(struct pipe_context *pctx) { struct etna_context *ctx = etna_context(pctx); + util_copy_framebuffer_state(&ctx->framebuffer_s, NULL); + if (ctx->primconvert) util_primconvert_destroy(ctx->primconvert); @@ -296,10 +298,10 @@ etna_draw_vbo(struct pipe_context *pctx, const struct pipe_draw_info *info) if (DBG_ENABLED(ETNA_DBG_FLUSH_ALL)) pctx->flush(pctx, NULL, 0); - if (ctx->framebuffer.cbuf) - etna_resource(ctx->framebuffer.cbuf->texture)->seqno++; - if (ctx->framebuffer.zsbuf) - etna_resource(ctx->framebuffer.zsbuf->texture)->seqno++; + if (ctx->framebuffer_s.cbufs[0]) + etna_resource(ctx->framebuffer_s.cbufs[0]->texture)->seqno++; + if (ctx->framebuffer_s.zsbuf) + etna_resource(ctx->framebuffer_s.zsbuf->texture)->seqno++; if (info->index_size && indexbuf != info->index.resource) pipe_resource_reference(&indexbuf, NULL); } diff --git a/src/gallium/drivers/etnaviv/etnaviv_internal.h b/src/gallium/drivers/etnaviv/etnaviv_internal.h index 3424d8a7715..77214d9ccba 100644 --- a/src/gallium/drivers/etnaviv/etnaviv_internal.h +++ b/src/gallium/drivers/etnaviv/etnaviv_internal.h @@ -182,7 +182,6 @@ struct compiled_viewport_state { /* Compiled pipe_framebuffer_state */ struct compiled_framebuffer_state { - struct pipe_surface *cbuf, *zsbuf; /* keep reference to surfaces */ uint32_t GL_MULTI_SAMPLE_CONFIG; uint32_t PE_COLOR_FORMAT; uint32_t PE_DEPTH_CONFIG; diff --git a/src/gallium/drivers/etnaviv/etnaviv_state.c b/src/gallium/drivers/etnaviv/etnaviv_state.c index 87ba10b0dc9..520cc5a775f 100644 --- a/src/gallium/drivers/etnaviv/etnaviv_state.c +++ b/src/gallium/drivers/etnaviv/etnaviv_state.c @@ -37,6 +37,7 @@ #include "etnaviv_surface.h" #include "etnaviv_translate.h" #include "etnaviv_util.h" +#include "util/u_framebuffer.h" #include "util/u_helpers.h" #include "util/u_inlines.h" #include "util/u_math.h" @@ -130,7 +131,6 @@ etna_set_framebuffer_state(struct pipe_context *pctx, assert(res->layout & ETNA_LAYOUT_BIT_TILE); /* Cannot render to linear surfaces */ etna_update_render_resource(pctx, cbuf->base.texture); - pipe_surface_reference(&cs->cbuf, &cbuf->base); cs->PE_COLOR_FORMAT = VIVS_PE_COLOR_FORMAT_FORMAT(translate_rs_format(cbuf->base.format)) | VIVS_PE_COLOR_FORMAT_COMPONENTS__MASK | @@ -182,7 +182,6 @@ etna_set_framebuffer_state(struct pipe_context *pctx, nr_samples_color = cbuf->base.texture->nr_samples; } else { - pipe_surface_reference(&cs->cbuf, NULL); /* Clearing VIVS_PE_COLOR_FORMAT_COMPONENTS__MASK and * VIVS_PE_COLOR_FORMAT_OVERWRITE prevents us from overwriting the * color target */ @@ -201,7 +200,6 @@ etna_set_framebuffer_state(struct pipe_context *pctx, etna_update_render_resource(pctx, zsbuf->base.texture); - pipe_surface_reference(&cs->zsbuf, &zsbuf->base); assert(res->layout &ETNA_LAYOUT_BIT_TILE); /* Cannot render to linear surfaces */ uint32_t depth_format = translate_depth_format(zsbuf->base.format); @@ -252,7 +250,6 @@ etna_set_framebuffer_state(struct pipe_context *pctx, nr_samples_depth = zsbuf->base.texture->nr_samples; } else { - pipe_surface_reference(&cs->zsbuf, NULL); cs->PE_DEPTH_CONFIG = VIVS_PE_DEPTH_CONFIG_DEPTH_MODE_NONE; cs->PE_DEPTH_ADDR.bo = NULL; cs->PE_DEPTH_STRIDE = 0; @@ -325,7 +322,8 @@ etna_set_framebuffer_state(struct pipe_context *pctx, */ cs->PE_LOGIC_OP = VIVS_PE_LOGIC_OP_SINGLE_BUFFER(ctx->specs.single_buffer ? 3 : 0); - ctx->framebuffer_s = *sv; /* keep copy of original structure */ + /* keep copy of original structure */ + util_copy_framebuffer_state(&ctx->framebuffer_s, sv); ctx->dirty |= ETNA_DIRTY_FRAMEBUFFER | ETNA_DIRTY_DERIVE_TS; } |