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

◆ accumulate() [1/2]

void MayaFlux::Buffers::VolumeGridBuffer::accumulate ( const std::string &  name,
const Kinesis::SpatialField &  field 
)

Add sampled values into a scalar field.

Parameters
nameField name. Must have stride sizeof(float).
fieldSampled at each cell centre in world space and added to whatever the field already holds.

Blocking. Reads the current read slot to host memory, adds, and writes back, so it costs a full round trip at the lattice's byte size. Intended for authored injection on a coarse clock, not as a chain stage.

Definition at line 599 of file VolumeGridBuffer.cpp.

600{
601 const auto* decl = find_field(name, "accumulate");
602 if (!decl) {
603 return;
604 }
605
606 if (decl->stride_bytes != sizeof(float)) {
608 "VolumeGridBuffer::accumulate: field '{}' has stride {}, SpatialField requires {}",
609 name, decl->stride_bytes, sizeof(float));
610 return;
611 }
612
613 const glm::uvec3 res = m_lattice.resolution;
614 std::vector<float> values(m_lattice.cell_count());
615
616 read_field(name, values.data(), values.size() * sizeof(float));
617
618 size_t i = 0;
619 for (uint32_t z = 0; z < res.z; ++z) {
620 for (uint32_t y = 0; y < res.y; ++y) {
621 for (uint32_t x = 0; x < res.x; ++x) {
622 values[i++] += field(m_lattice.cell_center({ x, y, z }));
623 }
624 }
625 }
626
627 seed_raw(name, values.data(), values.size() * sizeof(float));
628}
#define MF_ERROR(comp, ctx,...)
std::vector< std::byte > values
Definition VDBWriter.cpp:26
std::string name
Definition VKDevice.cpp:123
const Field * find_field(const std::string &name, const char *context) const
Resolve a field by name.
void read_field(const std::string &name, void *data, size_t size)
Copy the current read slot of a field to host memory.
void seed_raw(const std::string &name, const void *data, size_t size)
Write initial values into a field from raw host memory.
@ BufferManagement
Buffer Management (Buffers::BufferManager, creating buffers)
@ Buffers
Buffers, Managers, processors and processing chains.
size_t cell_count() const noexcept
Total cell count.
Definition Lattice.hpp:36
glm::uvec3 resolution
Cell count per axis. Zero on any axis is invalid.
Definition Lattice.hpp:26
glm::vec3 cell_center(const glm::uvec3 &c) const noexcept
World position of a cell's centre.
Definition Lattice.hpp:70

References MayaFlux::Journal::BufferManagement, MayaFlux::Journal::Buffers, MayaFlux::Kinesis::Lattice3D::cell_center(), MayaFlux::Kinesis::Lattice3D::cell_count(), find_field(), m_lattice, MF_ERROR, name, read_field(), MayaFlux::Kinesis::Lattice3D::resolution, seed_raw(), and values.

+ Here is the call graph for this function: