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

◆ from_image()

void MayaFlux::Kakshya::TextureContainer::from_image ( const std::shared_ptr< Core::VKImage > &  image,
uint32_t  layer = 0 
)

Download pixel data from a VKImage into this container.

Parameters
imageSource GPU texture. Must be initialized and match dimensions.
layerArray layer index for array textures (default 0).

Blocking. Overwrites the existing pixel buffer. Does not change declared width, height, or format — caller must ensure consistency.

Definition at line 233 of file TextureContainer.cpp.

234{
235 if (!image || !image->is_initialized()) {
237 "TextureContainer::from_image called with uninitialised image");
238 return;
239 }
240
241 if (layer >= m_data.size()) {
243 "TextureContainer::from_image layer {} out of range ({})", layer, m_data.size());
244 return;
245 }
246
247 const size_t sz = byte_size();
248
249 const size_t element_count = static_cast<size_t>(m_width) * m_height * m_channels;
250 m_data[layer] = make_empty_storage(m_format, element_count);
251
252 auto [ptr, bytes] = variant_bytes_mut(m_data[layer]);
253 if (!ptr || bytes != sz) {
255 "TextureContainer::from_image variant size mismatch ({} vs {})", bytes, sz);
256 return;
257 }
258
260
261 {
262 std::unique_lock lock(m_data_mutex);
263 m_processed_data[layer] = m_data[layer];
264 }
265
267
269 "TextureContainer: downloaded {} bytes from VKImage", sz);
270}
#define MF_ERROR(comp, ctx,...)
#define MF_DEBUG(comp, ctx,...)
IO::ImageData image
void lock() override
Acquire a lock for thread-safe access.
void update_processing_state(ProcessingState state) override
Update the processing state of the container.
Portal::Graphics::ImageFormat m_format
std::vector< DataVariant > m_processed_data
size_t byte_size() const
Total byte count of the pixel buffer.
void download_data(const std::shared_ptr< Core::VKImage > &image, void *data, size_t size)
Download pixel data from a texture.
@ ContainerProcessing
Container operations (Kakshya - file/stream/region processing)
@ Kakshya
Containers[Signalsource, Stream, File], Regions, DataProcessors.
@ READY
Container has data loaded and is ready for processing.

References image, MF_DEBUG, and MF_ERROR.