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.
62 lines
1012 B
62 lines
1012 B
// Copyright 2022 Simon Boyé
|
|
|
|
#include <vk/ImageView.h>
|
|
#include <vk/Context.h>
|
|
|
|
#include <cassert>
|
|
|
|
|
|
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;
|
|
}
|
|
|
|
|
|
}
|
|
|