KhronosGroup / Vulkan-ValidationLayers

Vulkan Validation Layers (VVL)
https://vulkan.lunarg.com/doc/sdk/latest/linux/khronos_validation_layer.html
Other
777 stars 407 forks source link

Test suite crashes #7893

Open MennoVink opened 7 months ago

MennoVink commented 7 months ago

Environment:

Describe the Issue

I'm trying to run the testsuite according to these steps: https://github.com/KhronosGroup/Vulkan-ValidationLayers/issues/7891#issuecomment-2072390560 It mostly works fine up until about 30 tests in. Then it crashes inside TEST_F(VkBestPracticesLayerTest, UseDeprecatedInstanceExtensions) The loader jumps through graphics-hook64 (i think obs?) and then crashes in RTSSVkLayer64 (riva tuner statistics server, shipped with MSI Afterburner)

Expected behavior

The testsuite protects itself against faulty implicit layers. For example with the VK_LOADER_LAYERS_DISABLE + VK_LOADER_LAYERS_ENABLE combination.

artem-lunarg commented 7 months ago

OBS causes this issue. There is this documentation section: https://github.com/KhronosGroup/Vulkan-ValidationLayers/tree/main/tests#implicit-layers-note

Maybe this can be categorized as this issue https://github.com/KhronosGroup/Vulkan-ValidationLayers/issues/3681 (@spencer-lunarg )

I also have problem with OBS locally, and usually use this brute force solution (notice the underscore to disable layer), but I guess the best practice is to use the method from documentation: image

charles-lunarg commented 7 months ago

VK_LOADER_LAYERS_DISABLE=VK_LAYER_OBS_HOOK works well for disabling layers while running tests. To make it work for multiple layers, use a semicolon for windows and colon for linux/macOS.

So for windows: VK_LOADER_LAYERS_DISABLE=VK_LAYER_OBS_HOOK;VK_LAYER_RTSS

Linux/MacOS VK_LOADER_LAYERS_DISABLE=VK_LAYER_OBS_HOOK:VK_LAYER_RTSS

As for the tests setting these by themselves, its possible but doesn't work on older loaders (so only loaders 1.3.234 and newer will respect the environment variable). VK_LOADER_LAYERS_DISABLE=~implicit~ is the way to disable ALL implicit layers.

spencer-lunarg commented 7 months ago

@charles-lunarg is there a way for the app (in this case the VVL test app) to do the VK_LOADER_LAYERS_DISABLE here when creating the VkInstance?

charles-lunarg commented 7 months ago

@charles-lunarg is there a way for the app (in this case the VVL test app) to do the VK_LOADER_LAYERS_DISABLE here when creating the VkInstance?

If you mean through the Vulkan API, there is not one as far as I know.

However, it is not difficult to set environment variables. I recently made validation set VK_LAYER_PATH if it wasn't set already. It'd be trivial to set VK_LOADER_LAYERS_DISABLE=~implicit~ as well.

MennoVink commented 7 months ago

In my own apps i do something like this before i start using vulkan, copy it as you please

static bool SetEnvVar( char* envVarString )
{
#if defined( MEVI_WINDOWS )
    return _putenv( envVarString ) == 0;
#else
    return putenv( envVarString ) == 0;
#endif
}
bool VulkanLoader::SetDisabledLayers( ArrayProxy< const String > globPatterns )
{
    String envVar = "VK_LOADER_LAYERS_DISABLE=";
    for( size_t index = 0; index < globPatterns.Size(); ++index )
    {
        envVar << globPatterns[ index ];
        if( index < globPatterns.Size() - 1 )
            envVar << ",";
    }
    return SetEnvVar( envVar.GetCString() ) == 0;
}