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

◆ create_render_pass()

RenderPassID MayaFlux::Portal::Graphics::RenderFlow::create_render_pass ( const std::vector< RenderPassAttachment > &  attachments)

Create a render pass.

Parameters
attachmentsAttachment descriptions
Returns
Render pass ID

Definition at line 269 of file RenderFlow.cpp.

271{
272 if (!is_initialized()) {
274 "RenderFlow not initialized");
275 return INVALID_RENDER_PASS;
276 }
277
278 if (attachments.empty()) {
280 "Cannot create render pass with no attachments");
281 return INVALID_RENDER_PASS;
282 }
283
284 auto render_pass = std::make_shared<Core::VKRenderPass>();
285
286 Core::RenderPassCreateInfo create_info {};
287
288 for (const auto& att : attachments) {
289 Core::AttachmentDescription desc;
290 desc.format = att.format;
291 desc.samples = att.samples;
292 desc.load_op = att.load_op;
293 desc.store_op = att.store_op;
294 desc.initial_layout = att.initial_layout;
295 desc.final_layout = att.final_layout;
296 create_info.attachments.push_back(desc);
297 }
298
299 Core::SubpassDescription subpass;
300 subpass.bind_point = vk::PipelineBindPoint::eGraphics;
301 for (uint32_t i = 0; i < attachments.size(); ++i) {
302 vk::AttachmentReference ref;
303 ref.attachment = i;
304 ref.layout = vk::ImageLayout::eColorAttachmentOptimal;
305 subpass.color_attachments.push_back(ref);
306 }
307 create_info.subpasses.push_back(subpass);
308
309 // create_info.dependencies.emplace_back(
310 // VK_SUBPASS_EXTERNAL, 0,
311 // vk::PipelineStageFlagBits::eColorAttachmentOutput,
312 // vk::PipelineStageFlagBits::eColorAttachmentOutput,
313 // vk::AccessFlagBits::eColorAttachmentWrite,
314 // vk::AccessFlagBits::eColorAttachmentRead | vk::AccessFlagBits::eColorAttachmentWrite);
315
316 // create_info.dependencies.emplace_back(
317 // 0, VK_SUBPASS_EXTERNAL,
318 // vk::PipelineStageFlagBits::eColorAttachmentOutput,
319 // vk::PipelineStageFlagBits::eBottomOfPipe,
320 // vk::AccessFlagBits::eColorAttachmentWrite,
321 // vk::AccessFlagBits::eMemoryRead);
322
323 if (!render_pass->create(m_shader_foundry->get_device(), create_info)) {
325 "Failed to create VKRenderPass");
326 return INVALID_RENDER_PASS;
327 }
328
329 auto render_pass_id = m_next_render_pass_id.fetch_add(1);
330 RenderPassState state;
331 state.render_pass = render_pass;
332 state.attachments = attachments;
333 m_render_passes[render_pass_id] = std::move(state);
334
336 "Render pass created (ID: {}, {} attachments)",
337 render_pass_id, attachments.size());
338
339 return render_pass_id;
340}
#define MF_ERROR(comp, ctx,...)
#define MF_DEBUG(comp, ctx,...)
std::unordered_map< RenderPassID, RenderPassState > m_render_passes
std::atomic< uint64_t > m_next_render_pass_id
@ Rendering
GPU rendering operations (graphics pipeline, frame rendering)
@ Portal
High-level user-facing API layer.
constexpr RenderPassID INVALID_RENDER_PASS

References MayaFlux::Portal::Graphics::RenderFlow::RenderPassState::attachments, MayaFlux::Core::SubpassDescription::bind_point, MayaFlux::Core::SubpassDescription::color_attachments, MayaFlux::Core::AttachmentDescription::final_layout, MayaFlux::Core::AttachmentDescription::format, MayaFlux::Portal::Graphics::ShaderFoundry::get_device(), MayaFlux::Core::AttachmentDescription::initial_layout, MayaFlux::Portal::Graphics::INVALID_RENDER_PASS, is_initialized(), MayaFlux::Core::AttachmentDescription::load_op, m_next_render_pass_id, m_render_passes, m_shader_foundry, MF_DEBUG, MF_ERROR, MayaFlux::Journal::Portal, MayaFlux::Portal::Graphics::RenderFlow::RenderPassState::render_pass, MayaFlux::Journal::Rendering, MayaFlux::Core::AttachmentDescription::samples, and MayaFlux::Core::AttachmentDescription::store_op.

Referenced by create_simple_render_pass().

+ Here is the call graph for this function:
+ Here is the caller graph for this function: