Upload all layers as a Vulkan 2D array texture.
All layers must have been populated before calling this. Empty layers contribute zero bytes and will produce incorrect GPU data.
279{
280 const auto n =
static_cast<uint32_t
>(
m_data.size());
281 if (n == 0)
282 return nullptr;
283
284 if (n == 1) {
285 std::shared_ptr<Core::VKImage> img;
288 if (!
ptr || bytes == 0)
289 return;
291 });
292 return img;
293 }
294
296 std::vector<uint8_t> combined(layer_bytes * n);
297 for (uint32_t i = 0; i < n; ++i) {
300 if (!
ptr || bytes != layer_bytes) {
302 "TextureContainer::to_image_array layer {} has unexpected byte count ({} vs {})",
303 i, bytes, layer_bytes);
304 return;
305 }
306 std::memcpy(combined.data() + i * layer_bytes,
ptr, layer_bytes);
307 });
308 if (!ok)
309 return nullptr;
310 }
311
313}
#define MF_ERROR(comp, ctx,...)
Memory::SeqlockArray m_slot_locks
Portal::Graphics::ImageFormat m_format
std::vector< DataVariant > m_data
size_t byte_size() const
Total byte count of the pixel buffer.
static TextureLoom & instance()
std::shared_ptr< Core::VKImage > create_2d_array(uint32_t width, uint32_t height, uint32_t layers, ImageFormat format=ImageFormat::RGBA8, const void *data=nullptr)
Create a 2D texture array.
std::shared_ptr< Core::VKImage > create_2d(uint32_t width, uint32_t height, ImageFormat format=ImageFormat::RGBA8, const void *data=nullptr, uint32_t mip_levels=1)
Create a 2D texture.
@ 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.
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.