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

◆ upload_image()

bool MayaFlux::Kakshya::TextureContainer::upload_image ( const std::shared_ptr< Core::VKImage > &  image,
uint32_t  layer,
const std::shared_ptr< Buffers::VKBuffer > &  staging 
) const

Upload one layer into an existing VKImage instead of creating one.

Use this for an image retained separately from the container, such as an execution context's input image.

Parameters
imageTarget image. Must match this container's width, height and format, and be a single layer 2D image.
layerArray layer index (default 0).
stagingHost-visible staging VKBuffer sized to at least byte_size().
Returns
True when the layer was uploaded, false when the layer is out of range, empty, or the image is null.

Definition at line 445 of file TextureContainer.cpp.

449{
450 if (!image || layer >= m_data.size()) {
452 "TextureContainer::upload_image null image or layer {} out of range ({})", layer, m_data.size());
453 return false;
454 }
455
456 ensure_cpu(layer);
457
458 bool uploaded = false;
459 seqlock_read_void(m_slot_locks[layer], 8, [&] {
460 auto [ptr, bytes] = variant_bytes(m_data[layer]);
461 if (!ptr || bytes == 0) {
463 "TextureContainer::upload_image called on empty/invalid buffer");
464 return;
465 }
466 TextureLoom::instance().upload_data(image, ptr, bytes, staging);
467 uploaded = true;
468 });
469 return uploaded;
470}
#define MF_ERROR(comp, ctx,...)
IO::ImageData image
Definition Decoder.cpp:47
const uint8_t * ptr
void ensure_cpu(uint32_t layer) const
Download a GPU-held layer into m_data before a CPU read.
void upload_data(const std::shared_ptr< Core::VKImage > &image, const void *data, size_t size)
Upload pixel data to an existing texture.
@ ContainerProcessing
Container operations (Kakshya - file/stream/region processing)
@ Kakshya
Containers[Signalsource, Stream, File], Regions, DataProcessors.
std::pair< const uint8_t *, size_t > variant_bytes(const DataVariant &v)
Get a pointer to the raw bytes of a DataVariant and its size.
Definition DataUtils.cpp:95
bool seqlock_read_void(const Seqlock &lock, uint32_t max_attempts, Fn &&fn)
Invoke a void read functor under a Seqlock with a bounded retry count.
Definition SeqLock.hpp:268

References MayaFlux::Journal::ContainerProcessing, ensure_cpu(), image, MayaFlux::Portal::Graphics::TextureLoom::instance(), MayaFlux::Journal::Kakshya, m_data, m_slot_locks, MF_ERROR, ptr, MayaFlux::Portal::Graphics::TextureLoom::upload_data(), and MayaFlux::Kakshya::variant_bytes().

Referenced by MayaFlux::Yantra::TextureExecutionContext::container_image(), and upload_image_array().

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