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

◆ bind_audio_buffer()

void MayaFlux::Buffers::DescriptorBindingsProcessor::bind_audio_buffer ( const std::string &  name,
const std::shared_ptr< AudioBuffer > &  buffer,
const std::string &  descriptor_name,
uint32_t  set,
Portal::Graphics::DescriptorRole  role = Portal::Graphics::DescriptorRole::STORAGE 
)

Bind an AudioBuffer as a descriptor source.

Reads the buffer's double sample data each cycle, converts to float, and uploads to the descriptor. Always treated as VECTOR binding.

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

Definition at line 221 of file DescriptorBindingsProcessor.cpp.

227{
228 if (!buffer) {
230 "Cannot bind null AudioBuffer '{}'", name);
231 return;
232 }
233
234 if (m_config.bindings.find(descriptor_name) == m_config.bindings.end()) {
236 "Descriptor '{}' not found in shader config", descriptor_name);
237 return;
238 }
239
240 const auto& binding_config = m_config.bindings[descriptor_name];
241 size_t initial_size = buffer->get_num_samples() * sizeof(float);
242 auto gpu_buffer = create_descriptor_buffer(initial_size, role);
243
244 auto [it, inserted] = m_bindings.try_emplace(name);
245 auto& binding = it->second;
246
247 binding.buffer = buffer;
248 binding.descriptor_name = descriptor_name;
249 binding.set_index = set;
250 binding.binding_index = binding_config.binding;
251 binding.role = role;
252 binding.binding_type = BindingType::VECTOR;
253 binding.source_type = SourceType::AUDIO_BUFFER;
254 binding.gpu_buffer = gpu_buffer;
255 binding.buffer_offset = 0;
256 binding.buffer_size = initial_size;
257
258 bind_buffer(descriptor_name, gpu_buffer);
260
262 "Bound AudioBuffer '{}' to descriptor '{}' ({} samples)",
263 name, descriptor_name, buffer->get_num_samples());
264}
#define MF_ERROR(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.
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.
std::unordered_map< std::string, ShaderBinding > bindings

References AUDIO_BUFFER, 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, and VECTOR.

+ Here is the call graph for this function: