MayaFlux 1.0.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches
MayaFlux::Evolve Class Reference

Sets a system going from a config: state that persists, a rule that advances it every cycle, and rendering attached. More...

#include <Evolve.hpp>

+ Collaboration diagram for MayaFlux::Evolve:

Classes

struct  Impl
 Wiring sequences behind Evolve. More...
 

Public Types

using FieldBinder = std::function< void(const std::shared_ptr< Nodes::Network::GpuFieldOperator > &)>
 Callable that binds fields on the GpuFieldOperator before it is wired.
 
using RenderConfig = Buffers::VKBuffer::RenderConfig
 Render target and pipeline overrides, shared by every family.
 

Public Member Functions

 Evolve ()
 
 Evolve (const Evolve &)=delete
 
 Evolve (Evolve &&) noexcept
 
auto operator() (const Buffers::RelaxationGridBuffer::GridConfig &config, const RenderConfig &render) -> std::shared_ptr< Buffers::RelaxationGridBuffer >
 Build a relaxation grid, register it and attach rendering.
 
template<typename Seed >
requires std::invocable<Seed&, uint32_t, uint32_t> && GridCellData<std::remove_cvref_t<std::invoke_result_t<Seed&, uint32_t, uint32_t>>>
auto operator() (const Buffers::RelaxationGridBuffer::GridConfig &config, Seed &&seed, const RenderConfig &render) -> std::shared_ptr< Buffers::RelaxationGridBuffer >
 Build a relaxation grid seeded from a host callable.
 
auto operator() (const std::shared_ptr< Buffers::VolumeGridBuffer > &volume, const Buffers::VolumeGridBuffer::FlowConfig &flow, const RenderConfig &render) -> std::shared_ptr< Buffers::VolumeGridBuffer >
 Set the incompressible flow stages going over a volume and attach rendering.
 
template<typename Network >
requires std::is_base_of_v<Nodes::Network::NodeNetwork, Network>
auto operator() (const std::shared_ptr< Network > &network, const Nodes::Network::SpatialFieldConfig &spatial, const FieldBinder &bind, const RenderConfig &render) -> std::shared_ptr< Network >
 Drive a network's vertices with fields and spatial stages, and attach rendering.
 
Evolve & operator= (const Evolve &)=delete
 
Evolve & operator= (Evolve &&) noexcept
 
 ~Evolve ()
 

Private Member Functions

bool build_field (const std::shared_ptr< Nodes::Network::NodeNetwork > &network, const Nodes::Network::SpatialFieldConfig &spatial, const FieldBinder &bind, const RenderConfig &render)
 Create the field operator, bind, register the network and its buffer, and render.
 
bool build_flow (const std::shared_ptr< Buffers::VolumeGridBuffer > &volume, const Buffers::VolumeGridBuffer::FlowConfig &flow, const RenderConfig &render)
 Resolve refs, register, build the flow stages and render a volume.
 
std::shared_ptr< Buffers::RelaxationGridBuffer > build_grid (const Buffers::RelaxationGridBuffer::GridConfig &config, const RenderConfig &render, const std::vector< std::byte > &seed, size_t seed_stride)
 Construct, optionally seed, register and render a relaxation grid.
 

Private Attributes

std::unique_ptr< Impl > m_impl
 

Detailed Description

Sets a system going from a config: state that persists, a rule that advances it every cycle, and rendering attached.

Owned by Creator as a member. Each call performs the whole sequence its arguments imply and returns the real object it built or was handed, so nothing is left to attach afterwards. The returned object carries its own processors and advances on its own each cycle. The call sets it going and does not step it.

An evolving system is not a type here. It is a config handed to a class, and the sequence that class needs is what this performs. The name says nothing about a medium: it covers whatever the config's class advances, which today is three families, selected by the config they consume:

  • RelaxationGridBuffer::GridConfig builds a grid, seeds it, registers it in the graphics domain and attaches rendering.
  • VolumeGridBuffer::FlowConfig runs the incompressible flow stages over a volume. Required refs left unnamed are declared under default names, and any named ref the volume does not yet hold is declared.
  • Nodes::Network::SpatialFieldConfig drives a network's vertices through a GpuFieldOperator, reading its vertex layout from the network's own primary operator.

All three route to the graphics domain and every call requires RenderConfig::target_window. There is no default window. A null target logs an error and returns nullptr, and nothing is registered. Exceptions thrown by the classes' constructors propagate.

Nothing here is realtime safe. Call from the thread that constructs the objects.

auto life = vega.evolve(
.width = 256,
.height = 256,
.rule = { .state = Kakshya::GpuDataFormat::UINT32, .shader = "relax_conway_rule.comp.spv" },
.emit = { .state = Kakshya::GpuDataFormat::UINT32, .shader = "relax_vertex_emit.comp.spv" },
},
[](uint32_t x, uint32_t y) { return (x ^ y) % 7U == 0U ? 1U : 0U; },
{ .target_window = window });
auto volume = std::make_shared<Buffers::VolumeGridBuffer>(
lattice,
Buffers::VolumeGridBuffer::SurfaceConfig { "density", { 48, 48, 48 }, 0.5F });
auto density = volume->declare_scalar("density");
auto heat = volume->declare_scalar("heat");
volume,
{ .carried = { { density, 0.99F } },
.buoyancy = Buffers::VolumeGridBuffer::FlowConfig::Buoyancy { .temperature = heat, .density = density } },
{ .target_window = window });
auto particles = vega.ParticleNetwork(50000, glm::vec3(-1.0F), glm::vec3(1.0F), distribution);
particles,
{ .absorb_radius = 0.05F },
[](const auto& field) { field->bind(Nodes::Network::FieldTarget::POSITION, swirl); },
{ .target_window = window });
std::weak_ptr< Core::Window > window
Definition Picker.cpp:23
Evolve evolve
Sets a system going from a config: state that persists, a rule that advances it every cycle,...
Definition Creator.hpp:133
Creator vega
Global Creator instance.
Definition Creator.cpp:28
Arrangement of a relaxation grid: extent, the update rule, the emit stage that draws it,...

Definition at line 92 of file Evolve.hpp.


The documentation for this class was generated from the following files: