zink: Assert if we try to use a dedicated allocation with offset > 0

Acked-by: Mike Blumenkrantz <michael.blumenkrantz@gmail.com>
Reviewed-by: Mel Henning <mhenning@darkrefraction.com>
Tested-by: Mary Guillemard <mary@mary.zone>

Backport-to: 26.1
(cherry picked from commit baa13f6a86)

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/41402>
This commit is contained in:
Faith Ekstrand 2026-03-06 12:58:01 -05:00 committed by Eric Engestrom
parent 0db5577ee2
commit 4f5c5ab31f
2 changed files with 5 additions and 2 deletions

View file

@ -2224,7 +2224,7 @@
"description": "zink: Assert if we try to use a dedicated allocation with offset > 0",
"nominated": true,
"nomination_type": 4,
"resolution": 0,
"resolution": 1,
"main_sha": null,
"because_sha": null,
"notes": null

View file

@ -1467,6 +1467,7 @@ create_image(struct zink_screen *screen, struct zink_resource_object *obj,
infos[i].image = obj->image;
infos[i].memory = zink_bo_get_mem(obj->bo);
infos[i].memoryOffset = obj->plane_offsets[i];
assert(!alloc_info->need_dedicated || obj->plane_offsets[i] == 0);
if (templ->bind & ZINK_BIND_VIDEO) {
infos[i].pNext = &planes[i];
planes[i].sType = VK_STRUCTURE_TYPE_BIND_IMAGE_PLANE_MEMORY_INFO;
@ -1479,11 +1480,13 @@ create_image(struct zink_screen *screen, struct zink_resource_object *obj,
return roc_fail_and_cleanup_all;
}
} else {
if (!(templ->flags & PIPE_RESOURCE_FLAG_SPARSE))
if (!(templ->flags & PIPE_RESOURCE_FLAG_SPARSE)) {
assert(!alloc_info->need_dedicated || obj->offset == 0);
if (VKSCR(BindImageMemory)(screen->dev, obj->image, zink_bo_get_mem(obj->bo), obj->offset) != VK_SUCCESS) {
mesa_loge("ZINK: vkBindImageMemory failed");
return roc_fail_and_cleanup_all;
}
}
}
_mesa_set_init(&obj->surface_cache, NULL, NULL, equals_surface_key);
return roc_success;