MayaFlux 1.0.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 this warns and does nothing; use Buffers::upload_to_gpu.

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

Definition at line 80 of file VKBuffer.cpp.

81{
82 if (!is_initialized()) {
84 "Cannot set_data on uninitialized VKBuffer. Register with BufferManager first.");
85 return;
86 }
87
88 if (data.empty()) {
89 clear();
90 return;
91 }
92
93 if (is_host_visible() && m_resources.mapped_ptr) {
94 Kakshya::DataAccess accessor(
95 const_cast<Kakshya::DataVariant&>(data[0]),
96 {},
98
99 auto [ptr, bytes, format_hint] = accessor.gpu_buffer();
100
101 if (bytes > m_size_bytes) {
102 error<std::runtime_error>(
105 std::source_location::current(),
106 "Data size {} exceeds buffer capacity {}",
107 bytes, m_size_bytes);
108 }
109
110 await_use();
111 std::memcpy(m_resources.mapped_ptr, ptr, bytes);
113
115 } else {
117 "set_data() on a device-local buffer is not supported, use Buffers::upload_to_gpu");
118 }
119}
#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:296
void clear() override
Clear buffer contents.
Definition VKBuffer.cpp:37
void await_use() const
Block until the latest recorded submission has completed; returns at once if none.
Definition VKBuffer.cpp:217
void mark_dirty_range(size_t offset, size_t size)
Get device memory handle.
Definition VKBuffer.cpp:446
bool is_initialized() const
Check whether Vulkan handles are present (buffer registered).
Definition VKBuffer.hpp:283
bool is_host_visible() const
Whether this VKBuffer should be host-visible.
Definition VKBuffer.hpp:373
Kakshya::DataModality m_modality
Definition VKBuffer.hpp:684
@ 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:58