Commit Graph

3810 Commits

Author SHA1 Message Date
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
Charles Giessen
a72d5bc3eb Add 1.2.1 as valid Layer Manifest version 2022-01-10 16:07:30 -07:00
Charles Giessen
3cae9d8cf7 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.
2022-01-10 15:49:26 -07:00
Charles Giessen
6d8af313f7 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.
2022-01-10 15:49:26 -07:00
Charles Giessen
5f8a6e2d74 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.
2022-01-10 15:49:26 -07:00
Mark Young
f5d16bf89e Remove unnecessary code in test 2022-01-07 16:56:38 -07:00
Mark Young
232c6977d2 Fix a few code review snippets
Messages weren't clear on some errors, and rework the library ending
code based on @charles-lunarg suggestions
2022-01-07 16:56:38 -07:00
Mark Young
77c68768f6 Add layer tests for instance extension support
Verify that the loader properly handles instance extensions defined
in a layer (both implicit and explicit).
2022-01-07 16:56:38 -07:00
Mark Young
d413d4c602 Add device extension layer tests
Need to make sure the loader behaves appropriately for layers which report
one or more device extensions.
2022-01-07 16:56:38 -07:00
Mark Young
efb8b8f9c1 Fix debug utils wrapping in tests
Also fix another compiler warning.
2022-01-07 16:56:38 -07:00
Mark Young
afbe02aa48 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.
2022-01-07 16:56:38 -07:00
Mark Young
6c8e7c7cd7 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.
2022-01-07 16:56:38 -07:00
Simon McVittie
b9936f2b7a 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>
2022-01-06 11:24:11 -07:00
Simon McVittie
db5e3d0f45 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>
2022-01-06 11:24:11 -07:00
Mike Schuchardt
c6c0a2c3fd build: Update to header 1.2.203
- Update known-good
- Generate source
2021-12-20 08:46:42 -08:00
Dave Airlie
a11162fcac loader/aarch64: attempt to avoid text relocations in the unknown code 2021-12-14 19:21:01 -07:00
Mark Young
24373f2d98 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.
2021-12-13 11:05:15 -07:00
Charles Giessen
ca9efe3f1c 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.
2021-12-10 17:08:23 -07:00
Charles Giessen
6849c8d93a Use std::function in Layer callbacks
Also fixed the compilation issues in the linux build
2021-12-10 17:08:23 -07:00
Charles Giessen
0640d7acac 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.
2021-12-10 17:08:23 -07:00
Charles Giessen
e821601443 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.
2021-12-10 17:08:23 -07:00
Charles Giessen
b8f496c409 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.
2021-12-10 17:08:23 -07:00
Charles Giessen
f8709399e1 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.
2021-12-10 17:08:23 -07:00
Charles Giessen
b163d18858 Add Builder Pattern helpers to test framework
Allows quick creation of builders in test code.
2021-12-10 17:08:23 -07:00
Charles Giessen
0ed0e76146 Add test for no drivers and no physical devices 2021-12-10 17:08:23 -07:00
Charles Giessen
6f192222dc 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().
2021-12-10 17:08:23 -07:00
Mike Schuchardt
2bbfe2ef64 build: Update to header 1.2.202
- Update known-good
- Generate source
2021-12-07 10:25:37 -08:00
Charles Giessen
3d3aae8fab 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.
2021-12-06 11:57:43 -07:00
Charles Giessen
876a1b9c34 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.
2021-12-02 22:15:32 -07:00
Charles Giessen
143eb773e4 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.
2021-12-02 18:57:29 -07:00
Mark Young
737b390a4c 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.
2021-12-02 08:46:14 -07:00
Charles Giessen
f8c72d8fe4 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.
2021-12-01 14:02:09 -07:00
Mike Schuchardt
6df9f13c7b build: Update to header 1.2.201
- Update known-good
- Generate source (version bump only)
2021-12-01 09:54:01 -08:00
Charles Giessen
36cc581621 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.
2021-11-30 13:54:34 -07:00
Charles Giessen
a06909aaa6 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.
2021-11-30 13:53:34 -07:00
Charles Giessen
004be487c3 Fix leaks in Handle Validation Tests
Instances were being created but not destroyed. Switch all tests to using
the InstWrapper to automate this cleanup.
2021-11-30 13:39:34 -07:00
Charles Giessen
8ac4d2846e Fix error message in GetPhysDevImageFormatProps 2021-11-30 11:20:00 -07:00
Joel Winarske
3c1ad4b0d5 vulkan.pc cross-compile fix
- pkg-config variable ${prefix} is required for adjusting sysroot

Signed-off-by: Joel Winarske <joel.winarske@gmail.com>
2021-11-29 16:56:17 -07:00
Mike Schuchardt
01a41e8b78 build: Update to header 1.2.200
- Update known-good
- Generate source (version bump only)
2021-11-29 10:17:35 -08:00
Mark Young
ef2429635d Fix the spelling of Manfiest in docs and loader 2021-11-22 17:14:52 -07:00
Mark Young
c6f5be2e36 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.
2021-11-22 16:09:16 -07:00
Mark Young
b21acf16e7 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.
2021-11-19 10:32:13 -07:00
Charles Giessen
22e9c7c538 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.
2021-11-17 15:27:03 -07:00
Mike Schuchardt
447f2289f0 build: Update to header 1.2.199
- Update known-good
- Generate source (version bump only)
2021-11-16 11:22:26 -08:00
Eric Sullivan
4f78f14c05 loader: Add aarch64 unknown ext chain implementation 2021-11-12 11:01:34 -07:00