vulkan: Move to renderer module
Some checks failed
Build legacy Nix package on Ubuntu / build (push) Failing after 1s

This commit is contained in:
Florian RICHER 2024-11-27 20:59:39 +01:00
parent 001547dbc2
commit a669247406
Signed by: florian.richer
GPG key ID: C73D37CBED7BFC77
21 changed files with 61 additions and 63 deletions

View file

@ -0,0 +1,44 @@
use super::{VkDevice, VkRenderPass, VkSwapchain};
use ash::vk;
use std::sync::Arc;
pub struct VkFramebuffer {
device: Arc<VkDevice>,
image_view: Arc<vk::ImageView>,
render_pass: Arc<VkRenderPass>,
pub(super) handle: vk::Framebuffer,
}
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)
.height(swapchain.surface_resolution.height)
.attachments(&attachments)
.layers(1);
let framebuffer = unsafe { device.handle.create_framebuffer(&framebuffer_info, None)? };
Ok(Self {
device: device.clone(),
render_pass: render_pass.clone(),
image_view: image_view.clone(),
handle: framebuffer,
})
}
}
impl Drop for VkFramebuffer {
fn drop(&mut self) {
unsafe { self.device.handle.destroy_framebuffer(self.handle, None) };
}
}