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

◆ download_and_normalise()

MAYAFLUX_API std::span< const float > MayaFlux::Buffers::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.

Downloads image into raw_staging via TextureLoom::download_data, then normalises into work via Kakshya::as_normalised_float.

raw_staging is resized to match the image byte footprint when the image dimensions or format change. work is the caller-owned scratch buffer reused across calls to avoid per-frame allocation.

Returns an empty span if image is null, not initialised, or its format has no ImageFormat mapping.

Parameters
imageGPU-resident source image.
raw_stagingPersistent byte buffer for the GPU download. Reuse across calls.
workPersistent float buffer for normalisation output. Reuse across calls.
gpu_stagingOptional persistent staging buffer for device-local images. Reuse across calls.
Returns
Normalised float span pointing into work (or directly into the variant storage for float-format images).

Definition at line 454 of file StagingUtils.cpp.

459{
460 if (!image || !image->is_initialized())
461 return {};
462
463 auto& loom = Portal::Graphics::TextureLoom::instance();
464
465 const auto fmt_opt = loom.from_vulkan_format(image->get_format());
466 if (!fmt_opt)
467 return {};
468
469 const size_t byte_size = static_cast<size_t>(image->get_width())
470 * image->get_height()
471 * loom.get_bytes_per_pixel(*fmt_opt);
472
473 if (byte_size == 0)
474 return {};
475
476 raw_staging.resize(byte_size);
477 loom.download_data(image, raw_staging.data(), byte_size, gpu_staging);
478
479 Kakshya::DataVariant variant { raw_staging };
480 return Kakshya::as_normalised_float(variant, work);
481}
IO::ImageData image
Definition Decoder.cpp:64

References MayaFlux::Kakshya::as_normalised_float(), image, and MayaFlux::Portal::Graphics::TextureLoom::instance().

Referenced by MayaFlux::Buffers::ImageCVProcessor< T >::processing_function().

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