Add allocate image views
This commit is contained in:
@@ -327,6 +327,30 @@ void RenderEngine::create_swapchain(VkPresentModeKHR desired_present_mode)
|
||||
swapchain_extent_ = extent;
|
||||
}
|
||||
|
||||
void RenderEngine::create_image_views()
|
||||
{
|
||||
VkImageViewCreateInfo image_view_info{};
|
||||
image_view_info.sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO;
|
||||
image_view_info.viewType = VK_IMAGE_VIEW_TYPE_2D;
|
||||
image_view_info.format = swapchain_image_format_;
|
||||
image_view_info.components.r = VK_COMPONENT_SWIZZLE_IDENTITY;
|
||||
image_view_info.components.g = VK_COMPONENT_SWIZZLE_IDENTITY;
|
||||
image_view_info.components.b = VK_COMPONENT_SWIZZLE_IDENTITY;
|
||||
image_view_info.components.a = VK_COMPONENT_SWIZZLE_IDENTITY;
|
||||
image_view_info.subresourceRange.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT;
|
||||
image_view_info.subresourceRange.baseMipLevel = 0;
|
||||
image_view_info.subresourceRange.levelCount = 1;
|
||||
image_view_info.subresourceRange.baseArrayLayer = 0;
|
||||
image_view_info.subresourceRange.layerCount = 1;
|
||||
|
||||
swapchain_image_views_.resize(swapchain_images_.size());
|
||||
for (uint32_t i = 0; i < swapchain_images_.size(); ++i)
|
||||
{
|
||||
image_view_info.image = swapchain_images_[i];
|
||||
VK_CHECK(vkCreateImageView(device_, &image_view_info, nullptr, &swapchain_image_views_[i]));
|
||||
}
|
||||
}
|
||||
|
||||
void RenderEngine::create_surface()
|
||||
{
|
||||
VK_CHECK(glfwCreateWindowSurface(instance_, window_, nullptr, &surface_));
|
||||
@@ -344,10 +368,15 @@ window_(window)
|
||||
pick_physical_device();
|
||||
create_logical_device();
|
||||
create_swapchain(desired_present_mode);
|
||||
create_image_views();
|
||||
}
|
||||
|
||||
RenderEngine::~RenderEngine()
|
||||
{
|
||||
for (auto image_view : swapchain_image_views_)
|
||||
vkDestroyImageView(device_, image_view, nullptr);
|
||||
swapchain_image_views_.clear();
|
||||
|
||||
if (swapchain_ != VK_NULL_HANDLE)
|
||||
vkDestroySwapchainKHR(device_, swapchain_, nullptr);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user