create static method

VulkanDeviceHandle create({
  1. VulkanDeviceOptions? options,
})

Creates a Vulkan instance, device, and graphics queue for render sessions.

Attach sessions with the context from VulkanDeviceHandle.getContext(), in place of a device of your own. Without device_uuid or device_luid, it prefers a discrete GPU. The device enables the external memory and semaphore extensions that the GPU offers.

See mln_vulkan_device_create in the C API reference.

Errors:

  • Status.unsupported when supportedRenderBackendMask() lacks RenderBackendFlag.vulkan, or when presentation is true and the Vulkan loader or the GPU can't present.
  • Status.notFound when no GPU matches device_uuid and device_luid.
  • Status.nativeError when there is no Vulkan loader, no GPU has a graphics queue, or Vulkan can't create the instance or the device.

Implementation

static VulkanDeviceHandle create({VulkanDeviceOptions? options}) =>
    withNativeArena((arena) {
      ensureAbiVersion();
      final outDevice = arena<Uint64>();
      _check(
        raw.mln_vulkan_device_create(
          options == null
              ? nullptr
              : _writeVulkanDeviceOptions(options, arena),
          outDevice,
          nativeDiagnostic,
        ),
      );
      return _adoptOwned(
        outDevice.value,
        () => VulkanDeviceHandle._(_NativeVulkanDevice(outDevice.value)),
        (handle) {
          raw.mln_vulkan_device_release(handle);
        },
      );
    });