4

I'm new to Vulkan, and I've been following vulkan-tutorial.com which has been a great resource so far.

However, one weird thing I've come to realize is that validation layers are supported on my device, but cannot be used without being overridden in vkconfig.

Following the tutorial, this is my C++ code at the moment:

auto check_validation_layer_support() -> bool
{
    // Get the number of layers
    uint32_t layerCount = 0U;
    vkEnumerateInstanceLayerProperties(&layerCount, nullptr);

    // Get the layer properties
    std::vector<VkLayerProperties> availableLayers(layerCount);
    vkEnumerateInstanceLayerProperties(&layerCount, availableLayers.data());

    // Iterate through to check support
    for (const char* layerName : VulkanInstance::validationLayers)
    {
        bool layerFound = false;
        for (const auto& layerProperties : availableLayers)
        {
            if (strcmp(layerName, layerProperties.layerName) == 0)
            {
                layerFound = true;
                break;
            }
        }

        if(!layerFound)
            return false;
    }

    return true;
}
static constexpr std::array<const char* const, 1UL> validationLayers {
    "VK_LAYER_KHRONOS_validation",
};
source "/opt/vulkansdk/1.3.224.1/setup-env.sh"
export VK_LAYER_PATH="$VULKAN_SDK/lib/vulkan/layers"
export VK_INSTANCE_LAYERS="VK_LAYER_LUNARG_api_dump:VK_LAYER_KHRONOS_validation"

When running vkconfig and overriding to use Validation Layers, suddenly everything works perfectly fine. However, if it is not a forced override, it will not work at all.

I'm using the LunarG SDK (1.3.224.1) for Arch Linux (Wayland).

1 Answer 1

6

Your setting for VK_LAYER_PATH does not look right. The setup script should set a "layer path" environment variable for you and so you could try not exporting VK_LAYER_PATH after running the setup script. And if you were to set VK_LAYER_PATH, it should be something like $VULKAN_SDK/etc/vulkan/explicit_layer.d.

Note that the setup script actually sets VK_ADD_LAYER_PATH which tells the loader to look in the SDK in addition to and before the system default paths. Setting VK_LAYER_PATH after running the setup script causes the loader to ignore VK_ADD_LAYER_PATH and use only VK_LAYER_PATH, which was faulty in your case. This left the loader with no good paths to find layers.

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

2 Comments

Thanks so much for your response! I removed the VK_LAYER_PATH export in my ~/.bashrc file and that seems to have fixed the issue when running the program, though $VK_LAYER_PATH is effectively null in Bash's perspective.
The startup script sets VK_ADD_LAYER_PATH, not VK_LAYER_PATH. VK_ADD_LAYER_PATH is the same thing as VK_LAYER_PATH except that VK_ADD_LAYER_PATH also searches the system's layer install directories after looking in the specified path, which is in the SDK in this case. This lets you load layers that might be installed on your system that are not in the SDK. So you would not expect VK_LAYER_PATH to be set to anything.

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.