MayaFlux 0.2.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 234 of file DescriptorBindingsProcessor.cpp.

235{
236 if (!binding.node) {
238 "Binding has null node");
239 return;
240 }
241
242 Nodes::NodeContext& ctx = binding.node->get_last_context();
243
244 switch (binding.binding_type) {
245 case BindingType::SCALAR: {
246 auto value = static_cast<float>(binding.node->get_last_output());
247 ensure_buffer_capacity(binding, sizeof(float));
248
249 upload_to_gpu(&value, sizeof(float), binding.gpu_buffer, nullptr);
250 break;
251 }
252
253 case BindingType::VECTOR: {
254 auto* gpu_vec = dynamic_cast<Nodes::GpuVectorData*>(&ctx);
255 if (!gpu_vec || !gpu_vec->has_gpu_data()) {
257 "Node context does not provide GpuVectorData");
258 return;
259 }
260
261 auto data = gpu_vec->gpu_data();
262
263 ensure_buffer_capacity(binding, data.size_bytes());
264 upload_to_gpu(data.data(), data.size_bytes(), binding.gpu_buffer, nullptr);
265 break;
266 }
267
268 case BindingType::MATRIX: {
269 auto* gpu_mat = dynamic_cast<Nodes::GpuMatrixData*>(&ctx);
270 if (!gpu_mat || !gpu_mat->has_gpu_data()) {
272 "Node context does not provide GpuMatrixData");
273 return;
274 }
275
276 auto data = gpu_mat->gpu_data();
277 ensure_buffer_capacity(binding, data.size_bytes());
278 upload_to_gpu(data.data(), data.size_bytes(), binding.gpu_buffer, nullptr);
279 break;
280 }
281
283 auto* gpu_struct = dynamic_cast<Nodes::GpuStructuredData*>(&ctx);
284 if (!gpu_struct || !gpu_struct->has_gpu_data()) {
286 "Node context does not provide GpuStructuredData");
287 return;
288 }
289
290 auto data = gpu_struct->gpu_data();
291 ensure_buffer_capacity(binding, data.size_bytes());
292 upload_to_gpu(data.data(), data.size_bytes(), binding.gpu_buffer, nullptr);
293 break;
294 }
295 }
296}
#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 execute_shader().

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