attachDmaBufRing method
- DmaBufRingDescriptor descriptor,
- RenderSessionAttachOptions options, {
- VulkanDeviceHandle? device,
Creates a session that renders the map into a ring of dmabufs that the library allocates.
Acquire each frame with RenderSessionHandle.acquireFrame(), and get its
buffer with AcquiredFrameHandle.withDmaBuf().
RenderSessionHandle.resize() gives the ring new buffers of the new size.
A Vulkan build renders with device, or, when device is null, with a
device that the library creates. An OpenGL build uses an EGL context of
its own, and device must be null. Attach with
RenderDriverKind.coreWorker.
For a reader that waits on no sync file, such as a Wayland compositor
without explicit synchronization, attach without GpuSyncKindFlag.syncFd
in RenderSessionAttachOptions.producerSyncKinds, so that each frame
finishes before you acquire it. Keep each frame acquired until its reader
is done with the buffer. Give the ring 3 buffers, so the session can
render while you hold two frames.
See mln_map_attach_dma_buf_ring in the
C API reference.
Errors:
Status.unsupportedwhen the graphics context can't render into a dmabuf of any offormats.Status.nativeErrorwhen the library can't create its Vulkan device or initialize an EGL display.
Implementation
RenderSessionHandle attachDmaBufRing(
DmaBufRingDescriptor descriptor,
RenderSessionAttachOptions options, {
VulkanDeviceHandle? device,
}) {
final registrations = _NativeRegistrations(_CallbackRoots());
return _attach(
(arena, completion, outSession) => registrations.run(
() => raw.mln_map_attach_dma_buf_ring(
_handle.raw,
_writeDmaBufRingDescriptor(descriptor, arena),
(device?._handle.raw ?? 0),
_writeRenderSessionAttachOptions(options, arena, registrations),
outSession,
completion,
nativeDiagnostic,
),
),
(handle, ready) => _adoptOwned(
handle,
() =>
(RenderSessionHandle._(this, _NativeRenderSession(handle), ready)
.._state.retain(registrations)),
(handle) {
_check(raw.mln_render_session_dispose(handle, nativeDiagnostic));
},
),
);
}