Mesa (main): zink: move BAR allocation demotion up the stack
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Fri Jun 17 01:31:19 UTC 2022
Module: Mesa
Branch: main
Commit: 575005043222d317070b4c24568cdd059730f176
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=575005043222d317070b4c24568cdd059730f176
Author: Mike Blumenkrantz <michael.blumenkrantz at gmail.com>
Date: Thu Jun 16 12:06:51 2022 -0400
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 at redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17093>
---
src/gallium/drivers/zink/zink_bo.c | 6 ------
src/gallium/drivers/zink/zink_resource.c | 10 ++++++++--
2 files changed, 8 insertions(+), 8 deletions(-)
diff --git a/src/gallium/drivers/zink/zink_bo.c b/src/gallium/drivers/zink/zink_bo.c
index 5c70480f84f..846214cd3be 100644
--- a/src/gallium/drivers/zink/zink_bo.c
+++ b/src/gallium/drivers/zink/zink_bo.c
@@ -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;
}
diff --git a/src/gallium/drivers/zink/zink_resource.c b/src/gallium/drivers/zink/zink_resource.c
index 569b625d3f7..f4e0bb82b84 100644
--- a/src/gallium/drivers/zink/zink_resource.c
+++ b/src/gallium/drivers/zink/zink_resource.c
@@ -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 {
More information about the mesa-commit
mailing list