Search code examples
vulkan

Vulkan error vkCreateDevice : VK_ERROR_EXTENSION_NOT_PRESENT


I am starting with Vulkan and I follow the Niko Kauppi's tutorial on Youtube.

I have an error when creating a device with vkCreateDevice, it returns VK_ERROR_EXTENSION_NOT_PRESENT

Here some part of my code:

  1. The call to vkCreateDevice

    _gpu_count = 0;
    vkEnumeratePhysicalDevices(instance, &_gpu_count, nullptr);
    std::vector<VkPhysicalDevice> gpu_list(_gpu_count);
    vkEnumeratePhysicalDevices(instance, &_gpu_count, gpu_list.data());
    _gpu = gpu_list[0];
    
    vkGetPhysicalDeviceProperties(_gpu, &_gpu_properties);
    
    VkDeviceCreateInfo device_create_info = _CreateDeviceInfo();
    
    vulkanCheckError(vkCreateDevice(_gpu, &device_create_info, nullptr, &_device));
    

_gpu_count = 1 and _gpu_properties seems to recognize well my nvidia gpu (which is not up to date)

  1. device_create_info

    VkDeviceCreateInfo _createDeviceInfo;
    
    _createDeviceInfo.sType = VK_STRUCTURE_TYPE_DEVICE_CREATE_INFO;
    _createDeviceInfo.queueCreateInfoCount = 1;
    VkDeviceQueueCreateInfo _queueInfo = _CreateDeviceQueueInfo();
    _createDeviceInfo.pQueueCreateInfos = &_queueInfo;
    

I don't understand the meaning of the error: "A requested extension is not supported" according to Khronos' doc.

Thanks for your help


Solution

  • VK_ERROR_EXTENSION_NOT_PRESENT is returned when one of the extensions in [enabledExtensionCount, ppEnabledExtensionNames] vector you provided is not supported by the driver (as queried by vkEnumerateDeviceExtensionProperties()).

    Extensions can also have dependencies, so VK_ERROR_EXTENSION_NOT_PRESENT is also returned when an extension dependency of extension in the list is missing there too.

    If you want no device extensions, make sure enabledExtensionCount of VkDeviceCreateInfo is 0 (and not e.g. some uninitialized value).

    I assume 2. is the whole body of _CreateDeviceInfo(), which would confirm the "uninitialized value" suspicion.

    Usually though you would want a swapchain extension there to be able to render to screen directly.