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

◆ bind_network()

void MayaFlux::Buffers::DescriptorBindingsProcessor::bind_network ( const std::string &  name,
const std::shared_ptr< Nodes::Network::NodeNetwork > &  network,
const std::string &  descriptor_name,
uint32_t  set,
Portal::Graphics::DescriptorRole  role = Portal::Graphics::DescriptorRole::STORAGE 
)

Bind a NodeNetwork to a descriptor.

Resolves source type at bind time:

  • Networks with get_audio_buffer() output → NETWORK_AUDIO (VECTOR binding)
  • Networks with a GraphicsOperator → NETWORK_GPU (STRUCTURED binding)

Fails hard if the network satisfies neither condition.

Parameters
nameLogical binding name
networkNodeNetwork to read from
descriptor_nameName in shader config bindings
setDescriptor set index
roleDescriptor role (default: STORAGE)

Definition at line 319 of file DescriptorBindingsProcessor.cpp.

325{
326 if (!network) {
328 "Cannot bind null network '{}'", name);
329 return;
330 }
331
332 if (m_config.bindings.find(descriptor_name) == m_config.bindings.end()) {
334 "Descriptor '{}' not found in shader config", descriptor_name);
335 return;
336 }
337
338 SourceType resolved {};
339 BindingType binding_type {};
340 size_t initial_size {};
341
342 auto network_mode = network->get_output_mode();
344 resolved = SourceType::NETWORK_AUDIO;
345 binding_type = BindingType::VECTOR;
346 auto probe = network->get_audio_buffer();
347 if (probe) {
348 initial_size = probe->size() * sizeof(float);
349 } else {
351 "Network '{}' is configured for audio output but has no audio buffer. "
352 "Binding will be created with default size of 4096 samples (16 KB).",
353 name);
354 initial_size = 4096 * sizeof(float);
355 }
356 } else if (network->has_operator() && dynamic_cast<Nodes::Network::GraphicsOperator*>(network->get_operator())) {
357 resolved = SourceType::NETWORK_GPU;
358 binding_type = BindingType::STRUCTURED;
359 initial_size = static_cast<size_t>(1024) * 64;
360 } else {
362 "Network '{}' produces neither audio nor GPU geometry. "
363 "Bind is only valid for networks with audio output or a GraphicsOperator.",
364 name);
365 return;
366 }
367
368 const auto& binding_config = m_config.bindings[descriptor_name];
369 auto gpu_buffer = create_descriptor_buffer(initial_size, role);
370
371 auto [it, inserted] = m_bindings.try_emplace(name);
372 auto& binding = it->second;
373
374 binding.network = network;
375 binding.descriptor_name = descriptor_name;
376 binding.set_index = set;
377 binding.binding_index = binding_config.binding;
378 binding.role = role;
379 binding.binding_type = binding_type;
380 binding.source_type = resolved;
381 binding.gpu_buffer = gpu_buffer;
382 binding.buffer_offset = 0;
383 binding.buffer_size = initial_size;
384
385 bind_buffer(descriptor_name, gpu_buffer);
387
389 "Bound network '{}' to descriptor '{}' (source: {})",
390 name, descriptor_name,
391 resolved == SourceType::NETWORK_AUDIO ? "NETWORK_AUDIO" : "NETWORK_GPU");
392}
#define MF_ERROR(comp, ctx,...)
#define MF_WARN(comp, ctx,...)
#define MF_DEBUG(comp, ctx,...)
std::unordered_map< std::string, DescriptorBinding > m_bindings
std::shared_ptr< VKBuffer > create_descriptor_buffer(size_t size, Portal::Graphics::DescriptorRole role)
Create GPU buffer for a descriptor binding.
@ STRUCTURED
Array of structs from StructuredContext.
void bind_buffer(const std::string &descriptor_name, const std::shared_ptr< VKBuffer > &buffer)
Bind a VKBuffer to a named shader descriptor.
@ BufferProcessing
Buffer processing (Buffers::BufferManager, processing chains)
@ Buffers
Buffers, Managers, processors and processing chains.
@ AUDIO_COMPUTE
processed each cycle but not sent to output
@ AUDIO_SINK
Aggregated audio samples sent to output.
std::unordered_map< std::string, ShaderBinding > bindings

References MayaFlux::Nodes::Network::AUDIO_COMPUTE, MayaFlux::Nodes::Network::AUDIO_SINK, MayaFlux::Buffers::ShaderProcessor::bind_buffer(), MayaFlux::Buffers::ShaderConfig::bindings, MayaFlux::Journal::BufferProcessing, MayaFlux::Journal::Buffers, create_descriptor_buffer(), m_bindings, MayaFlux::Buffers::ShaderProcessor::m_config, MayaFlux::Buffers::ShaderProcessor::m_needs_descriptor_rebuild, MF_DEBUG, MF_ERROR, MF_WARN, NETWORK_AUDIO, NETWORK_GPU, STRUCTURED, and VECTOR.

+ Here is the call graph for this function: