68 std::shared_ptr<VKBuffer>& staging);
88 std::shared_ptr<VKBuffer>& staging);
109MAYAFLUX_API
void download_host_visible(
const std::shared_ptr<VKBuffer>& source,
const std::shared_ptr<VKBuffer>& target);
123MAYAFLUX_API
void download_device_local(
const std::shared_ptr<VKBuffer>& source,
const std::shared_ptr<VKBuffer>& target,
const std::shared_ptr<VKBuffer>& staging_buffer);
141 std::shared_ptr<VKBuffer>& staging);
162 const std::shared_ptr<VKBuffer>& target,
163 const std::shared_ptr<VKBuffer>& staging =
nullptr,
164 size_t dst_offset = 0);
175 std::span<const T> data,
176 const std::shared_ptr<VKBuffer>& target,
177 const std::shared_ptr<VKBuffer>& staging =
nullptr)
179 upload_to_gpu(data.data(), data.size_bytes(), target, staging);
191 const std::vector<T>& data,
192 const std::shared_ptr<VKBuffer>& target,
193 const std::shared_ptr<VKBuffer>& staging =
nullptr)
213 const std::shared_ptr<VKBuffer>& target,
214 const std::shared_ptr<VKBuffer>& staging,
215 float growth_factor = 1.5F);
230 const std::shared_ptr<VKBuffer>& source,
233 const std::shared_ptr<VKBuffer>& staging =
nullptr);
244 const std::shared_ptr<VKBuffer>& source,
246 const std::shared_ptr<VKBuffer>& staging =
nullptr)
260 const std::shared_ptr<VKBuffer>& source,
261 std::vector<T>& data,
262 const std::shared_ptr<VKBuffer>& staging =
nullptr)
264 size_t element_count = source->get_size_bytes() /
sizeof(T);
265 data.resize(element_count);
288 const std::shared_ptr<VKBuffer>& source,
291 std::shared_ptr<VKBuffer>& staging);
304template <GpuImageSource T>
307 if constexpr (
requires(
const T&
b) {
308 {
b.get_texture() } -> std::convertible_to<std::shared_ptr<Core::VKImage>>;
310 return buffer.get_texture();
312 return buffer.get_gpu_texture();
337 const std::shared_ptr<Core::VKImage>&
image,
338 std::vector<uint8_t>& raw_staging,
339 std::vector<float>& work,
340 const std::shared_ptr<VKBuffer>& gpu_staging);
363MAYAFLUX_API
bool is_device_local(
const std::shared_ptr<VKBuffer>& buffer);
378 const std::shared_ptr<VKBuffer>& target,
379 const std::shared_ptr<VKBuffer>& staging,
396 const std::shared_ptr<VKBuffer>& target,
397 const std::shared_ptr<VKBuffer>& staging =
nullptr)
399 auto view = accessor.
view<T>();
401 const void* data_ptr = view.data();
402 size_t data_bytes = view.size() *
sizeof(T);
404 if constexpr (std::is_same_v<T, double>) {
405 const auto modality = target->get_modality();
409 "Uploading double precision to buffer with modality {}. Consider using AUDIO_1D or AUDIO_MULTICHANNEL.",
431 const std::shared_ptr<VKBuffer>& target,
432 const std::shared_ptr<VKBuffer>& staging =
nullptr)
435 error<std::invalid_argument>(
438 std::source_location::current(),
439 "Cannot upload structured view from non-structured data");
442 auto structured_view = accessor.
view<T>();
443 upload_to_gpu(structured_view.data(), structured_view.size_bytes(), target, staging);
451 const std::shared_ptr<VKBuffer>& source,
453 const std::vector<Kakshya::DataDimension>& dimensions,
455 const std::shared_ptr<VKBuffer>& staging =
nullptr)
457 size_t element_count = source->get_size_bytes() /
sizeof(T);
459 std::vector<T> temp_buffer(element_count);
462 target_variant = std::move(temp_buffer);
479 const std::shared_ptr<AudioBuffer>& audio_buffer,
480 const std::shared_ptr<VKBuffer>& gpu_buffer,
481 const std::shared_ptr<VKBuffer>& staging =
nullptr);
494 const std::shared_ptr<VKBuffer>& gpu_buffer,
495 const std::shared_ptr<AudioBuffer>& audio_buffer,
496 const std::shared_ptr<VKBuffer>& staging =
nullptr);
#define MF_WARN(comp, ctx,...)
auto view() const
Get explicit typed view of data.
bool is_structured() const
Type-erased accessor for NDData with semantic view construction.
void resolve_transfer(TransferHandle &handle)
Wait for a transfer and release its resources.
std::shared_ptr< VKBuffer > create_image_staging_buffer(size_t size)
Allocate a persistent host-visible staging buffer sized for repeated streaming uploads to an image of...
std::shared_ptr< void > TransferHandle
Opaque handle to an in-flight transfer.
void upload_audio_to_gpu(const std::shared_ptr< AudioBuffer > &audio_buffer, const std::shared_ptr< VKBuffer > &gpu_buffer, const std::shared_ptr< VKBuffer > &staging)
Upload AudioBuffer to GPU (always double precision)
void upload_structured_view(const Kakshya::DataAccess &accessor, const std::shared_ptr< VKBuffer > &target, const std::shared_ptr< VKBuffer > &staging=nullptr)
Upload structured data with GLM double-precision types.
void upload_resizing(const void *data, size_t size, const std::shared_ptr< VKBuffer > &target, const std::shared_ptr< VKBuffer > &staging, float growth_factor)
Upload size bytes to target, growing both buffers first if needed.
std::shared_ptr< Core::VKImage > resolve_gpu_image(const T &buffer)
Resolve the GPU-resident image from any GpuImageSource buffer.
constexpr float k_buffer_growth_factor
TransferHandle upload_back_buffer_async(const VKBufferResources::GenerationSlot &slot, const void *data, size_t size, std::shared_ptr< VKBuffer > &staging)
Upload to a back_buffers slot without waiting for completion.
std::span< const float > download_and_normalise(const std::shared_ptr< Core::VKImage > &image, std::vector< uint8_t > &raw_staging, std::vector< float > &work, const std::shared_ptr< VKBuffer > &gpu_staging)
Download a VKImage to CPU and return a normalised float span.
void download_from_gpu_async(const std::shared_ptr< VKBuffer > &source, void *data, size_t size, std::shared_ptr< VKBuffer > &staging)
Download from a device-local GPU buffer without stalling the graphics queue.
std::shared_ptr< VKBuffer > create_staging_buffer(size_t size)
Create staging buffer for transfers.
bool is_device_local(const std::shared_ptr< VKBuffer > &buffer)
Check if buffer is device-local (staging needed)
void download_audio_from_gpu(const std::shared_ptr< VKBuffer > &gpu_buffer, const std::shared_ptr< AudioBuffer > &audio_buffer, const std::shared_ptr< VKBuffer > &staging)
Download GPU buffer to AudioBuffer (expects double precision)
void upload_to_gpu(const void *data, size_t size, const std::shared_ptr< VKBuffer > &target, const std::shared_ptr< VKBuffer > &staging, size_t dst_offset)
Upload raw data to GPU buffer (auto-detects host-visible vs device-local)
void upload_from_view(const Kakshya::DataAccess &accessor, const std::shared_ptr< VKBuffer > &target, const std::shared_ptr< VKBuffer > &staging=nullptr)
Upload data from DataAccess view to GPU buffer (precision-preserving)
void download_from_gpu(const std::shared_ptr< VKBuffer > &source, void *data, size_t size, const std::shared_ptr< VKBuffer > &staging)
Download from GPU buffer to raw data (auto-detects host-visible vs device-local)
void download_host_visible(const std::shared_ptr< VKBuffer > &source, const std::shared_ptr< VKBuffer > &target)
Download data from a host-visible buffer.
void ensure_gpu_capacity(const std::shared_ptr< VKBuffer > &target, const std::shared_ptr< VKBuffer > &staging, size_t required, float growth_factor)
Grow a GPU buffer (and its paired staging buffer) to fit required bytes.
void download_back_buffer(const VKBufferResources::GenerationSlot &slot, void *data, size_t size, std::shared_ptr< VKBuffer > &staging)
Download a raw back_buffers slot to host memory.
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.
Kakshya::DataAccess download_to_view(const std::shared_ptr< VKBuffer > &source, Kakshya::DataVariant &target_variant, const std::vector< Kakshya::DataDimension > &dimensions, Kakshya::DataModality modality, const std::shared_ptr< VKBuffer > &staging=nullptr)
Download GPU buffer to DataAccess-compatible format (precision-preserving)
void upload_host_visible(const std::shared_ptr< VKBuffer > &target, const Kakshya::DataVariant &data, size_t dst_offset)
Upload data to a host-visible buffer.
void upload_device_local(const std::shared_ptr< VKBuffer > &target, const std::shared_ptr< VKBuffer > &staging_buffer, const Kakshya::DataVariant &data, size_t dst_offset)
Upload data to a device-local buffer using a staging buffer.
void upload_back_buffer(const VKBufferResources::GenerationSlot &slot, const void *data, size_t size, std::shared_ptr< VKBuffer > &staging)
Upload host memory into a raw back_buffers slot.
@ BufferProcessing
Buffer processing (Buffers::BufferManager, processing chains)
@ 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.
DataModality
Data modality types for cross-modal analysis.
@ AUDIO_MULTICHANNEL
Multi-channel audio.
@ AUDIO_1D
1D audio signal
std::string_view modality_to_string(DataModality modality)
Convert DataModality enum to string representation.