| 1570 | } |
| 1571 | |
| 1572 | static bool VulkanIsSupported() |
| 1573 | { |
| 1574 | #if defined(DM_PLATFORM_VENDOR) |
| 1575 | // If we are on a private platform, and this driver is registered, then it's already supported. |
| 1576 | // We do this skip to avoid calling NativeInit(), or creating an extra api to support creating a vendor specific device twice with |
| 1577 | // memory etc. |
| 1578 | // It might make more sense if this function was queried with some actual parameters, but as it is now |
| 1579 | // it is merely a question of "is Vulkan supported at all on this platform" /MAWE |
| 1580 | return true; |
| 1581 | #else |
| 1582 | |
| 1583 | #if ANDROID |
| 1584 | // VkQuality is only useful when Vulkan can fall back to another linked graphics adapter. |
| 1585 | // If Vulkan is the only linked adapter, continue with the regular Vulkan support probe. |
| 1586 | const bool only_linked_graphics_adapter = GetLinkedGraphicsAdapterCount() == 1; |
| 1587 | if (!only_linked_graphics_adapter && !AndroidVulkanIsRecommended()) |
| 1588 | { |
| 1589 | return false; |
| 1590 | } |
| 1591 | |
| 1592 | if (!LoadVulkanLibrary()) |
| 1593 | { |
| 1594 | dmLogError("Could not load Vulkan functions."); |
| 1595 | return 0x0; |
| 1596 | } |
| 1597 | #endif |
| 1598 | |
| 1599 | // GLFW 3.4 doesn't support static linking with vulkan, |
| 1600 | // instead we need to pass in the function that loads symbol for any |
| 1601 | // platform that is using GLFW. |
| 1602 | #if defined(__MACH__) && !defined(DM_PLATFORM_IOS) |
| 1603 | dmPlatform::VulkanSetLoader(); |
| 1604 | #endif |
| 1605 | |
| 1606 | uint16_t extensionNameCount = 0; |
| 1607 | const char** extensionNames = GetExtensionNames(&extensionNameCount); |
| 1608 | |
| 1609 | #ifdef DM_VULKAN_VALIDATION |
| 1610 | dmArray<const char*> support_probe_extension_names; |
| 1611 | support_probe_extension_names.SetCapacity(extensionNameCount + 1); |
| 1612 | for (uint16_t i = 0; i < extensionNameCount; ++i) |
| 1613 | { |
| 1614 | support_probe_extension_names.Push(extensionNames[i]); |
| 1615 | } |
| 1616 | |
| 1617 | const char* portabilityExt = VK_KHR_PORTABILITY_ENUMERATION_EXTENSION_NAME; |
| 1618 | support_probe_extension_names.Push(portabilityExt); |
| 1619 | |
| 1620 | extensionNames = support_probe_extension_names.Begin(); |
| 1621 | extensionNameCount = (uint16_t) support_probe_extension_names.Size(); |
| 1622 | #endif |
| 1623 | |
| 1624 | uint32_t vk_api_version = VK_MAKE_API_VERSION(0, 1, 0, 0); |
| 1625 | |
| 1626 | VkInstance inst; |
| 1627 | VkResult res = CreateInstance(&inst, vk_api_version, extensionNames, extensionNameCount, 0, 0, 0, 0); |
| 1628 | |
| 1629 | if (res == VK_SUCCESS) |
nothing calls this directly
no test coverage detected