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

◆ prepare_dependency()

GpuDispatchCore::DependencyPlan MayaFlux::Yantra::GpuDispatchCore::prepare_dependency ( const std::vector< DependencyStage > &  stages)
private

Definition at line 375 of file GpuDispatchCore.cpp.

376{
377 const GpuComputeConfig original_config = m_gpu_config;
378 const auto original_bindings = m_bindings;
379 const auto original_image_bindings = m_image_bindings;
380 const auto original_binding_data = m_binding_data;
381 const auto original_passthrough_bytes = m_passthrough_bytes;
382 const auto original_push_constants = m_push_constants;
383
384 DependencyPlan plan;
385 auto& keys = plan.keys;
386 auto& groups_per_key = plan.groups;
387 auto& pc_per_key = plan.push_constants;
388 auto& hazards_per_key = plan.hazards;
389 auto& indirect_per_key = plan.indirect;
390
391 keys.reserve(stages.size());
392 groups_per_key.reserve(stages.size());
393 pc_per_key.reserve(stages.size());
394 hazards_per_key.reserve(stages.size());
395 indirect_per_key.reserve(stages.size());
396
397 for (const auto& stage : stages) {
398 m_gpu_config = stage.config;
401 m_image_bindings.clear();
402 m_binding_data.clear();
403 m_passthrough_bytes.clear();
404 m_push_constants.clear();
405
406 stage.stage_fn(*this);
407
408 if (!ensure_gpu_ready()) {
409 error<std::runtime_error>(Journal::Component::Yantra,
411 std::source_location::current(),
412 "GpuDispatchCore: dispatch_core_dependency failed to initialise key '{}'",
413 stage.config.shader_path);
414 }
415
416 prepare_gpu_inputs({}, {});
417
419
420 keys.push_back(dispatch_key());
421 groups_per_key.push_back(stage.explicit_groups ? *stage.explicit_groups : calculate_dispatch_size(largest_binding_data_element_count(), {}));
422 pc_per_key.push_back(m_push_constants);
423 hazards_per_key.push_back(stage.hazard_fn ? stage.hazard_fn(*this) : std::vector<Portal::Graphics::HazardResource> {});
424
425 Portal::Graphics::IndirectDispatch indirect;
426 if (stage.indirect_groups) {
427 indirect.buffer = m_resources.shared_buffer_handle(stage.indirect_groups->set, stage.indirect_groups->binding).buffer;
428 indirect.offset = stage.indirect_groups->offset_bytes;
429 }
430 indirect_per_key.push_back(indirect);
431 }
432
433 m_gpu_config = original_config;
435 m_bindings = original_bindings;
436 m_image_bindings = original_image_bindings;
437 m_binding_data = original_binding_data;
438 m_passthrough_bytes = original_passthrough_bytes;
439 m_push_constants = original_push_constants;
440
441 return plan;
442}
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.
Portal::Graphics::GpuBufferHandle shared_buffer_handle(uint32_t set, size_t binding_index) const
Non-owning view of the shared buffer at (set, binding_index).
@ 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::Portal::Graphics::GpuBufferHandle::buffer, MayaFlux::Journal::BufferProcessing, calculate_dispatch_size(), declare_buffer_bindings(), dispatch_key(), ensure_gpu_ready(), MayaFlux::Yantra::GpuDispatchCore::DependencyPlan::groups, MayaFlux::Yantra::GpuDispatchCore::DependencyPlan::hazards, MayaFlux::Yantra::GpuDispatchCore::DependencyPlan::indirect, MayaFlux::Yantra::GpuDispatchCore::DependencyPlan::keys, largest_binding_data_element_count(), m_binding_data, m_bindings, m_gpu_config, m_image_bindings, m_passthrough_bytes, m_push_constants, m_resources, MayaFlux::Portal::Graphics::IndirectDispatch::offset, prepare_gpu_inputs(), MayaFlux::Yantra::GpuDispatchCore::DependencyPlan::push_constants, MayaFlux::Yantra::GpuResourceManager::shared_buffer_handle(), update_dispatch_key_cache(), and MayaFlux::Journal::Yantra.

Referenced by dispatch_core_dependency(), and dispatch_core_dependency_async().

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