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

124{
125 if (!image || !image->is_initialized()) {
127 "TextureContainer::from_image(staging) called with uninitialised image");
128 return;
129 }
130
131 if (layer >= m_data.size()) {
133 "TextureContainer::from_image(staging) layer {} out of range ({})", layer, m_data.size());
134 return;
135 }
136
137 const size_t sz = byte_size();
138 const size_t element_count = static_cast<size_t>(m_width) * m_height * m_channels;
139
140 {
141 Memory::SeqlockWriteGuard g(m_slot_locks[layer]);
142 m_data[layer] = make_empty_storage(m_format, element_count);
143 auto [ptr, bytes] = variant_bytes_mutable(m_data[layer]);
144 if (!ptr || bytes != sz) {
146 "TextureContainer::from_image(staging) variant size mismatch ({} vs {})", bytes, sz);
147 return;
148 }
150 }
151
152 m_normalised_dirty[layer].store(true, std::memory_order_release);
154}
#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.
DataVariant make_empty_storage(ImageFormat format, size_t element_count)
std::pair< uint8_t *, size_t > variant_bytes_mutable(DataVariant &v)
Get a mutable pointer to the raw bytes of a DataVariant and its size.

References image, MayaFlux::Kakshya::make_empty_storage(), MF_ERROR, ptr, and MayaFlux::Kakshya::variant_bytes_mutable().

+ Here is the call graph for this function: