void CreateDevice() { var features = new Native <VkPhysicalDeviceFeatures>(); VK.GetPhysicalDeviceFeatures(physicalDevice, features.Address); HashSet <uint> uniqueIndices = new HashSet <uint> { graphicsIndex, presentIndex }; var queueInfos = new NativeArray <VkDeviceQueueCreateInfo>(uniqueIndices.Count); var priorities = new Native <float>(1); int i = 0; foreach (var ind in uniqueIndices) { var queueInfo = new VkDeviceQueueCreateInfo(); queueInfo.sType = CSGL.Vulkan.VkStructureType.DeviceQueueCreateInfo; queueInfo.queueFamilyIndex = ind; queueInfo.queueCount = 1; queueInfo.pQueuePriorities = priorities.Address; queueInfos[i] = queueInfo; i++; } var info = new VkDeviceCreateInfo(); info.sType = CSGL.Vulkan.VkStructureType.DeviceCreateInfo; info.pQueueCreateInfos = queueInfos.Address; info.queueCreateInfoCount = (uint)uniqueIndices.Count; info.pEnabledFeatures = features.Address; var extensionsNative = new NativeStringArray(deviceExtensions); info.ppEnabledExtensionNames = extensionsNative.Address; info.enabledExtensionCount = (uint)deviceExtensions.Length; var result = VK.CreateDevice(physicalDevice, ref info, alloc, out device); VK.GetDeviceQueue(device, graphicsIndex, 0, out graphicsQueue); VK.GetDeviceQueue(device, presentIndex, 0, out presentQueue); features.Dispose(); priorities.Dispose(); queueInfos.Dispose(); extensionsNative.Dispose(); }
void CreateInstance() { var appName = new InteropString("Hello Triangle"); var appInfo = new VkApplicationInfo(); appInfo.sType = CSGL.Vulkan.VkStructureType.ApplicationInfo; appInfo.pApplicationName = appName.Address; appInfo.applicationVersion = new CSGL.Vulkan.VkVersion(1, 0, 0); appInfo.engineVersion = new CSGL.Vulkan.VkVersion(0, 0, 1); appInfo.apiVersion = new CSGL.Vulkan.VkVersion(1, 0, 0); var appInfoNative = new Native <VkApplicationInfo>(appInfo); var info = new VkInstanceCreateInfo(); info.sType = CSGL.Vulkan.VkStructureType.InstanceCreateInfo; info.pApplicationInfo = appInfoNative.Address; var extensions = GLFW.GetRequiredInstanceExceptions(); var extensionsNative = new NativeStringArray(extensions); info.ppEnabledExtensionNames = extensionsNative.Address; info.enabledExtensionCount = (uint)extensions.Count; var layersNative = new NativeStringArray(layers); info.ppEnabledLayerNames = layersNative.Address; info.enabledLayerCount = (uint)layers.Length; var result = VK.CreateInstance(ref info, alloc, out instance); appName.Dispose(); appInfoNative.Dispose(); extensionsNative.Dispose(); layersNative.Dispose(); }