Some checks failed
Build legacy Nix package on Ubuntu / build (push) Failing after 1s
44 lines
1.2 KiB
Rust
44 lines
1.2 KiB
Rust
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 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) };
|
|
}
|
|
}
|