The code previously would only log meta-layer messages when the instance
isn't NULL (so never during pre-instance calls). This leads to critical
information being left out while debugging, making issues harder to
diagnose.
The check assumed that 1.1.x was the highest Layer Manifest version in existance.
This causes 1.2 layer manifests to erroneously report a message. No functionality
is affected by the check, so this commit just silences a wrong warning.
The loader ICD ordering could be random on Linux based on using readdir
to find ICD manifest files. This can result in random behaviors as
applications that select only the first device can switch which device is
used. To resolve this, we now sort based on device type and then
internally to the types based on PCI bus information.
This also introduces a VK_LOADER_DEFAULT_DEVICE environment variable
that can be used to force a specific PCI device. This environment variable
is actually a duplicate of the MESA_VK_DEVICE_SELECT variable, which is
also looked for if the loader environment variable is not found.
Note, that at least one ICD must support it for the extension to be used at all.
So we only do the sorting if one ICD supports it.
Fixes part of #657
Add tests which exercise the case of a ICD being 1.0 with support for
VK_KHR_get_physical_device_properties2 while the ICD enables 1.1 and the
extension but tries to use the extension.
Removed TEST_F in this file, wasn't needed and caused an extra ICD to be found.
Converted the CompareXXX functions from internally using ASSERT_EQ to returning
a bool. This made the tests more robust since ASSERT_EQ in a function will just
return the function early, not end the test.
The functions added from VK_KHR_get_physical_device_properties2 were made core, but a
recent loader change meant that an application which was trying to use the extension may
use the fallback version (which ignores the pNext chain). This breaks existing
applications and thus needs to be rectified. This commit makes it so that if the core
GetPhysicalDeviceXXX functions aren't available and the extension is supported & enabled,
the extension version is used instead.
Simplified the WSI tests so that they don't actually create the
platform surfaces and attach them. Instead, the test_icd framework
allows us to simply provide a dummy. This allows the tests to work
in the regresssion framework. Because of this, removed the separate
test_wsi test and merged it into test_regression.
Fixed several compiler warnings from my previous change as well.
Fix some loader terminator functions for instance physical device
functions (that were pre-Vulkan 1.1). At that point in the API, we
didn't treat VkPhysicalDevices like VkDevices. Now, you must first
query the device for extension support for even VkPhysicalDevice calls.
Back then, the loader had to emulate the functionality.
Added tests to validate many of these functions.
Unfortunately, the taxonomy used for CMAKE_SYSTEM_PROCESSOR is
OS-specific: on Windows, IA32 is identified as x86, but on Linux,
it can be identified as i386, i486, i586 or i686.
Signed-off-by: Simon McVittie <smcv@collabora.com>
If we are cross-compiling, for example for aarch64 on x86, then the
compiler we care about here is the machine we are compiling *for*,
e.g. aarch64 (the "target" in CMake terminology, the "host system" in
Autotools/Meson) rather than the machine we are compiling *on*, e.g. x86
(the "host" in CMake terminology, the "build system" in Autotools/Meson).
Signed-off-by: Simon McVittie <smcv@collabora.com>
Define expected behavior for a well-behaved loader, layers, and drivers.
This has been reviewed with other companies so that when issues arise,
it is easy to clearly communicate where one of the components has failed
to properly behave.
Add warnings/errors in the loader output when cases of policy that can
be detected are noticed.
The test framework was not clearing out old registry values after successive
test runs. The new logic now correctly clears out the files and registry keys
after each run.
By adding builder style usage to most of the layer interface, it is easier to
create and use layers in tests. This commit refactors the layer interface and
updates most of the tests to use this style.
Move all the behavior found in child classes of FrameworkEnvironment to the
FrameworkEnvironment itself, allowing easier composibility of behavior. The
original idea was to allow special case behavior for specific test cases but
this resulted in a lot of code duplication and difficulty combining different
framework behavior, such as adding a fake ICD and setting VK_ICD_FILENAMES at
the same time.
Make use of BUILDER_VALUE and BUILDER_VECTOR in the various structs of the test
framework. This allows easier usage of the components by allowing a builder
style continuation of setting parameters in the drivers and physical devices.
The CheckCreate function was not correctly checking that the VkResult matched what was
expected. The old code required the client to wrap the call in EXPECT_TRUE().
Passing in a VkInstanceCreateInfo where the layer count or extension count was non zero but
their respective pointers were NULL caused a nullptr dereference. The loader now checks for
this condition in the layer and instance extension validation functions and returns
VK_ERROR_LAYER|EXTENSION_NOT_PRESENT.
Previously, Death tests would unknowningly create multiple registry overrides
and subsequently leak them when the death test dies. This is fixed by only
calling override once in main and setting an environment variable to prevent
subprocesses (death tests) from calling override again.
This change also moves the override setup from the shim setup to main, since
it had no depencies on the shim library itself.
Vulkan header updated 1.2.193 changed the behavior of vkGetInstanceProcAddr for
global entrypoints. They used to always be returned regardless of the value of
the instance paramtere. The spec was amended in this version to only allow
querying global level entrypoints with a NULL instance. However, as to not
break old applications, the new behavior is only applied if the instance passed
in is both valid and minor version is greater than 1.2, which was when this
change in behavior occurred. Only instances with a newer version will get the
new behavior.
When handle wrapping is performed in a layer, the loader would provide the incorrect
instance handles after the recent handle validation changes. This was exposed by
RenderDoc.
Also add several tests to catch this case.
Need to use target_compile_definitions instead of target_compile_options.
Also appears that generator expressions do not play nicely, so best to revert
to classic if-else chains.
The Windows-2016 environment is being removed March 15 2022. In preparation
of this, the loader will only use windows-latest and remove the workarounds
that were in place to run on the Windows-2016 environment.
Additionally, redundant manual downloading of detours was removed.
The readlink function required _GNU_SOURCE to be a compiler definition but
wasn't added since it was in a different executable than the main vulkan
loader. Adding it to the asm_offset target fixes the error.
Some tests were failing in the validation layer tests because it expected
the validation layers to catch certain issues and return specific messages.
The loader had been modified to include catching those tests and failing
early, but this change undoes those checks as it wasn't really part
of handle validation.
Validate the Vulkan dispatchable handles (VkInstance, VkPhysicalDevice, etc) for
any trampoline functions the loader uses to query the dispatch table from.
This is so we can at least report errors before something bad happens.
Also, add tests to the test framework to catch this case. Right now they simply
check to make sure we aborted, but they don't know why the loader aborted.
Eventually, we need to come back and check the loader messages and make sure it
aborted for the reasons we want.
Fix a generator warning in dispatch_table_helper_generator.py where a compare was
the wrong type.
Fixes GH Issue #64.
The loader recently added support for calling into drivers in
vkGetPhysicalDeviceToolPropertieesEXT. However, it only used the value of
the function pointer to determine if it was safe. It was found that Mesa
drivers will return a non-null function pointer, even though they do not
support the extension, and so the loader called this function pointer which
would then segfault.
The loader prevents this by first checking if the extension is supported by
the physical device. This necessitates calling
vkEnumerateDeviceExtensionProperties and allocating some memory on each call
but since the number of times this function is called should be low, it is
not an undue performance burden. In the future, the loader should cache the
list of extensions when calling vkEnumeratePhysicalDevices so that checking if
a extension function is supported is fast and easy.