From 22347bb45e427ea763295d77da0de0d2ef9c2395 Mon Sep 17 00:00:00 2001 From: Eleni Maria Stea Date: Sun, 11 Mar 2018 21:34:54 +0200 Subject: [PATCH] free the allocated memory --- src/vulkan/allocator.cc | 5 +++++ src/vulkan/allocator.h | 3 +++ src/vulkan/mesh-vk.cc | 1 - src/vulkan/vkutil.cc | 3 +++ 4 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/vulkan/allocator.cc b/src/vulkan/allocator.cc index 9d71e9b..714b7cc 100644 --- a/src/vulkan/allocator.cc +++ b/src/vulkan/allocator.cc @@ -25,3 +25,8 @@ bool vku_allocate(int size, DevMemBlock *block) return true; } + +void vku_free(VkDeviceMemory gpu_memory) +{ + vkFreeMemory(vk_device, gpu_memory, 0); +} diff --git a/src/vulkan/allocator.h b/src/vulkan/allocator.h index ad4c87f..83ccee9 100644 --- a/src/vulkan/allocator.h +++ b/src/vulkan/allocator.h @@ -12,4 +12,7 @@ struct DevMemBlock { bool vku_allocate(int size, DevMemBlock *block); void vku_free(VkDeviceMemory gpu_memory); +bool vku_map_memory(VkDeviceMemory gpu_mem, int size, void *data); +void vku_unmap_memory(VkDeviceMemory gpu_mem); + #endif // ALLOCATOR_H_ diff --git a/src/vulkan/mesh-vk.cc b/src/vulkan/mesh-vk.cc index b495ea2..97ce2f0 100644 --- a/src/vulkan/mesh-vk.cc +++ b/src/vulkan/mesh-vk.cc @@ -88,7 +88,6 @@ bool MeshVK::update_vertex_data() //TODO this is going to change when we allocate one mem block for all data, //for the moment we map each buffer memory block and we set the data - return true; } diff --git a/src/vulkan/vkutil.cc b/src/vulkan/vkutil.cc index a64f86f..35a85dd 100644 --- a/src/vulkan/vkutil.cc +++ b/src/vulkan/vkutil.cc @@ -460,6 +460,9 @@ struct vku_buffer *vku_create_buffer(int sz, unsigned int usage) void vku_destroy_buffer(struct vku_buffer *buf) { if(buf) { + //TODO change when the allocator changes + vku_free(buf->mem_pool); + vkDestroyBuffer(vk_device, buf->buf, 0); delete buf; } -- 1.7.10.4