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

◆ image_at() [1/2]

std::shared_ptr< Core::VKImage > MayaFlux::Kakshya::WindowContainer::image_at ( const std::shared_ptr< Buffers::VKBuffer > &  staging,
uint32_t  frame_index 
) const

Upload m_data[frame_index] reusing a caller-supplied staging buffer.

Parameters
stagingHost-visible VKBuffer sized to at least w * h * bpp.
frame_indexIndex into m_data in [0, frame_capacity).

Definition at line 295 of file WindowContainer.cpp.

297{
298 std::shared_lock lock(m_data_mutex);
299
300 if (frame_index >= m_data.size()) {
302 "WindowContainer::image_at(staging, {}) : out of range (capacity={})",
303 frame_index, m_frame_capacity);
304 return nullptr;
305 }
306
307 {
308 const uint64_t written = m_frames_written.load(std::memory_order_acquire);
309 const uint32_t head = m_write_head.load(std::memory_order_acquire);
310 const bool ring_full = written >= m_frame_capacity;
311 const bool slot_valid = ring_full || frame_index < head;
312 if (!slot_valid) {
314 "WindowContainer::image_at(staging, {}) : frame index is ahead of write head ({}), data may be stale or uninitialized",
315 frame_index, head);
316 return nullptr;
317 }
318 }
319
320 const auto* pixels = std::get_if<std::vector<uint8_t>>(&m_data[frame_index]);
321 if (!pixels || pixels->empty()) {
323 "WindowContainer::image_at(staging, {}) — slot is empty", frame_index);
324 return nullptr;
325 }
326
327 const auto img_fmt = surface_format_to_image_format(query_surface_format(m_window));
329
330 auto img = loom.create_2d(
331 m_structure.get_width(), m_structure.get_height(), img_fmt, nullptr);
332 if (!img) {
334 "WindowContainer::image_at(staging, {}) : VKImage allocation failed", frame_index);
335 return nullptr;
336 }
337
338 loom.upload_data(img, pixels->data(), pixels->size(), staging);
339 return img;
340}
#define MF_RT_WARN(comp, ctx,...)
#define MF_RT_ERROR(comp, ctx,...)
const std::vector< float > * pixels
Definition Decoder.cpp:58
std::shared_ptr< Core::Window > m_window
void lock() override
Acquire a lock for thread-safe access.
std::vector< DataVariant > m_data
std::atomic< uint64_t > m_frames_written
@ ContainerProcessing
Container operations (Kakshya - file/stream/region processing)
@ Kakshya
Containers[Signalsource, Stream, File], Regions, DataProcessors.
Core::GraphicsSurfaceInfo::SurfaceFormat query_surface_format(const std::shared_ptr< Core::Window > &window)
Query the actual vk::Format in use by the window's live swapchain, translated back to the MayaFlux su...
static uint64_t get_height(const std::vector< DataDimension > &dimensions)
Extract height from image/video dimensions.
static uint64_t get_width(const std::vector< DataDimension > &dimensions)
Extract width from image/video dimensions.

References MayaFlux::Journal::ContainerProcessing, MayaFlux::Kakshya::ContainerDataStructure::get_height(), MayaFlux::Kakshya::ContainerDataStructure::get_width(), MayaFlux::Portal::Graphics::TextureLoom::instance(), MayaFlux::Journal::Kakshya, lock(), m_data, m_data_mutex, m_frame_capacity, m_frames_written, m_structure, m_window, m_write_head, MF_RT_ERROR, MF_RT_WARN, pixels, and MayaFlux::Kakshya::query_surface_format().

+ Here is the call graph for this function: