MayaFlux 0.1.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches
AggregateBindingsProcessor.hpp
Go to the documentation of this file.
1#pragma once
2
4
5namespace MayaFlux::Nodes {
6class Node;
7}
8
9namespace MayaFlux::Buffers {
10
11/**
12 * @class AggregateBindingsProcessor
13 * @brief BufferProcessor that aggregates multiple node outputs into GPU buffers
14 *
15 * Collects outputs from multiple nodes and uploads them as contiguous arrays
16 * to GPU buffers. Supports multiple independent target buffers, each receiving
17 * aggregated data from a subset of nodes.
18 *
19 * Behavior:
20 * - Uploads ALL registered aggregates to their target buffers
21 * - If attached buffer is one of the targets, it receives its aggregate
22 * - If attached buffer is NOT a target, it receives the first aggregate
23 *
24 * Usage:
25 * auto velocity_buffer = std::make_shared<VKBuffer>(1000 * sizeof(float), ...);
26 * auto aggregate = std::make_shared<AggregateBindingsProcessor>();
27 *
28 * // Add nodes to "velocities" aggregate
29 * for (int i = 0; i < 1000; i++) {
30 * aggregate->add_node("velocities", velocity_node, velocity_buffer);
31 * }
32 *
33 * velocity_buffer->set_default_processor(aggregate);
34 * velocity_buffer->process_default(); // Uploads all aggregates
35 */
36class MAYAFLUX_API AggregateBindingsProcessor : public VKBufferProcessor {
37public:
39 std::vector<std::shared_ptr<Nodes::Node>> nodes;
40 std::shared_ptr<VKBuffer> target_buffer;
41 std::vector<float> staging_data;
42 };
43
44 /**
45 * @brief Default constructor
46 */
48
49 /**
50 * @brief Add a node to a named aggregate
51 * @param aggregate_name Name of the aggregate group
52 * @param node Node to add
53 * @param target Target buffer for this aggregate
54 *
55 * Nodes with the same aggregate_name are grouped together and uploaded
56 * to the same target buffer. Nodes are ordered by insertion.
57 */
58 void add_node(
59 const std::string& aggregate_name,
60 const std::shared_ptr<Nodes::Node>& node,
61 const std::shared_ptr<VKBuffer>& target);
62
63 /**
64 * @brief Remove a node from an aggregate
65 * @param aggregate_name Name of the aggregate group
66 * @param node Node to remove
67 */
68 void remove_node(
69 const std::string& aggregate_name,
70 const std::shared_ptr<Nodes::Node>& node);
71
72 /**
73 * @brief Clear all nodes from an aggregate
74 * @param aggregate_name Name of the aggregate group
75 */
76 void clear_aggregate(const std::string& aggregate_name);
77
78 /**
79 * @brief Clear all aggregates
80 */
81 void clear_all_aggregates();
82
83 /**
84 * @brief Get number of nodes in an aggregate
85 * @param aggregate_name Name of the aggregate group
86 * @return Node count (0 if aggregate doesn't exist)
87 */
88 [[nodiscard]] size_t get_node_count(const std::string& aggregate_name) const;
89
90 /**
91 * @brief Get total number of nodes across all aggregates
92 * @return Total node count
93 */
94 [[nodiscard]] size_t get_total_node_count() const;
95
96 /**
97 * @brief Get all aggregate names
98 * @return Vector of aggregate names
99 */
100 [[nodiscard]] std::vector<std::string> get_aggregate_names() const;
101
102 /**
103 * @brief Get number of aggregates
104 * @return Aggregate count
105 */
106 [[nodiscard]] size_t get_aggregate_count() const;
107
108 /**
109 * @brief BufferProcessor interface - uploads all aggregates
110 * @param buffer The buffer this processor is attached to
111 */
112 void processing_function(std::shared_ptr<Buffer> buffer) override;
113
114private:
115 std::unordered_map<std::string, AggregateBinding> m_aggregates;
116};
117
118} // namespace MayaFlux::Buffers
AggregateBindingsProcessor()=default
Default constructor.
std::unordered_map< std::string, AggregateBinding > m_aggregates
BufferProcessor that aggregates multiple node outputs into GPU buffers.
Contains the node-based computational processing system components.
Definition Chronie.hpp:5