aboutsummaryrefslogtreecommitdiff
path: root/render
diff options
context:
space:
mode:
authorSimon Ser <contact@emersion.fr>2022-09-19 11:45:10 +0200
committerSimon Zeni <simon@bl4ckb0ne.ca>2022-09-19 10:33:29 +0000
commit8d6d2101bc2b33f6590de1d201a661620a48aa19 (patch)
treebbca89cc6d43a1acd7305fb4aa04e9efc4e98afe /render
parent5206cea566953a81788627a6c01533d579edc71a (diff)
render/vulkan: add error handling for vulkan_find_mem_type()
The function returns -1 if it doesn't find a suitable memory type.
Diffstat (limited to 'render')
-rw-r--r--render/vulkan/renderer.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/render/vulkan/renderer.c b/render/vulkan/renderer.c
index 45796ca9..8649ff14 100644
--- a/render/vulkan/renderer.c
+++ b/render/vulkan/renderer.c
@@ -271,12 +271,18 @@ struct wlr_vk_buffer_span vulkan_get_stage_span(struct wlr_vk_renderer *r,
VkMemoryRequirements mem_reqs;
vkGetBufferMemoryRequirements(r->dev->dev, buf->buffer, &mem_reqs);
+ int mem_type_index = vulkan_find_mem_type(r->dev,
+ VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT |
+ VK_MEMORY_PROPERTY_HOST_COHERENT_BIT, mem_reqs.memoryTypeBits);
+ if (mem_type_index < 0) {
+ wlr_log(WLR_ERROR, "Failed to find memory type");
+ goto error;
+ }
+
VkMemoryAllocateInfo mem_info = {0};
mem_info.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO;
mem_info.allocationSize = mem_reqs.size;
- mem_info.memoryTypeIndex = vulkan_find_mem_type(r->dev,
- VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT |
- VK_MEMORY_PROPERTY_HOST_COHERENT_BIT, mem_reqs.memoryTypeBits);
+ mem_info.memoryTypeIndex = (uint32_t)mem_type_index;
res = vkAllocateMemory(r->dev->dev, &mem_info, NULL, &buf->memory);
if (res != VK_SUCCESS) {
wlr_vk_error("vkAllocatorMemory", res);