platform/upstream/Vulkan-Loader.git
2 years agoloader: Try to handle ICD failure in vkEnumeratePhysicalDevices
Adam Jackson [Fri, 3 Dec 2021 16:08:54 +0000 (11:08 -0500)]
loader: Try to handle ICD failure in vkEnumeratePhysicalDevices

If any ICD failed to enumerate device groups here, we would fail the call entirely, which means a broken driver for device A could prevent you from using device B. Just skip over the failing ICD instead.

2 years agoAdd tests to validate layer extensions
Mark Young [Mon, 31 Jan 2022 23:27:36 +0000 (16:27 -0700)]
Add tests to validate layer extensions

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.

2 years agoloader log error if a requested layer not loaded
Mark Young [Thu, 9 Dec 2021 04:16:08 +0000 (21:16 -0700)]
loader log error if a requested layer not loaded

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.

2 years agoFix warning for using wrong variant layers
Charles Giessen [Fri, 28 Jan 2022 23:40:17 +0000 (16:40 -0700)]
Fix warning for using wrong variant layers

Mistakenly used DRIVER instead of LAYER logging level.

2 years agoAdd wrong Variant tests
Charles Giessen [Fri, 28 Jan 2022 19:33:48 +0000 (12:33 -0700)]
Add wrong Variant tests

2 years agoIgnore layers with non zero variant value
Charles Giessen [Fri, 28 Jan 2022 18:28:23 +0000 (11:28 -0700)]
Ignore layers with non zero variant value

Layers which contain an API version where the variant value is non zero are not
designed for the Vulkan-Loader, so it should be ignored.

2 years agoRefactor json and API version parsing code
Charles Giessen [Fri, 28 Jan 2022 18:16:20 +0000 (11:16 -0700)]
Refactor json and API version parsing code

Reuse the loader_api_struct struct and associated parsing functions where
appropriate to reduce code duplication.

2 years agoSkip ICD's with non zero variant value
Charles Giessen [Wed, 26 Jan 2022 22:42:21 +0000 (15:42 -0700)]
Skip ICD's with non zero variant value

If the JSON ICD Manifest contains an api_version that has a non zero variant
value, then the ICD should be skipped since it corresponds to a Vulkan variant.

2 years agoDetect Variant versions in given api versions
Charles Giessen [Wed, 26 Jan 2022 22:40:03 +0000 (15:40 -0700)]
Detect Variant versions in given api versions

Since it is possible that API versions given to the loader have a variant
component, the loader should know how to handle them. It shouldn't use a
variant other than 0, but that is up to the caller to handle.

2 years agoUpdate tests to use correct version macro
Charles Giessen [Wed, 26 Jan 2022 22:14:39 +0000 (15:14 -0700)]
Update tests to use correct version macro

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.

2 years agoWarn when the apiVersion's variant isn't 0
Charles Giessen [Wed, 26 Jan 2022 20:37:04 +0000 (13:37 -0700)]
Warn when the apiVersion's variant isn't 0

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.

2 years agoUse VK_API_VERSION_XXX macros everywhere
Charles Giessen [Wed, 26 Jan 2022 20:26:37 +0000 (13:26 -0700)]
Use VK_API_VERSION_XXX macros everywhere

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.

2 years agoAdd test for implicit layer with 0.1 API version
Charles Giessen [Wed, 26 Jan 2022 20:14:22 +0000 (13:14 -0700)]
Add test for implicit layer with 0.1 API version

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.

2 years agoTest EnumPhysDev to make sure handles don't change
Mark Young [Wed, 26 Jan 2022 20:15:12 +0000 (13:15 -0700)]
Test EnumPhysDev to make sure handles don't change

Add a test to make sure that the physical device handles don't change
between calls to vkEnumeratePhysicalDevices

2 years agoFix Linux sort order crash
Mark Young [Wed, 26 Jan 2022 19:15:53 +0000 (12:15 -0700)]
Fix Linux sort order crash

We were completely re-creating the physical device lists every time
EnumeratePhysicalDevices was triggered in the loader.  This could
cause applications to have out-dated physical device handles.
We need to copy existing handles that match devices whenever they're
found.

2 years agoAdd VK_NN_vi_surface to WSI extension names array
Kevin McCullough [Tue, 25 Jan 2022 23:32:46 +0000 (15:32 -0800)]
Add VK_NN_vi_surface to WSI extension names array

2 years agoVK_NN_vi_surface WSI implementation
Kevin McCullough [Tue, 25 Jan 2022 23:55:27 +0000 (15:55 -0800)]
VK_NN_vi_surface WSI implementation

2 years agoUse size_t instead of uint32_t in test_icd
Charles Giessen [Tue, 25 Jan 2022 18:52:54 +0000 (11:52 -0700)]
Use size_t instead of uint32_t in test_icd

Compiler complained about possible loss of data. This fixes it.

2 years agoUpdate LoaderLayerInterface.md documentation
Charles Giessen [Tue, 25 Jan 2022 18:43:20 +0000 (11:43 -0700)]
Update LoaderLayerInterface.md documentation

Expand override layer documentation to include override_paths

Add Versioning and Activation Interactions section which details some of the
more complex rules around when a layer is activated or not.

2 years agoAdd override_paths tests for OverrideLayer
Charles Giessen [Tue, 25 Jan 2022 02:38:22 +0000 (19:38 -0700)]
Add override_paths tests for OverrideLayer

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.

2 years agoFix loader manifest version checks
Charles Giessen [Tue, 25 Jan 2022 02:34:50 +0000 (19:34 -0700)]
Fix loader manifest version checks

Several version checks were underspecified and either caused false positives
or didn't catch version violations.
For example, a manifest version 1.2.0 is valid but would emit warnings implying
the version is less than 1.1.

2 years agoAdd TestLayerDetails helper struct
Charles Giessen [Tue, 25 Jan 2022 02:03:21 +0000 (19:03 -0700)]
Add TestLayerDetails helper struct

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.

2 years agoMake layer tests specify number of extensions
Charles Giessen [Mon, 24 Jan 2022 21:42:04 +0000 (14:42 -0700)]
Make layer tests specify number of extensions

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.

2 years agoFixup tests/README to use newlines for sentences
Charles Giessen [Fri, 21 Jan 2022 03:10:45 +0000 (20:10 -0700)]
Fixup tests/README to use newlines for sentences

2 years agoAdd meta layer blacklist test
Charles Giessen [Fri, 21 Jan 2022 03:10:03 +0000 (20:10 -0700)]
Add meta layer blacklist test

2 years agoAdd meta layer fields to layer manifest in tests
Charles Giessen [Fri, 21 Jan 2022 03:09:03 +0000 (20:09 -0700)]
Add meta layer fields to layer manifest in tests

2 years agoAdd check_permutation test helper
Charles Giessen [Tue, 18 Jan 2022 23:40:01 +0000 (16:40 -0700)]
Add check_permutation test helper

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.

2 years agoAdd many meta-layer tests
Charles Giessen [Tue, 18 Jan 2022 03:11:23 +0000 (20:11 -0700)]
Add many meta-layer tests

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.

2 years agoCleanup loader layer removal code
Charles Giessen [Tue, 18 Jan 2022 02:02:44 +0000 (19:02 -0700)]
Cleanup loader layer removal code

The loader_read_layer_json function wasn't decrementing the count of layers in the
list if it failed to load, leading to inconsistent results.

Several places were removing layers in a layer list manually when the functions
loader_remove_layer_in_list exists. They also weren't modifying their loop counters
when it was necessary.

2 years agoSimplify test framework FolderManager write function
Charles Giessen [Tue, 18 Jan 2022 01:27:31 +0000 (18:27 -0700)]
Simplify test framework FolderManager write function

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.

2 years agoRemove redundant layer validity check
Charles Giessen [Tue, 18 Jan 2022 00:34:21 +0000 (17:34 -0700)]
Remove redundant layer validity check

The Loader makes sure all component layers in a meta layer are found. It would then do this check
immediately afterwards. This is redundant and can be removed.

2 years agoTestICD return features, props, & memprops
Charles Giessen [Wed, 1 Dec 2021 21:19:54 +0000 (14:19 -0700)]
TestICD return features, props, & memprops

Make the TestICD return the features, properties, & memory properties of
a physical device.

2 years agoCheck for version 1.3 in GetP.D.ToolProperties
Charles Giessen [Wed, 1 Dec 2021 21:02:52 +0000 (14:02 -0700)]
Check for version 1.3 in GetP.D.ToolProperties

To ensure that no crashes occur due to calling into the driver's
vkGetPhysicalDeviceToolProperties. This prevents cases where the function is
exported but the physical device doesn't actually support the function (such
as mesa with its function dispatcher shared between drivers).

2 years agoloader: Add basic 1.3 tests
Charles Giessen [Mon, 13 Sep 2021 23:57:49 +0000 (17:57 -0600)]
loader: Add basic 1.3 tests

Not complete and mainly just makes sure an app can load the function pointer and call it
without crashing.

2 years agoloader: Add manual trampolines for 1.3
Charles Giessen [Mon, 13 Sep 2021 21:13:18 +0000 (15:13 -0600)]
loader: Add manual trampolines for 1.3

2 years agoloader: Add core 1.3 function to gpa_helper
Charles Giessen [Mon, 13 Sep 2021 17:40:36 +0000 (11:40 -0600)]
loader: Add core 1.3 function to gpa_helper

2 years agoloader: Add 1.3 symbols defs to appropriate files
Charles Giessen [Mon, 13 Sep 2021 17:36:07 +0000 (11:36 -0600)]
loader: Add 1.3 symbols defs to appropriate files

vulkan-1.def and vulkan.symbols.api for fuschia

2 years agoloader: Add GetToolinInfo trampoline/terminator
Charles Giessen [Fri, 10 Sep 2021 23:06:21 +0000 (17:06 -0600)]
loader: Add GetToolinInfo trampoline/terminator

2 years agobuild: Update to header 1.3.204
Mike Schuchardt [Tue, 25 Jan 2022 15:42:28 +0000 (07:42 -0800)]
build: Update to header 1.3.204

- Update known-good
- Generate source

2 years agoAdd support for building on ChromeOS
Alexis Hetu [Tue, 25 Jan 2022 15:09:00 +0000 (10:09 -0500)]
Add support for building on ChromeOS

2 years agoFix writing to filtered extension list
Ari Suonpää [Sat, 22 Jan 2022 07:13:42 +0000 (09:13 +0200)]
Fix writing to filtered extension list

VK_KHR_get_physical_device_properties2 is added to an extension list
on Linux targets, but the index used for setting the extension string
in that list is wrong, leaving a NULL pointer where the extension
name should be.

2 years agoFix issue #802
Mark Young [Mon, 24 Jan 2022 16:34:29 +0000 (09:34 -0700)]
Fix issue #802

The loader assumed if Vulkan 1.1 is supported, then the PCI bus extension
must automatically be supported.  This was a mistake as that extension is
not part of core.

2 years agoDowngrade all policy messages from ERROR to WARN
Charles Giessen [Fri, 21 Jan 2022 03:26:37 +0000 (20:26 -0700)]
Downgrade all policy messages from ERROR to WARN

2 years agoEnable Address Sanitizser in Github Actions
Charles Giessen [Tue, 18 Jan 2022 22:54:20 +0000 (15:54 -0700)]
Enable Address Sanitizser in Github Actions

2 years agoAdd VK_LOADER_TEST_LOADER_PATH env-var for tests
Charles Giessen [Tue, 18 Jan 2022 22:19:26 +0000 (15:19 -0700)]
Add VK_LOADER_TEST_LOADER_PATH env-var for tests

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.

2 years agomurmurhash: Fix an undefined behavior when hashing function names
Yilong Li [Thu, 13 Jan 2022 05:52:21 +0000 (21:52 -0800)]
murmurhash: Fix an undefined behavior when hashing function names

In Vulkan loader GetProcAddr handlers, for functions that are
not specified in the Vulkan registry, the loader will try loading
the name from ICDs or layers, and store the function entry into
a hashtable. The hashtable uses |murmurhash()| function to hash
Vulkan function names.

murmurhash handles data as 4-byte chunks and read one chunk at a
time; and it simply converts uint8_t pointers to uint32_t pointers
while loading data. However, the address of function name might
not be 32-bit aligned and this will cause an undefined behavior in
C99 / C11.

This change fixes the murmurhash() behavior so that it handles
unaligned access correctly. For most common platforms that supports
unaligned memory access this could compile into a single mov/load
instruction even if compiling using -O0.

Change-Id: I16011720198a0ee96e556855858a9909f95ec376

2 years agoAdd test for older implicit layer version
Charles Giessen [Wed, 12 Jan 2022 23:29:55 +0000 (17:29 -0600)]
Add test for older implicit layer version

Add NewerInstanceVersionThanImplicitLayer test which exercises the loader's
removal of layers whoses API version is less than the application specified
API version.

2 years agoAdd meta-layer versioning tests
Charles Giessen [Wed, 12 Jan 2022 23:04:15 +0000 (17:04 -0600)]
Add meta-layer versioning tests

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.

2 years agoFix layers not being removed by meta-layer
Charles Giessen [Wed, 12 Jan 2022 22:56:59 +0000 (16:56 -0600)]
Fix layers not being removed by meta-layer

The code was faulty and would remove the layers that were supposed to be kept,
such as the meta layer itself. Bugs include taking a copy instead of a pointer
which led to an assignment being forgotten and using the wrong list when
looking through the list of layers.

2 years agoCheck for duplicates before adding layer
Charles Giessen [Wed, 12 Jan 2022 22:55:12 +0000 (16:55 -0600)]
Check for duplicates before adding layer

If an application decided to enable an implicit layer, it would result in the
layer properties being stored twice in the activated layer list. Simply not
adding the layer if it already is in the list prevents the duplication.

2 years agoLog meta-layer messages when inst is NULL
Charles Giessen [Wed, 12 Jan 2022 22:51:44 +0000 (16:51 -0600)]
Log meta-layer messages when inst is NULL

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.

2 years agoFix layer manifest version check
Charles Giessen [Wed, 12 Jan 2022 19:42:03 +0000 (13:42 -0600)]
Fix layer manifest version check

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.

2 years agoAdd test for manually enabled implicit layer
Charles Giessen [Wed, 5 Jan 2022 21:53:00 +0000 (15:53 -0600)]
Add test for manually enabled implicit layer

If an application manually enabled an implicit layer, the layer should
be enabled without issue.

2 years agoConsistent loader device ordering
Mark Young [Mon, 15 Nov 2021 17:49:37 +0000 (10:49 -0700)]
Consistent loader device ordering

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

2 years agoMove the LDP_DRIVER_6 message to a warning for now
Mark Young [Tue, 11 Jan 2022 21:51:52 +0000 (14:51 -0700)]
Move the LDP_DRIVER_6 message to a warning for now

2 years agoAdd 1.2.1 as valid Layer Manifest version
Charles Giessen [Mon, 10 Jan 2022 22:52:50 +0000 (16:52 -0600)]
Add 1.2.1 as valid Layer Manifest version

2 years agoFixup phys_dev_inst_ext_tests
Charles Giessen [Mon, 10 Jan 2022 22:35:39 +0000 (16:35 -0600)]
Fixup phys_dev_inst_ext_tests

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.

2 years agoTests separate 1.1 and VK_KHR_get_phys_dev_props2
Charles Giessen [Mon, 10 Jan 2022 22:33:01 +0000 (16:33 -0600)]
Tests separate 1.1 and VK_KHR_get_phys_dev_props2

Previously the TestICD would conflate the 2 distinct situations by accident. This commit
moves the logic into their separate blocks to prevent mixups.

2 years agoFallback to 2KHR terminators if available
Charles Giessen [Sun, 9 Jan 2022 23:39:39 +0000 (17:39 -0600)]
Fallback to 2KHR terminators if available

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.

2 years agoRemove unnecessary code in test
Mark Young [Fri, 7 Jan 2022 23:27:38 +0000 (16:27 -0700)]
Remove unnecessary code in test

2 years agoFix a few code review snippets
Mark Young [Fri, 7 Jan 2022 21:27:26 +0000 (14:27 -0700)]
Fix a few code review snippets

Messages weren't clear on some errors, and rework the library ending
code based on @charles-lunarg suggestions

2 years agoAdd layer tests for instance extension support
Mark Young [Mon, 3 Jan 2022 22:16:45 +0000 (15:16 -0700)]
Add layer tests for instance extension support

Verify that the loader properly handles instance extensions defined
in a layer (both implicit and explicit).

2 years agoAdd device extension layer tests
Mark Young [Thu, 30 Dec 2021 22:26:29 +0000 (15:26 -0700)]
Add device extension layer tests

Need to make sure the loader behaves appropriately for layers which report
one or more device extensions.

2 years agoFix debug utils wrapping in tests
Mark Young [Wed, 29 Dec 2021 20:39:21 +0000 (13:39 -0700)]
Fix debug utils wrapping in tests

Also fix another compiler warning.

2 years agoAdd more WSI tests, and fix some compiler warnings.
Mark Young [Mon, 20 Dec 2021 22:49:09 +0000 (15:49 -0700)]
Add more WSI tests, and fix some compiler warnings.

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.

2 years agoFix loader phys dev termin for physical device extensions.
Mark Young [Wed, 15 Dec 2021 17:06:00 +0000 (10:06 -0700)]
Fix loader phys dev termin for physical device extensions.

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.

2 years agoloader: Compile x86-specific code on x86 Linux
Simon McVittie [Thu, 6 Jan 2022 14:03:40 +0000 (14:03 +0000)]
loader: Compile x86-specific code on x86 Linux

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>
2 years agoloader: Check for processor of compiler, not processor of build system
Simon McVittie [Thu, 6 Jan 2022 14:00:45 +0000 (14:00 +0000)]
loader: Check for processor of compiler, not processor of build system

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>
2 years agobuild: Update to header 1.2.203
Mike Schuchardt [Mon, 20 Dec 2021 15:46:25 +0000 (07:46 -0800)]
build: Update to header 1.2.203

- Update known-good
- Generate source

2 years agoloader/aarch64: attempt to avoid text relocations in the unknown code
Dave Airlie [Mon, 13 Dec 2021 04:48:31 +0000 (23:48 -0500)]
loader/aarch64: attempt to avoid text relocations in the unknown code

2 years agoAdd loader policy statements
Mark Young [Thu, 21 Oct 2021 16:01:42 +0000 (10:01 -0600)]
Add loader policy statements

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.

2 years agoTests to use unique layer names
Charles Giessen [Fri, 10 Dec 2021 19:04:04 +0000 (12:04 -0700)]
Tests to use unique layer names

While the logic to copy TestLayer binaries was present, it didn't rename them
to a unique string to prevent collisions when using the same binary.

2 years agoUse std::function in Layer callbacks
Charles Giessen [Fri, 10 Dec 2021 03:17:57 +0000 (20:17 -0700)]
Use std::function in Layer callbacks

Also fixed the compilation issues in the linux build

2 years agoFix Test folders and registry cleaning logic
Charles Giessen [Fri, 10 Dec 2021 00:03:42 +0000 (17:03 -0700)]
Fix Test folders and registry cleaning logic

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.

2 years agoRefactor TestLayer framework interface
Charles Giessen [Thu, 9 Dec 2021 04:07:24 +0000 (21:07 -0700)]
Refactor TestLayer framework interface

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.

2 years agoRefactor tests FrameworkEnvironment class
Charles Giessen [Wed, 8 Dec 2021 19:48:52 +0000 (12:48 -0700)]
Refactor tests FrameworkEnvironment class

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.

2 years agoUse builders in test framework components
Charles Giessen [Wed, 8 Dec 2021 19:44:48 +0000 (12:44 -0700)]
Use builders in test framework components

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.

2 years agoAdd Builder Pattern helpers to test framework
Charles Giessen [Tue, 7 Dec 2021 23:04:00 +0000 (16:04 -0700)]
Add Builder Pattern helpers to test framework

Allows quick creation of builders in test code.

2 years agoAdd test for no drivers and no physical devices
Charles Giessen [Mon, 6 Dec 2021 21:10:12 +0000 (14:10 -0700)]
Add test for no drivers and no physical devices

2 years agoFix InstWrapper not checking instance creation
Charles Giessen [Mon, 6 Dec 2021 21:07:09 +0000 (14:07 -0700)]
Fix InstWrapper not checking instance creation

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().

2 years agobuild: Update to header 1.2.202
Mike Schuchardt [Tue, 7 Dec 2021 15:52:15 +0000 (07:52 -0800)]
build: Update to header 1.2.202

- Update known-good
- Generate source

2 years agoFix crash from Null instance layer or extension ptr
Charles Giessen [Sat, 4 Dec 2021 06:10:10 +0000 (23:10 -0700)]
Fix crash from Null instance layer or extension ptr

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.

2 years agoFix test framework leaking registry entries
Charles Giessen [Fri, 3 Dec 2021 05:02:09 +0000 (22:02 -0700)]
Fix test framework leaking registry entries

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.

2 years agoRevert to old behavior in GIPA for old apps
Charles Giessen [Fri, 3 Dec 2021 01:40:58 +0000 (18:40 -0700)]
Revert to old behavior in GIPA for old apps

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.

2 years agoFix handle validation crash in RenderDoc
Mark Young [Tue, 30 Nov 2021 20:54:02 +0000 (13:54 -0700)]
Fix handle validation crash in RenderDoc

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.

2 years agoFix per-platform defines in test framework not showing up
Charles Giessen [Wed, 1 Dec 2021 20:41:28 +0000 (13:41 -0700)]
Fix per-platform defines in test framework not showing up

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.

2 years agobuild: Update to header 1.2.201
Mike Schuchardt [Wed, 1 Dec 2021 17:19:39 +0000 (09:19 -0800)]
build: Update to header 1.2.201

- Update known-good
- Generate source (version bump only)

2 years agoUse windows-latest in github actions
Charles Giessen [Tue, 30 Nov 2021 18:09:06 +0000 (11:09 -0700)]
Use windows-latest in github actions

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.

2 years agoFix readlink error in asm_offset on linux
Charles Giessen [Tue, 30 Nov 2021 18:21:01 +0000 (11:21 -0700)]
Fix readlink error in asm_offset on linux

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.

2 years agoFix leaks in Handle Validation Tests
Charles Giessen [Tue, 30 Nov 2021 18:39:35 +0000 (11:39 -0700)]
Fix leaks in Handle Validation Tests

Instances were being created but not destroyed. Switch all tests to using
the InstWrapper to automate this cleanup.

2 years agoFix error message in GetPhysDevImageFormatProps
Charles Giessen [Sat, 20 Nov 2021 00:28:43 +0000 (17:28 -0700)]
Fix error message in GetPhysDevImageFormatProps

2 years agovulkan.pc cross-compile fix
Joel Winarske [Mon, 29 Nov 2021 22:37:38 +0000 (14:37 -0800)]
vulkan.pc cross-compile fix

- pkg-config variable ${prefix} is required for adjusting sysroot

Signed-off-by: Joel Winarske <joel.winarske@gmail.com>
2 years agobuild: Update to header 1.2.200
Mike Schuchardt [Mon, 29 Nov 2021 18:02:10 +0000 (10:02 -0800)]
build: Update to header 1.2.200

- Update known-good
- Generate source (version bump only)

2 years agoFix the spelling of Manfiest in docs and loader
Mark Young [Mon, 22 Nov 2021 23:51:39 +0000 (16:51 -0700)]
Fix the spelling of Manfiest in docs and loader

2 years agoFix validation_layer_test failures from handle validation change
Mark Young [Mon, 22 Nov 2021 21:59:23 +0000 (14:59 -0700)]
Fix validation_layer_test failures from handle validation change

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.

2 years agoUpdate loader to include handle validation
Mark Young [Thu, 29 Jul 2021 14:42:44 +0000 (08:42 -0600)]
Update loader to include 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.

2 years agoDont call ToolProps on drivers without support
Charles Giessen [Wed, 17 Nov 2021 21:44:11 +0000 (14:44 -0700)]
Dont call ToolProps on drivers without support

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.

2 years agobuild: Update to header 1.2.199
Mike Schuchardt [Tue, 16 Nov 2021 18:45:49 +0000 (10:45 -0800)]
build: Update to header 1.2.199

- Update known-good
- Generate source (version bump only)

2 years agoloader: Add aarch64 unknown ext chain implementation
Eric Sullivan [Thu, 28 Oct 2021 23:18:45 +0000 (16:18 -0700)]
loader: Add aarch64 unknown ext chain implementation

2 years agoloader: Update assembly file names to specify their target architecture
Eric Sullivan [Tue, 26 Oct 2021 18:03:43 +0000 (11:03 -0700)]
loader: Update assembly file names to specify their target architecture