MayaFlux 0.4.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches
MayaFlux::Nodes::Network::InstanceNetwork Class Reference

NodeNetwork whose slots are flat, peer GeometrySlots for instanced rendering. More...

#include <InstanceNetwork.hpp>

+ Inheritance diagram for MayaFlux::Nodes::Network::InstanceNetwork:
+ Collaboration diagram for MayaFlux::Nodes::Network::InstanceNetwork:

Public Member Functions

uint32_t add_slot (std::string name, std::shared_ptr< GpuSync::GeometryWriterNode > node)
 
template<typename OpType , typename... Args>
std::shared_ptr< OpType > create_operator (Args &&... args)
 
GeometrySlotfind_slot (std::string_view name)
 
const GeometrySlotfind_slot (std::string_view name) const
 
std::unordered_map< std::string, std::string > get_metadata () const override
 Get network metadata for debugging/visualization.
 
size_t get_node_count () const override
 Get the number of nodes in the network.
 
std::optional< double > get_node_output (size_t index) const override
 Get output of specific internal node (for ONE_TO_ONE mapping)
 
const NetworkOperatorget_operator () const override
 
NetworkOperatorget_operator () override
 
GeometrySlotget_slot (uint32_t index)
 
const GeometrySlotget_slot (uint32_t index) const
 
bool has_operator () const override
 
 InstanceNetwork ()
 
void process_batch (unsigned int num_samples) override
 Process the network for the given number of samples.
 
void reset () override
 Reset network to initial state.
 
void set_operator (std::shared_ptr< NetworkOperator > op)
 
size_t slot_count () const
 
std::vector< GeometrySlot > & slots ()
 
const std::vector< GeometrySlot > & slots () const
 
 ~InstanceNetwork () override=default
 
- Public Member Functions inherited from MayaFlux::Nodes::Network::NodeNetwork
void add_channel_usage (uint32_t channel_id)
 Register network usage on a specific channel.
 
virtual std::optional< std::vector< double > > get_audio_buffer () const
 Get cached audio buffer from last process_batch()
 
uint32_t get_block_size () const
 
uint32_t get_channel_mask () const
 Get channel mask (bitfield of registered channels)
 
virtual std::optional< std::span< const double > > get_node_audio_buffer (size_t) const
 Get output of specific internal node as audio buffer (for ONE_TO_ONE mapping)
 
std::shared_ptr< OperatorChainget_operator_chain () const
 Access the secondary operator chain.
 
OutputMode get_output_mode () const
 Get the current output routing mode.
 
double get_output_scale () const
 Get the current output scale factor.
 
std::vector< uint32_t > get_registered_channels () const
 Get all channels this network is registered on.
 
RoutingStateget_routing_state ()
 Retrieves the current routing state of the network (non-const)
 
const RoutingStateget_routing_state () const
 Retrieves the current routing state of the network.
 
uint32_t get_sample_rate () const
 
Topology get_topology () const
 Get the current topology.
 
virtual void initialize ()
 Called once before first process_batch()
 
bool is_enabled () const
 Check if network is enabled.
 
bool is_processed_this_cycle () const
 Check if network has been processed this cycle (lock-free)
 
bool is_processing () const
 Check if network is currently processing (lock-free)
 
bool is_registered_on_channel (uint32_t channel_id) const
 Check if network is registered on a channel.
 
virtual void map_parameter (const std::string &param_name, const std::shared_ptr< Node > &source, MappingMode mode=MappingMode::BROADCAST)
 Map external node output to network parameter.
 
virtual void map_parameter (const std::string &param_name, const std::shared_ptr< NodeNetwork > &source_network)
 Map external node network to network parameters (ONE_TO_ONE)
 
void mark_processed (bool processed)
 Mark network as processed this cycle (lock-free)
 
void mark_processing (bool processing)
 Mark network as processing or not (lock-free)
 
bool needs_channel_routing () const
 Checks if the network is currently in a routing transition phase.
 
void remove_channel_usage (uint32_t channel_id)
 Unregister network from a specific channel.
 
void request_reset_from_channel (uint32_t channel_id)
 Request a reset from a specific channel.
 
void set_block_size (uint32_t block_size)
 
void set_channel_mask (uint32_t mask)
 Set channel mask directly.
 
void set_enabled (bool enabled)
 Enable/disable the network.
 
void set_output_mode (OutputMode mode)
 Set the network's output routing mode.
 
void set_output_scale (double scale)
 Set the scalar multiplier applied to the network's output buffer after processing.
 
void set_sample_rate (uint32_t sample_rate)
 
virtual void set_topology (Topology topology)
 Set the network's topology.
 
virtual void unmap_parameter (const std::string &param_name)
 Remove parameter mapping.
 
virtual ~NodeNetwork ()=default
 

Private Attributes

std::shared_ptr< NetworkOperatorm_operator
 
std::vector< GeometrySlotm_slots
 

Additional Inherited Members

- Protected Member Functions inherited from MayaFlux::Nodes::Network::NodeNetwork
void apply_output_scale ()
 Apply m_output_scale to m_last_audio_buffer.
 
void ensure_initialized ()
 Ensure initialize() is called exactly once.
 
- Static Protected Member Functions inherited from MayaFlux::Nodes::Network::NodeNetwork
static std::unordered_map< size_t, std::vector< size_t > > build_chain_neighbors (size_t count)
 Build neighbor map for CHAIN topology.
 
static std::unordered_map< size_t, std::vector< size_t > > build_grid_2d_neighbors (size_t width, size_t height)
 Build neighbor map for GRID_2D topology.
 
static std::unordered_map< size_t, std::vector< size_t > > build_grid_3d_neighbors (size_t width, size_t height, size_t depth)
 Build neighbor map for GRID_3D topology.
 
static std::unordered_map< size_t, std::vector< size_t > > build_ring_neighbors (size_t count)
 Build neighbor map for RING topology.
 
static void extract_node_samples (const std::shared_ptr< Nodes::Node > &node, std::vector< double > &buffer, size_t &buffer_pos, size_t num_samples)
 Extract num_samples from node into buffer using snapshot guard.
 
- Protected Attributes inherited from MayaFlux::Nodes::Network::NodeNetwork
std::atomic_flag m_audio_buffer_lock = ATOMIC_FLAG_INIT
 Spinlock guarding m_last_audio_buffer.
 
uint32_t m_block_size { 512 }
 
std::atomic< uint32_t > m_channel_mask { 0 }
 Bitfield of channels this network is registered on.
 
bool m_enabled = true
 
bool m_initialized = false
 
std::vector< double > m_last_audio_buffer
 
std::shared_ptr< OperatorChainm_operator_chain
 
OutputMode m_output_mode = OutputMode::NONE
 
double m_output_scale { 1.0 }
 Post-processing scalar applied to m_last_audio_buffer each batch.
 
std::vector< ParameterMappingm_parameter_mappings
 
std::atomic< uint32_t > m_pending_reset_mask { 0 }
 
std::atomic< bool > m_processed_this_cycle { false }
 
std::atomic< bool > m_processing_state { false }
 Per-channel processing state (lock-free atomic flags)
 
uint32_t m_sample_rate { 48000 }
 
Topology m_topology = Topology::INDEPENDENT
 

Detailed Description

NodeNetwork whose slots are flat, peer GeometrySlots for instanced rendering.

All slots may hold the same node (shared template geometry) or distinct nodes. No DAG, no parent indices. process_batch() runs the operator chain then calls compute_frame() on each slot's node. The buffer layer reads the slot list each cycle and uploads per-instance transforms as an SSBO for a single instanced draw call. Per-vertex data (color, normals, UVs) is owned by each node's vertex buffer and is unchanged by the instancing path.

Usage:

auto net = std::make_shared<InstanceNetwork>();
auto tmpl = std::make_shared<PathGeneratorNode>(...);
for (uint32_t i = 0; i < 200; ++i) {
uint32_t idx = net->add_slot("inst_" + std::to_string(i), tmpl);
net->get_slot(idx).transform = glm::translate(glm::mat4{1}, positions[i]);
}
auto op = net->create_operator<InstanceFieldOperator>();
op->bind_position(0, Kinesis::VectorField { [](glm::vec3 p) {
return p + glm::vec3(0.01F, 0, 0);
}});
Typed, composable, stateless callable from domain D to range R.
Definition Tendency.hpp:22

Definition at line 35 of file InstanceNetwork.hpp.


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