SpiecsEngine
 
Loading...
Searching...
No Matches
VulkanMemoryAllocator.cpp
Go to the documentation of this file.
1/**
2* @file VulkanMemoryAllocator.cpp.
3* @brief The VulkanMemoryAllocator Class Implementation.
4* @author Spices.
5*/
6
7#include "Pchheader.h"
9
10#define VMA_IMPLEMENTATION
11#include "vk_mem_alloc.h"
12
13namespace Spices {
14
16 : VulkanObject(vulkanState)
17 {
19
20 /**
21 * @brief Instance a VmaAllocatorCreateInfo.
22 * @see https://gpuopen-librariesandsdks.github.io/VulkanMemoryAllocator/html/quick_start.html
23 */
24 VmaAllocatorCreateInfo createInfo {};
25 createInfo.instance = vulkanState.m_Instance;
26 createInfo.physicalDevice = vulkanState.m_PhysicalDevice;
27 createInfo.device = vulkanState.m_Device;
28 createInfo.vulkanApiVersion = VK_API_VERSION_1_3;
29 createInfo.flags = VMA_ALLOCATOR_CREATE_KHR_DEDICATED_ALLOCATION_BIT |
30 VMA_ALLOCATOR_CREATE_KHR_BIND_MEMORY2_BIT |
31 VMA_ALLOCATOR_CREATE_KHR_MAINTENANCE4_BIT |
32 VMA_ALLOCATOR_CREATE_KHR_MAINTENANCE5_BIT |
33 VMA_ALLOCATOR_CREATE_EXT_MEMORY_BUDGET_BIT |
34 VMA_ALLOCATOR_CREATE_BUFFER_DEVICE_ADDRESS_BIT |
35 VMA_ALLOCATOR_CREATE_EXT_MEMORY_PRIORITY_BIT |
36 VMA_ALLOCATION_CREATE_HOST_ACCESS_SEQUENTIAL_WRITE_BIT |
37 VMA_ALLOCATION_CREATE_HOST_ACCESS_RANDOM_BIT ;
38
39 /**
40 * @brief Create Global Allocator.
41 */
42 VK_CHECK(vmaCreateAllocator(&createInfo, &vulkanState.m_VmaAllocator))
43 }
44
46 {
48
49 vmaDestroyAllocator(m_VulkanState.m_VmaAllocator);
50 m_VulkanState.m_VmaAllocator = nullptr;
51 }
52}
#define SPICES_PROFILE_ZONE
#define VK_CHECK(expr)
Vulkan Check macro. Verify Vulkan API Effectiveness.
Definition VulkanUtils.h:68
virtual ~VulkanMemoryAllocator() override
Destructor Function.
VulkanMemoryAllocator(VulkanState &vulkanState)
Constructor Function. Create Specific ThreadPool.
VulkanState & m_VulkanState
The global VulkanState Referenced from VulkanRenderBackend.
VulkanObject(VulkanState &vulkanState)
Constructor Function. Init member variables.
VulkanObject Class. This class defines the basic behaves of VulkanObject. When we create an new Vulka...
This struct contains all Vulkan object in used global.
Definition VulkanUtils.h:74