zink: move BAR allocation demotion up the stack

having this so far down in the BO allocation path meant that slabs were
getting demoted to device-local and then stored as BAR in the pb cache,
which broke the cache pretty badly

cc: mesa-stable

Reviewed-by: Dave Airlie <airlied@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17093>
This commit is contained in:
Mike Blumenkrantz 2022-06-16 12:06:51 -04:00 committed by Marge Bot
parent d63e04e583
commit 5750050432
2 changed files with 8 additions and 8 deletions

View file

@ -262,7 +262,6 @@ bo_create_internal(struct zink_screen *screen,
mai.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO;
mai.pNext = pNext;
mai.allocationSize = size;
demote:
mai.memoryTypeIndex = screen->heap_map[heap];
if (screen->info.mem_props.memoryTypes[mai.memoryTypeIndex].propertyFlags & VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT) {
alignment = MAX2(alignment, screen->info.props.limits.minMemoryMapAlignment);
@ -285,11 +284,6 @@ demote:
VkResult ret = VKSCR(AllocateMemory)(screen->dev, &mai, NULL, &bo->mem);
if (!zink_screen_handle_vkresult(screen, ret)) {
if (heap == ZINK_HEAP_DEVICE_LOCAL_VISIBLE) {
heap = ZINK_HEAP_DEVICE_LOCAL;
mesa_loge("zink: %p couldn't allocate memory! from BAR heap: retrying as device-local", bo);
goto demote;
}
mesa_loge("zink: couldn't allocate memory! from heap %u", heap);
goto fail;
}

View file

@ -957,9 +957,15 @@ resource_object_create(struct zink_screen *screen, const struct pipe_resource *t
if (templ->usage == PIPE_USAGE_STAGING && obj->is_buffer)
alignment = MAX2(alignment, screen->info.props.limits.minMemoryMapAlignment);
obj->alignment = alignment;
retry:
obj->bo = zink_bo(zink_bo_create(screen, reqs.size, alignment, heap, mai.pNext ? ZINK_ALLOC_NO_SUBALLOC : 0, mai.pNext));
if (!obj->bo)
goto fail2;
if (!obj->bo) {
if (heap == ZINK_HEAP_DEVICE_LOCAL_VISIBLE) {
heap = ZINK_HEAP_DEVICE_LOCAL;
goto retry;
}
goto fail2;
}
if (aflags == ZINK_ALLOC_SPARSE) {
obj->size = templ->width0;
} else {