MayaFlux 0.1.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches
ComputeOutNode.cpp
Go to the documentation of this file.
1#include "ComputeOutNode.hpp"
3
5
7
8ComputeOutNode::ComputeOutNode(const std::shared_ptr<Buffers::VKBuffer>& buffer, size_t element_count)
9 : m_gpu_buffer(buffer)
10 , m_readback_data(element_count)
11 , m_element_count(element_count)
12{
13 if (!m_gpu_buffer) {
14 error<std::invalid_argument>(
17 std::source_location::current(),
18 "Cannot create ComputeOutNode with null GPU buffer");
19 }
20
21 if (element_count == 0) {
22 error<std::invalid_argument>(
25 std::source_location::current(),
26 "Cannot create ComputeOutNode with zero element count");
27 }
28
29 size_t required_size = element_count * sizeof(double);
30 if (m_gpu_buffer->get_size_bytes() < required_size) {
32 "GPU buffer size ({} bytes) is smaller than requested element count ({} elements = {} bytes)",
33 m_gpu_buffer->get_size_bytes(), element_count, required_size);
34 }
35}
36
46
47[[nodiscard]] double ComputeOutNode::get_element(size_t index) const
48{
49 if (index >= m_readback_data.size()) {
50 error<std::out_of_range>(
53 std::source_location::current(),
54 "Element index {} out of range (size: {})",
55 index, m_readback_data.size());
56 }
57 return m_readback_data[index];
58}
59
60} // namespace MayaFlux::Nodes
#define MF_WARN(comp, ctx,...)
void compute_frame() override
Compute GPU data for this frame.
double get_element(size_t index) const
Get specific element from readback data.
std::shared_ptr< Buffers::VKBuffer > m_gpu_buffer
ComputeOutNode(const std::shared_ptr< Buffers::VKBuffer > &buffer, size_t element_count)
Construct with GPU buffer and element count.
double m_last_output
The most recent sample value generated by this oscillator.
Definition Node.hpp:378
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)
@ NodeProcessing
Node graph processing (Nodes::NodeGraphManager)
@ Nodes
DSP Generator and Filter Nodes, graph pipeline, node management.