19 #include "shared/shared.h"
21 #include <vulkan/vulkan.h>
29 #define ALLOCATOR_CAPACITY 33554432 // 32MiB
30 #define ALLOCATOR_BLOCK_SIZE 1024 // 1024B
54 allocator->
memory = memory;
62 const uint32_t memory_type = device_memory->
memory_type;
84 if (sub_allocator->
next != NULL)
86 sub_allocator = sub_allocator->
next;
105 sub_allocator = sub_allocator->
next;
112 for (uint32_t i = 0; i < VK_MAX_MEMORY_TYPES; i++)
115 while (sub_allocator != NULL)
117 vkFreeMemory(allocator->
device, sub_allocator->
memory, NULL);
118 sub_allocator = sub_allocator->
next;
129 VkMemoryAllocateInfo memory_allocate_info = {
130 .sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO,
132 .memoryTypeIndex = memory_type
135 #ifdef VKPT_DEVICE_GROUPS
136 VkMemoryAllocateFlagsInfoKHR mem_alloc_flags = {
137 .sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_FLAGS_INFO_KHR,
138 .flags = VK_MEMORY_ALLOCATE_DEVICE_MASK_BIT_KHR,
143 memory_allocate_info.pNext = &mem_alloc_flags;
147 const VkResult result = vkAllocateMemory(allocator->
device, &memory_allocate_info, NULL, &sub_allocator->
memory);
148 if (result != VK_SUCCESS)