MayaFlux 0.4.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 888 of file BackendWindowHandler.cpp.

889{
890 if (ctx.capture || !ctx.swapchain || !ctx.window->is_capture_enabled())
891 return;
892
893 auto dev = m_context.get_device();
894 const vk::Format fmt = ctx.swapchain->get_image_format();
895 const uint32_t bpp = Core::vk_format_bytes_per_pixel(fmt);
896
897 ctx.capture = std::make_unique<CaptureState>();
898 ctx.capture->format = fmt;
899 ctx.capture->bpp = bpp;
900
901 const uint32_t count = ctx.swapchain->get_image_count();
902 ctx.capture->slots.reserve(count);
903 for (uint32_t i = 0; i < count; ++i) {
904 auto slot = std::make_unique<CaptureSlot>();
906 vk::CommandBufferLevel::ePrimary);
907 slot->fence = dev.createFence({});
908 ctx.capture->slots.push_back(std::move(slot));
909 }
910
911 start_readback_thread(*ctx.capture, dev);
912}
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: