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

◆ pump_feeds()

void MayaFlux::Buffers::ShaderProcessor::pump_feeds ( )
protected

Pull every feed and write its result.

Called at the top of processing_function, before descriptors are rebuilt, so a storage feed creating its buffer binds the same cycle. Callables run on whichever thread drives the chain.

Definition at line 308 of file ShaderProcessor.cpp.

309{
310 for (auto& [name, entry] : m_feeds) {
311 FeedValue value = entry.source();
312
313 if (!entry.is_storage) {
314 const auto* scalar = std::get_if<double>(&value);
315 if (!scalar) {
316 if (!entry.mismatch_logged) {
318 "feed '{}' writes a push constant but returned a DataVariant", name);
319 entry.mismatch_logged = true;
320 }
321 continue;
322 }
323
324 auto& data = get_push_constant_data();
325 const size_t required = entry.offset + entry.size;
326 if (data.size() < required) {
327 data.resize(required);
328 }
329
330 if (entry.size == sizeof(float)) {
331 const auto narrowed = static_cast<float>(*scalar);
332 std::memcpy(data.data() + entry.offset, &narrowed, sizeof(float));
333 } else {
334 std::memcpy(data.data() + entry.offset, scalar, sizeof(double));
335 }
336 continue;
337 }
338
339 auto* variant = std::get_if<Kakshya::DataVariant>(&value);
340 if (!variant) {
341 if (!entry.mismatch_logged) {
343 "feed '{}' writes a storage descriptor but returned a double", name);
344 entry.mismatch_logged = true;
345 }
346 continue;
347 }
348
349 Kakshya::DataAccess accessor(*variant, {}, Kakshya::DataModality::UNKNOWN);
350 auto [ptr, bytes, format] = accessor.gpu_buffer();
351
352 if (!ptr || bytes == 0) {
354 "feed '{}' produced no bytes", name);
355 continue;
356 }
357
358 if (!entry.buffer) {
359 entry.buffer = std::make_shared<VKBuffer>(
360 static_cast<size_t>(static_cast<float>(bytes) * 1.5F),
361 m_config.bindings.at(entry.descriptor_name).type == vk::DescriptorType::eUniformBuffer
362 ? VKBuffer::Usage::UNIFORM
363 : VKBuffer::Usage::HOST_STORAGE,
365
366 bind_buffer(entry.descriptor_name, entry.buffer);
367
369 "feed '{}' backing buffer created at {} bytes",
370 name, entry.buffer->get_size_bytes());
371 } else if (entry.buffer->get_size_bytes() < bytes) {
372 const size_t grown = bytes * 3 / 2;
373
375 "feed '{}' backing buffer resized {} to {} bytes",
376 name, entry.buffer->get_size_bytes(), grown);
377
378 entry.buffer->resize(grown, false);
380 }
381
382 upload_host_visible(entry.buffer, *variant);
383 }
384}
#define MF_ERROR(comp, ctx,...)
#define MF_RT_WARN(comp, ctx,...)
#define MF_DEBUG(comp, ctx,...)
const uint8_t * ptr
float value
const std::vector< uint8_t > & get_push_constant_data() const
Get current push constant data.
std::variant< double, Kakshya::DataVariant > FeedValue
What a feed callable returns.
std::unordered_map< std::string, Feed > m_feeds
void bind_buffer(const std::string &descriptor_name, const std::shared_ptr< VKBuffer > &buffer)
Bind a VKBuffer to a named shader descriptor.
void upload_host_visible(const std::shared_ptr< VKBuffer > &target, const Kakshya::DataVariant &data)
Upload data to a host-visible buffer.
@ BufferProcessing
Buffer processing (Buffers::BufferManager, processing chains)
@ Buffers
Buffers, Managers, processors and processing chains.
@ Kakshya
Containers[Signalsource, Stream, File], Regions, DataProcessors.
DataModality
Data modality types for cross-modal analysis.
Definition NDData.hpp:164
@ UNKNOWN
Unknown or undefined modality.
@ HOST_STORAGE
Host-visible storage buffer (eStorageBuffer + eHostVisible|eHostCoherent)
std::unordered_map< std::string, ShaderBinding > bindings

References bind_buffer(), MayaFlux::Buffers::ShaderConfig::bindings, MayaFlux::Journal::BufferProcessing, MayaFlux::Journal::Buffers, get_push_constant_data(), MayaFlux::Kakshya::DataAccess::gpu_buffer(), m_config, m_feeds, m_needs_descriptor_rebuild, MF_DEBUG, MF_ERROR, MF_RT_WARN, ptr, MayaFlux::Kakshya::UNKNOWN, MayaFlux::Buffers::upload_host_visible(), and value.

Referenced by processing_function().

+ Here is the call graph for this function:
+ Here is the caller graph for this function: