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

◆ update_from_node()

void MayaFlux::Buffers::DescriptorBindingsProcessor::update_from_node ( DescriptorBinding binding)
private

Definition at line 511 of file DescriptorBindingsProcessor.cpp.

512{
513 if (!binding.node) {
515 "Binding has null node");
516 return;
517 }
518
519 float value {};
520
521 if (binding.processing_mode.load(std::memory_order_acquire) == ProcessingMode::INTERNAL) {
522 value = static_cast<float>(Buffers::extract_single_sample(binding.node));
523 } else {
524 value = static_cast<float>(binding.node->get_last_output());
525 }
526 Nodes::NodeContext& ctx = binding.node->get_last_context();
527
528 switch (binding.binding_type) {
529
530 case BindingType::SCALAR: {
531 ensure_buffer_capacity(binding, sizeof(float));
532 upload_to_gpu(&value, sizeof(float), binding.gpu_buffer, nullptr);
533 break;
534 }
535
536 case BindingType::VECTOR: {
537 auto* gpu_vec = dynamic_cast<Nodes::GpuVectorData*>(&ctx);
538 if (!gpu_vec || !gpu_vec->has_gpu_data()) {
540 "Node context does not provide GpuVectorData");
541 return;
542 }
543
544 auto data = gpu_vec->gpu_data();
545
546 ensure_buffer_capacity(binding, data.size_bytes());
547 upload_to_gpu(data.data(), data.size_bytes(), binding.gpu_buffer, nullptr);
548 break;
549 }
550
551 case BindingType::MATRIX: {
552 auto* gpu_mat = dynamic_cast<Nodes::GpuMatrixData*>(&ctx);
553 if (!gpu_mat || !gpu_mat->has_gpu_data()) {
555 "Node context does not provide GpuMatrixData");
556 return;
557 }
558
559 auto data = gpu_mat->gpu_data();
560 ensure_buffer_capacity(binding, data.size_bytes());
561 upload_to_gpu(data.data(), data.size_bytes(), binding.gpu_buffer, nullptr);
562 break;
563 }
564
566 auto* gpu_struct = dynamic_cast<Nodes::GpuStructuredData*>(&ctx);
567 if (!gpu_struct || !gpu_struct->has_gpu_data()) {
569 "Node context does not provide GpuStructuredData");
570 return;
571 }
572
573 auto data = gpu_struct->gpu_data();
574 ensure_buffer_capacity(binding, data.size_bytes());
575 upload_to_gpu(data.data(), data.size_bytes(), binding.gpu_buffer, nullptr);
576 break;
577 }
578 }
579}
#define MF_RT_ERROR(comp, ctx,...)
void ensure_buffer_capacity(DescriptorBinding &binding, size_t required_size)
Ensure descriptor buffer has sufficient capacity.
@ INTERNAL
Processor calls extract_single_sample() or processes node context.
@ STRUCTURED
Array of structs from StructuredContext.
double extract_single_sample(const std::shared_ptr< Nodes::Node > &node)
Extract a single sample from a node with proper snapshot management.
void upload_to_gpu(const void *data, size_t size, const std::shared_ptr< VKBuffer > &target, const std::shared_ptr< VKBuffer > &staging)
Upload raw data to GPU buffer (auto-detects host-visible vs device-local)
@ BufferProcessing
Buffer processing (Buffers::BufferManager, processing chains)
@ Buffers
Buffers, Managers, processors and processing chains.

References MayaFlux::Buffers::DescriptorBindingsProcessor::DescriptorBinding::binding_type, MayaFlux::Journal::BufferProcessing, MayaFlux::Journal::Buffers, ensure_buffer_capacity(), MayaFlux::Buffers::extract_single_sample(), MayaFlux::Buffers::DescriptorBindingsProcessor::DescriptorBinding::gpu_buffer, INTERNAL, MATRIX, MF_RT_ERROR, MayaFlux::Buffers::DescriptorBindingsProcessor::DescriptorBinding::node, MayaFlux::Buffers::DescriptorBindingsProcessor::DescriptorBinding::processing_mode, SCALAR, STRUCTURED, MayaFlux::Buffers::upload_to_gpu(), and VECTOR.

Referenced by update_descriptor_data().

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