Revert "zink: simplify some dumb code in invalidate_buffer"

This reverts commit 6bda555cc0.

this needs to stay dumb in order to preserve the ref on the resource
without destroying it during rebind

Reviewed-by: Dave Airlie <airlied@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12118>
This commit is contained in:
Mike Blumenkrantz 2021-07-28 19:04:55 -04:00 committed by Marge Bot
parent d413fd0219
commit 2668489cf9
1 changed files with 8 additions and 1 deletions

View File

@ -1022,18 +1022,25 @@ invalidate_buffer(struct zink_context *ctx, struct zink_resource *res)
return false;
struct zink_resource_object *old_obj = res->obj;
bool has_usage = zink_resource_has_usage(res);
struct zink_resource_object *new_obj = resource_object_create(screen, &res->base.b, NULL, NULL, NULL, 0);
if (!new_obj) {
debug_printf("new backing resource alloc failed!");
return false;
}
bool needs_unref = true;
if (has_usage) {
zink_batch_reference_resource_move(&ctx->batch, res);
needs_unref = false;
}
res->obj = new_obj;
res->access_stage = 0;
res->access = 0;
res->unordered_barrier = false;
zink_resource_rebind(ctx, res);
zink_descriptor_set_refs_clear(&old_obj->desc_set_refs, old_obj);
zink_batch_reference_resource_move(&ctx->batch, res);
if (needs_unref)
zink_resource_object_reference(screen, &old_obj, NULL);
return true;
}