Moves the definition of VK_NO_PROTOTYPES out of a header and into cmake so that
so that libraries and executables can set or not set it if they so desire. This
allows binaries to link directly to the loader if need be.
While CMake will append appropriate file extensions when the full name isn't
given, such as "wrap_objects", it is best to specify the file with its
extension for explicitness.
* Googletest has been updated to 1.11 which means the TR1 deprecation notice is
unecessary.
* The `/permissive-` flag has been moved to loader_common_options so it doesn't
have to be repeated over and over.
* Since we do not support VS 2013 and early, use /guard:cf everywhere
* Remove MSVC_LOADER_COMPILE_OPTIONS in favor of loader_common_options
* Remove reduntant compile options and include directories
Move the WSI macro defines into their own target such that it can be shared
with the loader and test code. Note that this commit is a part of a series
and not intended to work standalone.
Add "additive" environment variables for adding additional layer
paths or driver JSON files instead of replacing default ones.
Also, rename VK_ICD_FILENAMES to VK_DRIVER_FILES since we're trying
to remove references to ICDs because software driver implementations
of Vulkan aren't ICDs (but continue to support the old name as well).
Added documentation around these changes to reflect the new name and
the new variables.
Angle drops the security enforcement of the loader on environment
variables and the additional "is_high_integrity" checks on my
previous loader change caused failures in the Angle run.
Revert the high-integrity checks and update the layer test to
work properly.
Enable testing to check if the loader is running with elevated
privileges. This is to make sure we're ignoring the appropriate
environment variables in those scenarios to potentially avoid
escalation exploits.
My previous commit to enable physical device modifications in a layer
required new compiled layers to do the work. Since this can more
cleanly be done by setting layer flags (as suggested by @charles-lunarg)
I have gone back and done that.
The loader trampoline previously would query all devices every time
vkEnumeratePhysicalDevices was called.
To do this, it would make two calls every time:
- First, it would ignore the passed in user values
- Second, it would query the total number of available devices.
- Third, it would query the values for every available device
This resulted in layers reporting 2 vkEnumeratePhysicalDevices call for
every 1 the application made which could get very polluted in output.
It didn't break any functionality, just made things messy.
This change removes that behavior and adds a bunch of test cases to verify
nothing broke in the move.
Don't build live verification tests by default. These are meant as manual tests for
developers to run to diagnose issues or verify correctness on a real system.
Since device layers are pretty much ignored, make sure that they don't
change any behavior.
Also add a few "load" entrypoint helper routines based on what was already
done elsewhere in the test system.
Some things need to be verified against real drivers. The supporting code in test_util and
test_environment make it easy to write application code which works against real drivers and
layers. This allows quickly verifying loader behavior out in the wild.
Add tests for unknown device functions queried with both vkGetDeviceProcAddr
and vkGetInstanceProcAddr. Also loops enough times to exhaust the available
unknown function supply.
Had to fix the vk_layerGetPhysicalDeviceProcAddr in TestLayer to make the tests
pass.
MacOS currently skips tests which use vkGetInstanceProcAddr. This is due to the
need for unknown functions being lower priority and so do not warrent the time
needed to write the assembly necessary to resolve the issue fully.
Add tests to verify that the 3 pre-instance functions are properly
intercepted by the layer when everything is well-defined.
Also include two fixes:
1) Disable environment variable value of 0 should be treated the same as not present
2) The vkEnumerateInstanceVersion override path was broken, missing a NULL check
If a meta layer which contains `override_paths` is active, all of the paths in
VK_LAYER_PATH are ignored when searchign for explicit layers. This may be changed
changed in the future but for now is better tested and documented.
Adds 2 tests:
* ZeroPhysicalDevices - Return VK_ERROR_INITIALIZATION_FAILED if the driver has zero
physical devices.
* ZeroPhyiscalDeviceExtensions - Return VK_SUCCESS if no physical device extensions are
found.
There was a regression with 1.3 that meant vkGetInstanceProcAddr wouldn't be
able to query itself if instance was set for 1.3. This commit makes it possible
to query for vkGetInstanceProcAddr with itself no matter the value of instance.
Verify that using vkGetInstanceProcAddr to get an entrypoint to a device
extension works when the extension is enabled, and crashes when the
extension isn't enabled.
Also, update a copyright notice date for my last commit.
Add 2 tests to verify that physical devices supporting instance
and device extensions (which are really physical device extensions)
are properly handled.
We had tests that verified that instance and device extensions defined
in a layer had the non-null pointers returned from the corresponding
vkGetXXXProcAddr functions, but we weren't verifying that the functions
actually got called.
This should throw an error message if a requested layer didn't load.
This could happen if the JSON file is present, but only a library
exists on the system for the wrong target (like 32 vs 64-bit).
If it did fail because of being the wrong bit-type, we report an info
message only, unless it was directly requested by the application.
Modify the improper bit-depth layer loading test so that it is now 4
tests:
- Verify bad explicit layer generates VK_ERROR_LAYER_NOT_PRESENT error
- Verify bad implicit layer generates only an info in the loader output
- Test case with both a bad implicit and explicit layer with INFO logging
we should see both messages.
- Test case with both a bad implicit and explicit layer with ERROR logging
we should see only the explicit failure message.
Report info failure for ICD wrong bit-type as well.
Finally, fixed a small compilation warning for disabled code.
The VK_MAKE_API_VERSION macro and the VK_API_VERSION_1_X macros are better to
use. This commit switches the tests over to the non-deprecated versions of the
macros.
The 1.2.175 header release saw the addition of API Variants. For the purposes
of the loader, this should always be set to 0. If this value isn't zero, the
loader should warn about it.
The older VK_VERSION_XXX macros are deprecated and cause confusion when they
report a MAJOR version that is above zero. All uses of the deprecated macro are
now replaced with the correct macro.
The loader disables implicit layers if their API version isn't the same or
greater than the application. Make sure this still works even with pre 1.0
versions.
Add 4 tests:
* Shows the override_paths object in the layer manifest is being used to find a
layer.
* Shows that regular explicit layers are not found
* Shows that the log properly identifies meta layers which have an
override_paths object but shouldn't according to their manifest.
* Shows that implicit layers not in the override paths are not found.
Increasingly it is common to need more control over what the framework
environment does when adding layers. While only a refactor, this change
makes it easier to extend the functionality by adding data to the
TestLayerDetails struct.
The code to check whether the lib_path specified in add_layer_impl was
improved by using the `.stem()` functionality of the fs::path abstraction.
size_t was replaced with uint32_t where the compiler gave warnings.
It is good practice to make use of equality checks vs comparison checks where
possible. Here, the number of extensions is knowable, as its debug_report +
debug_utils + however many come from implicit layers, which some tests do.
This allows easily checking that the returned list of extensions or layers
is a valid permutation. Since the order of layers and extensions isn't
deterministic, tests cannot rely on the returned order to verify the output.
Add tests for:
ExplicitMetaLayer - meta layer found in explicit paths
MetaLayerNameInComponentLayers - meta layer contains itself
MetaLayerWhichAddsmetaLayer - when a meta layer enables another meta layer
InstanceExtensionInComponentLayer - instance extension propagation
DeviceExtensionInComponentLayer - device extension propagation
OverrideMetaLayer.OlderVersionThanInstance - Checks behavior of override layer
if the applications version is greater.
Condense the overloaded write function from taking either an icd manifest or a layer manifest
and only take a string. This reduces the amount of copy-paste code.
The environment variable VK_LOADER_TEST_LOADER_PATH allows running of tests
using a different binary than the one built by the repo. This is extremely
useful for checking that a test exercises a bugfix, by quickly allowing the
running of the same test on the current 'fixed' loader and an older 'broken'
loader.
Add NewerInstanceVersionThanImplicitLayer test which exercises the loader's
removal of layers whoses API version is less than the application specified
API version.
Adds three tests:
* OlderMetaLayerWithNewerInstanceVersion - Checks for interaction between app's
instance version and the meta layer version
* NewerComponentLayerInMetaLayer - When a component layer has an API version
newer than the meta layer, the meta layer is disabled.
* OlderComponentLayerInMetaLayer - When a component layer has an API version
older than the meta layer, the meta layer is disabled.
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.
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.
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.
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.
Basic tests which just makes sure the trampoline + terminator pass the data
through correctly. Data only originates from TestICD, TestLayer has no
support for the extension.
The code was written with an assumption that the functions needed to be inlined
so they would appear in the correct places (both the test binaries and shim
library). This can be achieved using static libraries, which is what this
commit does.
Warnings/fixes include:
* strcpy/strncpy/wstrcpy
* Dropping static on inline functions
* Use localtime_s
* Name shadowing
* Use wcstombs_s
* 32<->64 bit int conversion
* Silence spurious C4996 generated in vs2015
The issue was that trying to get a non-pre-instance function with a NULL
instance handle would cause a crash. This change also adds a test that
would of caught the oversight.
Added FreeBSD in supported platforms in vk_loader_platform.h, and tests,
defined BSD_VISIBLE and included some necessary header files for
Vulkan-Loader to compile on FreeBSD.
v2: did the same in loader/loader.c (Charles Giessen)
v3: did the same in the tests (Charles Giessen)
v4: applied this downstream patch from Jan Beich because there's no /proc
on FreeBSD: 7caf52e37b/graphics/vulkan-loader/files/patch-loader_vk__loader__platform.h (Jan Beich)
v4: rebased to master and modified tests/loader_regression_tests.cpp,
tests/loader_testing_main.cpp
v5: moved the definition of __BSD_VISIBLE 1 (required for alloca to
work) in CMakeLists.txt from header files (Charles Giessen)
v6: replaced ${CMAKE_SYSTEM_NAME} with CMAKE_SYSTEM_NAME in
loader/CMakeLists.txt to match the style of previous checks (Jan Beich)
v7: replaced add_compile_definitions with target_compile_definitions to
prevent the macro from being applied unnecessarily (Charles Giessen)
vkGetInstanceProcAddr should only return the pre-instance, aka global
functions, when the VkInstance handle is NULL. This brings the desktop
vulkan loader into alignment on the spec and with the android loader.
https://github.com/KhronosGroup/Vulkan-Docs/issues/1605
The repo previously did follow this rule, but was changes in the
1.0.42 header version timeframe for unknown reasons.