vulkan_memory_allocator: Add allocation support for download types

Implements the allocator logic to handle download memory types. This
will try to use HOST_CACHED_BIT when available.
This commit is contained in:
ReinUsesLisp
2021-01-03 20:51:11 -03:00
parent 72541af3bc
commit 8f22f5470c
2 changed files with 91 additions and 55 deletions

View File

@ -92,13 +92,22 @@ public:
private:
/// Allocates a chunk of memory.
void AllocMemory(VkMemoryPropertyFlags wanted_properties, u32 type_mask, u64 size);
void AllocMemory(VkMemoryPropertyFlags flags, u32 type_mask, u64 size);
/// Tries to allocate a memory commit.
std::optional<MemoryCommit> TryAllocCommit(const VkMemoryRequirements& requirements,
VkMemoryPropertyFlags wanted_properties);
std::optional<MemoryCommit> TryCommit(const VkMemoryRequirements& requirements,
VkMemoryPropertyFlags flags);
const Device& device; ///< Device handler.
/// Returns the fastest compatible memory property flags from a wanted usage.
VkMemoryPropertyFlags MemoryPropertyFlags(u32 type_mask, MemoryUsage usage) const;
/// Returns the fastest compatible memory property flags from the wanted flags.
VkMemoryPropertyFlags MemoryPropertyFlags(u32 type_mask, VkMemoryPropertyFlags flags) const;
/// Returns index to the fastest memory type compatible with the passed requirements.
std::optional<u32> FindType(VkMemoryPropertyFlags flags, u32 type_mask) const;
const Device& device; ///< Device handle.
const VkPhysicalDeviceMemoryProperties properties; ///< Physical device properties.
std::vector<std::unique_ptr<MemoryAllocation>> allocations; ///< Current allocations.
};