While the adding and removing of data from this global linked list
was guarded, GetInstanceProcAddr & GetDeviceProcAddr did not have
such guards. This results in race conditions that were detected with
thread sanitizer. This commit adds a mutex solely for the
loader.instances global variable.
Instance extensions are aggregated, therefore an application has no way of
knowing whether an ICD supports a WSI function or not. This necessitates
returning instead of aborting from WSI functions, as well as writing 0,
NULL, or returning false as needed for each function. This also needs
additional NULL checks before calling down into the driver.
This change makes the loader conform to the latests specification
update, 1.3.227, which removes the requirement that implicit layers
API version is at least as high as the application provided API
version.
This change reduces friction for layer developers and API users.
Some functions in the wrapping test layer exported functions that are not necessary.
This caused some warnings in builds. Removing them fixes the warnings.
Put all of the parsing for ICD Manifest data into a separate function.
This cleans it up by not requiring manual tracking of allocated resources
while parsing, and allow much saner 'skipping' of incorrect ICD's.
This commit also addresses an issue where OOM during ICD parsing wasn't
immediately ending parsing and returning.
There was a small issue with the initial version of the portability
enumeration extension where the portability enumeration flag bit would
be passed down to ICDs which did not expect flags to contain anything
other than zero.
While an argument could be made for those drivers to ignore flags they
do not recognize, just like extensions and other 'unknown' things, it
is best to play nice as this is the first instance creation flag bit
added.
When creating a device, the loader looks for the VkDeviceGroupCreateInfo
structure and replaces it with its own. This allows the loader to edit the
struct. However, to do this required editing the pNext chain. Because the
edited chain contained pointers to structures whose lifetimes end when the
vkCreateDevice function returns, the pNext chain is now corrupted.
This commit fixes that by storing a pointer to the user's
VkDeviceGroupCreateInfo and fixing up the pNext chain to use that instead.
Previously, the loader supported static linking. This capability was restricted
to MacOS only, however the necessary functionality was never implemented. This
commit adds the required code to properly initialize the loader when statically
linked with MacOS
Since the test framework was designed to dynamically load everything, it would
require significant rearchitecting to support it. As such, a simple verification
executable was added to the live_verification folder, instead of full support
in the test framework.
Use the order defined the FolderManager's to define the order readdir
uses, rather than leaving it undetermined. This makes tests more consistent
by forcing layers and drivers to always be found in the same order on all
systems.
Note: MacOS doesn't currently have consistent ordering due to a crash with
ASAN. But even if ASAN isn't running, the dirent structure is being filled
out incorrectly, causing further test failures. While not ideal to disable
consistent ordering on MacOS, it is needed for linux and thus the issue
isn't high enough priority to resolve.
Allows drivers and layers to specify if they are 32 bit or 64 bit in the
manifest file. This makes the loader able to prune manifests without
loading the library and finding that it failed to load.
Shuffle the bus IDs for discrete devices pd0, pd3, and pd4. Notably this
puts pd0 from icd0 in between pd4 and pd3 from icd2, making default
sorted order extremely unlikely if not impossible.
When checking for unknown physical device functions, check the first layer that supports
vk_layerGetPhysicalDeviceProcAddr in the chain starting with the layer closest to the
application. This prevents unecessary work being done, and if any layer wraps VkInstance
will properly call through the wrapping layer first without calling into any other layer.
Various situations could cause an OOM to turn into a hard crash due to double freeing
of memory that was improperly cleaned up. Also fixed memory leaks when layers would
report OOM.
Previously the loader would destroy any debug callbacks created during instance creation
to later create new ones during instance destruction. This required a memory allocation
to occur inside vkDestroyInstance, which can cause leaks if an OOM occurs during
instance destruction.
This commit simplifies the logic by keeping around the allocations made during instance
creation by moving them into their own debug node chain. Then during instance destruction
moves them back.
Also renames several functions to better describe their intended purpose.
When checking for the portability driver field of driver manifests,
the loader did not check if inst was NULL first. Since this function
is called in pre-instance functions, this crashes the loader.
Unless the portability enumeration extension is enabled and the create instance flags
contain VK_INSTANCE_CREATE_ENUMERATE_PORTABILITY_BIT_KHR, do not enumerate drivers that
contain `is_portability_driver` in their JSON Manifest. This is phase 2 of the release
for the VK_KHR_portability_enumeration extension.
An error message will be printed when no drivers were reported but there was a
portability driver which was skipped over.
Make it possible for layers to declare that they support unknown functions
and set up the layer dispatch table appropriately. A very niche use case
but helpful when developing validation for functions not yet out in the
public headers.
Log an error if an application creates a VkDevice from a physical device which
was enumerated from a driver that is a portability driver but the application
didn't correctly enable the portability enumeration flag & extension.
Relax the requirement that all component layers in a meta layer must equal the version of the meta layer.
This allows enabling layers that do not have the same API version as the meta layer.
The previous logic would cause any non-sorted physical devices to be missed
when aggregating the final list. This caused crashes due to the phys_dev
value not being initialized. The fix is to make sure both sorted and non
sorted physical devices are included in the final output of
setup_loader_term_phys_devs().
Many tests were using the V6 TestICD, which means that it exports the
EnumerateAdapterPhysicalDevices. The loader then only looks for devices
using that functionality and if the test didn't set it up, the driver
won't have its devices found.
Also:
* Cleaned up handle_validation_tests
* Added WSI setup helpers, which put all the setup code for WSI in one place
* Created a to/from_nondispatch_handle function for TestICD, probably should
be in a more general location
Since the loader is meant to be forward compatible, it makes little sense to emit
a warning when an ICD or Layer manifest is found with a version that it doesn't
understand. Thus they now are INFO level.
Enable /W4 errors on MSVC and fix all corresponding errors.
Refactor the CMakeLists.txt to allow for compiling with clang-cl. This required
figuring out that -Wall -Wextra mangle the set of warnings used. The solution
is to use /W4 instead when compiling with clang-cl on Windows.
Test fixturing (TEST_F) is useful when there is a lot of common code that needs
to be run for a suite of tests. However, the FrameworkEnvironment encapsulates
almost all of the setup work all tests needs, and so doesn't need to be in a
fixture. Making the add_icd call inside the tests makes it clear which binary
is being used.
This commit also uses the corrent signed/unsigned constants in tests, as was
warned by compilers when enhanced warnings were enabled (/W4 in msvc).
The sorting algorithm needed to take into account both the application
API version as well as the driver API version.
This required additional changes to the sorting algorithm for the fallback
since even if the instance supports the extension or Vulkan 1.1, the individual
drivers may not.
Also, add supporting tests which would catch these cases in the future.
In the process, I realized we assumed that the presence of an extension in the
test_icd indicated "enablement" which was incorrect. So I separated out
that into a set of "enabled instance extensions"
The physical device terminator was missing the ICD index in the
non-sorted path. This caused crashes in Angle before it was realized
that the sorting code was unintentionally disabled in that build
path.
Also, add tests to catch this case in the future in the WSI code, but
this required converting all the TEST_F tests to TEST since Gtest
didn't like mixing the 2 on my system.
Finally, fix a few WSI error messages in the loader which were
missing spaces.
Fixes#863 for non-sorting paths
The fs::FolderManager can't close objects that are in use, thus if the tests
keep open a binary then the destructor will fail to delete the file. This
commit manually cleans out the FrameworkEnvironment's loaded layers to prevent
this from happening.
Previously the way the test framework worked was to fake the registry using a
special windows API call. However this led to brittle tests and was incompatible
with googletest's death test capabilities.
These death tests highlighted that the current set of them didn't use the built in
matcher to verify a correct crash/abort. This commit also amends all uses of
ASSERT_DEATH to provide the relevant death message.
If a driver reports an interface version greater than 0 but doesn't export
vk_icdGetInstanceProcAddr, the loader will now skip the driver.