21 : m_scheduler(scheduler)
22 , m_buffer_manager(buffer_manager)
28 for (
auto& [layer, records] :
m_records) {
29 for (
auto& [
id, rec] : records) {
36 for (
const auto&
name : tasks)
47 std::shared_ptr<Nodes::Node> node,
48 std::function<
float(
double)> project)
51 ? std::function<float()>([n = std::move(node), p = std::move(project)] {
52 return p(n->get_last_output());
54 : std::function<float()>([n = std::move(node)] {
55 return static_cast<float>(n->get_last_output());
71 "Bridge::bind: unknown element id {}", ref.second);
78 rec->inbound_task =
name;
80 auto writer = rec->writer;
83 std::function<float()>
src,
86 while (!p.should_terminate) {
93 std::make_shared<Vruta::GraphicsRoutine>(
94 routine(
m_scheduler, std::move(source), std::move(writer))),
104 const std::shared_ptr<Buffers::VKBuffer>& target_buffer,
105 const std::string& shader_path,
112 "Bridge::write: unknown element id {}", ref.second);
116 if (!rec->bindings) {
117 rec->bindings = std::make_shared<Buffers::FormaBindingsProcessor>(shader_path);
122 auto binding_name = std::to_string(ref.second) +
"_pc_" + std::to_string(
offset);
123 rec->bindings->bind_push_constant(binding_name, rec->reader,
offset,
size);
124 rec->binding_names.push_back(std::move(binding_name));
129 const std::shared_ptr<Buffers::VKBuffer>& target_buffer,
130 const std::string& shader_path,
137 "Bridge::write: unknown element id {}", ref.second);
141 if (!rec->bindings) {
142 rec->bindings = std::make_shared<Buffers::FormaBindingsProcessor>(shader_path);
147 auto binding_name = std::to_string(ref.second) +
"_pc_" + std::to_string(
offset);
148 if (rec->typed_reader && rec->typed_format ==
format) {
149 rec->bindings->bind_typed_push_constant(binding_name, rec->typed_reader,
offset);
151 rec->bindings->bind_push_constant(binding_name, rec->reader,
offset,
format);
153 rec->binding_names.push_back(std::move(binding_name));
158 const std::shared_ptr<Buffers::VKBuffer>& target_buffer,
159 const std::string& shader_path,
160 const std::string& descriptor_name,
161 uint32_t binding_index,
168 "Bridge::write: unknown element id {}", ref.second);
172 if (!rec->bindings) {
173 rec->bindings = std::make_shared<Buffers::FormaBindingsProcessor>(shader_path);
178 auto binding_name = descriptor_name +
"_" + std::to_string(ref.second);
179 rec->bindings->bind_descriptor(binding_name, rec->reader, descriptor_name, binding_index, set, role);
180 rec->binding_names.push_back(std::move(binding_name));
188 "Bridge::write: unknown element id {}", ref.second);
193 rec->outbound_tasks.push_back(
name);
195 auto bulk = rec->bulk_reader;
196 auto reader = rec->reader;
200 std::function<std::vector<float>()>
b,
201 std::shared_ptr<Buffers::AudioWriteProcessor> proc)
204 while (!p.should_terminate) {
205 proc->set_data(std::span<const float>(
b()));
210 std::make_shared<Vruta::GraphicsRoutine>(
211 routine(
m_scheduler, std::move(bulk), std::move(target))),
215 std::function<float()> r,
216 std::shared_ptr<Buffers::AudioWriteProcessor> proc)
219 while (!p.should_terminate) {
220 proc->set_data(std::vector<double> {
static_cast<double>(r()) });
225 std::make_shared<Vruta::GraphicsRoutine>(
226 routine(
m_scheduler, std::move(reader), std::move(target))),
236 "Bridge::write: unknown element id {}", ref.second);
241 rec->outbound_tasks.push_back(
name);
243 auto bulk = rec->bulk_reader;
244 auto reader = rec->reader;
248 std::function<std::vector<float>()>
b,
249 std::shared_ptr<Buffers::DataWriteProcessor> proc)
252 while (!p.should_terminate) {
258 std::make_shared<Vruta::GraphicsRoutine>(
259 routine(
m_scheduler, std::move(bulk), std::move(target))),
263 std::function<float()> r,
264 std::shared_ptr<Buffers::DataWriteProcessor> proc)
267 while (!p.should_terminate) {
268 proc->set_data(std::vector<Kakshya::DataVariant> {
Kakshya::DataVariant { std::vector<float> { r() } } });
273 std::make_shared<Vruta::GraphicsRoutine>(
274 routine(
m_scheduler, std::move(reader), std::move(target))),
284 "Bridge::write: unknown element id {}", ref.second);
289 rec->outbound_tasks.push_back(
name);
291 auto reader = rec->reader;
294 std::function<float()> r,
295 std::shared_ptr<Nodes::Constant> n)
298 while (!p.should_terminate) {
299 n->set_constant(
static_cast<double>(r()));
305 std::make_shared<Vruta::GraphicsRoutine>(
306 routine(
m_scheduler, std::move(reader), std::move(node))),
315 "Bridge::write: unknown element id {}", ref.second);
320 rec->outbound_tasks.push_back(
name);
322 auto bulk = rec->bulk_reader;
323 auto reader = rec->reader;
327 std::function<std::vector<float>()>
b,
328 std::function<void(std::span<const float>)> s)
331 while (!p.should_terminate) {
338 std::make_shared<Vruta::GraphicsRoutine>(
339 routine(
m_scheduler, std::move(bulk), std::move(sink))),
343 std::function<float()> r,
344 std::function<void(std::span<const float>)> s)
348 while (!p.should_terminate) {
350 s(std::span<const float> { &val, 1 });
355 std::make_shared<Vruta::GraphicsRoutine>(
356 routine(
m_scheduler, std::move(reader), std::move(sink))),
364 std::function<
void(std::span<const float>)> sink)
366 std::vector<std::function<float()>> readers;
367 readers.reserve(states.size());
368 for (
const auto& state : states) {
369 readers.emplace_back([state] {
396 for (
const auto&
name : it->second)
408 const auto layer_it =
m_records.find(ref.first);
412 const auto it = layer_it->second.find(ref.second);
413 return it == layer_it->second.end() ? nullptr : &it->second;
418 return "forma_bridge_" + std::to_string(
id) +
"_" + suffix
424 return "forma_bridge_layer_" + std::string(suffix)
453 const ElementRef ref { layer.weak_from_this(),
id };
456 rec->outbound_tasks.push_back(
name);
461 while (!p.should_terminate) {
468 std::make_shared<Vruta::GraphicsRoutine>(
475 std::vector<std::function<
float()>> readers,
476 std::function<
void(std::span<const float>)> sink)
482 std::vector<std::function<float()>> sources,
483 std::function<void(std::span<const float>)> target)
486 std::vector<float>
values(sources.size());
487 while (!p.should_terminate) {
488 for (
size_t i = 0; i < sources.size(); ++i)
496 std::make_shared<Vruta::GraphicsRoutine>(
497 routine(
m_scheduler, std::move(readers), std::move(sink))),
514 while (!p.should_terminate) {
521 std::make_shared<Vruta::GraphicsRoutine>(
#define MF_ERROR(comp, ctx,...)
std::vector< std::byte > values
void add_processor(const std::shared_ptr< BufferProcessor > &processor, const std::shared_ptr< Buffer > &buffer, ProcessingToken token=ProcessingToken::AUDIO_BACKEND)
Adds a processor to a buffer.
Token-based multimodal buffer management system for unified data stream processing.
A C++20 coroutine-based graphics processing task with frame-accurate timing.
void add_task(const std::shared_ptr< Routine > &routine, const std::string &name="", bool initialize=false)
Add a routine to the scheduler based on its processing token.
bool cancel_task(const std::shared_ptr< Routine > &routine)
Cancels and removes a task from the scheduler.
Token-based multimodal task scheduling system for unified coroutine processing.
@ GRAPHICS_BACKEND
Standard graphics processing backend configuration.
@ Init
Engine/subsystem initialization.
@ Portal
High-level user-facing API layer.
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.
GpuDataFormat
GPU data formats with explicit precision levels.
DescriptorRole
Semantic descriptor type — maps to Vulkan descriptor types internally.
graphics-domain awaiter for frame-accurate timing delays
Templated awaitable for accessing a coroutine's promise object.