Move create_image_view to vkSwapchain->create_present_image_view
Some checks failed
Build legacy Nix package on Ubuntu / build (push) Failing after 0s

This commit is contained in:
Florian RICHER 2024-11-17 16:18:35 +01:00
parent 891835c4af
commit 002d6fa9a4
Signed by: florian.richer
GPG key ID: C73D37CBED7BFC77
2 changed files with 27 additions and 28 deletions

View file

@ -69,32 +69,6 @@ impl VkDevice {
self.queues.get(queue_index as usize)
}
pub(super) fn create_image_view(
&self,
image: vk::Image,
surface_format: vk::SurfaceFormatKHR,
) -> VkResult<vk::ImageView> {
let create_view_info = vk::ImageViewCreateInfo::default()
.view_type(vk::ImageViewType::TYPE_2D)
.format(surface_format.format)
.components(vk::ComponentMapping {
r: vk::ComponentSwizzle::R,
g: vk::ComponentSwizzle::G,
b: vk::ComponentSwizzle::B,
a: vk::ComponentSwizzle::A,
})
.subresource_range(vk::ImageSubresourceRange {
aspect_mask: vk::ImageAspectFlags::COLOR,
base_mip_level: 0,
level_count: 1,
base_array_layer: 0,
layer_count: 1,
})
.image(image);
unsafe { self.handle.create_image_view(&create_view_info, None) }
}
pub(super) fn create_command_pool(
&self,
info: &vk::CommandPoolCreateInfo,

View file

@ -96,8 +96,7 @@ impl VkSwapchain {
let present_images_view = present_images
.iter()
.map(|i| {
self.device
.create_image_view(*i, self.surface_format)
self.create_present_image_view(*i)
.expect("Failed to create image view")
})
.collect::<Vec<_>>();
@ -210,6 +209,32 @@ impl VkSwapchain {
.find(|&mode| mode == vk::PresentModeKHR::MAILBOX)
.unwrap_or(vk::PresentModeKHR::FIFO)
}
fn create_present_image_view(&self, image: vk::Image) -> VkResult<vk::ImageView> {
let create_view_info = vk::ImageViewCreateInfo::default()
.view_type(vk::ImageViewType::TYPE_2D)
.format(self.surface_format.format)
.components(vk::ComponentMapping {
r: vk::ComponentSwizzle::R,
g: vk::ComponentSwizzle::G,
b: vk::ComponentSwizzle::B,
a: vk::ComponentSwizzle::A,
})
.subresource_range(vk::ImageSubresourceRange {
aspect_mask: vk::ImageAspectFlags::COLOR,
base_mip_level: 0,
level_count: 1,
base_array_layer: 0,
layer_count: 1,
})
.image(image);
unsafe {
self.device
.handle
.create_image_view(&create_view_info, None)
}
}
}
impl Drop for VkSwapchain {