mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-05 05:18:08 +02:00
zink: simplify some dumb code in invalidate_buffer (v2)
the ref has to be preserved so that rebind doesn't destroy it prematurely Reviewed-by: Dave Airlie <airlied@redhat.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12118>
This commit is contained in:
parent
2668489cf9
commit
461662bf3c
1 changed files with 2 additions and 8 deletions
|
|
@ -1022,25 +1022,19 @@ 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;
|
||||
}
|
||||
/* this ref must be transferred before rebind or else BOOM */
|
||||
zink_batch_reference_resource_move(&ctx->batch, res);
|
||||
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);
|
||||
if (needs_unref)
|
||||
zink_resource_object_reference(screen, &old_obj, NULL);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue