MayaFlux 0.4.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 85 of file VKBuffer.cpp.

86{
87 if (!is_initialized()) {
89 "Cannot set_data on uninitialized VKBuffer. Register with BufferManager first.");
90 return;
91 }
92
93 if (data.empty()) {
94 clear();
95 return;
96 }
97
99 Kakshya::DataAccess accessor(
100 const_cast<Kakshya::DataVariant&>(data[0]),
101 {},
102 m_modality);
103
104 auto [ptr, bytes, format_hint] = accessor.gpu_buffer();
105
106 if (bytes > m_size_bytes) {
107 error<std::runtime_error>(
110 std::source_location::current(),
111 "Data size {} exceeds buffer capacity {}",
112 bytes, m_size_bytes);
113 }
114
115 std::memcpy(m_resources.mapped_ptr, ptr, bytes);
117
119 } else {
121 "set_data() on device-local buffer requires BufferUploadProcessor in chain");
122 }
123}
#define MF_WARN(comp, ctx,...)
const uint8_t * ptr
void infer_dimensions_from_data(size_t byte_count)
Infer Kakshya::DataDimension entries from a given byte count.
Definition VKBuffer.cpp:300
void clear() override
Clear buffer contents.
Definition VKBuffer.cpp:37
VKBufferResources m_resources
Definition VKBuffer.hpp:621
void mark_dirty_range(size_t offset, size_t size)
Get device memory handle.
Definition VKBuffer.cpp:386
bool is_initialized() const
Check whether Vulkan handles are present (buffer registered)
Definition VKBuffer.hpp:282
Kakshya::DataModality m_modality
Definition VKBuffer.hpp:629
bool is_host_visible() const
Whether this VKBuffer should be host-visible.
Definition VKBuffer.hpp:369
@ 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:76

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(), MF_WARN, and ptr.

+ Here is the call graph for this function: