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

◆ write_field()

void MayaFlux::Buffers::DataWriteProcessor::write_field ( std::string  name,
Kakshya::DataVariant  data 
)

Write a named field of the attached buffer.

A VolumeGridBuffer field is written through seed_raw, and a NetworkGeometryBuffer state field into the slot its next stage reads. The data size must equal the field's byte size.

Definition at line 71 of file DataWriteProcessor.cpp.

72{
73 auto payload = std::make_shared<Kakshya::DataVariant>(std::move(data));
74 enqueue_write([name = std::move(name), payload](DataWriteProcessor& self, const std::shared_ptr<VKBuffer>& vk) {
75 const auto bytes = Kakshya::convert_variant<uint8_t>(*payload);
76 const size_t size = bytes.size_bytes();
77
78 if (const auto volume = std::dynamic_pointer_cast<VolumeGridBuffer>(vk);
79 volume && volume->has_field(name)) {
80 if (size != volume->get_field_bytes(name)) {
82 "DataWriteProcessor write_field '{}' needs exactly {} bytes", name, volume->get_field_bytes(name));
83 return;
84 }
85 volume->seed_raw(name, bytes.data(), size);
86 return;
87 }
88
89 if (const auto network = std::dynamic_pointer_cast<NetworkGeometryBuffer>(vk);
90 network && network->has_state(name)) {
91 if (size != network->get_state_bytes(name)) {
93 "DataWriteProcessor write_field '{}' needs exactly {} bytes", name, network->get_state_bytes(name));
94 return;
95 }
96 const auto slot = network->read_state_slot(name);
97 if (!slot.mapped_ptr) {
98 ensure_staging(self.m_write_staging, size);
99 }
100 upload_back_buffer(slot, bytes.data(), size, self.m_write_staging);
101 return;
102 }
103
105 "DataWriteProcessor write_field found no field named '{}' on the attached buffer", name);
106 });
107}
#define MF_RT_ERROR(comp, ctx,...)
uint64_t payload
Definition Composite.cpp:18
Core::GlobalNetworkConfig network
Definition Config.cpp:43
bool size
std::string name
Definition VKDevice.cpp:123
void upload_back_buffer(const VKBufferResources::GenerationSlot &slot, const void *data, size_t size, std::shared_ptr< VKBuffer > &staging)
Upload host memory into a raw back_buffers slot.
@ BufferProcessing
Buffer processing (Buffers::BufferManager, processing chains)
@ Buffers
Buffers, Managers, processors and processing chains.

References MayaFlux::Journal::BufferProcessing, MayaFlux::Journal::Buffers, enqueue_write(), m_write_staging, MF_RT_ERROR, name, network, payload, size, and MayaFlux::Buffers::upload_back_buffer().

+ Here is the call graph for this function: