private static SwapChainSupportDetails QuerySwapChainSupport(IVkPhysicalDevice physicalDevice, IVkSurfaceKHR surface) { return(new SwapChainSupportDetails { Capabilities = physicalDevice.GetSurfaceCapabilitiesKHR(surface).Object, Formats = physicalDevice.GetSurfaceFormatsKHR(surface).Object, PresentModes = physicalDevice.GetSurfacePresentModesKHR(surface).Object }); }
public VkDisplayPropertiesKHR(Raw *raw, IVkPhysicalDevice physicalDevice) { Display = physicalDevice.GetDisplay(raw->display); DisplayName = VkHelpers.ToString(raw->displayName); PhysicalDimensions = raw->physicalDimensions; PhysicalResolution = raw->physicalResolution; SupportedTransforms = raw->supportedTransforms; PlaneReorderPossible = (bool)raw->planeReorderPossible; PersistentContent = (bool)raw->persistentContent; }
private void PickPhysicalDevice() { var devices = instance.PhysicalDevices; if (devices.Count == 0) { throw new Exception("Failed to find GPUs with Vulkan support."); } physicalDevice = devices.FirstOrDefault(x => IsDeviceSuitable(x, surface)); if (physicalDevice == null) { throw new Exception("Failed to find a suitable GPU."); } }
private static bool IsDeviceSuitable(IVkPhysicalDevice physicalDevice, IVkSurfaceKHR surface) { var extensionProps = physicalDevice.EnumerateDeviceExtensionProperties(null).Object; if (!DeviceExtensions.All(e => extensionProps.Any(p => p.ExtensionName == e))) { return(false); } var swapChainSupportDetails = QuerySwapChainSupport(physicalDevice, surface); return (swapChainSupportDetails.Formats.Any() && swapChainSupportDetails.PresentModes.Any() && FindQueueFamilies(physicalDevice, surface).HasValue); }
private static QueueFamilyIndices?FindQueueFamilies(IVkPhysicalDevice physicalDevice, IVkSurfaceKHR surface) { var graphicsFamily = physicalDevice.QueueFamilyProperties .Select((p, i) => new { p, i }) .FirstOrDefault(x => x.p.QueueCount > 0 && (x.p.QueueFlags & VkQueueFlags.Graphics) != 0) ?.i; var presentFamily = physicalDevice.QueueFamilyProperties .Select((p, i) => new { p, i }) .FirstOrDefault(x => x.p.QueueCount > 0 && physicalDevice.GetSurfaceSupportKHR(x.i, surface).Object) ?.i; return(graphicsFamily.HasValue && presentFamily.HasValue ? new QueueFamilyIndices { GraphicsFamily = graphicsFamily.Value, PresentFamily = presentFamily.Value } : (QueueFamilyIndices?)null); }
public VkDisplayPlanePropertiesKHR(Raw *raw, IVkPhysicalDevice physicalDevice) { CurrentDisplay = physicalDevice.GetDisplay(raw->currentDisplay); CurrentStackIndex = raw->currentStackIndex; }