use anyhow::Result; use vulkanalia::prelude::v1_0::*; use crate::{app::AppData, image_view::create_image_view, texture_image::create_image}; pub(crate) unsafe fn get_max_msaa_samples( instance: &Instance, data: &AppData, ) -> vk::SampleCountFlags { let properties = instance.get_physical_device_properties(data.physical_device); let counts = properties.limits.framebuffer_color_sample_counts & properties.limits.framebuffer_depth_sample_counts; [ vk::SampleCountFlags::_64, vk::SampleCountFlags::_32, vk::SampleCountFlags::_16, vk::SampleCountFlags::_8, vk::SampleCountFlags::_4, vk::SampleCountFlags::_2, ] .iter() .cloned() .find(|c| counts.contains(*c)) .unwrap_or(vk::SampleCountFlags::_1) } pub(crate) unsafe fn create_color_objects( instance: &Instance, device: &Device, data: &mut AppData, ) -> Result<()> { let (color_image, color_image_memory) = create_image( instance, device, data, data.swapchain_extent.width, data.swapchain_extent.height, 1, data.msaa_samples, data.swapchain_format, vk::ImageTiling::OPTIMAL, vk::ImageUsageFlags::COLOR_ATTACHMENT | vk::ImageUsageFlags::TRANSIENT_ATTACHMENT, vk::MemoryPropertyFlags::DEVICE_LOCAL, )?; data.color_image = color_image; data.color_image_memory = color_image_memory; let aspects = vk::ImageAspectFlags::COLOR; let mip_levels = 1; data.color_image_view = create_image_view( device, &data.color_image, &data.swapchain_format, &aspects, &mip_levels, )?; Ok(()) }