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 249 of file TextureContainer.cpp.

251{
252 if (layer >= m_data.size()) {
254 "TextureContainer::to_image(staging) layer {} out of range ({})", layer, m_data.size());
255 return nullptr;
256 }
257
258 std::shared_ptr<Core::VKImage> img;
259 seqlock_read_void(m_slot_locks[layer], 8, [&] {
260 auto [ptr, bytes] = variant_bytes(m_data[layer]);
261 if (!ptr || bytes == 0) {
263 "TextureContainer::to_image(staging) called on empty/invalid buffer");
264 return;
265 }
266 auto& loom = TextureLoom::instance();
267 img = loom.create_2d(m_width, m_height, m_format, nullptr);
268 if (!img) {
270 "TextureContainer::to_image(staging): VKImage allocation failed");
271 return;
272 }
273 loom.upload_data(img, ptr, bytes, staging);
274 });
275 return img;
276}
#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.
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:222

References MF_ERROR, ptr, and MayaFlux::Kakshya::variant_bytes().

+ Here is the call graph for this function: