// Copyright 2022 Simon Boyé #include #include #include namespace vk { DescriptorPool::DescriptorPool() noexcept { } DescriptorPool::DescriptorPool( Context& context, uint32_t max_sets, Array 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; } }