Create a clone of this buffer with the same data and properties.
The cloned buffer will have the same size, modality, dimensions, processing chain and default processor as the original. Changes to one buffer after cloning do not affect the other.
376{
378
380 buffer->set_vertex_layout(layout.value());
381 }
382
385
387 if (buffer->is_host_visible()) {
389 buffer->set_data({ std::vector<uint8_t>(src_ptr, src_ptr +
m_size_bytes) });
390 } else {
392 std::dynamic_pointer_cast<VKBuffer>(shared_from_this()),
393 buffer,
394 nullptr);
395 }
396 } else {
397 if (buffer->is_host_visible()) {
399 buffer,
400 std::dynamic_pointer_cast<VKBuffer>(shared_from_this()),
402 } else {
404 "Cloning device-local VKBuffer to another device-local VKBuffer requires external data transfer");
405 }
406 }
407
408 return buffer;
409}
#define MF_WARN(comp, ctx,...)
std::vector< Kakshya::DataVariant > get_data()
Read buffer contents as Kakshya DataVariant.
std::shared_ptr< Buffers::BufferProcessor > get_default_processor() const override
Get the currently attached default processor.
std::shared_ptr< Buffers::BufferProcessingChain > get_processing_chain() override
Access the buffer's processing chain.
std::optional< Kakshya::VertexLayout > get_vertex_layout() const
Get vertex layout if set.
VKBufferResources m_resources
Kakshya::DataModality m_modality
bool is_host_visible() const
Whether this VKBuffer should be host-visible.
void upload_device_local(const std::shared_ptr< VKBuffer > &target, const std::shared_ptr< VKBuffer > &staging_buffer, const Kakshya::DataVariant &data)
Upload data to a device-local buffer using a staging buffer.
void download_device_local(const std::shared_ptr< VKBuffer > &source, const std::shared_ptr< VKBuffer > &target, const std::shared_ptr< VKBuffer > &staging_buffer)
Download data from a device-local buffer using a staging buffer.
@ BufferManagement
Buffer Management (Buffers::BufferManager, creating buffers)
@ Buffers
Buffers, Managers, processors and processing chains.