Commit Graph

1055 Commits

Author SHA1 Message Date
andrew0229
0281b281d0 update to v1.3.275
Signed-off-by: andrew0229 <zhangzhao62@huawei.com>
Change-Id: Ifc4224db2c6ea7c159d3cabe8f075475d47a41a8
2024-05-21 08:09:09 +00:00
Charles Giessen
23a050bc76 Guard loader.instances access with mutex.
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.
2022-10-12 10:48:16 -06:00
Charles Giessen
ae08f71147 Fix issue with MSVC 15 failing to compile test code
Was a basic case of googletest not allowing implicit conversion between
types.
2022-10-11 13:01:07 -06:00
Charles Giessen
cb519989cd Don't abort when drivers don't support WSI calls
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.
2022-10-10 14:54:07 -06:00
Charles Giessen
6c64537135 Enable cross compile test discovery
gtest_discover_tests() doesn't work in cross compilation environments, so if
that is happening fall back to gtest_add_tests().
2022-10-06 17:00:40 -06:00
PaperChalice
9c40a28e3e loader: fix log message 2022-09-26 11:56:43 -06:00
Charles Giessen
2f87e2b3a5 Allow implicit layers for all API versions
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.
2022-09-08 13:48:46 -06:00
Charles Giessen
823078c862 Remove unneeded exports in test_wrap_layers
Some functions in the wrapping test layer exported functions that are not necessary.
This caused some warnings in builds. Removing them fixes the warnings.
2022-09-01 13:13:14 -06:00
Charles Giessen
1bede3d1a0 Refactor loader_icd_scan()
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.
2022-09-01 13:13:14 -06:00
Charles Giessen
4f79db3afe Refactor unknown function tests
Allow multiple layers to intercept an unknown function and then create a single test
which tests many common combinations.
2022-09-01 12:23:17 -06:00
Brad Smith
efa8903d73 tests: Further fixes to be able to build on OpenBSD 2022-09-01 12:21:19 -06:00
Brad Smith
095a7bf60b loader: Add stub function for OpenBSD executable path 2022-08-31 14:11:59 -06:00
Charles Giessen
192efa48a7 Dont pass portability bit to ICDs that dont expect it
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.
2022-08-31 11:49:56 -06:00
Brad Smith
c745281f0f loader: Add OpenBSD support 2022-08-31 10:02:13 -06:00
Charles Giessen
57d5dd568b Fix corrupted pNext chain in vkCreateDevice
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.
2022-07-07 18:17:34 -06:00
Charles Giessen
0c7685be41 Initialize properly when statically linked
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.
2022-07-07 14:41:01 -06:00
Jesse Natalie
26921924d6 Enable the Vulkan loader to load VulkanOn12/Dozen out of the D3DMappingLayers app package 2022-07-05 14:34:53 -06:00
Charles Giessen
0ad591fa3c Make tests get files in a consistent order
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.
2022-07-01 13:36:27 -06:00
Andrew Naumov
5249c8f869 loader: Add unicode support 2022-06-24 13:14:10 -06:00
Charles Giessen
865626abba Add 32 & 64 bit field to json manifests
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.
2022-06-22 10:28:18 -06:00
Mike Schuchardt
e26be655eb build: Update to header 1.3.218
- Update known-good
- Generate source
- Add missing enums to test framework
2022-06-16 13:35:17 -07:00
Mike Schuchardt
0ace24470b tests: Shuffle devices for sort test
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.
2022-06-16 13:35:17 -07:00
Charles Giessen
c3601d4d91 Only check first GPDPA in the layer chain.
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.
2022-06-06 21:34:36 -06:00
Charles Giessen
9308d2f8f1 Fix crashes from OOM in vkDestroyInstance
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.
2022-05-27 17:25:52 -06:00
Charles Giessen
e52b98e356 Keep allocated debug callbacks until destroy instance
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.
2022-05-27 17:14:25 -06:00
Charles Giessen
c2897084d2 Fix a NULL inst crashing during loader_icd_scan
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.
2022-05-25 13:14:04 -06:00
Mike Schuchardt
5aa2ee48c9 build: Update to header 1.3.213
- Update known-good
- Generate source
2022-05-11 10:31:02 -07:00
Charles Giessen
8dc9ab5ce8 Revert "Implement unknown function intercept in layers"
This reverts commit 0fd2ff8384.
2022-05-11 08:57:30 -06:00
Charles Giessen
a9543c5ac3 Make portability drivers not load by default
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.
2022-05-04 15:40:27 -06:00
Charles Giessen
0fd2ff8384 Implement unknown function intercept in layers
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.
2022-05-03 17:38:09 -06:00
Charles Giessen
71bd6240af Add app_key OverrideMetaLayer tests 2022-04-14 13:18:54 -06:00
Charles Giessen
5b84b6d09a Refactor FrameworkEnvironment API a bit
Redo some of API's for adding layers and ICD's to the test framework.
2022-04-12 13:00:32 -06:00
Charles Giessen
717697987e Warn if portability_enumeration extension should be enabled
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.
2022-04-06 18:25:09 -06:00
Charles Giessen
1de26aad69 Increase discovery timeout for Gtest test to 100 seconds 2022-04-06 16:23:51 -06:00
Charles Giessen
469aead205 Allow meta layers to have newer component layers
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.
2022-04-04 19:17:07 -06:00
Charles Giessen
a06dd5484a Clean up version checking logic
Add a few helper functions to simplify checking that a X.Y.Z version is sufficient.
2022-04-04 19:17:07 -06:00
Charles Giessen
d24a1045fd Fix missed Physical Devices in Windows
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().
2022-04-04 16:38:17 -06:00
Charles Giessen
d921b818b3 Use correct TestICD in tests
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
2022-04-04 16:38:17 -06:00
Charles Giessen
c70d9c29a8 Add test for different ICD interface versions
Fix Test Framework not skipping Drivers which have a different LUID.
2022-04-04 16:38:17 -06:00
Charles Giessen
f8c97eea2f Dont emit warnings on unknown manifest file versions
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.
2022-03-31 11:54:03 -06:00
unknown
ca66d5aa8b Fixup several small issues found by Visual Studio
The VS Analyzer went through the codebase and pointed out a dozen warnings and
one possible crash.
2022-03-30 10:06:23 -06:00
Charles Giessen
336508b06b Enable /W4 errors and support clang-cl
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.
2022-03-29 16:10:30 -06:00
Charles Giessen
edc995aef7 Replace TEST_F with TEST in most tests
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).
2022-03-29 16:10:30 -06:00
Mark Young
b383c5131e Apply code review comments from @charles-lunarg 2022-03-25 15:29:40 -06:00
Mark Young
d72909ee28 Fix #888 crash in Lutris with Linux sorting
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"
2022-03-25 15:29:40 -06:00
Charles Giessen
ea503f36e6 Fixup windows test infrastructure
Cleaned up several bugs in the testing framework in the windows shim.
Rewrote the tests that exercise DXGI/D3DKMT functionality.
2022-03-24 19:00:28 -06:00
Mark Young
2d1860d238 Fix non-sorted surface indexing
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
2022-03-24 15:22:04 -06:00
Charles Giessen
6b3cb3705f Tests close layer handles when necessary
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.
2022-03-14 23:31:26 -06:00
Charles Giessen
38e9dc8faf Test framework now shims registry functions
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.
2022-03-14 23:31:26 -06:00
Charles Giessen
2ded39d6f8 Remove hasing of unknown functions
Use a simple linear search instead. This greatly simplifies the logic and
reduces the places for the logic to go awry.
2022-03-14 23:31:26 -06:00