| 580 | } |
| 581 | |
| 582 | bool VulkanCapsViewer::initVulkan() |
| 583 | { |
| 584 | VkResult vkRes; |
| 585 | |
| 586 | // Get the max. supported Vulkan Version if vkEnumerateInstanceVersion is available (loader version 1.1 and up) |
| 587 | PFN_vkEnumerateInstanceVersion vkEnumerateInstanceVersion = reinterpret_cast<PFN_vkEnumerateInstanceVersion>(vkGetInstanceProcAddr(nullptr, "vkEnumerateInstanceVersion")); |
| 588 | if (vkEnumerateInstanceVersion) { |
| 589 | vkEnumerateInstanceVersion(&instanceApiVersion); |
| 590 | } else { |
| 591 | instanceApiVersion = VK_API_VERSION_1_0; |
| 592 | } |
| 593 | |
| 594 | VkApplicationInfo appInfo = {}; |
| 595 | appInfo.sType = VK_STRUCTURE_TYPE_APPLICATION_INFO; |
| 596 | appInfo.pApplicationName = "VulkanCapsViewer"; |
| 597 | appInfo.applicationVersion = 1; |
| 598 | appInfo.pEngineName = "VulkanCapsViewer"; |
| 599 | appInfo.engineVersion = 1; |
| 600 | appInfo.apiVersion = instanceApiVersion; |
| 601 | |
| 602 | // Create Vulkan instance |
| 603 | VkInstanceCreateInfo instanceCreateInfo = {}; |
| 604 | instanceCreateInfo.sType = VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO; |
| 605 | instanceCreateInfo.pApplicationInfo = &appInfo; |
| 606 | |
| 607 | // Get instance layers |
| 608 | uint32_t layerCount = 0; |
| 609 | std::vector<VkLayerProperties> instanceLayerProperties; |
| 610 | do |
| 611 | { |
| 612 | vkRes = vkEnumerateInstanceLayerProperties(&layerCount, NULL); |
| 613 | instanceLayerProperties.resize(layerCount); |
| 614 | if (layerCount > 0) { |
| 615 | vkRes = vkEnumerateInstanceLayerProperties(&layerCount, &instanceLayerProperties.front()); |
| 616 | } |
| 617 | } while (vkRes == VK_INCOMPLETE); |
| 618 | assert(!vkRes); |
| 619 | |
| 620 | for (auto& layerProperty : instanceLayerProperties) { |
| 621 | VulkanLayerInfo layer; |
| 622 | layer.properties = layerProperty; |
| 623 | instanceLayers.push_back(layer); |
| 624 | } |
| 625 | |
| 626 | // Platform specific surface extensions |
| 627 | std::vector<std::string> possibleSurfaceExtensions = { |
| 628 | #if defined(VK_USE_PLATFORM_ANDROID_KHR) |
| 629 | VK_KHR_ANDROID_SURFACE_EXTENSION_NAME, |
| 630 | #endif |
| 631 | #if defined(VK_USE_PLATFORM_WAYLAND_KHR) |
| 632 | VK_KHR_WAYLAND_SURFACE_EXTENSION_NAME, |
| 633 | #endif |
| 634 | #if defined(VK_USE_PLATFORM_WIN32_KHR) |
| 635 | VK_KHR_WIN32_SURFACE_EXTENSION_NAME, |
| 636 | #endif |
| 637 | #if defined(VK_USE_PLATFORM_XCB_KHR) |
| 638 | VK_KHR_XCB_SURFACE_EXTENSION_NAME, |
| 639 | #endif |
nothing calls this directly
no outgoing calls
no test coverage detected