MayaFlux 1.0.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 885 of file StagingUtils.cpp.

890{
891 if (!image || !image->is_initialized())
892 return {};
893
894 auto& loom = Portal::Graphics::TextureLoom::instance();
895
896 const auto fmt_opt = loom.from_vulkan_format(image->get_format());
897 if (!fmt_opt)
898 return {};
899
900 const size_t byte_size = static_cast<size_t>(image->get_width())
901 * image->get_height()
902 * loom.get_bytes_per_pixel(*fmt_opt);
903
904 if (byte_size == 0)
905 return {};
906
907 raw_staging.resize(byte_size);
908 loom.download_data(image, raw_staging.data(), byte_size, gpu_staging);
909
910 Kakshya::DataVariant variant { raw_staging };
911 return Kakshya::as_normalised_float(variant, work);
912}
IO::ImageData image
Definition Decoder.cpp:47

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: