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

◆ set_data()

void MayaFlux::Buffers::VKBuffer::set_data ( const std::vector< Kakshya::DataVariant > &  data)

Write data into the buffer.

If the buffer is host-visible and mapped the provided data is copied into the mapped memory. For device-local buffers, a BufferUploadProcessor must be present in the processing chain to perform the staging/upload.

Parameters
dataVector of Kakshya::DataVariant containing the payload to copy.

Definition at line 52 of file VKBuffer.cpp.

53{
54 if (!is_initialized()) {
56 "Cannot set_data on uninitialized VKBuffer. Register with BufferManager first.");
57 return;
58 }
59
60 if (data.empty()) {
61 clear();
62 return;
63 }
64
66 Kakshya::DataAccess accessor(
67 const_cast<Kakshya::DataVariant&>(data[0]),
68 {},
70
71 auto [ptr, bytes, format_hint] = accessor.gpu_buffer();
72
73 if (bytes > m_size_bytes) {
74 error<std::runtime_error>(
77 std::source_location::current(),
78 "Data size {} exceeds buffer capacity {}",
79 bytes, m_size_bytes);
80 }
81
82 std::memcpy(m_resources.mapped_ptr, ptr, bytes);
84
86 } else {
88 "set_data() on device-local buffer requires BufferUploadProcessor in chain");
89 }
90}
#define MF_WARN(comp, ctx,...)
void infer_dimensions_from_data(size_t byte_count)
Infer Kakshya::DataDimension entries from a given byte count.
Definition VKBuffer.cpp:291
void clear() override
Clear buffer contents.
Definition VKBuffer.cpp:36
VKBufferResources m_resources
Definition VKBuffer.hpp:447
void mark_dirty_range(size_t offset, size_t size)
Get device memory handle.
Definition VKBuffer.cpp:340
bool is_initialized() const
Check whether Vulkan handles are present (buffer registered)
Definition VKBuffer.hpp:244
Kakshya::DataModality m_modality
Definition VKBuffer.hpp:454
bool is_host_visible() const
Whether this VKBuffer should be host-visible.
Definition VKBuffer.hpp:292
@ BufferManagement
Buffer Management (Buffers::BufferManager, creating buffers)
@ Buffers
Buffers, Managers, processors and processing chains.
std::variant< std::vector< double >, std::vector< float >, std::vector< uint8_t >, std::vector< uint16_t >, std::vector< uint32_t >, std::vector< std::complex< float > >, std::vector< std::complex< double > >, std::vector< glm::vec2 >, std::vector< glm::vec3 >, std::vector< glm::vec4 >, std::vector< glm::mat4 > > DataVariant
Multi-type data storage for different precision needs.
Definition NDData.hpp:73

References MayaFlux::Journal::BufferManagement, MayaFlux::Journal::Buffers, clear(), MayaFlux::Kakshya::DataAccess::gpu_buffer(), infer_dimensions_from_data(), is_host_visible(), is_initialized(), m_modality, m_resources, m_size_bytes, MayaFlux::Buffers::VKBufferResources::mapped_ptr, mark_dirty_range(), and MF_WARN.

+ Here is the call graph for this function: