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

Buffer for aggregating multiple geometry nodes with independent topologies. More...

#include <CompositeGeometryBuffer.hpp>

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

Public Member Functions

 CompositeGeometryBuffer (size_t initial_capacity=1024 *1024, float over_allocate_factor=1.5F)
 Create empty composite buffer.
 
 ~CompositeGeometryBuffer () override=default
 
void add_geometry (const std::string &name, const std::shared_ptr< Nodes::GpuSync::GeometryWriterNode > &node, Portal::Graphics::PrimitiveTopology topology, const std::shared_ptr< Core::Window > &target_window)
 Add a geometry collection.
 
void add_geometry (const std::string &name, const std::shared_ptr< Nodes::GpuSync::GeometryWriterNode > &node, Portal::Graphics::PrimitiveTopology topology, const RenderConfig &config)
 Add a geometry collection with explicit render config.
 
void remove_geometry (const std::string &name)
 Remove a geometry collection.
 
std::optional< CompositeGeometryProcessor::GeometryCollectionget_collection (const std::string &name) const
 Get geometry collection metadata.
 
size_t get_collection_count () const
 Get number of geometry collections.
 
void setup_processors (ProcessingToken token) override
 Initialize buffer processors.
 
void setup_rendering (const RenderConfig &config)
 Setup rendering (DEPRECATED for CompositeGeometryBuffer)
 
std::shared_ptr< CompositeGeometryProcessorget_composite_processor () const
 Get the composite processor managing uploads.
 
std::vector< std::shared_ptr< RenderProcessor > > get_render_processors () const
 Get all render processors (one per collection)
 
void update_collection_render_range (const std::string &name, uint32_t vertex_offset, uint32_t vertex_count)
 Update the vertex range for a specific geometry collection's render processor.
 
void update_collection_vertex_layout (const std::string &name, const Kakshya::VertexLayout &layout)
 Push a topology-specific vertex layout to the matching RenderProcessor.
 
- 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 (const std::shared_ptr< 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 (const std::shared_ptr< 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)
 
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.
 
PipelineContextget_pipeline_context ()
 Access the pipeline context for custom metadata (non-const)
 
const PipelineContextget_pipeline_context () const
 Access the pipeline context for custom metadata (const)
 
virtual void mark_render_config_dirty (bool is_dirty=true)
 Mark config as changed (processors will detect and react)
 
bool is_render_config_dirty () const
 Check if config has changed since last frame.
 
RenderConfig get_render_config () const
 Get the current render configuration.
 
virtual void set_render_config (const RenderConfig &config)
 Update the render configuration and mark as dirty.
 
- Public Member Functions inherited from MayaFlux::Buffers::Buffer
virtual ~Buffer ()=default
 Virtual destructor for proper resource management.
 

Static Private Member Functions

static size_t calculate_initial_size (size_t requested_capacity)
 Calculate initial buffer size.
 

Private Attributes

std::shared_ptr< CompositeGeometryProcessorm_processor
 
std::unordered_map< std::string, RenderDatam_render_data
 
float m_over_allocate_factor
 

Additional Inherited Members

- Public Types inherited from MayaFlux::Buffers::VKBuffer
enum class  Usage : uint8_t {
  STAGING , DEVICE , COMPUTE , VERTEX ,
  INDEX , UNIFORM
}
 
using RenderConfig = Portal::Graphics::RenderConfig
 
- Protected Member Functions inherited from MayaFlux::Buffers::VKBuffer
void set_default_render_config (const RenderConfig &config)
 Called by derived classes to set their context-specific defaults.
 
- Protected Attributes inherited from MayaFlux::Buffers::VKBuffer
bool m_render_config_dirty {}
 
RenderConfig m_render_config
 

Detailed Description

Buffer for aggregating multiple geometry nodes with independent topologies.

Allows manual composition of multiple GeometryWriterNodes, each rendered with its own primitive topology. All geometry is aggregated into a single GPU buffer for efficient upload, but rendered with separate draw calls per topology.

Philosophy:

  • Manual composition for full control
  • Each geometry can have different topology (LINE_STRIP, LINE_LIST, POINT_LIST, etc.)
  • Single buffer upload, multiple render passes
  • Efficient batching without topology constraints

Key Differences from GeometryBuffer:

  • Accepts multiple nodes (not single GeometryWriterNode)
  • Each node can have different topology
  • Automatically creates multiple RenderProcessors

Key Differences from NetworkGeometryBuffer:

  • Manual node registration (not NodeNetwork-driven)
  • Explicit topology specification per node
  • Not tied to network operators or topology inference

Usage:

auto path_node = vega.PathGeneratorNode(...);
auto normals_node = vega.PointCollectionNode();
// ... populate normals
auto composite = std::make_shared<CompositeGeometryBuffer>();
composite->add_geometry("path", path_node, PrimitiveTopology::LINE_STRIP);
composite->add_geometry("normals", normals_node, PrimitiveTopology::LINE_LIST);
composite->add_geometry("control_points", points_node, PrimitiveTopology::POINT_LIST);
composite->setup_processors(ProcessingToken::GRAPHICS_BACKEND);
composite->setup_rendering({.target_window = window});
auto PathGeneratorNode(Args &&... args) -> CreationHandle< MayaFlux::Nodes::GpuSync::PathGeneratorNode >
Definition Creator.hpp:190
auto PointCollectionNode(Args &&... args) -> CreationHandle< MayaFlux::Nodes::GpuSync::PointCollectionNode >
Definition Creator.hpp:190
@ GRAPHICS_BACKEND
Standard graphics processing backend configuration.
Creator vega
Global Creator instance for creating nodes, buffers, and containers.
Definition Creator.cpp:19

Each frame:

  1. CompositeGeometryProcessor aggregates all nodes → single GPU upload
  2. Multiple RenderProcessors draw subsets with different topologies

Definition at line 60 of file CompositeGeometryBuffer.hpp.


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