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

◆ from_image_array() [2/2]

void MayaFlux::Kakshya::TextureContainer::from_image_array ( const std::shared_ptr< Core::VKImage > &  image,
const std::shared_ptr< Buffers::VKBuffer > &  staging 
)

Download all array layers from a VKImage, reusing a caller-supplied persistent staging buffer.

Identical to from_image_array() but passes staging through to TextureLoom::download_data. The staging buffer must be at least byte_size() * get_layer_count() bytes. Use Buffers::create_image_staging_buffer(byte_size() * get_layer_count()) to allocate it once before the render loop.

Parameters
imageSource VKImage with array_layers >= get_layer_count().
stagingHost-visible staging VKBuffer sized to at least byte_size() * get_layer_count().

Definition at line 190 of file TextureContainer.cpp.

193{
194 if (!image || !image->is_initialized()) {
196 "TextureContainer::from_image_array(staging) called with uninitialised image");
197 return;
198 }
199
200 const auto n = static_cast<uint32_t>(m_data.size());
201 if (image->get_array_layers() < n) {
203 "TextureContainer::from_image_array(staging) image has {} layers, container expects {}",
204 image->get_array_layers(), n);
205 return;
206 }
207
208 const size_t layer_bytes = byte_size();
209 std::vector<uint8_t> combined(layer_bytes * n);
210 TextureLoom::instance().download_data(image, combined.data(), combined.size(), staging);
211
212 const size_t element_count = static_cast<size_t>(m_width) * m_height * m_channels;
213 for (uint32_t i = 0; i < n; ++i) {
214 Memory::SeqlockWriteGuard g(m_slot_locks[i]);
215 m_data[i] = make_empty_storage(m_format, element_count);
216 auto [ptr, bytes] = variant_bytes_mutable(m_data[i]);
217 if (ptr && bytes == layer_bytes)
218 std::memcpy(ptr, combined.data() + i * layer_bytes, layer_bytes);
219
220 m_normalised_dirty[i].store(true, std::memory_order_release);
221 }
222
224}
#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: