// Copyright 2022 Simon Boyé #include #include #include namespace vk { ImageView::ImageView() noexcept { } ImageView::ImageView(Context& context, const VkImageViewCreateInfo& create_info) : m_context(&context) { assert(m_context); if(vkCreateImageView( context.device(), &create_info, nullptr, &m_image_view ) != VK_SUCCESS) throw std::runtime_error("failed to create image view"); } ImageView::ImageView(ImageView&& other) noexcept { swap(*this, other); } ImageView::~ImageView() noexcept { if(!is_null()) destroy(); } ImageView& ImageView::operator=(ImageView&& other) noexcept { swap(*this, other); if(other) other.destroy(); return *this; } void ImageView::destroy() noexcept { assert(!is_null()); assert(m_context); vkDestroyImageView( m_context->device(), m_image_view, nullptr ); m_image_view = nullptr; } }