MayaFlux 0.1.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 56 of file VKBuffer.cpp.

57{
58 if (!is_initialized()) {
60 "Cannot set_data on uninitialized VKBuffer. Register with BufferManager first.");
61 return;
62 }
63
64 if (data.empty()) {
65 clear();
66 return;
67 }
68
70 Kakshya::DataAccess accessor(
71 const_cast<Kakshya::DataVariant&>(data[0]),
72 {},
74
75 auto [ptr, bytes, format_hint] = accessor.gpu_buffer();
76
77 if (bytes > m_size_bytes) {
78 error<std::runtime_error>(
81 std::source_location::current(),
82 "Data size {} exceeds buffer capacity {}",
83 bytes, m_size_bytes);
84 }
85
86 std::memcpy(m_resources.mapped_ptr, ptr, bytes);
88
90 } else {
92 "set_data() on device-local buffer requires BufferUploadProcessor in chain");
93 }
94}
#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:295
void clear() override
Clear buffer contents.
Definition VKBuffer.cpp:37
VKBufferResources m_resources
Definition VKBuffer.hpp:427
void mark_dirty_range(size_t offset, size_t size)
Get device memory handle.
Definition VKBuffer.cpp:344
bool is_initialized() const
Check whether Vulkan handles are present (buffer registered)
Definition VKBuffer.hpp:230
Kakshya::DataModality m_modality
Definition VKBuffer.hpp:434
bool is_host_visible() const
Whether this VKBuffer should be host-visible.
Definition VKBuffer.hpp:278
@ 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: