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.
309{
310 for (
auto& [name, entry] :
m_feeds) {
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
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
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
365
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
383 }
384}
#define MF_ERROR(comp, ctx,...)
#define MF_RT_WARN(comp, ctx,...)
#define MF_DEBUG(comp, ctx,...)
const std::vector< uint8_t > & get_push_constant_data() const
Get current push constant data.
bool m_needs_descriptor_rebuild
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.
@ UNKNOWN
Unknown or undefined modality.
@ HOST_STORAGE
Host-visible storage buffer (eStorageBuffer + eHostVisible|eHostCoherent)
std::unordered_map< std::string, ShaderBinding > bindings