|
MayaFlux 0.5.0
Digital-First Multimedia Processing Framework
|
| bool MayaFlux::IO::write_network_geometry_buffer_sample | ( | SpatialCache & | cache, |
| const std::string & | stream_name, | ||
| const std::shared_ptr< Buffers::NetworkGeometryBuffer > & | buffer | ||
| ) |
Pack a NetworkGeometryBuffer's driving network into one or more SpatialCache streams, choosing CPU or GPU readback depending on whether the network's CPU-side vertex state is still authoritative.
A GpuFieldOperator anywhere in the network's operator chain (detected via OperatorChain::find<GpuFieldOperator>()) means vertex positions are mutated directly on the GPU: the CPU-side GraphicsOperator buffer write_operator_sample() would otherwise read is stale. In that case this downloads the live vertex bytes straight from the buffer itself (it is a VKBuffer, so the same download_from_gpu_async() pattern download_compute_mesh() uses for ComputeMeshBuffer applies directly), using the still-CPU-tracked get_vertex_count()/get_vertex_layout()/ declared_topology() for population size, record schema, and sample shape (these describe the buffer's contract, not its live GPU bytes, so they stay valid regardless of which side owns the vertex data), then reads the downloaded bytes as Kakshya::Vertex records exactly as write_operator_sample() reads them from CPU memory: color, scalar, uv, normal, and tangent all come along with position, since the record schema is unchanged by which side owns the bytes; only the transfer differs. A curve topology chunks on build_cluster_ids() the same way write_operator_sample() does, since graph/path membership is structural and unaffected by what a GpuFieldOperator does to positions. Also attaches the declared hash_cluster_id state field as a "cluster" attribute when present. Written as a single stream named stream_name: once GPU-driven, the buffer is one flat array and no longer separable by originating operator. Velocities and any per-rule state beyond hash_cluster_id are left out deliberately, the same way relaxation_grid_positions() leaves per-cell state to the caller: a GpuFieldOperator's own bespoke state fields have no shape this function can decode generically.
Without a GpuFieldOperator, every GraphicsOperator on the network (its primary operator plus any in get_operator_chain()) is CPU-readable and each is written through write_operator_sample() as its own set: a network with exactly one GraphicsOperator keeps the plain stream_name unchanged, while a network chaining several writes one child stream per operator, named "<stream_name>_<get_type_name()>" (a trailing index appended for a repeated type), the same role multiple named aiMesh entries play for a multi-submesh ModelWriter export. A per-operator "cluster" attribute (from that operator's own build_cluster_ids()) continues to mark distinct populations within one operator, e.g. PhysicsOperator's collections.
| cache | Target cache, already open(). |
| stream_name | Stream (or stream-name prefix, if the network chains several GraphicsOperators) to write. |
| buffer | Source buffer. Must be non-null, with a non-null network exposing at least one GraphicsOperator. |
Definition at line 356 of file SpatialExport.cpp.
References buffer, chain, MayaFlux::Journal::FileIO, MayaFlux::Journal::IO, MF_ERROR, network, and write_operator_sample().
Referenced by make_network_geometry_source().
Here is the call graph for this function:
Here is the caller graph for this function: