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

◆ update_descriptor_from_node()

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

Update descriptor from node context.

Definition at line 207 of file DescriptorBindingsProcessor.cpp.

208{
209 if (!binding.node) {
211 "Binding has null node");
212 return;
213 }
214
215 Nodes::NodeContext& ctx = binding.node->get_last_context();
216
217 switch (binding.binding_type) {
218 case BindingType::SCALAR: {
219 auto value = static_cast<float>(binding.node->get_last_output());
220 ensure_buffer_capacity(binding, sizeof(float));
221
222 upload_to_gpu(&value, sizeof(float), binding.gpu_buffer, nullptr);
223 break;
224 }
225
226 case BindingType::VECTOR: {
227 auto* gpu_vec = dynamic_cast<Nodes::GpuVectorData*>(&ctx);
228 if (!gpu_vec || !gpu_vec->has_gpu_data()) {
230 "Node context does not provide GpuVectorData");
231 return;
232 }
233
234 auto data = gpu_vec->gpu_data();
235
236 ensure_buffer_capacity(binding, data.size_bytes());
237 upload_to_gpu(data.data(), data.size_bytes(), binding.gpu_buffer, nullptr);
238 break;
239 }
240
241 case BindingType::MATRIX: {
242 auto* gpu_mat = dynamic_cast<Nodes::GpuMatrixData*>(&ctx);
243 if (!gpu_mat || !gpu_mat->has_gpu_data()) {
245 "Node context does not provide GpuMatrixData");
246 return;
247 }
248
249 auto data = gpu_mat->gpu_data();
250 ensure_buffer_capacity(binding, data.size_bytes());
251 upload_to_gpu(data.data(), data.size_bytes(), binding.gpu_buffer, nullptr);
252 break;
253 }
254
256 auto* gpu_struct = dynamic_cast<Nodes::GpuStructuredData*>(&ctx);
257 if (!gpu_struct || !gpu_struct->has_gpu_data()) {
259 "Node context does not provide GpuStructuredData");
260 return;
261 }
262
263 auto data = gpu_struct->gpu_data();
264 ensure_buffer_capacity(binding, data.size_bytes());
265 upload_to_gpu(data.data(), data.size_bytes(), binding.gpu_buffer, nullptr);
266 break;
267 }
268 }
269}
#define MF_RT_ERROR(comp, ctx,...)
void ensure_buffer_capacity(DescriptorBinding &binding, size_t required_size)
Ensure descriptor buffer has sufficient capacity.
@ STRUCTURED
Array of structs from StructuredContext.
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::DescriptorBindingsProcessor::DescriptorBinding::gpu_buffer, MATRIX, MF_RT_ERROR, MayaFlux::Buffers::DescriptorBindingsProcessor::DescriptorBinding::node, SCALAR, STRUCTURED, MayaFlux::Buffers::upload_to_gpu(), and VECTOR.

Referenced by on_before_dispatch().

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