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

◆ ensure_capture_state()

void MayaFlux::Core::BackendWindowHandler::ensure_capture_state ( WindowRenderContext &  ctx)
private

Ensure capture state is initialized for a window context.

Parameters
ctxWindow render context to initialize capture state for

If the context does not already have capture state and the associated window has capture enabled, this initializes the capture state including allocating command buffers and synchronization objects for readback.

Definition at line 911 of file BackendWindowHandler.cpp.

912{
913 if (ctx.capture || !ctx.swapchain || !ctx.window->is_capture_enabled())
914 return;
915
916 auto dev = m_context.get_device();
917 const vk::Format fmt = ctx.swapchain->get_image_format();
918 const uint32_t bpp = Core::vk_format_bytes_per_pixel(fmt);
919
920 ctx.capture = std::make_unique<CaptureState>();
921 ctx.capture->format = fmt;
922 ctx.capture->bpp = bpp;
923
924 const uint32_t count = ctx.swapchain->get_image_count();
925 ctx.capture->slots.reserve(count);
926 for (uint32_t i = 0; i < count; ++i) {
927 auto slot = std::make_unique<CaptureSlot>();
929 vk::CommandBufferLevel::ePrimary);
930 slot->fence = dev.createFence(vk::FenceCreateInfo { vk::FenceCreateFlagBits::eSignaled });
931 ctx.capture->slots.push_back(std::move(slot));
932 }
933
934 start_readback_thread(*ctx.capture, dev);
935}
size_t count
void start_readback_thread(CaptureState &state, vk::Device dev)
Thread function to perform asynchronous readback of captured frames.
vk::CommandBuffer allocate_command_buffer(vk::CommandBufferLevel level=vk::CommandBufferLevel::ePrimary)
Allocate a command buffer with specified level.
vk::Device get_device() const
Get logical device.
Definition VKContext.hpp:49
uint32_t vk_format_bytes_per_pixel(vk::Format fmt)
Byte width of a single pixel for a given Vulkan format.

References MayaFlux::Core::WindowRenderContext::capture, count, MayaFlux::Core::WindowRenderContext::swapchain, MayaFlux::Core::vk_format_bytes_per_pixel(), and MayaFlux::Core::WindowRenderContext::window.

Referenced by setup_backend_service().

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