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

◆ to_image() [1/2]

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

Upload one layer to a new VKImage, reusing a caller-supplied staging buffer.

Allocates the VKImage without pixel data (create_2d with nullptr), then uploads via the provided staging buffer, bypassing the per-call VkBuffer allocation inside TextureLoom. Use TextureLoom::create_streaming_staging() to allocate the staging buffer once before the render loop.

Parameters
layerArray layer index (default 0).
stagingHost-visible staging VKBuffer sized to at least byte_size().
Returns
Newly created VKImage, or nullptr on failure.

Definition at line 407 of file TextureContainer.cpp.

409{
410 if (layer >= m_data.size()) {
412 "TextureContainer::to_image(staging) layer {} out of range ({})", layer, m_data.size());
413 return nullptr;
414 }
415
416 std::shared_ptr<Core::VKImage> img;
417 seqlock_read_void(m_slot_locks[layer], 8, [&] {
418 auto [ptr, bytes] = variant_bytes(m_data[layer]);
419 if (!ptr || bytes == 0) {
421 "TextureContainer::to_image(staging) called on empty/invalid buffer");
422 return;
423 }
424 auto& loom = TextureLoom::instance();
425 img = loom.create_2d(m_width, m_height, m_format, nullptr);
426 if (!img) {
428 "TextureContainer::to_image(staging): VKImage allocation failed");
429 return;
430 }
431 loom.upload_data(img, ptr, bytes, staging);
432 });
433 return img;
434}
#define MF_ERROR(comp, ctx,...)
const uint8_t * ptr
Portal::Graphics::ImageFormat m_format
@ ContainerProcessing
Container operations (Kakshya - file/stream/region processing)
@ Kakshya
Containers[Signalsource, Stream, File], Regions, DataProcessors.
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:222

References MF_ERROR, and ptr.