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

27 lines
829 B
Rust
Raw Normal View History

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