Nameless Engine
Loading...
Searching...
No Matches
KtxLoadingCallbackManager.h
1#pragma once
2
3// Standard.
4#include <mutex>
5#include <unordered_map>
6#include <format>
7
8// External.
9#include "VulkanMemoryAllocator/include/vk_mem_alloc.h"
10#include "ktxvulkan.h"
11
12namespace ne {
18 public:
24 static size_t getCurrentAllocationCount();
25
31 static ktxVulkanTexture_subAllocatorCallbacks getKtxSubAllocatorCallbacks();
32
42 static uint64_t allocMem(
43 VkMemoryAllocateInfo* pAllocationInfo,
44 VkMemoryRequirements* pMemoryRequirements,
45 uint64_t* pPageCount);
46
55 static VkResult bindBuffer(VkBuffer pBuffer, uint64_t iAllocationId);
56
65 static VkResult bindImage(VkImage pImage, uint64_t iAllocationId);
66
77 static VkResult
78 memoryMap(uint64_t iAllocationId, uint64_t iPageNumber, VkDeviceSize* pMapLength, void** pData);
79
86 static void memoryUnmap(uint64_t iAllocationId, uint64_t iPageNumber);
87
93 static void freeMem(uint64_t iAllocationId);
94
95 private:
97 struct Data {
102 std::unordered_map<uint64_t, std::pair<VmaAllocation, VkDeviceSize>> allocations;
103
105 uint64_t iAllocationId = 0;
106 };
107
113 static VmaAllocator getMemoryAllocator();
114
120 static VkPhysicalDevice getPhysicalDevice();
121
123 static std::pair<std::recursive_mutex, Data> mtxData;
124 };
125} // namespace ne
Definition: KtxLoadingCallbackManager.h:17
static VkResult bindBuffer(VkBuffer pBuffer, uint64_t iAllocationId)
Definition: KtxLoadingCallbackManager.cpp:136
static void freeMem(uint64_t iAllocationId)
Definition: KtxLoadingCallbackManager.cpp:220
static void memoryUnmap(uint64_t iAllocationId, uint64_t iPageNumber)
Definition: KtxLoadingCallbackManager.cpp:206
static size_t getCurrentAllocationCount()
Definition: KtxLoadingCallbackManager.cpp:18
static std::pair< std::recursive_mutex, Data > mtxData
Definition: KtxLoadingCallbackManager.h:123
static VkPhysicalDevice getPhysicalDevice()
Definition: KtxLoadingCallbackManager.cpp:244
static VmaAllocator getMemoryAllocator()
Definition: KtxLoadingCallbackManager.cpp:238
static VkResult bindImage(VkImage pImage, uint64_t iAllocationId)
Definition: KtxLoadingCallbackManager.cpp:158
static ktxVulkanTexture_subAllocatorCallbacks getKtxSubAllocatorCallbacks()
Definition: KtxLoadingCallbackManager.cpp:23
static VkResult memoryMap(uint64_t iAllocationId, uint64_t iPageNumber, VkDeviceSize *pMapLength, void **pData)
Definition: KtxLoadingCallbackManager.cpp:180
static uint64_t allocMem(VkMemoryAllocateInfo *pAllocationInfo, VkMemoryRequirements *pMemoryRequirements, uint64_t *pPageCount)
Definition: KtxLoadingCallbackManager.cpp:35
Definition: KtxLoadingCallbackManager.h:97
uint64_t iAllocationId
Definition: KtxLoadingCallbackManager.h:105
std::unordered_map< uint64_t, std::pair< VmaAllocation, VkDeviceSize > > allocations
Definition: KtxLoadingCallbackManager.h:102