internal static SwapchainKhr[] CreateSharedKhr(Device parent, SwapchainCreateInfoKhr[] createInfos,
                                                       ref AllocationCallbacks?allocator)
        {
            int count             = createInfos?.Length ?? 0;
            var nativeCreateInfos = stackalloc SwapchainCreateInfoKhr.Native[count];

            for (int i = 0; i < count; i++)
            {
                createInfos[i].ToNative(out nativeCreateInfos[i]);
            }

            AllocationCallbacks.Native nativeAllocator;
            allocator?.ToNative(&nativeAllocator);

            long * handles = stackalloc long[count];
            Result result  = vkCreateSharedSwapchainsKHR(parent, count, nativeCreateInfos,
                                                         allocator.HasValue ? &nativeAllocator : null, handles);

            for (int i = 0; i < count; i++)
            {
                nativeCreateInfos[i].Free();
            }
            VulkanException.ThrowForInvalidResult(result);

            var swapchains = new SwapchainKhr[count];

            for (int i = 0; i < count; i++)
            {
                swapchains[i] = new SwapchainKhr(parent, handles[i], ref allocator);
            }
            return(swapchains);
        }