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

◆ from_image() [1/2]

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

Download pixel data from a VKImage, reusing a caller-supplied persistent staging buffer.

Identical to from_image() but passes staging through to TextureLoom::download_data, eliminating the per-call Vulkan object allocation. Use Buffers::create_image_staging_buffer(byte_size()) to allocate the staging buffer once before the render loop.

Parameters
imageSource GPU texture. Must be initialised and match dimensions.
stagingHost-visible staging VKBuffer sized to at least byte_size().
layerArray layer index (default 0).

Definition at line 278 of file TextureContainer.cpp.

282{
283 if (!image || !image->is_initialized()) {
285 "TextureContainer::from_image(staging) called with uninitialised image");
286 return;
287 }
288
289 if (layer >= m_data.size()) {
291 "TextureContainer::from_image(staging) layer {} out of range ({})", layer, m_data.size());
292 return;
293 }
294
295 const size_t sz = byte_size();
296 const size_t element_count = static_cast<size_t>(m_width) * m_height * m_channels;
297
298 {
299 Memory::SeqlockWriteGuard g(m_slot_locks[layer]);
300 m_data[layer] = make_empty_storage(m_format, element_count);
301 auto [ptr, bytes] = variant_bytes_mut(m_data[layer]);
302 if (!ptr || bytes != sz) {
304 "TextureContainer::from_image(staging) variant size mismatch ({} vs {})", bytes, sz);
305 return;
306 }
308 }
309
310 m_normalised_dirty[layer].store(true, std::memory_order_release);
312}
#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.