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

◆ set_gpu_executor()

void MayaFlux::Nodes::Network::InstanceFieldOperator::set_gpu_executor ( std::shared_ptr< Yantra::ShaderExecutionContext<> >  executor,
bool  continuous = true 
)

Attach a GPU executor and switch to async dispatch mode.

Constructs a GpuComputeNode from the executor. On each process() call the node's compute_frame() is driven instead of the CPU field loop. The on_complete callback reads gpu_result.primary as tightly-packed mat4 rows (16 floats per slot, in slot-index order) and writes into m_slots directly.

CPU field bindings are preserved but ignored while a GPU executor is attached. Passing nullptr clears the GPU path and restores CPU evaluation.

Parameters
executorPre-configured ShaderExecutionContext. Output binding must be sized for slot_count * 16 * sizeof(float). nullptr clears.
continuousIf true the node re-arms after every completed dispatch.

Definition at line 29 of file InstanceFieldOperator.cpp.

31{
32 if (!executor) {
33 m_compute_node.reset();
34 m_executor.reset();
35 return;
36 }
37
38 m_executor = std::move(executor);
39 m_compute_node = std::make_shared<Nodes::GpuSync::GpuComputeNode>(m_executor, continuous);
40
41 m_compute_node->on_complete([this](Nodes::GpuSync::GpuComputeContext& ctx) {
42 if (!m_slots)
43 return;
44
45 const auto& primary = ctx.gpu_result.primary;
46 const size_t floats_per_slot = 16;
47
48 for (size_t i = 0; i < m_slots->size(); ++i) {
49 const size_t base = i * floats_per_slot;
50 if (base + floats_per_slot > primary.size())
51 break;
52
53 auto& slot = (*m_slots)[i];
54 std::memcpy(glm::value_ptr(slot.transform), primary.data() + base,
55 floats_per_slot * sizeof(float));
56 slot.dirty = true;
57 }
58 });
59
60 m_compute_node->set_dirty();
61}
std::shared_ptr< Nodes::GpuSync::GpuComputeNode > m_compute_node
std::shared_ptr< Yantra::ShaderExecutionContext<> > m_executor

References MayaFlux::Nodes::GpuSync::GpuComputeContext::gpu_result, m_compute_node, m_executor, MayaFlux::Nodes::Network::InstanceOperator::m_slots, and MayaFlux::Yantra::GpuChannelResult::primary.