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

◆ for_each_stage()

void MayaFlux::Yantra::GpuDispatchCore::for_each_stage ( const std::vector< DependencyStage > & stages,
const std::function< void(const std::array< uint32_t, 3 > &, const Portal::Graphics::IndirectDispatch &)> & on_stage )
private

Stage each of stages in turn and hand its dispatch key, groups, push constants and indirect source to on_stage, then restore the context's own config, bindings and staged data.

Definition at line 460 of file GpuDispatchCore.cpp.

462{
463 const GpuComputeConfig original_config = m_gpu_config;
464 const auto original_bindings = m_bindings;
465 const auto original_image_bindings = m_image_bindings;
466 const auto original_binding_data = m_binding_data;
467 const auto original_passthrough_bytes = m_passthrough_bytes;
468 const auto original_push_constants = m_push_constants;
469
470 for (const auto& stage : stages) {
471 m_gpu_config = stage.config;
473 m_image_bindings.clear();
474 m_binding_data.clear();
475 m_passthrough_bytes.clear();
476 m_push_constants.clear();
478
479 stage.stage_fn(*this);
480
481 if (!ensure_gpu_ready()) {
482 error<std::runtime_error>(Journal::Component::Yantra,
484 std::source_location::current(),
485 "GpuDispatchCore: failed to initialise key '{}' for a dependency stage",
486 stage.config.shader_path);
487 }
488
489 prepare_gpu_inputs({}, {});
490
492
493 Portal::Graphics::IndirectDispatch indirect;
494 if (stage.indirect_groups) {
495 indirect.buffer = m_resources.shared_buffer_handle(stage.indirect_groups->set, stage.indirect_groups->binding).buffer;
496 indirect.offset = stage.indirect_groups->offset_bytes;
497 }
498
499 on_stage(stage.explicit_groups ? *stage.explicit_groups : calculate_dispatch_size(m_prepared_elements, {}), indirect);
500 }
501
502 m_gpu_config = original_config;
504 m_bindings = original_bindings;
505 m_image_bindings = original_image_bindings;
506 m_binding_data = original_binding_data;
507 m_passthrough_bytes = original_passthrough_bytes;
508 m_push_constants = original_push_constants;
509}
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.
std::vector< GpuBufferBinding > declared_bindings() const
declare_buffer_bindings less the bindings the current unit's layout does not hold.
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
size_t m_prepared_elements
Element count of the dispatch most recently prepared.
@ BufferProcessing
Buffer processing (Buffers::BufferManager, processing chains).
@ Yantra
DSP algorithms, computational units, matrix operations, Grammar.
Portal::Graphics::GpuComputeConfig GpuComputeConfig

References bind_all_descriptors(), MayaFlux::Portal::Graphics::IndirectDispatch::buffer, MayaFlux::Journal::BufferProcessing, calculate_dispatch_size(), declared_bindings(), ensure_gpu_ready(), m_binding_data, m_bindings, m_gpu_config, m_image_bindings, m_passthrough_bytes, m_prepared_elements, m_push_constants, m_resources, MayaFlux::Portal::Graphics::IndirectDispatch::offset, prepare_gpu_inputs(), update_dispatch_key_cache(), and MayaFlux::Journal::Yantra.

Referenced by record_stages().

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