MayaFlux 0.5.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches

◆ upload_audio_to_gpu()

void MayaFlux::Buffers::upload_audio_to_gpu ( const std::shared_ptr< AudioBuffer > &  audio_buffer,
const std::shared_ptr< VKBuffer > &  gpu_buffer,
const std::shared_ptr< VKBuffer > &  staging = nullptr 
)

Upload AudioBuffer to GPU (always double precision)

Parameters
audio_bufferSource audio buffer (double[])
gpu_bufferTarget GPU buffer (must support R64Sfloat format)
stagingOptional staging buffer (auto-created if needed)

AudioBuffer is always double precision. This function ensures the GPU buffer is configured for double precision and performs a direct upload with no conversion.

Exceptions
std::runtime_errorif gpu_buffer doesn't support double precision

Definition at line 483 of file StagingUtils.cpp.

487{
488 const auto modality = gpu_buffer->get_modality();
489 if (modality != Kakshya::DataModality::AUDIO_1D
490 && modality != Kakshya::DataModality::AUDIO_MULTICHANNEL
491 && modality != Kakshya::DataModality::UNKNOWN) {
492
493 error<std::runtime_error>(
494 Journal::Component::Buffers,
495 Journal::Context::BufferProcessing,
496 std::source_location::current(),
497 "GPU buffer modality is {} but audio requires AUDIO_1D or AUDIO_MULTICHANNEL. "
498 "Create VKBuffer with DataModality::AUDIO_1D or AUDIO_MULTICHANNEL.",
499 Kakshya::modality_to_string(modality));
500 }
501
502 auto& audio_data = audio_buffer->get_data();
503
504 if (audio_data.empty()) {
505 MF_ERROR(Journal::Component::Buffers, Journal::Context::BufferProcessing,
506 "AudioBuffer contains no data to upload");
507 return;
508 }
509
510 const void* data_ptr = audio_data.data();
511 size_t data_bytes = audio_data.size() * sizeof(double);
512
513 upload_to_gpu(data_ptr, data_bytes, gpu_buffer, staging);
514
515 MF_DEBUG(Journal::Component::Buffers, Journal::Context::BufferProcessing,
516 "Uploaded {} bytes of double-precision audio to GPU", data_bytes);
517}
#define MF_ERROR(comp, ctx,...)
#define MF_DEBUG(comp, ctx,...)

References MayaFlux::Kakshya::AUDIO_1D, MayaFlux::Kakshya::AUDIO_MULTICHANNEL, MayaFlux::Journal::BufferProcessing, MayaFlux::Journal::Buffers, MF_DEBUG, MF_ERROR, MayaFlux::Kakshya::modality_to_string(), MayaFlux::Kakshya::UNKNOWN, and upload_to_gpu().

Referenced by MayaFlux::Buffers::TransferProcessor::process_audio_to_gpu().

+ Here is the call graph for this function:
+ Here is the caller graph for this function: