MayaFlux 0.2.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches
MayaFlux::Portal::Graphics::RenderFlow Class Reference

Graphics pipeline orchestration for dynamic rendering. More...

#include <RenderFlow.hpp>

+ Collaboration diagram for MayaFlux::Portal::Graphics::RenderFlow:

Classes

struct  PipelineState
 
struct  WindowRenderAssociation
 

Public Member Functions

 RenderFlow (const RenderFlow &)=delete
 
RenderFlowoperator= (const RenderFlow &)=delete
 
 RenderFlow (RenderFlow &&) noexcept=delete
 
RenderFlowoperator= (RenderFlow &&) noexcept=delete
 
bool initialize ()
 
void stop ()
 
void shutdown ()
 
bool is_initialized () const
 
RenderPipelineID create_pipeline (const RenderPipelineConfig &config, const std::vector< vk::Format > &color_formats, vk::Format depth_format=vk::Format::eUndefined)
 Create graphics pipeline for dynamic rendering (no render pass object)
 
void destroy_pipeline (RenderPipelineID pipeline_id)
 Destroy a graphics pipeline.
 
void begin_rendering (CommandBufferID cmd_id, const std::shared_ptr< Core::Window > &window, vk::Image swapchain_image, const std::array< float, 4 > &clear_color={ 0.0F, 0.0F, 0.0F, 1.0F })
 Begin dynamic rendering to a window.
 
void end_rendering (CommandBufferID cmd_id, const std::shared_ptr< Core::Window > &window)
 End dynamic rendering.
 
void bind_pipeline (CommandBufferID cmd_id, RenderPipelineID pipeline)
 Bind graphics pipeline.
 
void bind_vertex_buffers (CommandBufferID cmd_id, const std::vector< std::shared_ptr< Buffers::VKBuffer > > &buffers, uint32_t first_binding=0)
 Bind vertex buffers.
 
void bind_index_buffer (CommandBufferID cmd_id, const std::shared_ptr< Buffers::VKBuffer > &buffer, vk::IndexType index_type=vk::IndexType::eUint32)
 Bind index buffer.
 
void bind_descriptor_sets (CommandBufferID cmd_id, RenderPipelineID pipeline, const std::vector< DescriptorSetID > &descriptor_sets)
 Bind descriptor sets.
 
void push_constants (CommandBufferID cmd_id, RenderPipelineID pipeline, const void *data, size_t size)
 Push constants.
 
void draw (CommandBufferID cmd_id, uint32_t vertex_count, uint32_t instance_count=1, uint32_t first_vertex=0, uint32_t first_instance=0)
 Draw command.
 
void draw_indexed (CommandBufferID cmd_id, uint32_t index_count, uint32_t instance_count=1, uint32_t first_index=0, int32_t vertex_offset=0, uint32_t first_instance=0)
 Indexed draw command.
 
void register_window_for_rendering (const std::shared_ptr< Core::Window > &window)
 Register a window for dynamic rendering.
 
void unregister_window (const std::shared_ptr< Core::Window > &window)
 Unregister a window from rendering.
 
bool is_window_registered (const std::shared_ptr< Core::Window > &window) const
 Check if a window is registered for rendering.
 
std::vector< std::shared_ptr< Core::Window > > get_registered_windows () const
 Get all registered windows.
 
std::vector< DescriptorSetIDallocate_pipeline_descriptors (RenderPipelineID pipeline)
 Allocate descriptor sets for pipeline.
 

Static Public Member Functions

static RenderFlowinstance ()
 

Private Member Functions

 RenderFlow ()=default
 
 ~RenderFlow ()
 
void cleanup_pipelines ()
 
vk::ImageView get_current_image_view (const std::shared_ptr< Core::Window > &window)
 Get current image view for window.
 

Private Attributes

std::unordered_map< RenderPipelineID, PipelineStatem_pipelines
 
std::unordered_map< std::shared_ptr< Core::Window >, WindowRenderAssociationm_window_associations
 
std::atomic< uint64_t > m_next_pipeline_id { 1 }
 
ShaderFoundrym_shader_foundry = nullptr
 
Registry::Service::DisplayServicem_display_service = nullptr
 

Static Private Attributes

static bool s_initialized = false
 

Detailed Description

Graphics pipeline orchestration for dynamic rendering.

RenderFlow is the rendering counterpart to ComputePress. It manages graphics pipelines and draw command recording using Vulkan 1.3 dynamic rendering.

Responsibilities:

  • Create graphics pipelines for dynamic rendering
  • Record render commands to secondary command buffers
  • Manage dynamic rendering state (begin/end rendering)
  • Coordinate with ShaderFoundry for resources

Design Philosophy (parallel to ComputePress):

  • Uses ShaderFoundry for low-level resources
  • Provides high-level rendering API
  • Backend-agnostic interface
  • Integrates with RootGraphicsBuffer
  • No render pass objects - uses vkCmdBeginRendering/vkCmdEndRendering

Usage Pattern:

// Create pipeline for dynamic rendering
config.vertex_shader = vertex_id;
config.fragment_shader = fragment_id;
config.semantic_vertex_layout = buffer->get_vertex_layout();
auto pipeline_id = flow.create_pipeline(config, { swapchain_format });
// In RenderProcessor - record secondary command buffer:
auto cmd_id = foundry.begin_secondary_commands(swapchain_format);
flow.bind_pipeline(cmd_id, pipeline_id);
flow.bind_vertex_buffers(cmd_id, {buffer});
flow.draw(cmd_id, vertex_count);
foundry.end_commands(cmd_id);
// In PresentProcessor - execute secondaries in primary:
auto primary_id = foundry.begin_commands(CommandBufferType::GRAPHICS);
flow.begin_rendering(primary_id, window, swapchain_image);
primary_cmd.executeCommands(secondary_buffers);
flow.end_rendering(primary_id, window);
display_service->submit_and_present(window, primary_cmd);
MAYAFLUX_API RenderFlow & get_render_flow()
Get the global render flow instance.
MAYAFLUX_API ShaderFoundry & get_shader_foundry()
Get the global shader compiler instance.
std::optional< Kakshya::VertexLayout > semantic_vertex_layout
Complete render pipeline configuration.

Definition at line 68 of file RenderFlow.hpp.


The documentation for this class was generated from the following files: