summaryrefslogtreecommitdiffstats
path: root/src/video_core/vulkan_common/vulkan_memory_allocator.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/video_core/vulkan_common/vulkan_memory_allocator.h')
-rw-r--r--src/video_core/vulkan_common/vulkan_memory_allocator.h28
1 files changed, 13 insertions, 15 deletions
diff --git a/src/video_core/vulkan_common/vulkan_memory_allocator.h b/src/video_core/vulkan_common/vulkan_memory_allocator.h
index a5bff03fe..f449bc8d0 100644
--- a/src/video_core/vulkan_common/vulkan_memory_allocator.h
+++ b/src/video_core/vulkan_common/vulkan_memory_allocator.h
@@ -9,6 +9,8 @@
#include "common/common_types.h"
#include "video_core/vulkan_common/vulkan_wrapper.h"
+VK_DEFINE_HANDLE(VmaAllocator)
+
namespace Vulkan {
class Device;
@@ -17,9 +19,11 @@ class MemoryAllocation;
/// Hints and requirements for the backing memory type of a commit
enum class MemoryUsage {
- DeviceLocal, ///< Hints device local usages, fastest memory type to read and write from the GPU
+ DeviceLocal, ///< Requests device local host visible buffer, falling back to device local
+ ///< memory.
Upload, ///< Requires a host visible memory type optimized for CPU to GPU uploads
Download, ///< Requires a host visible memory type optimized for GPU to CPU readbacks
+ Stream, ///< Requests device local host visible buffer, falling back host memory.
};
/// Ownership handle of a memory commitment.
@@ -41,9 +45,6 @@ public:
/// It will map the backing allocation if it hasn't been mapped before.
std::span<u8> Map();
- /// Returns an non-owning OpenGL handle, creating one if it doesn't exist.
- u32 ExportOpenGLHandle() const;
-
/// Returns the Vulkan memory handler.
VkDeviceMemory Memory() const {
return memory;
@@ -74,16 +75,19 @@ public:
* Construct memory allocator
*
* @param device_ Device to allocate from
- * @param export_allocations_ True when allocations have to be exported
*
* @throw vk::Exception on failure
*/
- explicit MemoryAllocator(const Device& device_, bool export_allocations_);
+ explicit MemoryAllocator(const Device& device_);
~MemoryAllocator();
MemoryAllocator& operator=(const MemoryAllocator&) = delete;
MemoryAllocator(const MemoryAllocator&) = delete;
+ vk::Image CreateImage(const VkImageCreateInfo& ci) const;
+
+ vk::Buffer CreateBuffer(const VkBufferCreateInfo& ci, MemoryUsage usage) const;
+
/**
* Commits a memory with the specified requirements.
*
@@ -97,9 +101,6 @@ public:
/// Commits memory required by the buffer and binds it.
MemoryCommit Commit(const vk::Buffer& buffer, MemoryUsage usage);
- /// Commits memory required by the image and binds it.
- MemoryCommit Commit(const vk::Image& image, MemoryUsage usage);
-
private:
/// Tries to allocate a chunk of memory.
bool TryAllocMemory(VkMemoryPropertyFlags flags, u32 type_mask, u64 size);
@@ -117,15 +118,12 @@ private:
/// 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.
- const bool export_allocations; ///< True when memory allocations have to be exported.
+ const Device& device; ///< Device handle.
+ VmaAllocator allocator; ///< Vma allocator.
+ const VkPhysicalDeviceMemoryProperties properties; ///< Physical device properties.
std::vector<std::unique_ptr<MemoryAllocation>> allocations; ///< Current allocations.
VkDeviceSize buffer_image_granularity; // The granularity for adjacent offsets between buffers
// and optimal images
};
-/// Returns true when a memory usage is guaranteed to be host visible.
-bool IsHostVisible(MemoryUsage usage) noexcept;
-
} // namespace Vulkan