Add and make use of Vulkan Memory Allocator
This commit is contained in:
@@ -27,15 +27,15 @@ namespace Nz
|
||||
RenderBuffer(RenderBuffer&&) = default;
|
||||
~RenderBuffer() = default;
|
||||
|
||||
bool Fill(const void* data, UInt32 offset, UInt32 size) override final;
|
||||
bool Fill(const void* data, UInt32 offset, UInt32 size) final;
|
||||
|
||||
bool Initialize(UInt32 size, BufferUsageFlags usage) override;
|
||||
|
||||
AbstractBuffer* GetHardwareBuffer(RenderDevice* device);
|
||||
DataStorage GetStorage() const override;
|
||||
|
||||
void* Map(BufferAccess access, UInt32 offset = 0, UInt32 size = 0) override final;
|
||||
bool Unmap() override final;
|
||||
void* Map(BufferAccess access, UInt32 offset = 0, UInt32 size = 0) final;
|
||||
bool Unmap() final;
|
||||
|
||||
RenderBuffer& operator=(const RenderBuffer&) = delete;
|
||||
RenderBuffer& operator=(RenderBuffer&&) = default;
|
||||
@@ -44,6 +44,10 @@ namespace Nz
|
||||
bool Synchronize(RenderDevice* device);
|
||||
|
||||
private:
|
||||
struct HardwareBuffer;
|
||||
|
||||
HardwareBuffer* GetHardwareBufferData(RenderDevice* device);
|
||||
|
||||
struct HardwareBuffer
|
||||
{
|
||||
std::unique_ptr<AbstractBuffer> buffer;
|
||||
|
||||
@@ -58,6 +58,7 @@ namespace Nz
|
||||
{
|
||||
BufferUsage_DeviceLocal,
|
||||
BufferUsage_DirectMapping,
|
||||
BufferUsage_PersistentMapping,
|
||||
|
||||
BufferUsage_Max = BufferUsage_DirectMapping
|
||||
};
|
||||
|
||||
@@ -28,7 +28,7 @@ namespace Nz
|
||||
|
||||
bool Fill(const void* data, UInt32 offset, UInt32 size) override;
|
||||
|
||||
inline Nz::Vk::Buffer& GetBufferHandle();
|
||||
inline VkBuffer GetBuffer();
|
||||
bool Initialize(UInt32 size, BufferUsageFlags usage) override;
|
||||
|
||||
DataStorage GetStorage() const override;
|
||||
@@ -40,14 +40,14 @@ namespace Nz
|
||||
VulkanBuffer& operator=(VulkanBuffer&&) = delete; ///TODO
|
||||
|
||||
private:
|
||||
Vk::Buffer m_stagingBuffer;
|
||||
Vk::DeviceMemory m_stagingMemory;
|
||||
BufferType m_type;
|
||||
BufferUsageFlags m_usage;
|
||||
UInt32 m_size;
|
||||
Vk::Buffer m_buffer;
|
||||
VkBuffer m_buffer;
|
||||
VkBuffer m_stagingBuffer;
|
||||
VmaAllocation m_allocation;
|
||||
VmaAllocation m_stagingAllocation;
|
||||
Vk::Device& m_device;
|
||||
Vk::DeviceMemory m_memory;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@ namespace Nz
|
||||
{
|
||||
}
|
||||
|
||||
inline Vk::Buffer& VulkanBuffer::GetBufferHandle()
|
||||
inline VkBuffer VulkanBuffer::GetBuffer()
|
||||
{
|
||||
return m_buffer;
|
||||
}
|
||||
|
||||
@@ -15,6 +15,9 @@
|
||||
#include <memory>
|
||||
#include <unordered_set>
|
||||
|
||||
VK_DEFINE_HANDLE(VmaAllocator)
|
||||
VK_DEFINE_HANDLE(VmaAllocation)
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
namespace Vk
|
||||
@@ -47,6 +50,7 @@ namespace Nz
|
||||
inline Instance& GetInstance();
|
||||
inline const Instance& GetInstance() const;
|
||||
inline VkResult GetLastErrorCode() const;
|
||||
inline VmaAllocator GetMemoryAllocator() const;
|
||||
inline VkPhysicalDevice GetPhysicalDevice() const;
|
||||
inline const Vk::PhysicalDevice& GetPhysicalDeviceInfo() const;
|
||||
|
||||
@@ -63,15 +67,17 @@ namespace Nz
|
||||
inline operator VkDevice();
|
||||
|
||||
// Vulkan functions
|
||||
#define NAZARA_VULKANRENDERER_DEVICE_FUNCTION(func) PFN_##func func = nullptr;
|
||||
#define NAZARA_VULKANRENDERER_DEVICE_CORE_EXT_FUNCTION(func, ...) NAZARA_VULKANRENDERER_DEVICE_FUNCTION(func)
|
||||
#define NAZARA_VULKANRENDERER_DEVICE_EXT_BEGIN(ext)
|
||||
#define NAZARA_VULKANRENDERER_DEVICE_EXT_END()
|
||||
#define NAZARA_VULKANRENDERER_DEVICE_FUNCTION(func) PFN_##func func = nullptr;
|
||||
|
||||
#include <Nazara/VulkanRenderer/Wrapper/DeviceFunctions.hpp>
|
||||
|
||||
#undef NAZARA_VULKANRENDERER_DEVICE_CORE_EXT_FUNCTION
|
||||
#undef NAZARA_VULKANRENDERER_DEVICE_FUNCTION
|
||||
#undef NAZARA_VULKANRENDERER_DEVICE_EXT_BEGIN
|
||||
#undef NAZARA_VULKANRENDERER_DEVICE_EXT_END
|
||||
#undef NAZARA_VULKANRENDERER_DEVICE_FUNCTION
|
||||
|
||||
struct QueueInfo
|
||||
{
|
||||
@@ -103,6 +109,7 @@ namespace Nz
|
||||
VkAllocationCallbacks m_allocator;
|
||||
VkDevice m_device;
|
||||
VkResult m_lastErrorCode;
|
||||
VmaAllocator m_memAllocator;
|
||||
UInt32 m_transferQueueFamilyIndex;
|
||||
std::unordered_set<std::string> m_loadedExtensions;
|
||||
std::unordered_set<std::string> m_loadedLayers;
|
||||
|
||||
@@ -39,6 +39,11 @@ namespace Nz
|
||||
return m_lastErrorCode;
|
||||
}
|
||||
|
||||
inline VmaAllocator Device::GetMemoryAllocator() const
|
||||
{
|
||||
return m_memAllocator;
|
||||
}
|
||||
|
||||
inline VkPhysicalDevice Device::GetPhysicalDevice() const
|
||||
{
|
||||
return m_physicalDevice->physDevice;
|
||||
|
||||
Reference in New Issue
Block a user