Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Regression: VK_INSTANCE_LAYERS is not respecting the layer order #1168

Closed
HansKristian-Work opened this issue Mar 30, 2023 · 12 comments · Fixed by #1170
Closed

Regression: VK_INSTANCE_LAYERS is not respecting the layer order #1168

HansKristian-Work opened this issue Mar 30, 2023 · 12 comments · Fixed by #1170
Assignees
Labels
bug Something isn't working

Comments

@HansKristian-Work
Copy link

With this profile:

{
    "$schema": "https://schema.khronos.org/vulkan/profiles-0.8.0-139.json#",
    "capabilities": {
        "baseline": {
            "extensions": {
                "VK_KHR_16bit_storage": 1,
                "VK_KHR_8bit_storage": 1,
                "VK_KHR_create_renderpass2": 1
            },
            "features": {
                "VkPhysicalDeviceFeatures": {
                    "robustBufferAccess": false
                }
            }
        },
        "externalHost": {
            "extensions": {
                "VK_EXT_external_memory_host": 1
            },
            "features": {
                "VkPhysicalDeviceFeatures": {
                    "robustBufferAccess": false
                }
            },
            "properties": {
                "VkPhysicalDeviceExternalMemoryHostPropertiesEXT": {
                    "minImportedHostPointerAlignment": 65536
                }
            }
        }
    },
    "profiles": {
        "VP_PARALLEL_RDP_baseline": {
            "version": 1,
            "api-version": "1.1.0",
            "label": "parallel-RDP baseline profile",
            "description": "Minimum baseline for running parallel-RDP.",
            "contributors": {},
            "history": [
                {
                    "revision": 1,
                    "date": "2023-03-30",
                    "author": "Themaister",
                    "comment": "First draft"
                }
            ],
            "capabilities": [
                "baseline"
            ]
        },
        "VP_PARALLEL_RDP_optimal": {
            "version": 1,
            "api-version": "1.1.0",
            "label": "parallel-RDP optimal profile",
            "description": "Optimal configuration for running parallel-RDP.",
            "contributors": {},
            "history": [
                {
                    "revision": 1,
                    "date": "2023-03-30",
                    "author": "Themaister",
                    "comment": "First draft"
                }
            ],
            "capabilities": [
                "baseline", "externalHost"
            ]
        }
    }
}

I set up env-variables:

export VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation:VK_LAYER_KHRONOS_profiles
export VK_KHRONOS_PROFILES_PROFILE_FILE=blah.json
export VK_KHRONOS_PROFILES_PROFILE_NAME=VP_PARALLEL_RDP_optimal
export VK_KHRONOS_PROFILES_SIMULATE_CAPABILITIES=SIMULATE_API_VERSION_BIT,SIMULATE_FEATURES_BIT,SIMULATE_PROPERTIES_BIT,SIMULATE_EXTENSIONS_BIT,SIMULATE_FORMATS_BIT,SIMULATE_QUEUE_FAMILY_PROPERTIES_BIT

I got this from https://github.com/KhronosGroup/Vulkan-ValidationLayers/tree/main/tests#running-tests-on-mockicd-and-profiles-layer

And I get:

VUID-vkGetPhysicalDeviceFormatProperties2-format-parameter(ERROR / SPEC): msgNum: 1183011175 - Validation Error: [ VUID-vkGetPhysicalDeviceFormatProperties2-format-parameter ] Object 0: VK_NULL_HANDLE, type = VK_OBJECT_TYPE_DEVICE; | MessageID = 0x46835167 | vkGetPhysicalDeviceFormatProperties2: value of format (1000330000) does not fall within the begin..end range of the core VkFormat enumeration tokens and is not an extension added token. The Vulkan spec states: format must be a valid VkFormat value (https://www.khronos.org/registry/vulkan/specs/1.3-extensions/html/vkspec.html#VUID-vkGetPhysicalDeviceFormatProperties2-format-parameter)
    Objects: 1
        [0] 0, type: 3, name: NULL
VUID-vkGetPhysicalDeviceFormatProperties2-format-parameter(ERROR / SPEC): msgNum: 1183011175 - Validation Error: [ VUID-vkGetPhysicalDeviceFormatProperties2-format-parameter ] Object 0: VK_NULL_HANDLE, type = VK_OBJECT_TYPE_DEVICE; | MessageID = 0x46835167 | vkGetPhysicalDeviceFormatProperties2: value of format (1000330001) does not fall within the begin..end range of the core VkFormat enumeration tokens and is not an extension added token. The Vulkan spec states: format must be a valid VkFormat value (https://www.khronos.org/registry/vulkan/specs/1.3-extensions/html/vkspec.html#VUID-vkGetPhysicalDeviceFormatProperties2-format-parameter)
    Objects: 1
        [0] 0, type: 3, name: NULL
VUID-vkGetPhysicalDeviceFormatProperties2-format-parameter(ERROR / SPEC): msgNum: 1183011175 - Validation Error: [ VUID-vkGetPhysicalDeviceFormatProperties2-format-parameter ] Object 0: VK_NULL_HANDLE, type = VK_OBJECT_TYPE_DEVICE; | MessageID = 0x46835167 | vkGetPhysicalDeviceFormatProperties2: value of format (1000330002) does not fall within the begin..end range of the core VkFormat enumeration tokens and is not an extension added token. The Vulkan spec states: format must be a valid VkFormat value (https://www.khronos.org/registry/vulkan/specs/1.3-extensions/html/vkspec.html#VUID-vkGetPhysicalDeviceFormatProperties2-format-parameter)
    Objects: 1
        [0] 0, type: 3, name: NULL

etc. In vkEnumeratePhysicalDevices, it seems like the profiles layer is querying YCbCr formats and it ends up in validation layer somehow. This is surprising, given that profile layer should come after validation here. Can be reproduced by calling vulkaninfo.

@spencer-lunarg
Copy link
Contributor

side question, if you are using VK_EXT_ycbcr_2plane_444_formats formats, wouldn't you want your profile to support the extension or Vulkan 1.3?

@HansKristian-Work
Copy link
Author

I'm not using that EXT at all. It's the profile layer that queries the format.

@HansKristian-Work
Copy link
Author

Here's a backtrace:

* thread KhronosGroup/Vulkan-Profiles#1, name = 'MainThread', stop reason = breakpoint 3.1
  * frame #0: 0x000055dcc29c577f rdp-conformance`Vulkan::vulkan_messenger_cb(messageSeverity=VK_DEBUG_UTILS_MESSAGE_SEVERITY_ERROR_BIT_EXT, messageType=2, pCallbackData=0x00007ffd854f3070, pUserData=0x00007ffd854f7e60) at context.cpp:301:52
    frame KhronosGroup/Vulkan-Profiles#1: 0x00007f064dfbf425 libVkLayer_khronos_validation.so`::debug_log_msg(debug_data=0x000055dcc4d619e0, msg_flags=8, objects=0x00007ffd854f3680, layer_prefix="Validation", message="vkGetPhysicalDeviceFormatProperties2: value of format (1000330000) does not fall within the begin..end range of the core VkFormat enumeration tokens and is not an extension added token. The Vulkan spec states: format must be a valid VkFormat value (https:/"..., text_vuid="VUID-vkGetPhysicalDeviceFormatProperties2-format-parameter") at logging.cpp:198:67
    frame KhronosGroup/Vulkan-Profiles#2: 0x00007f064dfc0621 libVkLayer_khronos_validation.so`LogMsg(debug_data=0x000055dcc4d619e0, msg_flags=8, objects=0x00007ffd854f3680, vuid_text="VUID-vkGetPhysicalDeviceFormatProperties2-format-parameter", format="%s: value of %s (%d) does not fall within the begin..end range of the core %s enumeration tokens and is not an extension added token.", argptr=0x00007ffd854f34e0) at logging.cpp:434:25
    frame KhronosGroup/Vulkan-Profiles#3: 0x00007f064d16ca42 libVkLayer_khronos_validation.so`ValidationObject::LogError(this=0x000055dcc570bb40, objlist=0x00007ffd854f3680, vuid_text="VUID-vkGetPhysicalDeviceFormatProperties2-format-parameter", format="%s: value of %s (%d) does not fall within the begin..end range of the core %s enumeration tokens and is not an extension added token.") const at chassis.h:4026:39
    frame KhronosGroup/Vulkan-Profiles#4: 0x00007f064d8f0c9e libVkLayer_khronos_validation.so`bool StatelessValidation::ValidateRangedEnum<VkFormat>(this=0x000055dcc570bb40, apiName="vkGetPhysicalDeviceFormatProperties2", parameterName=0x00007ffd854f3740, enumName="VkFormat", value=VK_FORMAT_G8_B8R8_2PLANE_444_UNORM, vuid="VUID-vkGetPhysicalDeviceFormatProperties2-format-parameter") const at stateless_validation.h:670:25
    frame KhronosGroup/Vulkan-Profiles#5: 0x00007f064d843677 libVkLayer_khronos_validation.so`StatelessValidation::PreCallValidateGetPhysicalDeviceFormatProperties2(this=0x000055dcc570bb40, physicalDevice=0x000055dcc5788110, format=VK_FORMAT_G8_B8R8_2PLANE_444_UNORM, pFormatProperties=0x00007ffd854f3930) const at parameter_validation.cpp:8682:31
    frame KhronosGroup/Vulkan-Profiles#6: 0x00007f064d53d052 libVkLayer_khronos_validation.so`vulkan_layer_chassis::GetPhysicalDeviceFormatProperties2(physicalDevice=0x000055dcc5788110, format=VK_FORMAT_G8_B8R8_2PLANE_444_UNORM, pFormatProperties=0x00007ffd854f3930) at chassis.cpp:4042:77
    frame KhronosGroup/Vulkan-Profiles#7: 0x00007f064cd29747 libVkLayer_khronos_profiles.so`(anonymous namespace)::EnumeratePhysicalDevices(VkInstance_T*, unsigned int*, VkPhysicalDevice_T**) + 18199
    frame KhronosGroup/Vulkan-Profiles#8: 0x00007f0674527951 libvulkan.so.1`vkEnumeratePhysicalDevices + 145
    frame KhronosGroup/Vulkan-Profiles#9: 0x000055dcc29c7170 rdp-conformance`Vulkan::Context::create_device(this=0x00007ffd854f7e60, gpu_=0x0000000000000000, surface=0x0000000000000000, required_device_extensions=0x0000000000000000, num_required_device_extensions=0, required_features=0x00007ffd854f7a80, flags=1) at context.cpp:602:33
    frame KhronosGroup/Vulkan-Profiles#10: 0x000055dcc29c50c9 rdp-conformance`Vulkan::Context::init_device(this=0x00007ffd854f7e60, gpu_=0x0000000000000000, surface_compat=0x0000000000000000, device_ext=0x0000000000000000, device_ext_count=0, flags=1) at context.cpp:130:20
    frame KhronosGroup/Vulkan-Profiles#11: 0x000055dcc29c51c8 rdp-conformance`Vulkan::Context::init_instance_and_device(this=0x00007ffd854f7e60, instance_ext=0x0000000000000000, instance_ext_count=0, device_ext=0x0000000000000000, device_ext_count=0, flags=1) at context.cpp:146:18
    frame KhronosGroup/Vulkan-Profiles#12: 0x000055dcc2769faa rdp-conformance`RDP::ReplayerState::init_common(this=0x00007ffd854f7e60, custom_device=0x0000000000000000) at conformance_utils.hpp:178:40
    frame KhronosGroup/Vulkan-Profiles#13: 0x000055dcc276a117 rdp-conformance`RDP::ReplayerState::init(this=0x00007ffd854f7e60, device_=0x0000000000000000) at conformance_utils.hpp:196:18
    frame KhronosGroup/Vulkan-Profiles#14: 0x000055dcc276a08b rdp-conformance`RDP::ReplayerState::init(this=0x00007ffd854f7e60) at conformance_utils.hpp:191:13

@spencer-lunarg
Copy link
Contributor

Can be reproduced by calling vulkaninfo.

So I took this blah.json and ran the commands with latest SDK (1.3.243) setting the env listed above, then ran vulkaninfo and couldn't reproduce this

used a debug build and I don't see this going profile->validation like you have

Just to double check, you aren't explicitly enabling layers via VkInstanceCreateInfo::ppEnabledLayerNames

@HansKristian-Work
Copy link
Author

Just to double check, you aren't explicitly enabling layers via VkInstanceCreateInfo::ppEnabledLayerNames

I think in this backtrace ppEnabledLayerNames was using the layer, yes. But vulkaninfo wouldn't do that ... Is there some debug spew I can enable to make it easier to figure out?

@spencer-lunarg
Copy link
Contributor

VK_LOADER_DEBUG=layer can help see what the Loader is doing... shows me

LAYER:            vkCreateInstance layer callstack setup to:
LAYER:               <Application>
LAYER:                 ||
LAYER:               <Loader>
LAYER:                 ||
LAYER:               VK_LAYER_MESA_device_select
LAYER:                       Type: Implicit
LAYER:                 ||
LAYER:               VK_LAYER_KHRONOS_validation
LAYER:                       Type: Explicit
LAYER:                 ||
LAYER:               VK_LAYER_KHRONOS_profiles
LAYER:                       Type: Explicit
LAYER:                 ||
LAYER:               <Drivers>

@HansKristian-Work
Copy link
Author

WARNING | LAYER:  env var 'VK_INSTANCE_LAYERS' defined and adding layers "VK_LAYER_KHRONOS_validation:VK_LAYER_KHRONOS_profiles"
WARNING | LAYER:  env var 'VK_INSTANCE_LAYERS' defined and adding layers "VK_LAYER_KHRONOS_validation:VK_LAYER_KHRONOS_profiles"
DEBUG | LAYER:    Loading layer library libVkLayer_khronos_validation.so
INFO | LAYER:     Insert instance layer "VK_LAYER_KHRONOS_validation" (libVkLayer_khronos_validation.so)
DEBUG | LAYER:    Loading layer library /home/maister/.local/lib/libVkLayer_khronos_profiles.so
INFO | LAYER:     Insert instance layer "VK_LAYER_KHRONOS_profiles" (/home/maister/.local/lib/libVkLayer_khronos_profiles.so)
LAYER:            vkCreateInstance layer callstack setup to:
LAYER:               <Application>
LAYER:                 ||
LAYER:               <Loader>
LAYER:                 ||
LAYER:               VK_LAYER_KHRONOS_profiles
LAYER:                       Type: Explicit
LAYER:                       Manifest: /home/maister/.local/share/vulkan/explicit_layer.d/VkLayer_khronos_profiles.json
LAYER:                       Library:  /home/maister/.local/lib/libVkLayer_khronos_profiles.so
LAYER:                 ||
LAYER:               VK_LAYER_KHRONOS_validation
LAYER:                       Type: Explicit
LAYER:                       Manifest: /usr/share/vulkan/explicit_layer.d/VkLayer_khronos_validation.json
LAYER:                       Library:  libVkLayer_khronos_validation.so
LAYER:                 ||
LAYER:               <Drivers>

[ERROR]: [Vulkan]: Validation Error: Validation Error: [ VUID-vkGetPhysicalDeviceFormatProperties2-format-parameter ] Object 0: VK_NULL_HANDLE

I guess app-explicit layers are moved last? Maybe that explains that. I'll try vulkaninfo ...

@HansKristian-Work
Copy link
Author

Vulkaninfo gets

WARNING: [Loader Message] Code 0 : env var 'VK_INSTANCE_LAYERS' defined and adding layers "VK_LAYER_KHRONOS_validation:VK_LAYER_KHRONOS_profiles"
WARNING | LAYER:  env var 'VK_INSTANCE_LAYERS' defined and adding layers "VK_LAYER_KHRONOS_validation:VK_LAYER_KHRONOS_profiles"
WARNING: [Loader Message] Code 0 : env var 'VK_INSTANCE_LAYERS' defined and adding layers "VK_LAYER_KHRONOS_validation:VK_LAYER_KHRONOS_profiles"
WARNING | LAYER:  env var 'VK_INSTANCE_LAYERS' defined and adding layers "VK_LAYER_KHRONOS_validation:VK_LAYER_KHRONOS_profiles"
DEBUG | LAYER:    Loading layer library libVkLayer_khronos_validation.so
INFO | LAYER:     Insert instance layer "VK_LAYER_KHRONOS_validation" (libVkLayer_khronos_validation.so)
DEBUG | LAYER:    Loading layer library /home/maister/.local/lib/libVkLayer_khronos_profiles.so
INFO | LAYER:     Insert instance layer "VK_LAYER_KHRONOS_profiles" (/home/maister/.local/lib/libVkLayer_khronos_profiles.so)
LAYER:            vkCreateInstance layer callstack setup to:
LAYER:               <Application>
LAYER:                 ||
LAYER:               <Loader>
LAYER:                 ||
LAYER:               VK_LAYER_KHRONOS_profiles
LAYER:                       Type: Explicit
LAYER:                       Manifest: /home/maister/.local/share/vulkan/explicit_layer.d/VkLayer_khronos_profiles.json
LAYER:                       Library:  /home/maister/.local/lib/libVkLayer_khronos_profiles.so
LAYER:                 ||
LAYER:               VK_LAYER_KHRONOS_validation
LAYER:                       Type: Explicit
LAYER:                       Manifest: /usr/share/vulkan/explicit_layer.d/VkLayer_khronos_validation.json
LAYER:                       Library:  libVkLayer_khronos_validation.so
LAYER:                 ||
LAYER:               <Drivers>

ERROR: [Validation] Code 0 : Validation Error: [ VUID-vkGetPhysicalDeviceFormatProperties2-format-parameter ] Object 0: VK_NULL_HANDLE, type = VK_OBJECT_TYPE_DEVICE; | MessageID = 0x46835167 | vkGetPhysicalDeviceFormatProperties2: value of format (1000054000) does not fall within the begin..end range of the core VkFormat enumeration tokens and is not an extension added token. The Vulkan spec states: format must be a valid VkFormat value (https://www.khronos.org/registry/vulkan/specs/1.3-extensions/html/vkspec.html#VUID-vkGetPhysicalDeviceFormatProperties2-format-parameter)

@charles-lunarg
Copy link
Collaborator

charles-lunarg commented Mar 31, 2023

This appears to be a loader bug. EDIT: It definitely is a loader bug :(

I am able to construct a situation in the test framework where VK_INSTANCE_LAYERS=LayerA:LayerB results in a callstack that has an order of B then A.

I will work on fixing this, but in the mean time you can get the correct order by enabling the layers through the application API or by setting the VK_LAYER_PATH to the layers such that the validation layer appears first in the VK_LAYER_PATH env-var.

@spencer-lunarg
Copy link
Contributor

spencer-lunarg commented Mar 31, 2023

by setting the VK_LAYER_PATH to the layers such that the validation layer appears first in the VK_LAYER_PATH env-var

Can confirm this is the issue and I see Hans Kristian's problem now

(Transferred over to Loader repo)

@spencer-lunarg spencer-lunarg transferred this issue from KhronosGroup/Vulkan-Profiles Mar 31, 2023
@charles-lunarg charles-lunarg added the bug Something isn't working label Mar 31, 2023
@christophe-lunarg christophe-lunarg self-assigned this Apr 4, 2023
@charles-lunarg charles-lunarg changed the title Profiles layer triggers validation errors with formats Regression: VK_INSTANCE_LAYERS is not respecting the layer order Apr 5, 2023
@juan-lunarg
Copy link
Contributor

I'm now able to get Ubuntu 22.04 on our CI now that this is fixed. For some reason only 22.04 had this issue on CI but not 20.04
KhronosGroup/Vulkan-ValidationLayers#5597

@HansKristian-Work
Copy link
Author

you can get the correct order by enabling the layers through the application API or by setting the VK_LAYER_PATH to the layers such that the validation layer appears first in the VK_LAYER_PATH env-var.

That seemed to work in the interim, thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants