Update [broken]
Some checks failed
Build legacy Nix package on Ubuntu / build (push) Failing after 0s
Some checks failed
Build legacy Nix package on Ubuntu / build (push) Failing after 0s
This commit is contained in:
parent
8f1172e888
commit
1dc9da0d61
8 changed files with 222 additions and 31 deletions
52
src/vulkan/vk_framebuffer.rs
Normal file
52
src/vulkan/vk_framebuffer.rs
Normal file
|
@ -0,0 +1,52 @@
|
|||
use crate::vulkan::vk_render_pass::VkRenderPass;
|
||||
use crate::vulkan::{VkDevice, VkSwapchain};
|
||||
use ash::prelude::VkResult;
|
||||
use ash::vk;
|
||||
use std::sync::Arc;
|
||||
|
||||
pub struct VkSwapchainFramebuffer {
|
||||
device: Arc<VkDevice>,
|
||||
swapchain: Arc<VkSwapchain>,
|
||||
render_pass: Arc<VkRenderPass>,
|
||||
image_view_index: usize,
|
||||
|
||||
pub(super) handle: vk::Framebuffer,
|
||||
}
|
||||
|
||||
impl VkSwapchainFramebuffer {
|
||||
pub fn new(
|
||||
device: Arc<VkDevice>,
|
||||
swapchain: Arc<VkSwapchain>,
|
||||
render_pass: Arc<VkRenderPass>,
|
||||
image_view_index: usize,
|
||||
) -> VkResult<Self> {
|
||||
let present_image_view = swapchain
|
||||
.present_image_views
|
||||
.as_ref()
|
||||
.unwrap()[image_view_index];
|
||||
let attachments = [present_image_view];
|
||||
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,
|
||||
swapchain,
|
||||
render_pass,
|
||||
image_view_index,
|
||||
|
||||
handle: framebuffer,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
impl Drop for VkSwapchainFramebuffer {
|
||||
fn drop(&mut self) {
|
||||
unsafe { self.device.handle.destroy_framebuffer(self.handle, None) };
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue