attachDxgiSharedTextureRing method
Creates a session that renders the map into a ring of DXGI shared textures that the library allocates.
Acquire each frame with RenderSessionHandle.acquireFrame(), and get its
texture with AcquiredFrameHandle.withDxgiSharedTexture().
RenderSessionHandle.resize() gives the ring new textures of the new
size.
The session renders with the Vulkan device device, or, when device is
null, with one that the library creates. The textures belong to the
device's GPU, so open them on a D3D11 or D3D12 device of the same adapter.
To pick the GPU, create device with VulkanDeviceOptions.deviceLuid set
to your adapter's LUID. Attach with RenderDriverKind.coreWorker.
For a reader that waits on no fence, such as Flutter's texture registrar,
attach without GpuSyncKindFlag.d3d12Fence in
RenderSessionAttachOptions.producerSyncKinds, so that each frame
finishes before you acquire it. Release a frame with
GpuSyncKind.cpuComplete only once the reader has finished with its
texture.
See mln_map_attach_dxgi_shared_texture_ring in the
C API reference.
Errors:
Status.unsupportedin an OpenGL build, or when the GPU can't share the textures: D3D11 has no adapter with the Vulkan device's LUID or can't share textures through NT handles, or the device lacks VK_KHR_external_memory_win32 or can't import D3D11 textures.Status.nativeErrorwhen the library can't create its Vulkan device or a D3D11 device on the adapter.
Implementation
RenderSessionHandle attachDxgiSharedTextureRing(
DxgiSharedTextureRingDescriptor descriptor,
RenderSessionAttachOptions options, {
VulkanDeviceHandle? device,
}) {
final registrations = _NativeRegistrations(_CallbackRoots());
return _attach(
(arena, completion, outSession) => registrations.run(
() => raw.mln_map_attach_dxgi_shared_texture_ring(
_handle.raw,
_writeDxgiSharedTextureRingDescriptor(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));
},
),
);
}