MayaFlux 0.1.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches
MayaFlux::Buffers::RootGraphicsBuffer Class Reference

Root container for GPU buffer lifecycle management and batch processing. More...

#include <RootGraphicsBuffer.hpp>

+ Inheritance diagram for MayaFlux::Buffers::RootGraphicsBuffer:
+ Collaboration diagram for MayaFlux::Buffers::RootGraphicsBuffer:

Classes

struct  RenderableBufferInfo
 Information about a buffer that's ready to render. More...
 

Public Member Functions

 RootGraphicsBuffer ()
 Creates a new root graphics buffer.
 
 ~RootGraphicsBuffer () override
 Virtual destructor ensuring proper cleanup.
 
void initialize ()
 Initializes the root buffer with default processor.
 
void process_default () override
 Processes this root buffer using default processing.
 
const std::vector< std::shared_ptr< VKBuffer > > & get_child_buffers () const
 Gets all child buffers managed by this root.
 
void set_final_processor (std::shared_ptr< BufferProcessor > processor)
 Sets an optional final processor.
 
std::shared_ptr< BufferProcessorget_final_processor () const
 Gets the current final processor.
 
std::vector< std::shared_ptr< VKBuffer > > get_buffers_by_usage (VKBuffer::Usage usage) const
 Gets buffers filtered by usage type.
 
void cleanup_marked_buffers ()
 Removes buffers marked for deletion.
 
size_t get_buffer_count () const
 Gets the number of child buffers.
 
bool has_buffer (const std::shared_ptr< VKBuffer > &buffer) const
 Checks if a specific buffer is registered.
 
void set_token_active (bool active) override
 Activates/deactivates processing for the current token.
 
bool is_token_active () const override
 Checks if the buffer is active for its assigned token.
 
const std::vector< RenderableBufferInfo > & get_renderable_buffers () const
 Get list of buffers ready for rendering.
 
void clear_renderable_buffers ()
 Clear the renderable buffers list.
 
- Public Member Functions inherited from MayaFlux::Buffers::RootBuffer< VKBuffer >
virtual void add_child_buffer (std::shared_ptr< VKBuffer > buffer)
 Adds a tributary buffer to this root buffer.
 
virtual bool try_add_child_buffer (std::shared_ptr< VKBuffer > buffer, std::string *rejection_reason=nullptr)
 Attempts to add a child buffer without throwing exceptions.
 
virtual void remove_child_buffer (std::shared_ptr< VKBuffer > buffer)
 Removes a tributary buffer from this root buffer.
 
size_t get_num_children () const
 Gets the number of tributary buffers in the aggregation hierarchy.
 
const std::vector< std::shared_ptr< VKBuffer > > & get_child_buffers () const
 Gets all tributary buffers in the aggregation hierarchy.
 
void clear () override
 Resets all data values in this buffer and its tributaries.
 
virtual void set_processing_rate_hint (uint32_t tick_rate)
 Sets processing rate hint for the buffer.
 
virtual uint32_t get_processing_rate_hint () const
 Gets the processing rate hint.
 
virtual void enable_cross_modal_sharing (bool enabled)
 Enables cross-modal data sharing.
 
virtual bool is_cross_modal_sharing_enabled () const
 Checks if cross-modal sharing is enabled.
 
bool is_buffer_acceptable (std::shared_ptr< VKBuffer > buffer, std::string *rejection_reason=nullptr) const
 Validates if a buffer is acceptable based on current token enforcement strategy.
 
bool has_pending_operations () const
 
- Public Member Functions inherited from MayaFlux::Buffers::VKBuffer
 VKBuffer (size_t size_bytes, Usage usage, Kakshya::DataModality modality)
 Construct an unregistered VKBuffer.
 
 VKBuffer ()=default
 
 ~VKBuffer () override
 Virtual destructor.
 
void clear () override
 Clear buffer contents.
 
std::vector< Kakshya::DataVariantget_data ()
 Read buffer contents as Kakshya DataVariant.
 
void set_data (const std::vector< Kakshya::DataVariant > &data)
 Write data into the buffer.
 
void resize (size_t new_size, bool preserve_data=false)
 Resize buffer and recreate GPU resources if needed.
 
size_t get_size () const
 Get current logical size in bytes.
 
void process_default () override
 Run the buffer's default processor (if set and enabled)
 
void set_default_processor (std::shared_ptr< Buffers::BufferProcessor > processor) override
 Set the buffer's default processor.
 
std::shared_ptr< Buffers::BufferProcessorget_default_processor () const override
 Get the currently attached default processor.
 
std::shared_ptr< Buffers::BufferProcessingChainget_processing_chain () override
 Access the buffer's processing chain.
 
void set_processing_chain (std::shared_ptr< Buffers::BufferProcessingChain > chain, bool force=false) override
 Replace the buffer's processing chain.
 
bool has_data_for_cycle () const override
 Checks if the buffer has data for the current processing cycle.
 
bool needs_removal () const override
 Checks if the buffer should be removed from processing chains.
 
void mark_for_processing (bool has_data) override
 Marks the buffer's data availability for the current processing cycle.
 
void mark_for_removal () override
 Marks the buffer for removal from processing chains.
 
void enforce_default_processing (bool should_process) override
 Controls whether the buffer should use default processing.
 
bool needs_default_processing () override
 Checks if the buffer should undergo default processing.
 
bool try_acquire_processing () override
 Try to acquire processing lock for this buffer.
 
void release_processing () override
 Release previously acquired processing lock.
 
bool is_processing () const override
 Query whether the buffer is currently being processed.
 
vk::Buffer & get_buffer ()
 Get VkBuffer handle (VK_NULL_HANDLE if not registered)
 
vk::DeviceSize get_size_bytes () const
 
vk::Format get_format () const
 Convert modality to a recommended VkFormat.
 
bool is_initialized () const
 Check whether Vulkan handles are present (buffer registered)
 
virtual void setup_processors (ProcessingToken token)
 Setup processors with a processing token.
 
Kakshya::DataModality get_modality () const
 Get the buffer's semantic modality.
 
const std::vector< Kakshya::DataDimension > & get_dimensions () const
 Get the inferred data dimensions for the buffer contents.
 
void set_modality (Kakshya::DataModality modality)
 Update the semantic modality and re-infer dimensions.
 
Usage get_usage () const
 Retrieve the declared usage intent.
 
void set_buffer (vk::Buffer buffer)
 Set VkBuffer handle after backend allocation.
 
void set_memory (vk::DeviceMemory memory)
 Set device memory handle after backend allocation.
 
void set_mapped_ptr (void *ptr)
 Set mapped host pointer (for host-visible allocations)
 
void set_buffer_resources (const VKBufferResources &resources)
 Set all buffer resources at once.
 
const VKBufferResourcesget_buffer_resources ()
 Get all buffer resources at once.
 
bool is_host_visible () const
 Whether this VKBuffer should be host-visible.
 
vk::BufferUsageFlags get_usage_flags () const
 Get appropriate VkBufferUsageFlags for creation based on Usage.
 
vk::MemoryPropertyFlags get_memory_properties () const
 Get appropriate VkMemoryPropertyFlags for allocation based on Usage.
 
void * get_mapped_ptr () const
 Get mapped host pointer (nullptr if not host-visible or unmapped)
 
void mark_dirty_range (size_t offset, size_t size)
 Get device memory handle.
 
void mark_invalid_range (size_t offset, size_t size)
 Mark a range as invalid (needs download)
 
std::vector< std::pair< size_t, size_t > > get_and_clear_dirty_ranges ()
 Retrieve and clear all dirty ranges.
 
std::vector< std::pair< size_t, size_t > > get_and_clear_invalid_ranges ()
 Retrieve and clear all invalid ranges.
 
void set_pipeline_window (RenderPipelineID id, const std::shared_ptr< Core::Window > &window)
 Associate this buffer with a window for rendering.
 
std::shared_ptr< Core::Windowget_pipeline_window (RenderPipelineID id) const
 Get the window associated with this buffer.
 
bool has_render_pipeline () const
 Check if this buffer has a rendering pipeline configured.
 
std::unordered_map< RenderPipelineID, std::shared_ptr< Core::Window > > get_render_pipelines () const
 Get all render pipelines associated with this buffer.
 
void set_pipeline_command (RenderPipelineID pipeline_id, CommandBufferID cmd_id)
 Store recorded command buffer for a pipeline.
 
CommandBufferID get_pipeline_command (RenderPipelineID pipeline_id) const
 Get recorded command buffer for a pipeline.
 
void clear_pipeline_commands ()
 Clear all recorded commands (called after presentation)
 
void set_vertex_layout (const Kakshya::VertexLayout &layout)
 Set vertex layout for this buffer.
 
std::optional< Kakshya::VertexLayoutget_vertex_layout () const
 Get vertex layout if set.
 
bool has_vertex_layout () const
 Check if this buffer has vertex layout configured.
 
void clear_vertex_layout ()
 Clear vertex layout.
 
std::shared_ptr< Bufferclone_to (uint8_t dest_desc) override
 Creates a clone of this buffer for a specific channel or usage enum.
 
std::shared_ptr< VKBufferclone_to (Usage usage)
 Create a clone of this buffer with the same data and properties.
 
void force_internal_usage (bool internal) override
 Set whether this buffer is for internal engine usage.
 
bool is_internal_only () const override
 Check whether this buffer is for internal engine usage.
 
- Public Member Functions inherited from MayaFlux::Buffers::Buffer
virtual ~Buffer ()=default
 Virtual destructor for proper resource management.
 

Private Member Functions

std::shared_ptr< BufferProcessorcreate_default_processor ()
 Creates the default graphics batch processor.
 
void add_renderable_buffer (const RenderableBufferInfo &info)
 Add a buffer to the renderable list.
 

Private Attributes

std::vector< RenderableBufferInfom_renderable_buffers
 
std::shared_ptr< BufferProcessorm_final_processor
 Optional final processor (rarely used in graphics)
 
std::vector< std::shared_ptr< VKBuffer > > m_pending_removal
 Buffers pending removal (cleaned up in next process cycle)
 
bool m_token_active {}
 Flag indicating if this buffer is active for token processing.
 

Friends

class GraphicsBatchProcessor
 

Additional Inherited Members

- Public Types inherited from MayaFlux::Buffers::VKBuffer
enum class  Usage : uint8_t {
  STAGING , DEVICE , COMPUTE , VERTEX ,
  INDEX , UNIFORM
}
 
- Protected Member Functions inherited from MayaFlux::Buffers::RootBuffer< VKBuffer >
void add_child_buffer_direct (std::shared_ptr< VKBuffer > buffer)
 
void remove_child_buffer_direct (std::shared_ptr< VKBuffer > buffer)
 
void process_pending_buffer_operations ()
 Process pending operations - call this at start of processing cycles.
 
- Protected Attributes inherited from MayaFlux::Buffers::RootBuffer< VKBuffer >
std::vector< std::shared_ptr< VKBuffer > > m_child_buffers
 Vector of tributary buffers that contribute to this root buffer.
 
uint32_t m_processing_rate_hint
 Processing rate hint for this buffer.
 
bool m_cross_modal_sharing
 Whether this buffer allows cross-modal data sharing.
 
TokenEnforcementStrategy m_token_enforcement_strategy
 Current token enforcement strategy for this root buffer.
 
ProcessingToken m_preferred_processing_token
 Preferred processing token for this root buffer.
 
std::atomic< uint32_t > m_pending_count
 
struct MayaFlux::Buffers::RootBuffer::PendingBufferOp m_pending_ops [MAX_PENDING]
 
- Static Protected Attributes inherited from MayaFlux::Buffers::RootBuffer< VKBuffer >
static constexpr size_t MAX_PENDING
 

Detailed Description

Root container for GPU buffer lifecycle management and batch processing.

RootGraphicsBuffer serves as the organizational hub for graphics buffers in a processing domain. Unlike RootAudioBuffer which accumulates and mixes sample data, RootGraphicsBuffer focuses on:

  • Managing the lifecycle of VKBuffer instances (GPU resources)
  • Coordinating batch processing across multiple GPU buffers
  • Tracking active GPU resources for backend queries
  • Providing cleanup mechanisms for marked buffers

Key Differences from RootAudioBuffer:

  • No data accumulation or mixing (each buffer is independent)
  • No "final output" concept (buffers are consumed by shaders/render passes)
  • Focuses on resource management and batch coordination
  • Processing means executing BufferProcessor chains (uploads, compute, etc.)

Token Compatibility:

  • Primary Token: GRAPHICS_BACKEND (frame-rate, GPU, parallel)
  • Compatible with GPU_PROCESS tokens for compute operations
  • Not compatible with AUDIO_BACKEND tokens (different processing model)

Definition at line 36 of file RootGraphicsBuffer.hpp.


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