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

◆ word_pair_map_stage() [2/3]

DependencyStage MayaFlux::Yantra::word_pair_map_stage ( WordPairExecutionContext & context,
const GpuComputeConfig & config,
Portal::Graphics::WordPairOp op,
size_t count,
uint32_t workgroup = 256 )
inlinenodiscard

The stage that applies the operation to count elements whose operands are already on the device.

The operands are whatever the context's bindings resolve to: shared buffers of the context, or buffers imported from another context with import_shared. Nothing is staged from the host. Give the context that owns the operands and this one the same recording, and record the owner's stage first.

producer.ensure_shared_buffer(0, 2, count, GpuBufferBinding::ElementType::VEC2_U32);
consumer.import_shared(0, 0, producer, 0, 2, GpuBufferBinding::ElementType::VEC2_U32);
producer.record_stages({ word_pair_map_stage(producer, product_config, WordPairOp::Mul, a, b) });
consumer.record_stages({ word_pair_map_stage(consumer, root_config, WordPairOp::Sqrt, count) });
const auto roots = consumer.download_words(1, count);
DependencyStage word_pair_map_stage(WordPairExecutionContext &context, const GpuComputeConfig &config, Portal::Graphics::WordPairOp op, size_t count, uint32_t workgroup=256)
The stage that applies the operation to count elements whose operands are already on the device.
Parameters
contextContext built with config.
configConfig of the spec the context was built from.
opOperation of the spec.
countElements to compute. The operand buffers must hold at least this many.
workgroupWorkgroup size of the spec.

Definition at line 86 of file WordPairMap.hpp.

89{
90 const uint32_t result_binding = word_pair_unary(op) ? 1U : 2U;
91 const std::array<uint32_t, 1> push { static_cast<uint32_t>(count) };
92 const uint32_t groups = std::max<uint32_t>(1U, static_cast<uint32_t>((count + workgroup - 1) / workgroup));
93
94 return DependencyStage {
95 .config = config,
96 .stage_fn = [&context, count, result_binding, element_bytes = word_pair_result_bytes(op), push](GpuDispatchCore&) {
97 if (!context.shared_buffer_info(0, result_binding)) {
98 context.set_output_size(result_binding, count * element_bytes);
99 }
100 context.set_push_constants(push);
101 },
102 .explicit_groups = std::array<uint32_t, 3> { groups, 1U, 1U },
103 };
104}
std::optional< SharedBufferInfo > shared_buffer_info(uint32_t set, size_t binding_index) const
What the shared buffer at (set, binding_index) declares, or nothing when absent.
void set_output_size(size_t index, size_t byte_size)
Declare the byte capacity of an output binding independently of input data.
void set_push_constants(const void *data, size_t bytes)
Set push constant data from a raw byte pointer.
constexpr size_t word_pair_result_bytes(Portal::Graphics::WordPairOp op) noexcept
Bytes of one result element: a word pair, or a float32 for ToFloat32.
constexpr bool word_pair_unary(Portal::Graphics::WordPairOp op) noexcept
True for an operation that takes no second operand.

References MayaFlux::Yantra::GpuDispatchCore::set_output_size(), MayaFlux::Yantra::GpuDispatchCore::set_push_constants(), MayaFlux::Yantra::GpuDispatchCore::shared_buffer_info(), word_pair_result_bytes(), and word_pair_unary().

Referenced by word_pair_map_stage(), and word_pair_map_stage().

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