librashader/librashader-runtime-vk/tests/hello_triangle/framebuffer.rs

30 lines
773 B
Rust
Raw Normal View History

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];
2024-08-01 15:23:18 +10:00
let framebuffer_info = vk::FramebufferCreateInfo::default()
2023-01-10 11:17:13 +11:00
.render_pass(*render_pass)
.attachments(attachments)
.width(width)
.height(height)
.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
}