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

Graphics pipeline and render pass orchestration. More...

#include <RenderFlow.hpp>

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

Classes

struct  PipelineState
 
struct  RenderPassState
 
struct  WindowRenderAssociation
 

Public Member Functions

 RenderFlow (const RenderFlow &)=delete
 
RenderFlowoperator= (const RenderFlow &)=delete
 
 RenderFlow (RenderFlow &&) noexcept=delete
 
RenderFlowoperator= (RenderFlow &&) noexcept=delete
 
bool initialize ()
 
void shutdown ()
 
bool is_initialized () const
 
RenderPassID create_render_pass (const std::vector< RenderPassAttachment > &attachments)
 Create a render pass.
 
RenderPassID create_simple_render_pass (vk::Format format=vk::Format::eB8G8R8A8Unorm, bool load_clear=true)
 Create a simple single-color render pass.
 
void destroy_render_pass (RenderPassID render_pass_id)
 
RenderPipelineID create_pipeline (const RenderPipelineConfig &config)
 Create graphics pipeline with full configuration.
 
RenderPipelineID create_simple_pipeline (ShaderID vertex_shader, ShaderID fragment_shader, RenderPassID render_pass)
 Create simple graphics pipeline (auto-configure most settings)
 
void destroy_pipeline (RenderPipelineID pipeline_id)
 
void begin_render_pass (CommandBufferID cmd_id, const std::shared_ptr< Core::Window > &window, const std::array< float, 4 > &clear_color={ 0.0F, 0.0F, 0.0F, 1.0F })
 Begin render pass.
 
void end_render_pass (CommandBufferID cmd_id)
 End current render pass.
 
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 present_rendered_image (CommandBufferID cmd_id, const std::shared_ptr< Core::Window > &window)
 Present rendered image to window.
 
void register_window_for_rendering (const std::shared_ptr< Core::Window > &window, RenderPassID render_pass_id)
 Associate a window with a render pass for 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 ()
 

Private Attributes

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

Static Private Attributes

static bool s_initialized = false
 

Detailed Description

Graphics pipeline and render pass orchestration.

RenderFlow is the rendering counterpart to ComputePress. It manages graphics pipelines, render passes, and draw command recording.

Responsibilities:

  • Create graphics pipelines
  • Create render passes
  • Record render commands
  • Manage rendering state
  • 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

Usage Pattern:

// Create pipeline
config.vertex_shader = vertex_id;
config.fragment_shader = fragment_id;
config.vertex_bindings = {{0, sizeof(Vertex)}};
config.vertex_attributes = {{0, 0, vk::Format::eR32G32B32Sfloat, 0}};
auto pipeline_id = flow.create_pipeline(config);
// In RenderProcessor callback:
auto cmd_id = foundry.begin_commands(CommandBufferType::GRAPHICS);
flow.begin_render_pass(cmd_id, render_pass_id, framebuffer_id);
flow.bind_pipeline(cmd_id, pipeline_id);
flow.bind_vertex_buffers(cmd_id, {vertex_buffer});
flow.draw(cmd_id, vertex_count);
flow.end_render_pass(cmd_id);
foundry.submit_and_present(cmd_id);
MAYAFLUX_API RenderFlow & get_render_flow()
Get the global render flow instance.
std::vector< Core::VertexAttribute > vertex_attributes
std::vector< Core::VertexBinding > vertex_bindings
Complete render pipeline configuration.

Definition at line 195 of file RenderFlow.hpp.


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