mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-06 00:49:04 +02:00
zink: stop leaking inferred resolve surfaces
this is tricky since the ownership model here works the other way around from normal: the resolve surface's lifetime is determined by the resource's lifetime, meaning that the surface should be destroyed by the resource instead of the resource being destroyed by the surface Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/31124>
This commit is contained in:
parent
a3c2be8f85
commit
d72f7cbc5a
2 changed files with 6 additions and 1 deletions
|
|
@ -3880,6 +3880,9 @@ zink_set_framebuffer_state(struct pipe_context *pctx,
|
|||
zink_screen_lock_context(screen);
|
||||
res->surface = screen->copy_context->base.create_surface(&screen->copy_context->base, &res->base.b, &tmpl);
|
||||
zink_screen_unlock_context(screen);
|
||||
/* delete extra ref: the resource controls the surface lifetime, not the other way around */
|
||||
struct pipe_resource *pres = ctx->fb_state.resolve;
|
||||
pipe_resource_reference(&pres, NULL);
|
||||
}
|
||||
}
|
||||
if (depth_bias_scale_factor != ctx->depth_bias_scale_factor &&
|
||||
|
|
|
|||
|
|
@ -234,6 +234,8 @@ zink_resource_destroy(struct pipe_screen *pscreen,
|
|||
{
|
||||
struct zink_screen *screen = zink_screen(pscreen);
|
||||
struct zink_resource *res = zink_resource(pres);
|
||||
/* prevent double-free when unrefing internal surfaces */
|
||||
res->base.b.reference.count = 999;
|
||||
if (pres->target == PIPE_BUFFER) {
|
||||
util_range_destroy(&res->valid_buffer_range);
|
||||
util_idalloc_mt_free(&screen->buffer_ids, res->base.buffer_id_unique);
|
||||
|
|
@ -241,10 +243,10 @@ zink_resource_destroy(struct pipe_screen *pscreen,
|
|||
simple_mtx_destroy(&res->bufferview_mtx);
|
||||
ralloc_free(res->bufferview_cache.table);
|
||||
} else {
|
||||
pipe_surface_reference(&res->surface, NULL);
|
||||
assert(!_mesa_hash_table_num_entries(&res->surface_cache));
|
||||
simple_mtx_destroy(&res->surface_mtx);
|
||||
ralloc_free(res->surface_cache.table);
|
||||
pipe_surface_reference(&res->surface, NULL);
|
||||
}
|
||||
/* no need to do anything for the caches, these objects own the resource lifetimes */
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue