12class ComputeMeshBuffer;
71 std::shared_ptr<VKBuffer>& staging);
91 std::shared_ptr<VKBuffer>& staging);
112MAYAFLUX_API
void download_host_visible(
const std::shared_ptr<VKBuffer>& source,
const std::shared_ptr<VKBuffer>& target);
126MAYAFLUX_API
void download_device_local(
const std::shared_ptr<VKBuffer>& source,
const std::shared_ptr<VKBuffer>& target,
const std::shared_ptr<VKBuffer>& staging_buffer);
144 std::shared_ptr<VKBuffer>& staging);
172 std::shared_ptr<VKBuffer>& staging,
173 size_t staging_offset = 0);
195 std::shared_ptr<VKBuffer>& staging,
196 size_t staging_offset = 0);
217 const std::shared_ptr<VKBuffer>& target,
218 const std::shared_ptr<VKBuffer>& staging =
nullptr,
219 size_t dst_offset = 0);
243 std::span<const T> data,
244 const std::shared_ptr<VKBuffer>& target,
245 const std::shared_ptr<VKBuffer>& staging =
nullptr)
247 upload_to_gpu(data.data(), data.size_bytes(), target, staging);
259 const std::vector<T>& data,
260 const std::shared_ptr<VKBuffer>& target,
261 const std::shared_ptr<VKBuffer>& staging =
nullptr)
281 const std::shared_ptr<VKBuffer>& target,
282 const std::shared_ptr<VKBuffer>& staging,
283 float growth_factor = 1.5F);
298 const std::shared_ptr<VKBuffer>& source,
301 const std::shared_ptr<VKBuffer>& staging =
nullptr);
312 const std::shared_ptr<VKBuffer>& source,
314 const std::shared_ptr<VKBuffer>& staging =
nullptr)
328 const std::shared_ptr<VKBuffer>& source,
329 std::vector<T>& data,
330 const std::shared_ptr<VKBuffer>& staging =
nullptr)
332 size_t element_count = source->get_size_bytes() /
sizeof(T);
333 data.resize(element_count);
356 const std::shared_ptr<VKBuffer>& source,
359 std::shared_ptr<VKBuffer>& staging);
372template <GpuImageSource T>
375 if constexpr (
requires(
const T&
b) {
376 {
b.get_texture() } -> std::convertible_to<std::shared_ptr<Core::VKImage>>;
378 return buffer.get_texture();
380 return buffer.get_gpu_texture();
405 const std::shared_ptr<Core::VKImage>&
image,
406 std::vector<uint8_t>& raw_staging,
407 std::vector<float>& work,
408 const std::shared_ptr<VKBuffer>& gpu_staging);
448 const std::shared_ptr<VKBuffer>&
buffer);
460 const VKBufferResources::GenerationSlot& slot,
469[[nodiscard]] MAYAFLUX_API VKBufferResources::GenerationSlot
generation_slot(
482 const std::shared_ptr<VKBuffer>& source);
492 std::span<const uint8_t> vertex_bytes);
506 const std::shared_ptr<ComputeMeshBuffer>&
buffer);
521 const std::shared_ptr<VKBuffer>& target,
522 const std::shared_ptr<VKBuffer>& staging,
542 std::span<
const std::pair<size_t, size_t>> intervals,
543 const std::shared_ptr<VKBuffer>& target,
544 std::shared_ptr<VKBuffer>& staging);
559 const std::shared_ptr<VKBuffer>& target,
560 const std::shared_ptr<VKBuffer>& staging =
nullptr)
562 auto view = accessor.
view<T>();
564 const void* data_ptr = view.data();
565 size_t data_bytes = view.size() *
sizeof(T);
567 if constexpr (std::is_same_v<T, double>) {
568 const auto modality = target->get_modality();
572 "Uploading double precision to buffer with modality {}. Consider using AUDIO_1D or AUDIO_MULTICHANNEL.",
594 const std::shared_ptr<VKBuffer>& target,
595 const std::shared_ptr<VKBuffer>& staging =
nullptr)
598 error<std::invalid_argument>(
601 std::source_location::current(),
602 "Cannot upload structured view from non-structured data");
605 auto structured_view = accessor.
view<T>();
606 upload_to_gpu(structured_view.data(), structured_view.size_bytes(), target, staging);
614 const std::shared_ptr<VKBuffer>& source,
616 const std::vector<Kakshya::DataDimension>& dimensions,
618 const std::shared_ptr<VKBuffer>& staging =
nullptr)
620 size_t element_count = source->get_size_bytes() /
sizeof(T);
622 std::vector<T> temp_buffer(element_count);
625 target_variant = std::move(temp_buffer);
642 const std::shared_ptr<AudioBuffer>& audio_buffer,
643 const std::shared_ptr<VKBuffer>& gpu_buffer,
644 const std::shared_ptr<VKBuffer>& staging =
nullptr);
657 const std::shared_ptr<VKBuffer>& gpu_buffer,
658 const std::shared_ptr<AudioBuffer>& audio_buffer,
659 const std::shared_ptr<VKBuffer>& staging =
nullptr);
#define MF_WARN(comp, ctx,...)
std::shared_ptr< NetworkGeometryBuffer > buffer
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_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.
Portal::Graphics::GpuBufferHandle gpu_buffer_handle(const std::shared_ptr< VKBuffer > &buffer)
View a buffer's primary GPU storage without reading it back.
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.
void upload_intervals(const void *base, std::span< const std::pair< size_t, size_t > > intervals, const std::shared_ptr< VKBuffer > &target, std::shared_ptr< VKBuffer > &staging)
Upload several byte ranges of one source to the same offsets in target.
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)
std::optional< Kakshya::MeshData > triangle_soup_mesh(std::span< const uint8_t > vertex_bytes)
Wrap non-indexed triangle vertices as MeshData.
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.
VKBufferResources::GenerationSlot generation_slot(const Portal::Graphics::GpuBufferHandle &handle)
Express a buffer handle as the slot the back_buffers transfer helpers take.
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)
std::optional< Kakshya::MeshData > download_compute_mesh(const std::shared_ptr< ComputeMeshBuffer > &buffer)
Download a ComputeMeshBuffer's current live geometry to CPU.
bool clear_gpu_buffer(const std::shared_ptr< VKBuffer > &target)
Zero a registered GPU buffer in place (auto-detects host-visible vs device-local)
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)
std::optional< Kakshya::VertexLayout > resolve_vertex_layout(const std::shared_ptr< VKBuffer > &source)
Resolve the vertex extent of a buffer's primary storage for reading.
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 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 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 resolve_back_buffer_read(TransferHandle &handle, const VKBufferResources::GenerationSlot &slot, void *data, size_t size, std::shared_ptr< VKBuffer > &staging, size_t staging_offset)
Wait for a recorded download, then copy it out of staging.
bool is_transfer_source(const std::shared_ptr< VKBuffer > &buffer)
Whether a buffer's memory can be the source of a transfer.
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.
TransferHandle download_back_buffer_async(const VKBufferResources::GenerationSlot &slot, size_t size, std::shared_ptr< VKBuffer > &staging, size_t staging_offset)
Record a slot-to-staging copy without waiting for completion.
@ 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.
Non-owning view of a GPU storage buffer produced by a compute path.