zink: only copy resource during add_bind if it is valid

this otherwise is a big no-op

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/36010>
This commit is contained in:
Mike Blumenkrantz 2025-07-08 12:40:02 -04:00 committed by Marge Bot
parent e59305c29f
commit b022cdc8a1

View file

@ -1772,13 +1772,15 @@ add_resource_bind(struct zink_context *ctx, struct zink_resource *res, unsigned
res->layout = VK_IMAGE_LAYOUT_UNDEFINED;
res->obj = new_obj;
res->queue = VK_QUEUE_FAMILY_IGNORED;
for (unsigned i = 0; i <= res->base.b.last_level; i++) {
struct pipe_box box;
u_box_3d(0, 0, 0,
u_minify(res->base.b.width0, i),
u_minify(res->base.b.height0, i), res->base.b.array_size, &box);
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 (res->valid) {
for (unsigned i = 0; i <= res->base.b.last_level; i++) {
struct pipe_box box;
u_box_3d(0, 0, 0,
u_minify(res->base.b.width0, i),
u_minify(res->base.b.height0, i), res->base.b.array_size, &box);
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);
}
}
res->rebind_count++;
if (old_obj->exportable) {