zink: always unref old images when adding new binds

at some point this was correct, but refactoring has since occurred,
and this ends up leaking storage image objects

cc: mesa-stable

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/20867>
(cherry picked from commit d745e3b0ab)
This commit is contained in:
Mike Blumenkrantz 2023-01-23 16:34:31 -05:00 committed by Dylan Baker
parent 0758a96117
commit 7c846e4606
2 changed files with 2 additions and 8 deletions

View file

@ -40,7 +40,7 @@
"description": "zink: always unref old images when adding new binds",
"nominated": true,
"nomination_type": 0,
"resolution": 0,
"resolution": 1,
"main_sha": null,
"because_sha": null
},

View file

@ -1312,11 +1312,6 @@ add_resource_bind(struct zink_context *ctx, struct zink_resource *res, unsigned
res->layout = VK_IMAGE_LAYOUT_UNDEFINED;
res->obj->access = 0;
res->obj->access_stage = 0;
bool needs_unref = true;
if (zink_resource_has_usage(res)) {
zink_batch_reference_resource_move(&ctx->batch, res);
needs_unref = false;
}
res->obj = new_obj;
for (unsigned i = 0; i <= res->base.b.last_level; i++) {
struct pipe_box box = {0, 0, 0,
@ -1325,8 +1320,7 @@ add_resource_bind(struct zink_context *ctx, struct zink_resource *res, unsigned
box.depth = util_num_layers(&res->base.b, i);
ctx->base.resource_copy_region(&ctx->base, &res->base.b, i, 0, 0, 0, &staging.base.b, i, &box);
}
if (needs_unref)
zink_resource_object_reference(screen, &old_obj, NULL);
zink_resource_object_reference(screen, &old_obj, NULL);
return true;
}