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,30 +1,24 @@
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 {
pub struct VkFramebuffer {
device: Arc<VkDevice>,
swapchain: Arc<VkSwapchain>,
image_view: Arc<vk::ImageView>,
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];
impl VkFramebuffer {
pub fn from_swapchain_image_view(
device: &Arc<VkDevice>,
render_pass: &Arc<VkRenderPass>,
image_view: &Arc<vk::ImageView>,
swapchain: &VkSwapchain,
) -> anyhow::Result<Self> {
let attachments = [*image_view.as_ref()];
let framebuffer_info = vk::FramebufferCreateInfo::default()
.render_pass(render_pass.handle)
.width(swapchain.surface_resolution.width)
@ -35,18 +29,17 @@ impl VkSwapchainFramebuffer {
let framebuffer = unsafe { device.handle.create_framebuffer(&framebuffer_info, None)? };
Ok(Self {
device,
swapchain,
render_pass,
image_view_index,
device: device.clone(),
render_pass: render_pass.clone(),
image_view: image_view.clone(),
handle: framebuffer,
})
}
}
impl Drop for VkSwapchainFramebuffer {
impl Drop for VkFramebuffer {
fn drop(&mut self) {
unsafe { self.device.handle.destroy_framebuffer(self.handle, None) };
}
}
}