MayaFlux 0.5.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 890 of file BackendWindowHandler.cpp.

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