MayaFlux 0.1.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches

◆ create() [2/2]

bool MayaFlux::Core::VKRenderPass::create ( vk::Device  device,
vk::Format  color_format 
)

Create a simple render pass with a single color attachment.

Parameters
deviceThe Vulkan device to create the render pass on.
color_formatThe format of the color attachment.
Returns
True if the render pass was created successfully, false otherwise.

Definition at line 7 of file VKRenderPass.cpp.

8{
9 vk::AttachmentDescription color_attachment {};
10 color_attachment.format = color_format;
11 color_attachment.samples = vk::SampleCountFlagBits::e1;
12 color_attachment.loadOp = vk::AttachmentLoadOp::eClear;
13 color_attachment.storeOp = vk::AttachmentStoreOp::eStore;
14 color_attachment.stencilLoadOp = vk::AttachmentLoadOp::eDontCare;
15 color_attachment.stencilStoreOp = vk::AttachmentStoreOp::eDontCare;
16 color_attachment.initialLayout = vk::ImageLayout::eUndefined;
17 color_attachment.finalLayout = vk::ImageLayout::ePresentSrcKHR;
18
19 vk::AttachmentReference color_attachment_ref {};
20 color_attachment_ref.attachment = 0;
21 color_attachment_ref.layout = vk::ImageLayout::eColorAttachmentOptimal;
22
23 vk::SubpassDescription subpass {};
24 subpass.pipelineBindPoint = vk::PipelineBindPoint::eGraphics;
25 subpass.colorAttachmentCount = 1;
26 subpass.pColorAttachments = &color_attachment_ref;
27
28 vk::RenderPassCreateInfo render_pass_info {};
29 render_pass_info.attachmentCount = 1;
30 render_pass_info.pAttachments = &color_attachment;
31 render_pass_info.subpassCount = 1;
32 render_pass_info.pSubpasses = &subpass;
33
34 try {
35 m_render_pass = device.createRenderPass(render_pass_info);
36 return true;
37 } catch (const vk::SystemError& e) {
38 MF_ERROR(Journal::Component::Core, Journal::Context::GraphicsBackend, "Failed to create render pass: {}", e.what());
39 return false;
40 }
41}
#define MF_ERROR(comp, ctx,...)
@ GraphicsBackend
Graphics/visual rendering backend (Vulkan, OpenGL)
@ Core
Core engine, backend, subsystems.

References MayaFlux::Journal::Core, MayaFlux::Journal::GraphicsBackend, m_render_pass, and MF_ERROR.