private void CreateInstance() { #if DEBUG if (!this.CheckValidationLayerSupport()) { throw new Exception("Validation layers requested, but not available!"); } #endif VkApplicationInfo appInfo = new VkApplicationInfo() { sType = VkStructureType.VK_STRUCTURE_TYPE_APPLICATION_INFO, pApplicationName = "Hello Triangle".ToPointer(), applicationVersion = Helpers.Version(1, 0, 0), pEngineName = "No Engine".ToPointer(), engineVersion = Helpers.Version(1, 0, 0), apiVersion = Helpers.Version(1, 2, 0), }; VkInstanceCreateInfo createInfo = default; createInfo.sType = VkStructureType.VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO; createInfo.pApplicationInfo = &appInfo; // Extensions this.GetAllInstanceExtensionsAvailables(); IntPtr *extensionsToBytesArray = stackalloc IntPtr[extensions.Length]; for (int i = 0; i < extensions.Length; i++) { extensionsToBytesArray[i] = Marshal.StringToHGlobalAnsi(extensions[i]); } createInfo.enabledExtensionCount = (uint)extensions.Length; createInfo.ppEnabledExtensionNames = (byte **)extensionsToBytesArray; // Validation layers #if DEBUG IntPtr *layersToBytesArray = stackalloc IntPtr[validationLayers.Length]; for (int i = 0; i < validationLayers.Length; i++) { layersToBytesArray[i] = Marshal.StringToHGlobalAnsi(validationLayers[i]); } createInfo.enabledLayerCount = (uint)validationLayers.Length; createInfo.ppEnabledLayerNames = (byte **)layersToBytesArray; #else createInfo.enabledLayerCount = 0; createInfo.pNext = null; #endif fixed(VkInstance *instancePtr = &instance) { Helpers.CheckErrors(VulkanNative.vkCreateInstance(&createInfo, null, instancePtr)); VulkanNative.LoadFuncionPointers(instance); } }