VOX
A little voxel engine
Loading...
Searching...
No Matches
VulkanMemoryAllocator.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <vulkan/vulkan.h>
4
5#include "Tracy.hpp"
6
7#include <map>
8#include <mutex>
9
15{
16
17public:
18
20 {
21 static VulkanMemoryAllocator instance;
22 return instance;
23 }
24
29
30 VkResult allocateMemory(
31 VkDevice device,
32 const VkMemoryAllocateInfo * pAllocateInfo,
33 const VkAllocationCallbacks * pAllocator,
34 VkDeviceMemory * pMemory
35 );
36
37 void freeMemory(
38 VkDevice device,
39 VkDeviceMemory memory,
40 const VkAllocationCallbacks * pAllocator
41 );
42
43 VkDeviceSize allocatedMemorySize() const;
44
45 uint32_t allocatedMemoryCount() const;
46
47private:
48
51
52 std::map<VkDeviceMemory, VkDeviceSize> m_allocated_memory;
53
54 VkDeviceSize m_allocated_memory_size = 0;
55
56 mutable TracyLockableN(std::mutex, m_mutex, "Vulkan Memory Allocator");
57};
Singleton class to keep track of allocated memory.
Definition: VulkanMemoryAllocator.hpp:15
static VulkanMemoryAllocator & getInstance()
Definition: VulkanMemoryAllocator.hpp:19
VulkanMemoryAllocator & operator=(const VulkanMemoryAllocator &)=delete
VulkanMemoryAllocator & operator=(VulkanMemoryAllocator &&)=delete
uint32_t allocatedMemoryCount() const
Definition: VulkanMemoryAllocator.cpp:56
VkDeviceSize allocatedMemorySize() const
Definition: VulkanMemoryAllocator.cpp:50
void freeMemory(VkDevice device, VkDeviceMemory memory, const VkAllocationCallbacks *pAllocator)
Definition: VulkanMemoryAllocator.cpp:33
VkResult allocateMemory(VkDevice device, const VkMemoryAllocateInfo *pAllocateInfo, const VkAllocationCallbacks *pAllocator, VkDeviceMemory *pMemory)
Definition: VulkanMemoryAllocator.cpp:13
VulkanMemoryAllocator(const VulkanMemoryAllocator &)=delete
VulkanMemoryAllocator(VulkanMemoryAllocator &&)=delete