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