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

◆ write_buffer()

void MayaFlux::Buffers::DataWriteProcessor::write_buffer ( std::shared_ptr< VKBuffer >  target,
Kakshya::DataVariant  data,
size_t  dst_offset = 0 
)

Write bytes into another VKBuffer, such as a plain descriptor-bound buffer.

The target is not resized. A device-local target is written through a persistent staging buffer. A buffer whose descriptor binding has a node, audio, or host-buffer source is rewritten from that source each cycle, so write to the source instead.

Parameters
targetBuffer to write; retained until the request runs.
dataSource data, converted to bytes when the request runs.
dst_offsetByte offset into target. offset plus data size must fit its allocation.

Definition at line 53 of file DataWriteProcessor.cpp.

54{
55 auto payload = std::make_shared<Kakshya::DataVariant>(std::move(data));
56 enqueue_write([target = std::move(target), payload, dst_offset](DataWriteProcessor& self, const std::shared_ptr<VKBuffer>&) {
57 const auto bytes = Kakshya::convert_variant<uint8_t>(*payload);
58 if (!target || !target->is_initialized() || bytes.size_bytes() == 0
59 || dst_offset + bytes.size_bytes() > target->get_size_bytes()) {
61 "DataWriteProcessor write_buffer needs an initialized target with room for the data");
62 return;
63 }
64 if (is_device_local(target)) {
65 ensure_staging(self.m_write_staging, bytes.size_bytes());
66 }
67 upload_to_gpu(bytes.data(), bytes.size_bytes(), target, self.m_write_staging, dst_offset);
68 });
69}
#define MF_RT_ERROR(comp, ctx,...)
uint64_t payload
Definition Composite.cpp:18
bool is_device_local(const std::shared_ptr< VKBuffer > &buffer)
Check if buffer is device-local (staging needed)
void upload_to_gpu(const void *data, size_t size, const std::shared_ptr< VKBuffer > &target, const std::shared_ptr< VKBuffer > &staging, size_t dst_offset)
Upload raw data to GPU buffer (auto-detects host-visible vs device-local)
@ BufferProcessing
Buffer processing (Buffers::BufferManager, processing chains)
@ Buffers
Buffers, Managers, processors and processing chains.

References MayaFlux::Journal::BufferProcessing, MayaFlux::Journal::Buffers, enqueue_write(), MayaFlux::Buffers::is_device_local(), m_write_staging, MF_RT_ERROR, payload, and MayaFlux::Buffers::upload_to_gpu().

+ Here is the call graph for this function: