MayaFlux 0.5.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 113 of file GpuExecutionContext.hpp.

114 {
115 auto info = OperationHelper::get_structure_info(const_cast<input_type&>(input));
116
117 const std::type_index native_type = [&]() -> std::type_index {
118 if constexpr (std::is_same_v<
119 std::decay_t<decltype(input.data)>,
120 std::shared_ptr<Kakshya::SignalSourceContainer>>) {
121 if (input.data)
122 return input.data->value_element_type();
123 } else if constexpr (std::is_same_v<
124 std::decay_t<decltype(input.data)>,
125 std::vector<Kakshya::DataVariant>>) {
126 if (!input.data.empty())
127 return Kakshya::FrameView(OperationHelper::extract_native_data(input.data[0])).element_type();
128 }
129 return typeid(double);
130 }();
131
132 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);
133
134 if (is_native_non_double) {
135 if constexpr (std::is_same_v<
136 std::decay_t<decltype(input.data)>,
137 std::vector<Kakshya::DataVariant>>) {
139 } else if constexpr (std::is_same_v<
140 std::decay_t<decltype(input.data)>,
141 std::shared_ptr<Kakshya::SignalSourceContainer>>) {
142 flatten_native_variants_to_staging(input.data->get_data(), info);
143 }
144 return { {}, std::move(info) };
145 }
146
147 auto [spans, double_info] = OperationHelper::extract_structured_double(
148 const_cast<input_type&>(input));
149
150 std::vector<std::vector<double>> channels(spans.size());
151 for (size_t c = 0; c < spans.size(); ++c)
152 channels[c].assign(spans[c].begin(), spans[c].end());
153 return { std::move(channels), std::move(double_info) };
154 }
Core::GlobalInputConfig input
Definition Config.cpp:38
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 DataStructureInfo get_structure_info(T &compute_data)
Populate DataStructureInfo from a Datum without extracting spans.
static Kakshya::DataSpanVariant extract_native_data(const Kakshya::DataVariant &variant)
Extract a single DataVariant as a type-erased span without conversion.
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 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: