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

◆ execute()

template<ComputeData InputType = std::vector<Kakshya::DataVariant>, ComputeData OutputType = InputType>
virtual output_type MayaFlux::Yantra::GpuExecutionContext< InputType, OutputType >::execute ( const input_type &  input,
const ExecutionContext &  ctx 
)
inlinevirtual

Dispatch to GPU and reconstruct a typed output Datum.

Routes to dispatch_core_chained for CHAINED mode; all other modes use dispatch_core. Both paths are defined in GpuDispatchCore.cpp.

Parameters
inputInput Datum to process.
ctxExecutionContext; CHAINED mode requires ChainedParams, CHAINED_INDIRECT requires ChainedIndirectParams, DEPENDENCY requires DependencyParams in parameters.
Exceptions
std::runtime_errorIf GPU initialisation fails.

Reimplemented in MayaFlux::Yantra::ShaderExecutionContext< InputType, OutputType >, and MayaFlux::Yantra::TextureExecutionContext.

Definition at line 60 of file GpuExecutionContext.hpp.

61 {
62 if (ctx.mode == ExecutionMode::DEPENDENCY) {
63 const auto& dependency_params = safe_variant_get_or_throw<DependencyParams>(ctx.parameters,
64 "GpuExecutionContext: DEPENDENCY mode requires DependencyParams");
65
66 if (dependency_params.async) {
67 output_type result;
68 result.set_metadata("gpu_fence", dispatch_core_dependency_async(dependency_params.stages));
69 return result;
70 }
71
72 dispatch_core_dependency(dependency_params.stages);
73 return output_type {};
74 }
75
76 if (!ensure_gpu_ready()) {
77 error<std::runtime_error>(
80 std::source_location::current(),
81 "GpuExecutionContext: GPU initialisation failed");
82 }
83
84 auto [ch_copies, structure_info] = extract_inputs(input);
85
86 GpuChannelResult raw;
87 switch (ctx.mode) {
89 raw = dispatch_core_chained(ch_copies, structure_info, ctx);
90 break;
92 raw = dispatch_core_chained_indirect(ch_copies, structure_info, ctx);
93 break;
94 default:
95 raw = dispatch_core(ch_copies, structure_info);
96 break;
97 }
98
99 return collect_gpu_outputs(raw, ch_copies, structure_info);
100 }
Core::GlobalInputConfig input
Definition Config.cpp:42
Portal::Graphics::FenceID dispatch_core_dependency_async(const std::vector< DependencyStage > &stages)
Non-blocking variant of dispatch_core_dependency.
GpuChannelResult dispatch_core(const std::vector< std::vector< double > > &channels, const DataStructureInfo &structure_info)
Full single-pass dispatch.
bool ensure_gpu_ready()
Ensure GPU resources are initialised.
void dispatch_core_dependency(const std::vector< DependencyStage > &stages)
Multi-pipeline dependency dispatch.
GpuChannelResult dispatch_core_chained(const std::vector< std::vector< double > > &channels, const DataStructureInfo &structure_info, const ExecutionContext &ctx)
Multi-pass (chained) dispatch.
GpuChannelResult dispatch_core_chained_indirect(const std::vector< std::vector< double > > &channels, const DataStructureInfo &structure_info, const ExecutionContext &ctx)
Multi-pass dispatch where a GPU-resident indirect buffer gates each pass's workgroup count instead of...
virtual output_type collect_gpu_outputs(const GpuChannelResult &raw, const std::vector< std::vector< double > > &channels, const DataStructureInfo &structure_info)
Reconstruct Datum<OutputType> from a GpuChannelResult.
virtual std::pair< std::vector< std::vector< double > >, DataStructureInfo > extract_inputs(const input_type &input)
Extract channel data and structure metadata from the input Datum.
@ BufferProcessing
Buffer processing (Buffers::BufferManager, processing chains)
@ Yantra
DSP algorithms, computational units, matrix operations, Grammar.
@ CHAINED
Part of a sequential chain.
@ DEPENDENCY
Part of dependency graph.
@ CHAINED_INDIRECT
Chained dispatch where a GPU-written indirect buffer gates each pass's workgroup count.
void set_metadata(const std::string &key, ValueType &&value)
Add or update metadata entry.
Definition DataIO.hpp:259

References MayaFlux::Journal::BufferProcessing, MayaFlux::Yantra::CHAINED, MayaFlux::Yantra::CHAINED_INDIRECT, MayaFlux::Yantra::GpuExecutionContext< InputType, OutputType >::collect_gpu_outputs(), MayaFlux::Yantra::DEPENDENCY, MayaFlux::Yantra::GpuDispatchCore::dispatch_core(), MayaFlux::Yantra::GpuDispatchCore::dispatch_core_chained(), MayaFlux::Yantra::GpuDispatchCore::dispatch_core_chained_indirect(), MayaFlux::Yantra::GpuDispatchCore::dispatch_core_dependency(), MayaFlux::Yantra::GpuDispatchCore::dispatch_core_dependency_async(), MayaFlux::Yantra::GpuDispatchCore::ensure_gpu_ready(), MayaFlux::Yantra::GpuExecutionContext< InputType, OutputType >::extract_inputs(), input, MayaFlux::Yantra::ExecutionContext::mode, MayaFlux::Yantra::ExecutionContext::parameters, MayaFlux::Yantra::Datum< T >::set_metadata(), and MayaFlux::Journal::Yantra.

Referenced by MayaFlux::Yantra::ShaderExecutionContext< InputType, OutputType >::execute().

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