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

◆ cached_array_image()

std::shared_ptr< Core::VKImage > MayaFlux::Kakshya::TextureContainer::cached_array_image ( const std::shared_ptr< Buffers::VKBuffer > &  staging) const
private

Definition at line 408 of file TextureContainer.cpp.

410{
411 const auto n = static_cast<uint32_t>(m_data.size());
412 if (n == 0)
413 return nullptr;
414
415 if (n == 1)
416 return cached_layer_image(0, staging);
417
419
420 const size_t layer_bytes = byte_size();
421 std::vector<uint8_t> combined(layer_bytes * n);
422 for (uint32_t i = 0; i < n; ++i) {
423 bool valid = false;
424 const bool copied = seqlock_read_void(m_slot_locks[i], 8, [&] {
425 auto [ptr, bytes] = variant_bytes(m_data[i]);
426 valid = ptr && bytes == layer_bytes;
427 if (valid)
428 std::memcpy(combined.data() + i * layer_bytes, ptr, layer_bytes);
429 });
430 if (!copied || !valid) {
432 "TextureContainer::to_image_array layer {} has invalid pixel data", i);
433 return nullptr;
434 }
435 }
436
437 const Portal::Graphics::ImageKey key {
438 .width = m_width, .height = m_height, .layers = n, .format = m_format, .kind = Portal::Graphics::ImageKey::Kind::SAMPLED_ARRAY
439 };
440 Memory::SerializedSeqlockWriteGuard image_guard(m_image_cache_lock);
442 m_array_image_cache, key, combined, staging);
443}
#define MF_ERROR(comp, ctx,...)
const uint8_t * ptr
std::shared_ptr< Core::VKImage > cached_layer_image(uint32_t layer, const std::shared_ptr< Buffers::VKBuffer > &staging) const
size_t byte_size() const
Total byte count of the pixel buffer.
Portal::Graphics::ImageCacheEntry m_array_image_cache
std::shared_ptr< Core::VKImage > refresh_cached_image(ImageCacheEntry &entry, const ImageKey &key, std::span< const uint8_t > pixels, const std::shared_ptr< Buffers::VKBuffer > &staging={})
Refresh a sampled image in an owner-held cache entry.
@ ContainerProcessing
Container operations (Kakshya - file/stream/region processing)
@ Kakshya
Containers[Signalsource, Stream, File], Regions, DataProcessors.
std::pair< const uint8_t *, size_t > variant_bytes(const DataVariant &v)
Get a pointer to the raw bytes of a DataVariant and its size.
Definition DataUtils.cpp:95
bool seqlock_read_void(const Seqlock &lock, uint32_t max_attempts, Fn &&fn)
Invoke a void read functor under a Seqlock with a bounded retry count.
Definition SeqLock.hpp:268

References byte_size(), cached_layer_image(), MayaFlux::Journal::ContainerProcessing, ensure_cpu_all(), MayaFlux::Portal::Graphics::TextureLoom::instance(), MayaFlux::Journal::Kakshya, m_array_image_cache, m_data, m_format, m_height, m_image_cache_lock, m_slot_locks, m_width, MF_ERROR, ptr, MayaFlux::Portal::Graphics::TextureLoom::refresh_cached_image(), MayaFlux::Portal::Graphics::ImageKey::SAMPLED_ARRAY, MayaFlux::Kakshya::variant_bytes(), and MayaFlux::Portal::Graphics::ImageKey::width.

Referenced by to_image_array(), and to_image_array().

+ Here is the call graph for this function:
+ Here is the caller graph for this function: