MayaFlux 0.4.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 449 of file StagingUtils.cpp.

453{
454 const auto modality = gpu_buffer->get_modality();
455 if (modality != Kakshya::DataModality::AUDIO_1D
456 && modality != Kakshya::DataModality::AUDIO_MULTICHANNEL
457 && modality != Kakshya::DataModality::UNKNOWN) {
458
459 error<std::runtime_error>(
460 Journal::Component::Buffers,
461 Journal::Context::BufferProcessing,
462 std::source_location::current(),
463 "GPU buffer modality is {} but audio requires AUDIO_1D or AUDIO_MULTICHANNEL. "
464 "Create VKBuffer with DataModality::AUDIO_1D or AUDIO_MULTICHANNEL.",
465 Kakshya::modality_to_string(modality));
466 }
467
468 auto& audio_data = audio_buffer->get_data();
469
470 if (audio_data.empty()) {
471 MF_ERROR(Journal::Component::Buffers, Journal::Context::BufferProcessing,
472 "AudioBuffer contains no data to upload");
473 return;
474 }
475
476 const void* data_ptr = audio_data.data();
477 size_t data_bytes = audio_data.size() * sizeof(double);
478
479 upload_to_gpu(data_ptr, data_bytes, gpu_buffer, staging);
480
481 MF_DEBUG(Journal::Component::Buffers, Journal::Context::BufferProcessing,
482 "Uploaded {} bytes of double-precision audio to GPU", data_bytes);
483}
#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: