zink: stop leaking buffers on replacement

I tried to be pointlessly clever here to avoid an atomic op, but the move()
here ended up leaking a ref in some cases (descriptor bind + multiple replacements in same cmdbuf)

more importantly, it's a stupid idea now that zink_resource_object structs
are entirely owned by the driver, meaning their refcounts are never
altered in threads, and thus the atomic ops are just regular ops

Reviewed-by: Adam Jackson <ajax@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13258>
This commit is contained in:
Mike Blumenkrantz 2021-10-07 17:45:26 -04:00 committed by Marge Bot
parent c161e08c9c
commit 77b3a3f00f
1 changed files with 5 additions and 7 deletions

View File

@ -3958,13 +3958,11 @@ zink_context_replace_buffer_storage(struct pipe_context *pctx, struct pipe_resou
assert(d->obj);
assert(s->obj);
util_idalloc_mt_free(&screen->buffer_ids, delete_buffer_id);
zink_resource_object_reference(screen, NULL, s->obj);
if (zink_resource_has_unflushed_usage(d) ||
(zink_resource_has_usage(d) && zink_resource_has_binds(d)))
zink_batch_reference_resource_move(&ctx->batch, d);
else
zink_resource_object_reference(screen, &d->obj, NULL);
d->obj = s->obj;
/* add a ref just like check_resource_for_batch_ref() would've */
if (zink_resource_has_binds(d) && zink_resource_has_usage(d))
zink_batch_reference_resource(&ctx->batch, d);
/* don't be too creative */
zink_resource_object_reference(screen, &d->obj, s->obj);
/* force counter buffer reset */
d->so_valid = false;
if (num_rebinds && rebind_buffer(ctx, d, rebind_mask, num_rebinds) < num_rebinds)