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

◆ read_output()

template<ComputeData InputType = std::vector<Kakshya::DataVariant>, ComputeData OutputType = InputType>
template<typename T >
static std::vector< T > MayaFlux::Yantra::ShaderExecutionContext< InputType, OutputType >::read_output ( const Datum< std::vector< Kakshya::DataVariant > > &  result,
size_t  binding_index 
)
inlinestatic

Read a typed output buffer from a pipeline result Datum.

Replaces the manual any_cast + reinterpret_cast pattern at call sites. Copies the raw bytes from metadata into a typed vector.

Template Parameters
TElement type to interpret the buffer as.
Parameters
resultDatum returned by ComputationPipeline::process or ComputeOperation::apply_operation.
binding_indexBinding index matching the OUTPUT or INPUT_OUTPUT declaration.
Returns
Vector of T with element count derived from raw byte size.
Eigen::Index count
Concrete GpuExecutionContext for a single fixed shader with fixed bindings.

Definition at line 299 of file ShaderExecutionContext.hpp.

302 {
303 const auto key = "gpu_output_" + std::to_string(binding_index);
304
305 if (!result.metadata.contains(key)) {
306 error<std::runtime_error>(Journal::Component::Yantra, Journal::Context::Runtime,
307 std::source_location::current(),
308 "read_output: metadata key '{}' not found", key);
309 }
310
311 const auto& raw = safe_any_cast_or_throw<std::vector<uint8_t>>(result.metadata.at(key));
312 const size_t count = raw.size() / sizeof(T);
313 std::vector<T> out(count);
314 std::memcpy(out.data(), raw.data(), count * sizeof(T));
315 return out;
316 }
@ Runtime
General runtime operations (default fallback)
@ Yantra
DSP algorithms, computational units, matrix operations, Grammar.
std::unordered_map< std::string, std::any > metadata
Associated metadata.
Definition DataIO.hpp:28

References count.