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

◆ dispatch_core_dependency()

void MayaFlux::Yantra::GpuDispatchCore::dispatch_core_dependency ( const std::vector< DependencyStage > &  stages)
protected

Multi-pipeline dependency dispatch.

For each stage, in order: applies its shader config (swap_shader equivalent), invokes stage_fn to perform whatever staging that stage needs, ensures its GpuResourceManager unit exists, binds its descriptors, invokes hazard_fn to resolve hazard resources now that this stage's data exists, then accumulates a Portal::Graphics::ComputeStage. After every stage is prepared, records and submits the full sequence in one command buffer via GpuResourceManager::dispatch_sequence.

Restores the context's original shader config, bindings, and staged data after the sequence runs, so a subsequent unrelated dispatch_core call on this context is unaffected.

Parameters
stagesOrdered list of stage descriptions.

Definition at line 358 of file GpuDispatchCore.cpp.

359{
360 const GpuComputeConfig original_config = m_gpu_config;
361 const auto original_bindings = m_bindings;
362 const auto original_image_bindings = m_image_bindings;
363 const auto original_binding_data = m_binding_data;
364 const auto original_passthrough_bytes = m_passthrough_bytes;
365 const auto original_push_constants = m_push_constants;
366
367 std::vector<std::string> keys;
368 std::vector<std::array<uint32_t, 3>> groups_per_key;
369 std::vector<std::vector<uint8_t>> pc_per_key;
370 std::vector<std::vector<Portal::Graphics::HazardResource>> hazards_per_key;
371
372 keys.reserve(stages.size());
373 groups_per_key.reserve(stages.size());
374 pc_per_key.reserve(stages.size());
375 hazards_per_key.reserve(stages.size());
376
377 for (const auto& stage : stages) {
378 m_gpu_config = stage.config;
381 m_image_bindings.clear();
382 m_binding_data.clear();
383 m_passthrough_bytes.clear();
384 m_push_constants.clear();
385
386 stage.stage_fn(*this);
387
388 if (!ensure_gpu_ready()) {
389 error<std::runtime_error>(Journal::Component::Yantra,
391 std::source_location::current(),
392 "GpuDispatchCore: dispatch_core_dependency failed to initialise key '{}'",
393 stage.config.shader_path);
394 }
395
396 prepare_gpu_inputs({}, {});
397
399
400 keys.push_back(dispatch_key());
401 groups_per_key.push_back(stage.explicit_groups ? *stage.explicit_groups : calculate_dispatch_size(largest_binding_data_element_count(), {}));
402 pc_per_key.push_back(m_push_constants);
403 hazards_per_key.push_back(stage.hazard_fn ? stage.hazard_fn(*this) : std::vector<Portal::Graphics::HazardResource> {});
404 }
405
406 m_resources.dispatch_sequence(keys, groups_per_key, pc_per_key, hazards_per_key);
407
408 m_gpu_config = original_config;
410 m_bindings = original_bindings;
411 m_image_bindings = original_image_bindings;
412 m_binding_data = original_binding_data;
413 m_passthrough_bytes = original_passthrough_bytes;
414 m_push_constants = original_push_constants;
415}
std::vector< ImageBinding > m_image_bindings
virtual std::array< uint32_t, 3 > calculate_dispatch_size(size_t total_elements, const DataStructureInfo &structure_info) const
Calculate workgroup dispatch counts from structure dimensions.
const std::string & dispatch_key() const
The key used for this context's GpuResourceManager unit.
std::vector< uint8_t > m_push_constants
std::vector< std::vector< uint8_t > > m_binding_data
std::vector< GpuBufferBinding > m_bindings
bool ensure_gpu_ready()
Ensure GPU resources are initialised.
virtual void prepare_gpu_inputs(const std::vector< std::vector< double > > &channels, const DataStructureInfo &structure_info)
Marshal channel data into GPU input buffers.
std::vector< std::vector< uint8_t > > m_passthrough_bytes
virtual std::vector< GpuBufferBinding > declare_buffer_bindings() const
Declare the storage buffers the shader expects.
void dispatch_sequence(const std::vector< std::string > &keys, const std::vector< std::array< uint32_t, 3 > > &groups_per_key, const std::vector< std::vector< uint8_t > > &push_constants_per_key, const std::vector< std::vector< Portal::Graphics::HazardResource > > &hazards_per_key)
Record a dispatch for each requested key into one command buffer via ComputePress::record_sequence,...
@ BufferProcessing
Buffer processing (Buffers::BufferManager, processing chains)
@ Yantra
DSP algorithms, computational units, matrix operations, Grammar.
Portal::Graphics::GpuComputeConfig GpuComputeConfig

References bind_all_descriptors(), MayaFlux::Journal::BufferProcessing, calculate_dispatch_size(), declare_buffer_bindings(), dispatch_key(), MayaFlux::Yantra::GpuResourceManager::dispatch_sequence(), ensure_gpu_ready(), largest_binding_data_element_count(), m_binding_data, m_bindings, m_gpu_config, m_image_bindings, m_passthrough_bytes, m_push_constants, m_resources, prepare_gpu_inputs(), update_dispatch_key_cache(), and MayaFlux::Journal::Yantra.

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

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