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

◆ extract_inputs()

template<ComputeData InputType = std::vector<Kakshya::DataVariant>, ComputeData OutputType = InputType>
virtual std::pair< std::vector< std::vector< double > >, DataStructureInfo > MayaFlux::Yantra::GpuExecutionContext< InputType, OutputType >::extract_inputs ( const input_type &  input)
inlineprotectedvirtual

Extract channel data and structure metadata from the input Datum.

Calls extract_structured_native first to obtain native-typed spans without any conversion, then resolves the native element type from the first span's active DataSpanVariant alternative (which is already determined by visiting the source variants – no separate original_type inspection needed).

  • float / uint8_t / uint16_t / uint32_t: stages raw bytes natively via flatten_native_variants_to_staging. Returns ({}, structure_info).
  • double / complex / anything else: converts spans to vector<vector<double>> for the standard double staging path. Unchanged from previous behaviour.

Override to return ({}, {}) when channel extraction is not needed (e.g. image-only shaders that stage via on_before_gpu_dispatch).

Reimplemented in MayaFlux::Yantra::TextureExecutionContext.

Definition at line 120 of file GpuExecutionContext.hpp.

121 {
122 auto info = OperationHelper::get_structure_info(const_cast<input_type&>(input));
123
124 const std::type_index native_type = [&]() -> std::type_index {
125 if constexpr (std::is_same_v<
126 std::decay_t<decltype(input.data)>,
127 std::shared_ptr<Kakshya::SignalSourceContainer>>) {
128 if (input.data)
129 return input.data->value_element_type();
130 } else if constexpr (std::is_same_v<
131 std::decay_t<decltype(input.data)>,
132 std::vector<Kakshya::DataVariant>>) {
133 if (!input.data.empty())
134 return Kakshya::FrameView(OperationHelper::extract_native_data(input.data[0])).element_type();
135 }
136 return typeid(double);
137 }();
138
139 const bool is_native_non_double = native_type == typeid(float) || native_type == typeid(uint8_t) || native_type == typeid(uint16_t) || native_type == typeid(uint32_t);
140
141 if (is_native_non_double) {
142 if constexpr (std::is_same_v<
143 std::decay_t<decltype(input.data)>,
144 std::vector<Kakshya::DataVariant>>) {
146 } else if constexpr (std::is_same_v<
147 std::decay_t<decltype(input.data)>,
148 std::shared_ptr<Kakshya::SignalSourceContainer>>) {
149 flatten_native_variants_to_staging(input.data->get_data(), info);
150 }
151 return { {}, std::move(info) };
152 }
153
154 auto [spans, double_info] = OperationHelper::extract_structured_double(
155 const_cast<input_type&>(input));
156
157 std::vector<std::vector<double>> channels(spans.size());
158 for (size_t c = 0; c < spans.size(); ++c)
159 channels[c].assign(spans[c].begin(), spans[c].end());
160 return { std::move(channels), std::move(double_info) };
161 }
Core::GlobalInputConfig input
Definition Config.cpp:42
uint32_t channels
void flatten_native_variants_to_staging(const std::vector< Kakshya::DataVariant > &variants, const DataStructureInfo &structure_info)
Flatten native-typed DataVariant channels into m_native_staging_bytes without any conversion.
static Kakshya::DataSpanVariant extract_native_data(const Kakshya::DataVariant &variant)
Extract a single DataVariant as a type-erased span without conversion.
static DataStructureInfo get_structure_info(const T &compute_data)
Populate DataStructureInfo from a Datum without extracting spans.
static std::tuple< std::vector< std::span< double > >, DataStructureInfo > extract_structured_double(T &compute_data)
Extract structured double data from Datum container or direct ComputeData with automatic container ha...

References channels, MayaFlux::Yantra::OperationHelper::extract_native_data(), MayaFlux::Yantra::OperationHelper::extract_structured_double(), MayaFlux::Yantra::GpuDispatchCore::flatten_native_variants_to_staging(), MayaFlux::Yantra::OperationHelper::get_structure_info(), and input.

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

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