#pragma once /* #include "vulkan_util.hpp" */ #include #include #include #include #include #include /* #include */ namespace gz::vk { struct MemoryInfo { VkDeviceMemory memory = VK_NULL_HANDLE; VkDeviceSize offset = 0; uint32_t memoryTypeIndex = 0; }; // if no memory is available, allocate a chunk of multiplier * requested size constexpr VkDeviceSize TODO_ALLOCATION_SIZE_MULTIPLIIER = 10; // defined in vulkan_instance.hpp class VulkanInstance; // defined in vulkan_allocator.cpp struct DeviceMemory; class VulkanAllocator { public: VulkanAllocator(VulkanInstance& instance); /** * @brief Get a block from a VkDeviceMemory * @details * Get a block of allocI.allocationSize of a VkDeviceMemory that was allocated with allocI.memoryTypeIndex. * * When this function returns, memoryInfo will contain the information about the available block. * You can then bind something of size allocI.allocationSize to memoryInfo.memory at offset memoryInfo.offset. * @throws VkException when a call to vkAllocateMemory is needed and fails * @todo Determine the size of new allocations */ void allocate(const VkMemoryAllocateInfo& allocI, MemoryInfo& memoryInfo); /** * @brief Free a block allocated with allocate() * * When this function returns, memoryInfo will be reset to default values * @throws VkUserError if memoryInfo was not allocated from this allocator */ void free(MemoryInfo& memoryInfo); private: /// allocated memory for memoryIndexType std::map> memory; Log aLog; VulkanInstance& vk; }; // class VulkanAllocator } // namespace gz::vk