/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* vk_imageview.cpp :+: :+: :+: */ /* +:+ +:+ +:+ */ /* By: maldavid +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2022/10/06 18:20:49 by maldavid #+# #+# */ /* Updated: 2022/10/06 18:21:51 by maldavid ### ########.fr */ /* */ /* ************************************************************************** */ #include "vk_swapchain.h" #include "vk_imageview.h" #include namespace mlx { void ImageView::init(SwapChain* swapchain, VkImage& image) { VkImageViewCreateInfo createInfo{}; createInfo.sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO; createInfo.image = image; createInfo.viewType = VK_IMAGE_VIEW_TYPE_2D; createInfo.format = swapchain->_swapChainImageFormat; createInfo.components.r = VK_COMPONENT_SWIZZLE_IDENTITY; createInfo.components.g = VK_COMPONENT_SWIZZLE_IDENTITY; createInfo.components.b = VK_COMPONENT_SWIZZLE_IDENTITY; createInfo.components.a = VK_COMPONENT_SWIZZLE_IDENTITY; createInfo.subresourceRange.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; createInfo.subresourceRange.baseMipLevel = 0; createInfo.subresourceRange.levelCount = 1; createInfo.subresourceRange.baseArrayLayer = 0; createInfo.subresourceRange.layerCount = 1; if(vkCreateImageView(Render_Core::get().getDevice().get(), &createInfo, nullptr, &_image) != VK_SUCCESS) core::error::report(e_kind::fatal_error, "Vulkan : failed to create an image view"); } void ImageView::destroy() noexcept { vkDestroyImageView(Render_Core::get().getDevice().get(), _image, nullptr); } }