Allow named vulkan allocations
This commit is contained in:
@@ -20,7 +20,6 @@
|
|||||||
#include "allocation.h"
|
#include "allocation.h"
|
||||||
#include "application.h"
|
#include "application.h"
|
||||||
|
|
||||||
#include "spdlog/spdlog.h"
|
|
||||||
#include "utils/check.h"
|
#include "utils/check.h"
|
||||||
|
|
||||||
#include "vulkan/vulkan_raii.hpp"
|
#include "vulkan/vulkan_raii.hpp"
|
||||||
@@ -29,14 +28,15 @@
|
|||||||
|
|
||||||
std::pair<vk::raii::Buffer, VmaAllocation> basic_allocation_traits<VkBuffer>::create(
|
std::pair<vk::raii::Buffer, VmaAllocation> basic_allocation_traits<VkBuffer>::create(
|
||||||
const CreateInfo& buffer_info,
|
const CreateInfo& buffer_info,
|
||||||
const VmaAllocationCreateInfo* alloc_info)
|
const VmaAllocationCreateInfo& alloc_info)
|
||||||
{
|
{
|
||||||
VmaAllocator allocator = application::get_allocator();
|
VmaAllocator allocator = application::get_allocator();
|
||||||
vk::raii::Device& device = application::get_device();
|
vk::raii::Device& device = application::get_device();
|
||||||
|
|
||||||
VmaAllocation allocation;
|
VmaAllocation allocation;
|
||||||
VkBuffer tmp;
|
VkBuffer tmp;
|
||||||
CHECK_VK(vmaCreateBuffer(allocator, &(NativeCreateInfo&)buffer_info, alloc_info, &tmp, &allocation, nullptr));
|
|
||||||
|
CHECK_VK(vmaCreateBuffer(allocator, &(NativeCreateInfo&)buffer_info, &alloc_info, &tmp, &allocation, nullptr));
|
||||||
|
|
||||||
return std::pair<vk::raii::Buffer, VmaAllocation>{vk::raii::Buffer{device, tmp}, allocation};
|
return std::pair<vk::raii::Buffer, VmaAllocation>{vk::raii::Buffer{device, tmp}, allocation};
|
||||||
|
|
||||||
@@ -73,14 +73,15 @@ void basic_allocation_traits_base::unmap(VmaAllocation allocation)
|
|||||||
|
|
||||||
std::pair<vk::raii::Image, VmaAllocation> basic_allocation_traits<VkImage>::create(
|
std::pair<vk::raii::Image, VmaAllocation> basic_allocation_traits<VkImage>::create(
|
||||||
const CreateInfo& image_info,
|
const CreateInfo& image_info,
|
||||||
const VmaAllocationCreateInfo* alloc_info)
|
const VmaAllocationCreateInfo& alloc_info)
|
||||||
{
|
{
|
||||||
VmaAllocator allocator = application::get_allocator();
|
VmaAllocator allocator = application::get_allocator();
|
||||||
vk::raii::Device& device = application::get_device();
|
vk::raii::Device& device = application::get_device();
|
||||||
|
|
||||||
VmaAllocation allocation;
|
VmaAllocation allocation;
|
||||||
VkImage tmp;
|
VkImage tmp;
|
||||||
CHECK_VK(vmaCreateImage(allocator, &(NativeCreateInfo&)image_info, alloc_info, &tmp, &allocation, nullptr));
|
|
||||||
|
CHECK_VK(vmaCreateImage(allocator, &(NativeCreateInfo&)image_info, &alloc_info, &tmp, &allocation, nullptr));
|
||||||
|
|
||||||
return std::pair<vk::raii::Image, VmaAllocation>{vk::raii::Image{device, tmp}, allocation};
|
return std::pair<vk::raii::Image, VmaAllocation>{vk::raii::Image{device, tmp}, allocation};
|
||||||
}
|
}
|
||||||
|
|||||||
+12
-3
@@ -21,6 +21,7 @@
|
|||||||
|
|
||||||
#include "vk_mem_alloc.h"
|
#include "vk_mem_alloc.h"
|
||||||
#include <vulkan/vulkan_raii.hpp>
|
#include <vulkan/vulkan_raii.hpp>
|
||||||
|
#include "application.h"
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
struct basic_allocation_traits
|
struct basic_allocation_traits
|
||||||
@@ -42,7 +43,7 @@ struct basic_allocation_traits<VkBuffer> : basic_allocation_traits_base
|
|||||||
|
|
||||||
static std::pair<RaiiType, VmaAllocation> create(
|
static std::pair<RaiiType, VmaAllocation> create(
|
||||||
const CreateInfo& buffer_info,
|
const CreateInfo& buffer_info,
|
||||||
const VmaAllocationCreateInfo* alloc_info);
|
const VmaAllocationCreateInfo& alloc_info);
|
||||||
|
|
||||||
static void destroy(
|
static void destroy(
|
||||||
RaiiType& buffer,
|
RaiiType& buffer,
|
||||||
@@ -59,7 +60,7 @@ struct basic_allocation_traits<VkImage> : basic_allocation_traits_base
|
|||||||
|
|
||||||
static std::pair<RaiiType, VmaAllocation> create(
|
static std::pair<RaiiType, VmaAllocation> create(
|
||||||
const CreateInfo& image_info,
|
const CreateInfo& image_info,
|
||||||
const VmaAllocationCreateInfo* alloc_info);
|
const VmaAllocationCreateInfo& alloc_info);
|
||||||
|
|
||||||
static void destroy(
|
static void destroy(
|
||||||
RaiiType& image,
|
RaiiType& image,
|
||||||
@@ -118,7 +119,15 @@ public:
|
|||||||
basic_allocation(const CreateInfo& create_info, const VmaAllocationCreateInfo& alloc_info) :
|
basic_allocation(const CreateInfo& create_info, const VmaAllocationCreateInfo& alloc_info) :
|
||||||
create_info(create_info)
|
create_info(create_info)
|
||||||
{
|
{
|
||||||
std::tie(resource, allocation) = traits::create(create_info, &alloc_info);
|
std::tie(resource, allocation) = traits::create(create_info, alloc_info);
|
||||||
|
}
|
||||||
|
|
||||||
|
basic_allocation(const CreateInfo& create_info, VmaAllocationCreateInfo alloc_info, const std::string& name) :
|
||||||
|
create_info(create_info)
|
||||||
|
{
|
||||||
|
std::tie(resource, allocation) = traits::create(create_info, alloc_info);
|
||||||
|
|
||||||
|
vmaSetAllocationName(application::get_allocator(), allocation, name.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
basic_allocation(const basic_allocation&) = delete;
|
basic_allocation(const basic_allocation&) = delete;
|
||||||
|
|||||||
Reference in New Issue
Block a user