MayaFlux 0.4.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches

◆ rebuild_sort()

void MayaFlux::Nodes::Network::MeshNetwork::rebuild_sort ( )
private

Definition at line 187 of file MeshNetwork.cpp.

188{
189 // Kahn's algorithm: process roots first, then children.
190 std::vector<uint32_t> in_degree(m_slots.size(), 0);
191 for (const auto& slot : m_slots) {
192 if (slot.parent_index.has_value())
193 ++in_degree[slot.parent_index.value()];
194 }
195
196 // Roots: slots with no parent.
197 std::vector<uint32_t> queue;
198 for (uint32_t i = 0; i < static_cast<uint32_t>(m_slots.size()); ++i) {
199 if (!m_slots[i].parent_index.has_value())
200 queue.push_back(i);
201 }
202
203 m_sorted_indices.clear();
204 m_sorted_indices.reserve(m_slots.size());
205
206 while (!queue.empty()) {
207 uint32_t idx = queue.front();
208 queue.erase(queue.begin());
209 m_sorted_indices.push_back(idx);
210
211 for (uint32_t child : m_slots[idx].child_indices)
212 queue.push_back(child);
213 }
214
215 if (m_sorted_indices.size() != m_slots.size()) {
217 "MeshNetwork: slot DAG contains a cycle — sort is incomplete");
218 }
219
220 m_sort_dirty = false;
221
223 "MeshNetwork: rebuilt slot sort order ({} slots)", m_sorted_indices.size());
224}
#define MF_ERROR(comp, ctx,...)
#define MF_DEBUG(comp, ctx,...)
std::vector< uint32_t > m_sorted_indices
Processing order: indices into m_slots, parents before children.
bool m_sort_dirty
Set when add_slot() changes the DAG and a re-sort is needed.
@ Init
Engine/subsystem initialization.
@ Nodes
DSP Generator and Filter Nodes, graph pipeline, node management.

References MayaFlux::Journal::Init, m_slots, m_sort_dirty, m_sorted_indices, MF_DEBUG, MF_ERROR, and MayaFlux::Journal::Nodes.

Referenced by ensure_sorted(), and process_batch().

+ Here is the caller graph for this function: