rewriting swapchain/image/allocation parts
[demo] / src / vulkan / allocator.cc
1 #include <stdio.h>
2 #include <string.h>
3
4 #include "allocator.h"
5 #include "vk.h"
6 #include "vkutil.h"
7
8 VkDeviceMemory vk_allocate(int size)
9 {
10         VkDeviceMemory gpu_mem;
11
12         VkMemoryAllocateInfo gpu_alloc_inf;
13         memset(&gpu_alloc_inf, 0, sizeof gpu_alloc_inf);
14         gpu_alloc_inf.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO;
15         gpu_alloc_inf.allocationSize = size;
16
17         if(vkAllocateMemory(vk_device, &gpu_alloc_inf, 0, &gpu_mem) != VK_SUCCESS) {
18                 fprintf(stderr, "Failed to allocate device memory, mem size: %d\n");
19                 return 0;
20         }
21
22         return gpu_mem;
23 }