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
56
src/renderer/vulkan/vk_render_pass.rs
Normal file
56
src/renderer/vulkan/vk_render_pass.rs
Normal file
|
@ -0,0 +1,56 @@
|
|||
use super::{VkDevice, VkSwapchain};
|
||||
use ash::prelude::VkResult;
|
||||
use ash::vk;
|
||||
use std::sync::Arc;
|
||||
|
||||
pub struct VkRenderPass {
|
||||
device: Arc<VkDevice>,
|
||||
|
||||
pub(super) handle: vk::RenderPass,
|
||||
}
|
||||
|
||||
impl VkRenderPass {
|
||||
pub fn new(device: &Arc<VkDevice>, swapchain: &Arc<VkSwapchain>) -> VkResult<Self> {
|
||||
let color_attachment = vk::AttachmentDescription::default()
|
||||
.format(swapchain.surface_format.format)
|
||||
.samples(vk::SampleCountFlags::TYPE_1)
|
||||
.load_op(vk::AttachmentLoadOp::CLEAR)
|
||||
.store_op(vk::AttachmentStoreOp::STORE)
|
||||
.stencil_load_op(vk::AttachmentLoadOp::DONT_CARE)
|
||||
.stencil_store_op(vk::AttachmentStoreOp::DONT_CARE)
|
||||
.initial_layout(vk::ImageLayout::UNDEFINED)
|
||||
.final_layout(vk::ImageLayout::PRESENT_SRC_KHR);
|
||||
|
||||
let color_attachment_ref = vk::AttachmentReference::default()
|
||||
.attachment(0)
|
||||
.layout(vk::ImageLayout::COLOR_ATTACHMENT_OPTIMAL);
|
||||
|
||||
let color_attachments = [color_attachment_ref];
|
||||
let subpass = vk::SubpassDescription::default()
|
||||
.pipeline_bind_point(vk::PipelineBindPoint::GRAPHICS)
|
||||
.color_attachments(&color_attachments);
|
||||
|
||||
let attachments = [color_attachment];
|
||||
let subpasses = [subpass];
|
||||
let render_pass_info = vk::RenderPassCreateInfo::default()
|
||||
.attachments(&attachments)
|
||||
.subpasses(&subpasses);
|
||||
|
||||
let render_pass = unsafe { device.handle.create_render_pass(&render_pass_info, None)? };
|
||||
log::debug!("Render pass created ({render_pass:?})");
|
||||
|
||||
Ok(Self {
|
||||
device: device.clone(),
|
||||
handle: render_pass,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
impl Drop for VkRenderPass {
|
||||
fn drop(&mut self) {
|
||||
unsafe {
|
||||
self.device.handle.destroy_render_pass(self.handle, None);
|
||||
log::debug!("Render pass destroyed ({:?})", self.handle);
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue