26 static void initAllocator(
const VkPhysicalDevice&,
const VkDevice&);
28 void* rawmap(
size_t offset = 0, VkDeviceSize size = VK_WHOLE_SIZE);
31 template <
typename T =
void>
32 inline T* map(
size_t offset = 0, VkDeviceSize size = VK_WHOLE_SIZE) {
33 return (T*)rawmap(offset, size);
36 inline void copy(
size_t size,
const void* data, VkDeviceSize offset = 0)
const {
37 memcpy((uint8_t*)mapped + offset, data, size);
41 inline void copy(
const T& data, VkDeviceSize offset = 0)
const {
42 copy(
sizeof(T), &data, offset);
46 inline void copy(
const std::vector<T>& data, VkDeviceSize offset = 0)
const {
47 copy(
sizeof(T) * data.size(), data.data(), offset);
50 void flush(VkDeviceSize size, VkDeviceSize offset = 0);
51 void invalidate(VkDeviceSize size, VkDeviceSize offset = 0);
52 virtual void destroy();
56 VkDeviceSize size{ 0 };
57 VkDeviceSize alignment{ 0 };
58 VkDeviceSize allocSize{ 0 };
61 static VmaAllocator& getAllocator();
63 VmaAllocation allocation;
65 VkMemoryPropertyFlags memoryPropertyFlags;
67 VkDeviceMemory memory;
69 void* mapped{
nullptr };