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

◆ start()

Chimera MayaFlux::Kriya::ChimeraBuilder::start ( )

Start feeding every declared layer on the frame clock.

Returns
The running set, or an empty one if the buffer is null, no layer was declared, or more layers were declared than the buffer holds.

Definition at line 470 of file Chimera.cpp.

471{
472 Chimera set;
473
474 if (!m_buffer || m_layers.empty()) {
476 "ChimeraBuilder::start needs a buffer and at least one layer");
477 return set;
478 }
479
480 if (m_layers.size() > m_buffer->get_layer_count()) {
482 "ChimeraBuilder::start declared {} layers, the buffer holds {}",
483 m_layers.size(), m_buffer->get_layer_count());
484 return set;
485 }
486
487 if (!m_pipeline) {
489 "ChimeraBuilder::start needs a pipeline to feed the layers");
490 return set;
491 }
492
493 for (auto& layer : m_layers) {
494 if (!layer.piped) {
495 continue;
496 }
497
498 layer.ring = m_pipeline->get_graphics_stream();
499 if (!layer.ring) {
501 "ChimeraBuilder::start found no stream in the pipeline for from_pipeline");
502 return set;
503 }
504 }
505
506 auto state = std::make_shared<Chimera::State>();
507
508 state->buffer = m_buffer;
509 state->pipeline = m_pipeline;
510 state->layers = m_layers;
511 state->frame_rate = std::max(static_cast<double>(Vruta::s_registered_frame_rate), 1.0);
512
513 uint32_t index = 0;
514 for (const auto& layer : state->layers) {
515 m_buffer->set_weight(index, layer.level);
516 if (layer.fit) {
517 m_buffer->set_layer_fit(index, layer.fit);
518 }
519 if (layer.params) {
520 m_buffer->set_layer_params(index, *layer.params);
521 }
522 ++index;
523 }
524
525 if (m_render) {
526 m_buffer->setup_rendering(*m_render);
527 m_render.reset();
528 }
529
530 const std::weak_ptr<Chimera::State> weak = state;
532 [weak](Kakshya::DataVariant&, uint32_t cycle) {
533 if (const auto running = weak.lock()) {
534 Chimera::tick(*running, cycle);
535 }
536 },
538
539 for (const auto& action : m_actions) {
540 const auto cycles = static_cast<uint32_t>(std::max(std::round(action.seconds * state->frame_rate), 1.0));
541
542 auto timed = BufferOperation::dispatch_to(
543 [weak, run = action.run](Kakshya::DataVariant&, uint32_t cycle) {
544 const auto running = weak.lock();
545 if (!running || cycle == 0) {
546 return;
547 }
548
549 Chimera view;
550 view.m_state = running;
551 run(view);
552 },
554 timed.every_n_cycles(cycles);
555
556 m_pipeline >> std::move(timed);
557 }
558
559 m_pipeline->execute_frame_rate();
560
561 set.m_guard = std::shared_ptr<void>(nullptr, [state](void*) { state->halt(); });
562 set.m_state = std::move(state);
563 return set;
564}
#define MF_ERROR(comp, ctx,...)
uint32_t index
Definition VKDevice.cpp:122
BufferOperation & every_n_cycles(uint32_t n)
Set cycle interval for periodic execution.
static BufferOperation dispatch_to(OperationFunction handler, Buffers::ProcessingToken token=Buffers::ProcessingToken::AUDIO_BACKEND)
Create a dispatch operation for external processing.
ChimeraBuilder & params(const glm::vec4 &values)
Params for the layer in the buffer's per-layer data, such as placement.
Definition Chimera.cpp:458
std::optional< Portal::Graphics::RenderConfig > m_render
Definition Chimera.hpp:320
ChimeraBuilder & fit(Portal::Graphics::FitMode mode)
Fit frames of another extent into this layer in this way, instead of the buffer's.
Definition Chimera.cpp:452
std::vector< Action > m_actions
Definition Chimera.hpp:322
ChimeraBuilder & level(double weight)
Weight passed to the shader for the layer.
Definition Chimera.cpp:464
std::shared_ptr< Buffers::TextureArrayBuffer > m_buffer
Definition Chimera.hpp:318
ChimeraBuilder & layer()
Open the next layer.
Definition Chimera.cpp:354
std::shared_ptr< BufferPipeline > m_pipeline
Definition Chimera.hpp:319
std::vector< Chimera::Layer > m_layers
Definition Chimera.hpp:321
void run()
Definition main.cpp:21
@ GRAPHICS_BACKEND
Standard graphics processing backend configuration.
@ Configuration
Configuration and parameter updates.
@ Kriya
Automatable tasks and fluent scheduling api for Nodes and Buffers.
std::variant< std::vector< double >, std::vector< float >, std::vector< uint8_t >, std::vector< uint16_t >, std::vector< uint32_t >, std::vector< std::complex< float > >, std::vector< std::complex< double > >, std::vector< glm::vec2 >, std::vector< glm::vec3 >, std::vector< glm::vec4 >, std::vector< glm::mat4 > > DataVariant
Multi-type data storage for different precision needs.
Definition NDData.hpp:70
MAYAFLUX_API uint32_t s_registered_frame_rate
Definition Clock.cpp:10

References MayaFlux::Journal::Configuration, MayaFlux::Kriya::BufferOperation::dispatch_to(), MayaFlux::Kriya::BufferOperation::every_n_cycles(), fit(), MayaFlux::Buffers::GRAPHICS_BACKEND, index, MayaFlux::Journal::Kriya, layer(), level(), m_actions, m_buffer, m_layers, m_pipeline, m_render, MF_ERROR, params(), run(), and MayaFlux::Vruta::s_registered_frame_rate.

+ Here is the call graph for this function: