MayaFlux 0.5.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches
MayaFlux::Nodes::Network::GpuFieldOperator Class Reference

Chain operator that declares Tendency field deformation as a compute shader rather than evaluating it on the CPU. More...

#include <GpuFieldOperator.hpp>

+ Inheritance diagram for MayaFlux::Nodes::Network::GpuFieldOperator:
+ Collaboration diagram for MayaFlux::Nodes::Network::GpuFieldOperator:

Classes

struct  Binding
 One target and the field driving it. More...
 

Public Member Functions

void bind (FieldTarget target, const Kinesis::DualSpatialField &field, std::optional< uint32_t > cluster=std::nullopt)
 Bind a scalar field.
 
void bind (FieldTarget target, const Kinesis::DualUVField &field, std::optional< uint32_t > cluster=std::nullopt)
 Bind a two-component field.
 
void bind (FieldTarget target, const Kinesis::DualVectorField &field, std::optional< uint32_t > cluster=std::nullopt)
 Bind a three-component field to one or more vec3 targets.
 
void bind (FieldTarget target, const Kinesis::TemporalSpatialField &field, std::optional< uint32_t > cluster=std::nullopt)
 Bind a scalar field of position and time.
 
void bind (FieldTarget target, const Kinesis::TemporalUVField &field, std::optional< uint32_t > cluster=std::nullopt)
 Bind a two-component field of position and time.
 
void bind (FieldTarget target, const Kinesis::TemporalVectorField &field, std::optional< uint32_t > cluster=std::nullopt)
 Bind a three-component field of position and time.
 
size_t binding_count () const
 Number of bound fields.
 
std::optional< Portal::Graphics::ShaderSpecbuild_spec () const
 Assemble the compute spec for the current bindings.
 
bool demands_full_vertex_restore () const override
 True once at least one field is bound: the VertexFieldProcessor this operator drives writes pos += f in place, so the geometry producer must keep restoring the reference vertices every frame.
 
const SpatialFieldConfigget_field_config () const
 The current SpatialFieldConfig: structural fields (which stages exist) and live-tunable values alike.
 
const Kakshya::VertexLayoutget_layout () const
 Layout the emitted shader addresses.
 
std::string_view get_type_name () const override
 Type name for introspection.
 
uint32_t get_vertex_binding () const noexcept
 Get the descriptor binding index the vertex SSBO occupies.
 
 GpuFieldOperator (Kakshya::VertexLayout layout, SpatialFieldConfig config={})
 
bool needs_cluster_id () const
 Whether build_spec() needs a per-vertex cluster id this cycle.
 
void process (float dt) override
 No per-cycle work.
 
std::optional< double > query_state (std::string_view query) const override
 Query operator internal state.
 
uint64_t revision () const noexcept
 Monotonic counter incremented whenever build_spec()'s result changes.
 
void set_capture_growth (float growth)
 Live-update ClaimProcessor's size-to-capture-radius scaling.
 
void set_cross_cluster (bool enabled)
 Live-update whether claims and density see across cluster boundaries.
 
void set_density_saturation_count (float count)
 Live-update HashDensityColorProcessor's saturation point.
 
void set_parameter (std::string_view param, double value) override
 No settable parameters.
 
void set_spawn_density_threshold (float threshold)
 Live-update PopulationSpawnProcessor's spawn density threshold.
 
void set_swallow_base_size (float size)
 Live-update ClaimSwallowProcessor's base survivor size.
 
void set_swallow_dim_factor (float factor)
 Live-update ClaimSwallowProcessor's absorbed-particle dimming.
 
void set_swallow_growth_rate (float rate)
 Live-update ClaimSwallowProcessor's per-swallow size increase.
 
void set_swallow_max_size (float size)
 Live-update ClaimSwallowProcessor's survivor size ceiling.
 
void set_vertex_binding (uint32_t binding)
 Descriptor binding index the vertex SSBO occupies.
 
void set_workgroup_size (uint32_t x)
 Workgroup size along x.
 
void unbind (FieldTarget target)
 Clear the given targets.
 
 ~GpuFieldOperator () override=default
 
- Public Member Functions inherited from MayaFlux::Nodes::Network::NetworkOperator
virtual void apply_one_to_one (std::string_view param, const std::shared_ptr< NodeNetwork > &source)
 Apply ONE_TO_ONE parameter mapping (per-point control)
 
virtual ~NetworkOperator ()=default
 

Protected Member Functions

void invalidate ()
 Clear the cached spec and bump revision().
 

Private Member Functions

bool accept (FieldTarget target, const Kinesis::FieldSource &source, uint32_t components)
 Shared validation for the three bind overloads.
 
std::optional< std::pair< uint32_t, uint32_t > > resolve_target (FieldTarget target) const
 Locate a target's word offset and component count in the layout.
 
void store (FieldTarget, const Kinesis::FieldSource &, uint32_t, bool, std::optional< uint32_t > cluster)
 Store a binding after validation.
 

Private Attributes

std::vector< Bindingm_bindings
 
SpatialFieldConfig m_field_config
 
Kakshya::VertexLayout m_layout
 
uint64_t m_revision {}
 
std::optional< Portal::Graphics::ShaderSpecm_spec_cache
 
uint32_t m_stride_words {}
 
uint32_t m_vertex_binding {}
 
uint32_t m_workgroup_size { 256 }
 

Detailed Description

Chain operator that declares Tendency field deformation as a compute shader rather than evaluating it on the CPU.

Holds no vertex data and no Vulkan objects. It owns bindings and emits a ShaderSpec; a ComputeProcessor in the buffer chain owns the dispatch. This is a NetworkOperator rather than a GraphicsOperator, so NetworkGeometryProcessor's dynamic_cast fails and the operator contributes an empty render slice without any participates_in_rendering bookkeeping.

Vertex-agnostic. Addressing is derived from the supplied VertexLayout, whose attribute offsets are identical across for_points, for_lines, for_meshes and for_raw, so one operator serves any of them. Pass for_raw(stride) for pre-packed data that fits no struct.

Bound fields are DualFields: the same authored text that FieldOperator would consume through .cpu is emitted here through .source as a GLSL function. A field can be moved between the two operators without being rewritten.

Field domain is always the vertex position read from the record, matching Tendency<glm::vec3, R>. FieldMode::ABSOLUTE is therefore only meaningful when the target is not POSITION: writing an absolute position would require a reference copy of the original vertices, which this operator does not allocate. bind() rejects that combination.

Consumers compile a pipeline from build_spec() and hold it. revision() increments whenever that spec changes, so a consumer records the revision it built against and rebuilds when it differs. Rebinding is authoring-time work and is not synchronised against a running process_batch, matching OperatorChain's contract.

namespace MayaFlux::Fields {
using namespace MayaFlux::ShaderCompat;
const auto swirl = MF_FIELD(swirl, [](vec3 p) -> vec3 {
return cross(vec3(0.0f, 1.0f, 0.0f), p) * 2.0f;
});
}
auto op = net->get_operator_chain()->emplace<GpuFieldOperator>(
op->bind(FieldTarget::POSITION | FieldTarget::NORMAL, Fields::swirl);
#define MF_FIELD(name, lambda)
Bind one authored expression to both the host and shader backends.
static VertexLayout for_points(uint32_t stride=60)
Factory: layout for PointVertex (position, color, size, uv, normal, tangent)

Definition at line 275 of file GpuFieldOperator.hpp.


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