Commit Graph

3654 Commits

Author SHA1 Message Date
Charles Giessen
1c64dac9b3 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.
2022-01-28 16:24:27 -07:00
Charles Giessen
9091b00fd3 Refactor json and API version parsing code
Reuse the loader_api_struct struct and associated parsing functions where
appropriate to reduce code duplication.
2022-01-28 16:24:27 -07:00
Charles Giessen
3a735a344c 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.
2022-01-28 16:24:27 -07:00
Charles Giessen
ddd6b69de7 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.
2022-01-28 16:24:27 -07:00
Charles Giessen
b411580d64 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.
2022-01-28 16:24:27 -07:00
Charles Giessen
469b7c03be 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.
2022-01-28 16:24:27 -07:00
Charles Giessen
200bd55ebd 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.
2022-01-28 16:24:27 -07:00
Charles Giessen
8d192539c5 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.
2022-01-28 16:24:27 -07:00
Mark Young
8aad559a09 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
2022-01-26 14:24:29 -07:00
Mark Young
356945ba66 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.
2022-01-26 12:51:13 -07:00
Kevin McCullough
db4c3177aa Add VK_NN_vi_surface to WSI extension names array 2022-01-25 19:34:27 -07:00
Kevin McCullough
50ba247da4 VK_NN_vi_surface WSI implementation 2022-01-25 19:33:49 -07:00
Charles Giessen
997595a9ff Use size_t instead of uint32_t in test_icd
Compiler complained about possible loss of data. This fixes it.
2022-01-25 12:32:56 -07:00
Charles Giessen
41ee578e10 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.
2022-01-25 12:32:56 -07:00
Charles Giessen
45c55b2558 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.
2022-01-25 12:32:56 -07:00
Charles Giessen
cbbcc6bc64 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.
2022-01-25 12:32:56 -07:00
Charles Giessen
c3b2624604 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.
2022-01-25 12:32:56 -07:00
Charles Giessen
928830f767 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.
2022-01-25 12:32:56 -07:00
Charles Giessen
415b3e59cd Fixup tests/README to use newlines for sentences 2022-01-25 12:32:56 -07:00
Charles Giessen
a07c794826 Add meta layer blacklist test 2022-01-25 12:32:56 -07:00
Charles Giessen
f51356c3c4 Add meta layer fields to layer manifest in tests 2022-01-25 12:32:56 -07:00
Charles Giessen
2424889ef5 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.
2022-01-25 12:32:56 -07:00
Charles Giessen
b9727a88d6 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.
2022-01-25 12:32:56 -07:00
Charles Giessen
7d122fc5b3 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.
2022-01-25 12:32:56 -07:00
Charles Giessen
ca8cac0751 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.
2022-01-25 12:32:56 -07:00
Charles Giessen
ef3d33752c 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.
2022-01-25 12:32:56 -07:00
Charles Giessen
f40a302af2 TestICD return features, props, & memprops
Make the TestICD return the features, properties, & memory properties of
a physical device.
2022-01-25 10:54:13 -08:00
Charles Giessen
522e2b6ba1 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).
2022-01-25 10:54:13 -08:00
Charles Giessen
890eb0ad30 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.
2022-01-25 10:54:13 -08:00
Charles Giessen
59cdff6cab loader: Add manual trampolines for 1.3 2022-01-25 10:54:13 -08:00
Charles Giessen
e874c0b06e loader: Add core 1.3 function to gpa_helper 2022-01-25 10:54:13 -08:00
Charles Giessen
848b669e1f loader: Add 1.3 symbols defs to appropriate files
vulkan-1.def and vulkan.symbols.api for fuschia
2022-01-25 10:54:13 -08:00
Charles Giessen
1bbf128d7a loader: Add GetToolinInfo trampoline/terminator 2022-01-25 10:54:13 -08:00
Mike Schuchardt
43a1474820 build: Update to header 1.3.204
- Update known-good
- Generate source
2022-01-25 10:54:13 -08:00
Alexis Hetu
ef193f2f56 Add support for building on ChromeOS 2022-01-25 09:59:13 -07:00
Ari Suonpää
ec84a665fd 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.
2022-01-24 10:22:06 -07:00
Mark Young
aeeab1c1f5 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.
2022-01-24 09:43:55 -07:00
Charles Giessen
dab15e0c45 Downgrade all policy messages from ERROR to WARN 2022-01-21 10:58:54 -07:00
Charles Giessen
60d17fe6c6 Enable Address Sanitizser in Github Actions 2022-01-18 16:02:17 -07:00
Charles Giessen
dcd6185384 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.
2022-01-18 15:51:14 -07:00
Yilong Li
0fd1cf08c9 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
2022-01-13 12:53:21 -07:00
Charles Giessen
1704ffa38a 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.
2022-01-12 17:44:07 -07:00
Charles Giessen
36deb9d914 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.
2022-01-12 17:44:07 -07:00
Charles Giessen
172861f8f0 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.
2022-01-12 17:44:07 -07:00
Charles Giessen
4b8046ef7e 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.
2022-01-12 17:44:07 -07:00
Charles Giessen
e9b2008c15 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.
2022-01-12 17:44:07 -07:00
Charles Giessen
5beb6dd136 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.
2022-01-12 17:44:07 -07:00
Charles Giessen
263ad96d97 Add test for manually enabled implicit layer
If an application manually enabled an implicit layer, the layer should
be enabled without issue.
2022-01-12 17:44:07 -07:00
Mark Young
cbe28ac790 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
2022-01-12 16:53:35 -07:00
Mark Young
1fb56971c5 Move the LDP_DRIVER_6 message to a warning for now 2022-01-11 15:09:46 -07:00