protected virtual void CreateDevice() { uint queuePriorities = 0; var queueCreateInfo = new DeviceQueueCreateInfo { StructureType = StructureType.DeviceQueueCreateInfo, QueueFamilyIndex = 0, QueueCount = 1, QueuePriorities = new IntPtr(&queuePriorities) }; var enabledLayerNames = new[] { Marshal.StringToHGlobalAnsi("VK_LAYER_LUNARG_standard_validation"), }; var enabledExtensionNames = new[] { Marshal.StringToHGlobalAnsi("VK_KHR_swapchain"), }; try { fixed (void* enabledLayerNamesPointer = &enabledLayerNames[0]) fixed (void* enabledExtensionNamesPointer = &enabledExtensionNames[0]) { var enabledFeatures = new PhysicalDeviceFeatures { ShaderClipDistance = true, }; var deviceCreateInfo = new DeviceCreateInfo { StructureType = StructureType.DeviceCreateInfo, QueueCreateInfoCount = 1, QueueCreateInfos = new IntPtr(&queueCreateInfo), EnabledExtensionCount = (uint)enabledExtensionNames.Length, EnabledExtensionNames = new IntPtr(enabledExtensionNamesPointer), EnabledFeatures = new IntPtr(&enabledFeatures) }; if (validate) { deviceCreateInfo.EnabledLayerCount = (uint)enabledLayerNames.Length; deviceCreateInfo.EnabledLayerNames = new IntPtr(enabledLayerNamesPointer); } device = physicalDevice.CreateDevice(ref deviceCreateInfo); } } finally { foreach (var enabledExtensionName in enabledExtensionNames) Marshal.FreeHGlobal(enabledExtensionName); foreach (var enabledLayerName in enabledLayerNames) Marshal.FreeHGlobal(enabledLayerName); } var queueNodeIndex = physicalDevice.QueueFamilyProperties. Where((properties, index) => (properties.QueueFlags & QueueFlags.Graphics) != 0 && physicalDevice.GetSurfaceSupport((uint)index, surface)). Select((properties, index) => index).First(); queue = device.GetQueue(0, (uint)queueNodeIndex); }
internal static unsafe extern Result vkQueueWaitIdle(Queue queue);
internal static unsafe extern Result vkQueueSubmit(Queue queue, uint submitCount, SubmitInfo* submits, Fence fence);
internal static unsafe extern Result vkQueuePresentKHR(Queue queue, PresentInfo* presentInfo);
internal static unsafe extern Result vkQueueBindSparse(Queue queue, uint bindInfoCount, BindSparseInfo* bindInfo, Fence fence);
internal static unsafe extern void vkGetDeviceQueue(Device device, uint queueFamilyIndex, uint queueIndex, Queue* queue);