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

◆ to_image() [2/2]

std::shared_ptr< Core::VKImage > MayaFlux::Kakshya::TextureContainer::to_image ( uint32_t  layer = 0) const

Upload the pixel buffer to a new VKImage via TextureLoom.

Parameters
layerArray layer index for array textures (default 0).
Returns
Newly created and uploaded VKImage. Null on failure.

Creates a fresh 2D texture each call. Does not cache the result. The returned image is owned by TextureLoom's internal registry.

Definition at line 226 of file TextureContainer.cpp.

227{
228 if (layer >= m_data.size()) {
230 "TextureContainer::to_image layer {} out of range ({})", layer, m_data.size());
231 return nullptr;
232 }
233
234 std::shared_ptr<Core::VKImage> img;
235 seqlock_read_void(m_slot_locks[layer], 8, [&] {
236 auto [ptr, bytes] = variant_bytes(m_data[layer]);
237 if (!ptr || bytes == 0)
238 return;
240 });
241
242 if (!img) {
244 "TextureContainer::to_image: TextureLoom failed to create VKImage");
245 }
246 return img;
247}
#define MF_ERROR(comp, ctx,...)
const uint8_t * ptr
Portal::Graphics::ImageFormat m_format
std::shared_ptr< Core::VKImage > create_2d(uint32_t width, uint32_t height, ImageFormat format=ImageFormat::RGBA8, const void *data=nullptr, uint32_t mip_levels=1)
Create a 2D 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:222

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

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

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