2023-01-10 11:17:13 +11:00
|
|
|
use ash::prelude::VkResult;
|
|
|
|
use ash::vk;
|
|
|
|
|
|
|
|
pub struct VulkanFramebuffer {
|
|
|
|
pub framebuffer: vk::Framebuffer,
|
|
|
|
}
|
|
|
|
|
|
|
|
impl VulkanFramebuffer {
|
2023-01-10 14:54:54 +11:00
|
|
|
pub fn new(
|
|
|
|
device: &ash::Device,
|
|
|
|
image_view: &vk::ImageView,
|
|
|
|
render_pass: &vk::RenderPass,
|
|
|
|
width: u32,
|
|
|
|
height: u32,
|
|
|
|
) -> VkResult<VulkanFramebuffer> {
|
2023-01-10 11:17:13 +11:00
|
|
|
let attachments = &[*image_view];
|
|
|
|
let framebuffer_info = vk::FramebufferCreateInfo::builder()
|
|
|
|
.render_pass(*render_pass)
|
|
|
|
.attachments(attachments)
|
|
|
|
.width(width)
|
|
|
|
.height(height)
|
2023-02-17 09:33:47 +11:00
|
|
|
.layers(1);
|
2023-01-10 11:17:13 +11:00
|
|
|
|
|
|
|
unsafe {
|
|
|
|
let framebuffer = device.create_framebuffer(&framebuffer_info, None)?;
|
2023-01-10 14:54:54 +11:00
|
|
|
Ok(VulkanFramebuffer { framebuffer })
|
2023-01-10 11:17:13 +11:00
|
|
|
}
|
|
|
|
}
|
2023-01-10 14:54:54 +11:00
|
|
|
}
|