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

◆ refresh_cached_image()

std::shared_ptr< Core::VKImage > MayaFlux::Portal::Graphics::TextureLoom::refresh_cached_image ( ImageCacheEntry &  entry,
const ImageKey &  key,
std::span< const uint8_t >  pixels,
const std::shared_ptr< Buffers::VKBuffer > &  staging = {} 
)

Refresh a sampled image in an owner-held cache entry.

Parameters
entryCache entry retained by the image producer.
keySampled image allocation properties.
pixelsComplete pixel bytes for every layer.
stagingOptional caller staging buffer. Without one, upload_data uses its existing transient staging path.
Returns
Refreshed image, or nullptr when validation or creation fails.

Definition at line 480 of file TextureLoom.cpp.

485{
486 if (key.kind == ImageKey::Kind::STORAGE_2D || key.width == 0
487 || key.height == 0 || key.layers == 0)
488 return nullptr;
489
490 const size_t required = calculate_image_size(key.width, key.height, 1, key.format)
491 * key.layers;
492 if (pixels.size() != required) {
494 "Cached image upload has {} bytes, expected {}", pixels.size(), required);
495 return nullptr;
496 }
497
498 if (staging && (staging->get_size() < required || !staging->get_mapped_ptr())) {
500 "Cached image staging buffer is unavailable or too small");
501 return nullptr;
502 }
503
504 auto image = acquire_cached_image(entry, key);
505 if (!image)
506 return nullptr;
507
508 if (staging) {
509 upload_data(image, pixels.data(), pixels.size(), staging);
510 } else {
511 upload_data(image, pixels.data(), pixels.size());
512 }
513
514 return image;
515}
#define MF_ERROR(comp, ctx,...)
IO::ImageData image
Definition Decoder.cpp:47
const std::vector< float > * pixels
Definition Decoder.cpp:48
static size_t calculate_image_size(uint32_t width, uint32_t height, uint32_t depth, ImageFormat format)
Calculate image data size.
void upload_data(const std::shared_ptr< Core::VKImage > &image, const void *data, size_t size)
Upload pixel data to an existing texture.
std::shared_ptr< Core::VKImage > acquire_cached_image(ImageCacheEntry &entry, const ImageKey &key)
Reuse a matching image in an owner-held entry or create it once.
@ ImageProcessing
Image processing tasks (filters, transformations)
@ Portal
High-level user-facing API layer.

References acquire_cached_image(), calculate_image_size(), MayaFlux::Portal::Graphics::ImageKey::format, MayaFlux::Portal::Graphics::ImageKey::height, image, MayaFlux::Journal::ImageProcessing, MayaFlux::Portal::Graphics::ImageKey::kind, MayaFlux::Portal::Graphics::ImageKey::layers, MF_ERROR, pixels, MayaFlux::Journal::Portal, MayaFlux::Portal::Graphics::ImageKey::STORAGE_2D, upload_data(), and MayaFlux::Portal::Graphics::ImageKey::width.

Referenced by MayaFlux::Kakshya::TextureContainer::cached_array_image(), MayaFlux::Kakshya::TextureContainer::cached_layer_image(), MayaFlux::Kakshya::WindowContainer::image_at(), MayaFlux::Kakshya::WindowContainer::image_at(), MayaFlux::Kakshya::WindowContainer::region_to_image(), MayaFlux::Buffers::TextureArrayBuffer::submit_layer(), MayaFlux::Kakshya::WindowContainer::to_image(), and MayaFlux::Kakshya::WindowContainer::to_image().

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