0

My PC supports DirectX11 & Vulkan. I run my unity game with vulkan without problems.

  • OS: Windows 10
  • GPU: Nvidia GeForce GT750M

I need to check Vulkan support in a separate C++ project. It is necessary to know about possibility to run my game with vulkan command line arguments.

Here's the code:

bool checkVulkanSupport(VkResult* res) {
    // Initialize Vulkan instance
    VkInstance instance;
    VkInstanceCreateInfo createInfo{};
    createInfo.sType = VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO;

    // Add validation layers
    const char* validationLayers[] = { "VK_LAYER_KHRONOS_validation" };
    createInfo.enabledLayerCount = 1;
    createInfo.ppEnabledLayerNames = validationLayers;

    *res = vkCreateInstance(&createInfo, nullptr, &instance);// << VK_ERROR_INITIALIZATION_FAILED
    // Create a Vulkan instance
    if (*res != VK_SUCCESS)
        return false; // Vulkan instance creation failed

    uint32_t deviceCount = 0;
    vkEnumeratePhysicalDevices(instance, &deviceCount, nullptr);

    if (deviceCount == 0) {
        vkDestroyInstance(instance, nullptr);
        return false; // No physical devices found
    }

    std::vector<VkPhysicalDevice> devices(deviceCount);
    vkEnumeratePhysicalDevices(instance, &deviceCount, devices.data());

    bool supportsVulkan = false;
    for (const auto& device : devices) {
        VkPhysicalDeviceProperties deviceProperties;
        vkGetPhysicalDeviceProperties(device, &deviceProperties);

        // Check if the Vulkan version is at least 1.0.0
        if (deviceProperties.apiVersion >= VK_API_VERSION_1_0) {
            supportsVulkan = true; // Found a Vulkan-supporting device
            break; // No need to check further
        }
    }

    vkDestroyInstance(instance, nullptr); // Clean up Vulkan instance
    return supportsVulkan;
}

I don't know why, but vkCreateInstance returns VK_ERROR_INITIALIZATION_FAILED.

This part of code causes the problem:

// Initialize Vulkan instance
VkInstance instance;
VkInstanceCreateInfo createInfo{};
createInfo.sType = VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO;
    
// Add validation layers
const char* validationLayers[] = { "VK_LAYER_KHRONOS_validation" };
createInfo.enabledLayerCount = 1;
createInfo.ppEnabledLayerNames = validationLayers;
    
*res = vkCreateInstance(&createInfo, nullptr, &instance);// << VK_ERROR_INITIALIZATION_FAILED

Why vkCreateInstance returns VK_ERROR_INITIALIZATION_FAILED?

10
  • 1
    how about a minimal reproducible example? a tag that reflects your os, will also help. Commented Nov 3, 2024 at 14:12
  • @user14063792468, thank you! I will send the link on it! Commented Nov 3, 2024 at 14:25
  • Very likely the CreateInstance call fails due to some parameters you set erroneously, or forgot to specify. Did you try a simple example? vulkan-tutorial.com/Drawing_a_triangle/Setup/Instance Commented Nov 3, 2024 at 14:58
  • I mean something that has int main(...), compiles and shows your issue is a good place to start. it will be helpful if you could add a make command to compile and run your example. Commented Nov 3, 2024 at 16:22
  • @user14063792468, here is a simple project: drive.google.com/file/d/1jyjpoqUlV356RHaRLpy_MEpQ_c8yXV41/… Problem appear in checkVulkanSupport(). res contains VK_ERROR_INITIALIZATION_FAILED and I don't understand the reason of this error. Commented Nov 3, 2024 at 17:01

1 Answer 1

1

If the only goal is to “check Vulkan support”, then try running vulkaninfo which will give you a lot of information. Nvidia includes this program in their driver installation, I believe.

If you still need to write a program, your code is acting like it can’t find the validation layer, which is a bit puzzling because you obviously have the Vulkan header files, which are usually obtained from the Vulkan SDK and also contains the validation layer. If you somehow obtained the headers in some other way, then you need to install the SDK to get the validation layer.

Sign up to request clarification or add additional context in comments.

4 Comments

Thank you for answer. I installed Vulkan SDK in standard way. I need to write a program. All headers are found and the program compiles, but it seems that Vulлan is not supported. I tried to run: C:\Users\Bob>"F:\Program Files\VulkanSDK\1.3.296.0\Bin32\vulkaninfoSDK.exe" ERROR at C:\j\msdk0\build\Khronos-Tools\repo\vulkaninfo\vulkaninfo.h:241:vkEnumerateInstanceExtensionProperties failed with ERROR_INITIALIZATION_FAILED I don't have C:\j\msdk0\build\. I Installed SDK in F:\Program Files\Vulkan\
Your GPU is really old and I see some indication that Nvidia placed it in "end of life" status, so it is likely that they dropped support for that GPU in their drivers. At least all evidence in this post points that way. You might want to dig around on the Nvidia web site to see if you can find and install an older driver that still supports it
Yeah, the Nvidia manual driver download site suggests that you'll need drivers back from 2018 or 2019 for that GPU.
That message about the "msdk0" path is just the path used by the build machine used to prepare the vulkaninfo binary. It has nothing to do with your system.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.