Fix errors
Some checks failed
Build legacy Nix package on Ubuntu / build (push) Failing after 0s

This commit is contained in:
Florian RICHER 2024-11-20 20:08:31 +01:00
parent 1dc9da0d61
commit 2590db0a06
Signed by: florian.richer
GPG key ID: C73D37CBED7BFC77
8 changed files with 123 additions and 88 deletions

View file

@ -1,9 +1,8 @@
use crate::display::Window;
use crate::vulkan::vk_framebuffer::VkSwapchainFramebuffer;
use crate::vulkan::vk_render_pass::VkRenderPass;
use crate::vulkan::vk_semaphore::VkSemaphore;
use crate::vulkan::vk_surface::SwapchainSupportDetails;
use crate::vulkan::{VkDevice, VkPhysicalDevice, VkSurface};
use crate::vulkan::{VkDevice, VkFramebuffer, VkPhysicalDevice, VkSurface};
use ash::prelude::VkResult;
use ash::vk;
use std::sync::Arc;
@ -22,14 +21,14 @@ pub struct VkSwapchain {
pub(super) pre_transform: vk::SurfaceTransformFlagsKHR,
pub(super) present_images: Option<Vec<vk::Image>>,
pub(super) present_image_views: Option<Vec<vk::ImageView>>,
pub(super) present_image_views: Option<Vec<Arc<vk::ImageView>>>,
}
impl VkSwapchain {
pub(super) fn new(
window: &Window,
surface: Arc<VkSurface>,
device: Arc<VkDevice>,
surface: &Arc<VkSurface>,
device: &Arc<VkDevice>,
physical_device: &VkPhysicalDevice,
) -> anyhow::Result<Self> {
log::debug!("Creating swapchain");
@ -61,8 +60,8 @@ impl VkSwapchain {
let present_mode = Self::choose_present_mode(present_modes);
let mut swapchain = Self {
surface,
device,
surface: surface.clone(),
device: device.clone(),
swapchain: None,
swapchain_support_details,
@ -104,6 +103,7 @@ impl VkSwapchain {
self.create_present_image_view(*i)
.expect("Failed to create image view")
})
.map(|i| Arc::new(i))
.collect::<Vec<_>>();
if log::log_enabled!(log::Level::Debug) {
@ -121,14 +121,27 @@ impl VkSwapchain {
Ok(())
}
pub(super) fn create_framebuffers(&self, render_pass: Arc<VkRenderPass>) -> Option<Vec<VkSwapchainFramebuffer>> {
pub(super) fn create_framebuffers(
&self,
render_pass: &Arc<VkRenderPass>,
) -> Option<Vec<Arc<VkFramebuffer>>> {
let present_image_views = self.present_image_views.as_ref()?;
present_image_views.iter().enumerate()
.map(|present_image_view| {
VkSwapchainFramebuffer::new()
})
.collect::<Vec<_>>()
Some(
present_image_views
.iter()
.map(|image_view| {
VkFramebuffer::from_swapchain_image_view(
&self.device,
&render_pass,
&image_view,
&self,
)
.unwrap()
})
.map(|framebuffer| Arc::new(framebuffer))
.collect::<Vec<_>>(),
)
}
pub(super) fn update_resolution(&mut self, width: u32, height: u32) -> VkResult<()> {