vulkan: Move to renderer module
Some checks failed
Build legacy Nix package on Ubuntu / build (push) Failing after 1s
Some checks failed
Build legacy Nix package on Ubuntu / build (push) Failing after 1s
This commit is contained in:
parent
001547dbc2
commit
a669247406
21 changed files with 61 additions and 63 deletions
44
src/renderer/vulkan/vk_framebuffer.rs
Normal file
44
src/renderer/vulkan/vk_framebuffer.rs
Normal file
|
@ -0,0 +1,44 @@
|
|||
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(super) 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) };
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue