MayaFlux 0.4.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches
GpuTransformer.hpp
Go to the documentation of this file.
1#pragma once
2
5
6namespace MayaFlux::Yantra {
7
8/**
9 * @class GpuTransformer
10 * @brief Concrete UniversalTransformer that dispatches entirely via a
11 * GpuExecutionContext. CPU path is a hard error.
12 *
13 * Use when no CPU fallback exists or is needed. Attach a configured
14 * GpuExecutionContext at construction. For operations where a CPU
15 * fallback is available, prefer attaching a GpuExecutionContext to
16 * an existing concrete transformer via set_gpu_backend() instead.
17 *
18 * @code
19 * auto op = std::make_shared<GpuTransformer<>>(
20 * std::make_shared<GpuExecutionContext<>>(
21 * GpuShaderConfig { "my_shader.comp", { 256, 1, 1 }, sizeof(MyPC) }));
22 * op->get_executor()->input(data).output(output_bytes).push(pc);
23 * pipeline->add_operation(op, "my_shader");
24 * @endcode
25 *
26 * @tparam InputType ComputeData type accepted.
27 * @tparam OutputType ComputeData type produced.
28 */
29template <ComputeData InputType = std::vector<Kakshya::DataVariant>,
30 ComputeData OutputType = InputType>
31class MAYAFLUX_API GpuTransformer : public UniversalTransformer<InputType, OutputType> {
32public:
35
36 /**
37 * @brief Construct with a configured GpuExecutionContext.
38 * @param executor Configured executor. Must not be null.
39 */
41 std::shared_ptr<GpuExecutionContext<InputType, OutputType>> executor)
42 {
43 assert(executor && "GpuTransformer: executor must not be null");
44 m_executor = executor;
45 this->set_gpu_backend(std::move(executor));
46 }
47
48 /**
49 * @brief Returns the attached GpuExecutionContext for further configuration.
50 */
51 [[nodiscard]] std::shared_ptr<GpuExecutionContext<InputType, OutputType>>
52 get_executor() const { return m_executor; }
53
54 [[nodiscard]] TransformationType get_transformation_type() const override
55 {
56 return TransformationType::CUSTOM;
57 }
58
59 [[nodiscard]] std::string get_transformer_name() const override
60 {
61 return "GpuTransformer";
62 }
63
64protected:
66 {
67 error<std::runtime_error>(
68 Journal::Component::Yantra,
69 Journal::Context::BufferProcessing,
70 std::source_location::current(),
71 "GpuTransformer: GPU unavailable and no CPU fallback provided");
72 }
73
74private:
75 std::shared_ptr<GpuExecutionContext<InputType, OutputType>> m_executor;
76};
77
78} // namespace MayaFlux::Yantra
Float Processing Guidelines.
Type-parameterised shell over GpuDispatchCore.
std::shared_ptr< GpuExecutionContext< InputType, OutputType > > get_executor() const
Returns the attached GpuExecutionContext for further configuration.
std::string get_transformer_name() const override
Get transformer-specific name (derived classes override this)
std::shared_ptr< GpuExecutionContext< InputType, OutputType > > m_executor
output_type transform_implementation(input_type &) override
Pure virtual transformation implementation - derived classes implement this.
GpuTransformer(std::shared_ptr< GpuExecutionContext< InputType, OutputType > > executor)
Construct with a configured GpuExecutionContext.
TransformationType get_transformation_type() const override
Gets the transformation type category for this transformer.
Concrete UniversalTransformer that dispatches entirely via a GpuExecutionContext.
Template-flexible transformer base with instance-defined I/O types.
TransformationType
Categories of transformation operations for discovery and organization.
Input/Output container for computation pipeline data flow with structure preservation.
Definition DataIO.hpp:24