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

◆ upload_image_array()

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

Upload all layers into an existing VKImage instead of creating one.

The counterpart of to_image_array(staging). A single layer container targets a plain 2D image, more layers a 2D array image with array_layers == get_layer_count().

Parameters
imageTarget image created by to_image_array.
stagingHost-visible staging VKBuffer sized to at least byte_size() * get_layer_count().
Returns
True when every layer was uploaded, false on a null image, an empty container, or a layer of unexpected size.

Definition at line 472 of file TextureContainer.cpp.

475{
476 const auto n = static_cast<uint32_t>(m_data.size());
477 if (!image || n == 0)
478 return false;
479
480 if (n == 1)
481 return upload_image(image, 0, staging);
482
484
485 const size_t layer_bytes = byte_size();
486 std::vector<uint8_t> combined(layer_bytes * n);
487 for (uint32_t i = 0; i < n; ++i) {
488 const bool ok = seqlock_read_void(m_slot_locks[i], 8, [&] {
489 auto [ptr, bytes] = variant_bytes(m_data[i]);
490 if (!ptr || bytes != layer_bytes) {
492 "TextureContainer::upload_image_array layer {} size mismatch", i);
493 return;
494 }
495 std::memcpy(combined.data() + i * layer_bytes, ptr, layer_bytes);
496 });
497 if (!ok)
498 return false;
499 }
500
501 TextureLoom::instance().upload_data(image, combined.data(), combined.size(), staging);
502 return true;
503}
#define MF_ERROR(comp, ctx,...)
IO::ImageData image
Definition Decoder.cpp:47
const uint8_t * ptr
bool 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.
size_t byte_size() const
Total byte count of the pixel buffer.
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 byte_size(), MayaFlux::Journal::ContainerProcessing, ensure_cpu_all(), image, MayaFlux::Portal::Graphics::TextureLoom::instance(), MayaFlux::Journal::Kakshya, m_data, m_slot_locks, MF_ERROR, ptr, MayaFlux::Portal::Graphics::TextureLoom::upload_data(), upload_image(), and MayaFlux::Kakshya::variant_bytes().

Referenced by MayaFlux::Yantra::TextureExecutionContext::container_image().

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