summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Blumenkrantz <michael.blumenkrantz@gmail.com>2021-11-17 16:45:20 -0500
committerMarge Bot <emma+marge@anholt.net>2021-11-18 21:22:30 +0000
commitea761a40d596edca419132f6625126616b475c65 (patch)
tree41c168fb420bbde36a769d1a3d50c77f3002d935
parentda9acf70886c66b1059cab3d23814da95d045a71 (diff)
zink: use pb_slab_alloc_reclaimed(reclaim_all) for BAR heap sometimes
this forces a full slab reclaim any time the device is known to have a too-small BAR in order to keep memory usage at a minimum when it might otherwise balloon out and crash us Reviewed-by: Marek Olšák <marek.olsak@amd.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13850>
-rw-r--r--src/gallium/drivers/zink/zink_bo.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/src/gallium/drivers/zink/zink_bo.c b/src/gallium/drivers/zink/zink_bo.c
index 083d6d9fa50..6623e99c82e 100644
--- a/src/gallium/drivers/zink/zink_bo.c
+++ b/src/gallium/drivers/zink/zink_bo.c
@@ -579,12 +579,20 @@ zink_bo_create(struct zink_screen *screen, uint64_t size, unsigned alignment, en
}
struct pb_slabs *slabs = get_slabs(screen, alloc_size, flags);
- entry = pb_slab_alloc(slabs, alloc_size, heap);
+ bool reclaim_all = false;
+ if (heap == ZINK_HEAP_DEVICE_LOCAL_VISIBLE && !screen->resizable_bar) {
+ unsigned low_bound = 128 * 1024 * 1024; //128MB is a very small BAR
+ if (screen->info.driver_props.driverID == VK_DRIVER_ID_NVIDIA_PROPRIETARY)
+ low_bound *= 2; //nvidia has fat textures or something
+ unsigned heapidx = screen->info.mem_props.memoryTypes[screen->heap_map[heap]].heapIndex;
+ reclaim_all = screen->info.mem_props.memoryHeaps[heapidx].size <= low_bound;
+ }
+ entry = pb_slab_alloc_reclaimed(slabs, alloc_size, heap, reclaim_all);
if (!entry) {
/* Clean up buffer managers and try again. */
clean_up_buffer_managers(screen);
- entry = pb_slab_alloc(slabs, alloc_size, heap);
+ entry = pb_slab_alloc_reclaimed(slabs, alloc_size, heap, true);
}
if (!entry)
return NULL;