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

◆ from_image() [2/2]

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

246{
247 if (!image || !image->is_initialized()) {
249 "TextureContainer::from_image called with uninitialised image");
250 return;
251 }
252
253 if (layer >= m_data.size()) {
255 "TextureContainer::from_image layer {} out of range ({})", layer, m_data.size());
256 return;
257 }
258
259 const size_t sz = byte_size();
260 const size_t element_count = static_cast<size_t>(m_width) * m_height * m_channels;
261
262 {
263 Memory::SeqlockWriteGuard g(m_slot_locks[layer]);
264 m_data[layer] = make_empty_storage(m_format, element_count);
265 auto [ptr, bytes] = variant_bytes_mut(m_data[layer]);
266 if (!ptr || bytes != sz) {
268 "TextureContainer::from_image variant size mismatch ({} vs {})", bytes, sz);
269 return;
270 }
272 }
273
274 m_normalised_dirty[layer].store(true, std::memory_order_release);
276}
#define MF_ERROR(comp, ctx,...)
IO::ImageData image
Definition Decoder.cpp:64
const uint8_t * ptr
std::vector< std::atomic< bool > > m_normalised_dirty
void update_processing_state(ProcessingState state) override
Update the processing state of the container.
Portal::Graphics::ImageFormat m_format
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, const std::shared_ptr< Buffers::VKBuffer > &staging, bool deferred=false)
Download pixel data from a VKImage, reusing a caller-supplied persistent staging buffer.
@ 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_ERROR, and ptr.