Why does my vulkan instance have no any validation layers?

Hi,

I attempt to call vkEnumerateInstanceLayerProperties to get count of layers that i can use.

uint32_t layerCount = 0;

    if (vkEnumerateInstanceLayerProperties(&layerCount, VK_NULL_HANDLE) != VK_SUCCESS) {
        throw std::runtime_error("could not enumerate avalible instance layers");
    }

    if (layerCount > 0)
    {

// …
}

vkEnumerateInstanceLayer returns VK_SUCCESS, but layerCount always is zero in result. So, the question is “Why vkEnumerateInstanceLayerProperties always return zero layers?”

When i creates Vulkan instance with no layers always works fine, but I need to use at least VK_LAYER_LUNARG_standard_validation in debug mode.

Maybe i do something wrong.


Information about my platform:

OS: Linux Ubuntu 14.04
Video: NVIDIA GTX 750
driver version: 367.108.0

Vulkan SDK version: 1.0.26.0

Maybe i do something wrong.

RTFM then to know for certain? SDK manual.

My chip is on this being the problem:

Starting with version 1.0.13.0, the installer will no longer copy the Vulkan development and runtime headers, libraries, and binaries to system locations. Since these files are not installed to the default system search locations, you must configure the environment variables LD_LIBRARY_PATH and VK_LAYER_PATH (see below) in order for Vulkan applications to locate the loader and layer modules.

Thanks, but it does not help.

  1. VK_LAYER_PATH set to ~/vulkan/VulkanSDK/1.0.26.0/x86_64/etc/explicit_layer.d

  2. explicit_layer.d contains all json manifest files:
    VkLayer_api_dump.json
    VkLayer_core_validation.json
    VkLayer_image.json
    VkLayer_object_tracker.json
    VkLayer_parameter_validation.json
    VkLayer_screenshot.json
    VkLayer_swapchain.json
    VkLayer_threading.json
    VkLayer_unique_objects.json
    VkLayer_vktrace_layer.json

  3. LD_LIBRARY_PATH set to ~/vulkan/VulkanSDK/1.0.26.0/x86_64/lib

  4. all json manifest files contains only names of libraries as library_path (example: “library_path”: “libVkLayer_core_validation.so”)

so, i add LD_LIBRARY_PATH to all manifests, like that: “library_path”: “$LD_LIBRARY_PATH/libVkLayer_core_validation.so”

and nothing, vkEnumerateInstanceLayerProperties still returns 0 layers count.


by the way, vulkaninfo works fine, and returns 11 layers and i can’t see difference between code of vulkaninfo and my app :).

Ouuhhhh… sorry, looks like i confused explicit_layer.d and implicit_layer.d :oops:

So, problem solved?

Anyway, you can also programatically enable debug_report extension (properly through both pNext and normal creation).

It gives information on what paths it searches and what manifests(=the json files) it detects.

Nope, now i set VK_INSTANCE_LAYERS with required layers, but my app still can see nothing.

thanks, i will try to use VK_EXT_debug_report.

With extension VK_EXT_debug_report I finally can see the reason.

when i create vulkan instance the loader founds only one json manifest - this one: /etc/vulkan/icd.d/nvidia_icd.json, and nothing more.

It’s looks like the loader ignore value of VK_LAYER_PATH variable, now i just need to find out why does it happen.

hmm…

Try to inspect getenv programatically from your app. VK_LAYER_PATH and LD_LIBRARY_PATH should be there as absolute path (no ~ and variables).

Don’t mess with the manifests as you did in 4)

Make sure your app is x64 (I think 32b is not supported on linux).

Check permissions (you might have accidentally sudo installed or something).

Make sure your app is actually compiled with the same SDK (same vulkan.so loader and such).

Sacrifice some sheep and dance around the fire frantically.

BTW you should not use VK_NULL_HANDLE in this context (pointers), but that’s just cosmetical (it is defined to 0 too, same as NULL).

Might also try:

Run vulkaninfo. It will tell you what layers are available. If it gives you a different answer than your app does, then there is probably something wrong with your app.

Also, try setting and exporting:

VK_LOADER_DEBUG=all

and try your app again or run vulkaninfo. You should get a ton of messages that reflect what the loader is doing while trying to find your layers.

But basically, your steps 1 and 3 look right and should be working. The advice about double-checking this is good.

krOoze is also right in that you shouldn’t mess or need to mess with the json files. If the library_path is just a file name, the layer would be searched for in the normal system loader path, as modified by LD_LIBRARY_PATH. If you were to change this value, then you could try setting it to an absolute path, like /home/username/vulkan/VulkanSDK/1.0.26.0/x86_64/lib//libVkLayer_core_validation.so.

Anton_Sedov said the vulkaninfo returns the correct number of layers. Which makes it tricky.

There’s very little to mess up in the app code itself.

I have trouble believing the loader is seriouslt bad. It would fail to enumerate for vulkaninfo too from time to time (and should perhaps work sometime for the app).

Which leaves the env, how the app is compiled/linked and with which SDK version it was originally linked. With only the given information that’s the only differences between vulkaninfo and the app I can see, hence the nature of my suggestions.

Oh and would you try to enable the layers from env (instead programatically) using VK_INSTANCE_LAYERS?

I finally, found the reason and solution too.

There was my stupid fault - i feel a little shame about that.

I’ve run setup-env.sh from terminal and it sets environment variables locally, but my application was not child process for that terminal, and could not see those variables from terminal’s environment.

(but vulkaninfo i’ve run from the same terminal as setup-env.sh, thats why vulkaninfo could work correctly)

Actually, in my case there is no suit way to setup common environment - some time i need to run my application from terminal, sometime as child process of IDE, sometime as child process of debugger ans etc - so, i just copy all manifest files to default location: /home/<user_name>/.local/share/vulkan/explicit_layer.d, and now everything works fine.

Thanks for the help.

BTW, VK_EXT_debug_report helps a lot, especially you setup VK_DEBUG_REPORT_DEBUG_BIT_EXT and VK_DEBUG_REPORT_INFORMATION_BIT_EXT, in this case debug callback show you where the loader actually attempts to find manifest files.

In my case debug output looks like that:

DEBUG: loader Code 0: Searching the following paths for manifest files: /etc/vulkan/explicit_layer.d:/usr/share/vulkan/explicit_layer.d

DEBUG: loader Code 0: Searching the following path for manifest files: /home/bantdit/.local/share/vulkan/explicit_layer.d

DEBUG: loader Code 0: Searching the following paths for manifest files: /etc/vulkan/implicit_layer.d:/usr/share/vulkan/implicit_layer.d

DEBUG: loader Code 0: Searching the following path for manifest files: /home/bantdit/.local/share/vulkan/implicit_layer.d

INFO: loader Code 0: Found manifest file /home/bantdit/.local/share/vulkan/explicit_layer.d/VkLayer_object_tracker.json, version “1.0.0”
INFO: loader Code 0: Found manifest file /home/bantdit/.local/share/vulkan/explicit_layer.d/VkLayer_unique_objects.json, version “1.0.0”
INFO: loader Code 0: Found manifest file /home/bantdit/.local/share/vulkan/explicit_layer.d/VkLayer_swapchain.json, version “1.0.0”
INFO: loader Code 0: Found manifest file /home/bantdit/.local/share/vulkan/explicit_layer.d/VkLayer_api_dump.json, version “1.0.0”
INFO: loader Code 0: Found manifest file /home/bantdit/.local/share/vulkan/explicit_layer.d/VkLayer_image.json, version “1.0.0”
INFO: loader Code 0: Found manifest file /home/bantdit/.local/share/vulkan/explicit_layer.d/VkLayer_threading.json, version “1.0.0”
INFO: loader Code 0: Found manifest file /home/bantdit/.local/share/vulkan/explicit_layer.d/VkLayer_vktrace_layer.json, version “1.0.0”
INFO: loader Code 0: Found manifest file /home/bantdit/.local/share/vulkan/explicit_layer.d/VkLayer_core_validation.json, version “1.0.0”
INFO: loader Code 0: Found manifest file /home/bantdit/.local/share/vulkan/explicit_layer.d/VkLayer_screenshot.json, version “1.0.0”
INFO: loader Code 0: Found manifest file /home/bantdit/.local/share/vulkan/explicit_layer.d/VkLayer_parameter_validation.json, version “1.0.0”
INFO: loader Code 0: Found meta layer VK_LAYER_LUNARG_standard_validation, replacing with actual layer group
DEBUG: loader Code 0: Searching the following paths for manifest files: /etc/vulkan/icd.d:/usr/share/vulkan/icd.d

DEBUG: loader Code 0: Searching the following path for manifest files: /home/bantdit/.local/share/vulkan/icd.d

INFO: loader Code 0: Found manifest file /etc/vulkan/icd.d/nvidia_icd.json, version “1.0.0”
DEBUG: loader Code 0: Searching for ICD drivers named libGLX_nvidia.so.0 default dir

DEBUG: loader Code 0: Build ICD instance extension list
DEBUG: loader Code 0: Instance Extension: VK_KHR_surface (libGLX_nvidia.so.0) version 0.0.25
DEBUG: loader Code 0: Instance Extension: VK_KHR_xcb_surface (libGLX_nvidia.so.0) version 0.0.6
DEBUG: loader Code 0: Instance Extension: VK_KHR_xlib_surface (libGLX_nvidia.so.0) version 0.0.6
DEBUG: loader Code 0: Instance Extension: VK_EXT_debug_report (libGLX_nvidia.so.0) version 0.0.2
DEBUG: loader Code 0: Chain: instance: Loading layer library libVkLayer_unique_objects.so
INFO: loader Code 0: Insert instance layer VK_LAYER_GOOGLE_unique_objects (libVkLayer_unique_objects.so)
DEBUG: loader Code 0: Chain: instance: Loading layer library libVkLayer_swapchain.so
INFO: loader Code 0: Insert instance layer VK_LAYER_LUNARG_swapchain (libVkLayer_swapchain.so)
DEBUG: loader Code 0: Chain: instance: Loading layer library libVkLayer_core_validation.so
INFO: loader Code 0: Insert instance layer VK_LAYER_LUNARG_core_validation (libVkLayer_core_validation.so)
DEBUG: loader Code 0: Chain: instance: Loading layer library libVkLayer_image.so
INFO: loader Code 0: Insert instance layer VK_LAYER_LUNARG_image (libVkLayer_image.so)
DEBUG: loader Code 0: Chain: instance: Loading layer library libVkLayer_object_tracker.so
INFO: loader Code 0: Insert instance layer VK_LAYER_LUNARG_object_tracker (libVkLayer_object_tracker.so)
DEBUG: loader Code 0: Chain: instance: Loading layer library libVkLayer_parameter_validation.so
INFO: loader Code 0: Insert instance layer VK_LAYER_LUNARG_parameter_validation (libVkLayer_parameter_validation.so)
DEBUG: loader Code 0: Chain: instance: Loading layer library libVkLayer_threading.so
INFO: loader Code 0: Insert instance layer VK_LAYER_GOOGLE_threading (libVkLayer_threading.so)
DEBUG: loader Code 0: Build ICD instance extension list
DEBUG: loader Code 0: Instance Extension: VK_KHR_surface (libGLX_nvidia.so.0) version 0.0.25
DEBUG: loader Code 0: Instance Extension: VK_KHR_xcb_surface (libGLX_nvidia.so.0) version 0.0.6
DEBUG: loader Code 0: Instance Extension: VK_KHR_xlib_surface (libGLX_nvidia.so.0) version 0.0.6
DEBUG: loader Code 0: Instance Extension: VK_EXT_debug_report (libGLX_nvidia.so.0) version 0.0.2

it makes loading process clear enough.

Sorry, I should have seen that it had to be environment related since it worked in one case, but not the other.

Depending on your Linux install and shell that you are using, you should be able to set env vars so that they take effect for all your use cases. For example, if you are using bash, then setting them in ~/.profile and/or ~/.bash_profile would set them for all login shells. (Read the bash docs about these files)