18 const std::shared_ptr<AudioBuffer>& source,
19 const std::shared_ptr<VKBuffer>& target)
27 const std::shared_ptr<AudioBuffer>& audio_buffer,
28 const std::shared_ptr<VKBuffer>& gpu_buffer,
42 const std::shared_ptr<AudioBuffer>& source,
43 const std::shared_ptr<VKBuffer>& target)
45 if (!source || !target) {
47 "TransferProcessor::connect_audio_to_gpu: null buffer provided");
56 const std::shared_ptr<VKBuffer>& source,
57 const std::shared_ptr<AudioBuffer>& target)
59 if (!source || !target) {
61 "TransferProcessor::connect_gpu_to_audio: null buffer provided");
70 const std::shared_ptr<VKBuffer>& target,
71 std::shared_ptr<VKBuffer> staging_buffer)
75 "TransferProcessor::setup_staging: null target provided");
85 [&target](
const auto& pair) {
return pair.second == target; });
91 [&target](
const auto& pair) {
return pair.second == target; });
97 if (
auto vk_buffer = std::dynamic_pointer_cast<VKBuffer>(buffer)) {
100 "TransferProcessor not configured for the attached VKBuffer instance (audio→gpu).");
104 if (!vk_buffer->is_initialized()) {
106 "VKBuffer not initialized - register with BufferManager first.");
110 if (!vk_buffer->is_host_visible()) {
114 "No staging buffer configured for device-local VKBuffer. Create one for efficient transfers.");
119 std::source_location::current(),
120 "TransferProcessor (audio→gpu) requires VKBuffer attachment");
124 if (
auto audio_buffer = std::dynamic_pointer_cast<AudioBuffer>(buffer)) {
127 "TransferProcessor not configured for the attached AudioBuffer instance (gpu→audio).");
132 std::source_location::current(),
133 "TransferProcessor (gpu→audio) requires AudioBuffer attachment");
141 if (
auto vk_buffer = std::dynamic_pointer_cast<VKBuffer>(buffer)) {
144 if (it->second == vk_buffer) {
152 if (
auto audio_buffer = std::dynamic_pointer_cast<AudioBuffer>(buffer)) {
154 if (it->second == audio_buffer) {
175 auto vk_buffer = std::dynamic_pointer_cast<VKBuffer>(gpu_buffer);
178 "TransferProcessor (audio→gpu) requires VKBuffer.");
183 [&vk_buffer](
const auto& pair) {
return pair.second == vk_buffer; });
187 "No source AudioBuffer configured for this VKBuffer.");
191 auto source_audio = transfer_it->first;
193 if (vk_buffer->is_host_visible()) {
199 "No staging buffer configured for device-local VKBuffer.");
208 auto audio = std::dynamic_pointer_cast<AudioBuffer>(audio_buffer);
211 "TransferProcessor (gpu→audio) requires AudioBuffer.");
216 [&audio](
const auto& pair) {
return pair.second == audio; });
220 "No source VKBuffer configured for this AudioBuffer.");
224 auto source_gpu = transfer_it->first;
227 std::shared_ptr<VKBuffer> staging = (staging_it !=
m_staging_map.end()) ? staging_it->second :
nullptr;
#define MF_ERROR(comp, ctx,...)
#define MF_RT_ERROR(comp, ctx,...)
#define MF_WARN(comp, ctx,...)
ProcessingToken m_processing_token
bool validate_audio_to_gpu(const std::shared_ptr< VKBuffer > &target) const
void processing_function(std::shared_ptr< Buffer > buffer) override
The core processing function that must be implemented by derived classes.
void on_attach(std::shared_ptr< Buffer > buffer) override
Called when this processor is attached to a buffer.
void connect_audio_to_gpu(const std::shared_ptr< AudioBuffer > &source, const std::shared_ptr< VKBuffer > &target)
Configure audio→GPU transfer.
void connect_gpu_to_audio(const std::shared_ptr< VKBuffer > &source, const std::shared_ptr< AudioBuffer > &target)
Configure GPU→audio transfer.
void setup_staging(const std::shared_ptr< VKBuffer > &target, std::shared_ptr< VKBuffer > staging_buffer)
Set up staging buffer for device-local GPU buffer.
std::unordered_map< std::shared_ptr< VKBuffer >, std::shared_ptr< AudioBuffer > > m_gpu_to_audio_map
bool validate_gpu_to_audio(const std::shared_ptr< AudioBuffer > &target) const
void process_gpu_to_audio(const std::shared_ptr< Buffer > &audio_buffer)
TransferDirection m_direction
std::unordered_map< std::shared_ptr< VKBuffer >, std::shared_ptr< VKBuffer > > m_staging_map
void process_audio_to_gpu(const std::shared_ptr< Buffer > &gpu_buffer)
void on_detach(std::shared_ptr< Buffer > buffer) override
Called when this processor is detached from a buffer.
std::unordered_map< std::shared_ptr< AudioBuffer >, std::shared_ptr< VKBuffer > > m_audio_to_gpu_map
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)
@ GRAPHICS_BACKEND
Standard graphics processing backend configuration.
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)
TransferDirection
Specifies the direction of data transfer.
@ BufferProcessing
Buffer processing (Buffers::BufferManager, processing chains)
@ Buffers
Buffers, Managers, processors and processing chains.