Update [broken]
Some checks failed
Build legacy Nix package on Ubuntu / build (push) Failing after 0s

This commit is contained in:
Florian RICHER 2024-11-20 17:45:26 +01:00
parent 8f1172e888
commit 1dc9da0d61
8 changed files with 222 additions and 31 deletions

View file

@ -0,0 +1,52 @@
use crate::vulkan::vk_render_pass::VkRenderPass;
use crate::vulkan::{VkDevice, VkSwapchain};
use ash::prelude::VkResult;
use ash::vk;
use std::sync::Arc;
pub struct VkSwapchainFramebuffer {
device: Arc<VkDevice>,
swapchain: Arc<VkSwapchain>,
render_pass: Arc<VkRenderPass>,
image_view_index: usize,
pub(super) handle: vk::Framebuffer,
}
impl VkSwapchainFramebuffer {
pub fn new(
device: Arc<VkDevice>,
swapchain: Arc<VkSwapchain>,
render_pass: Arc<VkRenderPass>,
image_view_index: usize,
) -> VkResult<Self> {
let present_image_view = swapchain
.present_image_views
.as_ref()
.unwrap()[image_view_index];
let attachments = [present_image_view];
let framebuffer_info = vk::FramebufferCreateInfo::default()
.render_pass(render_pass.handle)
.width(swapchain.surface_resolution.width)
.height(swapchain.surface_resolution.height)
.attachments(&attachments)
.layers(1);
let framebuffer = unsafe { device.handle.create_framebuffer(&framebuffer_info, None)? };
Ok(Self {
device,
swapchain,
render_pass,
image_view_index,
handle: framebuffer,
})
}
}
impl Drop for VkSwapchainFramebuffer {
fn drop(&mut self) {
unsafe { self.device.handle.destroy_framebuffer(self.handle, None) };
}
}