Mesa (staging/21.3): zink: error when trying to allocate a bo larger than heap size
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Mon Nov 1 19:36:41 UTC 2021
Module: Mesa
Branch: staging/21.3
Commit: 279e072a85da819b42fcda0d0986264389ac94f5
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=279e072a85da819b42fcda0d0986264389ac94f5
Author: Mike Blumenkrantz <michael.blumenkrantz at gmail.com>
Date: Thu Oct 28 09:48:15 2021 -0400
zink: error when trying to allocate a bo larger than heap size
this is illegal and would fail anyway
cc: mesa-stable
Reviewed-by: Dave Airlie <airlied at redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13584>
(cherry picked from commit fd2b47281f1b63312a58c2f7e77ee39f0858ba95)
---
.pick_status.json | 2 +-
src/gallium/drivers/zink/zink_bo.c | 24 +++++++++++++++---------
2 files changed, 16 insertions(+), 10 deletions(-)
diff --git a/.pick_status.json b/.pick_status.json
index 1834d1caa29..4039eb825c0 100644
--- a/.pick_status.json
+++ b/.pick_status.json
@@ -76,7 +76,7 @@
"description": "zink: error when trying to allocate a bo larger than heap size",
"nominated": true,
"nomination_type": 0,
- "resolution": 0,
+ "resolution": 1,
"main_sha": null,
"because_sha": null
},
diff --git a/src/gallium/drivers/zink/zink_bo.c b/src/gallium/drivers/zink/zink_bo.c
index 6a554ec91f2..ad4282dc2d8 100644
--- a/src/gallium/drivers/zink/zink_bo.c
+++ b/src/gallium/drivers/zink/zink_bo.c
@@ -243,6 +243,21 @@ bo_create_internal(struct zink_screen *screen,
alignment = get_optimal_alignment(screen, size, alignment);
+ VkMemoryAllocateInfo mai;
+ mai.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO;
+ mai.pNext = pNext;
+ mai.allocationSize = size;
+ 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);
+ mai.allocationSize = align64(mai.allocationSize, screen->info.props.limits.minMemoryMapAlignment);
+ }
+ unsigned heap_idx = screen->info.mem_props.memoryTypes[screen->heap_map[heap]].heapIndex;
+ if (mai.allocationSize > screen->info.mem_props.memoryHeaps[heap_idx].size) {
+ mesa_loge("zink: can't allocate %"PRIu64" bytes from heap that's only %"PRIu64" bytes!\n", mai.allocationSize, screen->info.mem_props.memoryHeaps[heap_idx].size);
+ return NULL;
+ }
+
/* all non-suballocated bo can cache */
init_pb_cache = true;
@@ -256,15 +271,6 @@ bo_create_internal(struct zink_screen *screen,
pb_cache_init_entry(&screen->pb.bo_cache, bo->cache_entry, &bo->base, heap);
}
- VkMemoryAllocateInfo mai;
- mai.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO;
- mai.pNext = pNext;
- mai.allocationSize = size;
- 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);
- mai.allocationSize = align64(mai.allocationSize, screen->info.props.limits.minMemoryMapAlignment);
- }
VkResult ret = VKSCR(AllocateMemory)(screen->dev, &mai, NULL, &bo->mem);
if (!zink_screen_handle_vkresult(screen, ret))
goto fail;
More information about the mesa-commit
mailing list