Experimentation using Vulkan.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

74 lines
1.4 KiB

// Copyright 2022 Simon Boyé
#include <vk/DescriptorPool.h>
#include <vk/Context.h>
#include <cassert>
namespace vk {
DescriptorPool::DescriptorPool() noexcept {
}
DescriptorPool::DescriptorPool(
Context& context,
uint32_t max_sets,
Array<const VkDescriptorPoolSize> pool_sizes,
VkDescriptorPoolCreateFlags flags
)
: Wrapper(context)
{
assert(m_context);
VkDescriptorPoolCreateInfo create_info {
.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO,
.flags = flags,
.maxSets = max_sets,
.poolSizeCount = uint32_t(pool_sizes.size()),
.pPoolSizes = pool_sizes.data(),
};
if(vkCreateDescriptorPool(
context.device(),
&create_info,
nullptr,
&m_descriptor_pool
) != VK_SUCCESS)
throw std::runtime_error("failed to create descriptor pool");
}
DescriptorPool::DescriptorPool(DescriptorPool&& other) noexcept
{
swap(other);
}
DescriptorPool::~DescriptorPool() noexcept {
if(!is_null())
destroy();
}
DescriptorPool& DescriptorPool::operator=(DescriptorPool&& other) noexcept {
swap(other);
if(other)
other.destroy();
return *this;
}
void DescriptorPool::destroy() noexcept {
assert(!is_null());
assert(m_context);
vkDestroyDescriptorPool(
m_context->device(),
m_descriptor_pool,
nullptr
);
m_descriptor_pool = nullptr;
}
}