Commit Graph

1055 Commits

Author SHA1 Message Date
Charles Giessen
972d690b5a Revamp unknown function tests
Make use of multiple different functions that are used so that its more
obvious when a test is actually calling the right function.
2022-03-14 23:31:26 -06:00
Charles Giessen
42d5db3f59 Remove VK_NO_PROTOTYPES from test_util.h 2022-03-09 16:02:22 -07:00
Charles Giessen
eac5f00928 make secure_getenv discovery project wide
Since the tests need to know if secure_getenv exists or not, the detection and
setup logic is now in the top level CMakeLists.txt.
2022-03-09 15:06:30 -07:00
Charles Giessen
7e55b0d86e Set VK_NO_PROTOTYPES on test targets
Moves the definition of VK_NO_PROTOTYPES out of a header and into cmake so that
so that libraries and executables can set or not set it if they so desire. This
allows binaries to link directly to the loader if need be.
2022-03-09 15:06:30 -07:00
Charles Giessen
a0b1b55780 Fix tests compiler warnings from bool conversions
While set_env_var did return a boolean, this caused odd performance warnings
on old compilers and wasn't being used by the tests.
2022-03-09 15:06:30 -07:00
Charles Giessen
bd0adb3040 Refactor CMake to user correct C/C++ Standard
Make sure the correct C++ version but also refactor the tests CMake code
to clean it up.
2022-03-09 15:06:30 -07:00
Charles Giessen
2ceafb359b Set CMake C & C++ standard per target 2022-03-09 15:06:30 -07:00
Charles Giessen
174a871a67 Specify wrap_objects.cpp in CMake code
While CMake will append appropriate file extensions when the full name isn't
given, such as "wrap_objects", it is best to specify the file with its
extension for explicitness.
2022-03-09 15:06:30 -07:00
Charles Giessen
02c4578121 Cleanup MSVC CMake code
* Googletest has been updated to 1.11 which means the TR1 deprecation notice is
unecessary.

* The `/permissive-` flag has been moved to loader_common_options so it doesn't
have to be repeated over and over.

* Since we do not support VS 2013 and early, use /guard:cf everywhere

* Remove MSVC_LOADER_COMPILE_OPTIONS in favor of loader_common_options

* Remove reduntant compile options and include directories
2022-03-09 15:06:30 -07:00
Charles Giessen
b935341a01 Fix compiler warnings in tests on MSVC 2022-03-09 15:06:30 -07:00
Charles Giessen
595cca67b0 Refactor CMake WSI platform defines
Move the WSI macro defines into their own target such that it can be shared
with the loader and test code. Note that this commit is a part of a series
and not intended to work standalone.
2022-03-09 15:06:30 -07:00
Charles Giessen
6524b598f6 Add live tests for OS dynamic loader behavior
Executes various combinations of loading and linking to libraries which
export the same symbols.
2022-03-04 15:40:01 -07:00
Mark Young
435070c405 Changes to additive env var based on code review 2022-03-04 15:38:46 -07:00
Mark Young
1d099bf9eb Fix WIndows elevation 2022-03-04 15:38:46 -07:00
Mark Young
46abc7dc4e Add "additive" environment variables
Add "additive" environment variables for adding additional layer
paths or driver JSON files instead of replacing default ones.

Also, rename VK_ICD_FILENAMES to VK_DRIVER_FILES since we're trying
to remove references to ICDs because software driver implementations
of Vulkan aren't ICDs (but continue to support the old name as well).

Added documentation around these changes to reflect the new name and
the new variables.
2022-03-04 15:38:46 -07:00
Mark Young
3a1b0842a3 Resolve Angle failure because it breaks with is_high_integrity
Angle drops the security enforcement of the loader on environment
variables and the additional "is_high_integrity" checks on my
previous loader change caused failures in the Angle run.
Revert the high-integrity checks and update the layer test to
work properly.
2022-02-28 12:06:57 -07:00
Charles Giessen
4c90ec3310 Fix compiler warnings in regression_tests 2022-02-21 11:49:17 -07:00
Charles Giessen
df8899628a Add consecutive create instance and device tests 2022-02-21 11:49:17 -07:00
Mark Young
18852aa1b9 Enable testing of high-integrity in the loader
Enable testing to check if the loader is running with elevated
privileges.  This is to make sure we're ignoring the appropriate
environment variables in those scenarios to potentially avoid
escalation exploits.
2022-02-17 11:37:30 -07:00
Mark Young
be01dafa1e Clean up layer test
My previous commit to enable physical device modifications in a layer
required new compiled layers to do the work.  Since this can more
cleanly be done by setting layer flags (as suggested by @charles-lunarg)
I have gone back and done that.
2022-02-16 10:09:29 -07:00
Mark Young
017bf51740 Fix Windows build and add proper phys dev group sorting 2022-02-16 08:29:42 -07:00
Mark Young
debd92589b Code review comment fixes.
Also, cleaned up Linux vs Windows code so that there was less duplication and
complexity.
2022-02-16 08:29:42 -07:00
Mark Young
0a19663fef Loader single EnumPhysDev call through layers
The loader trampoline previously would query all devices every time
vkEnumeratePhysicalDevices was called.
To do this, it would make two calls every time:
  - First, it would ignore the passed in user values
  - Second, it would query the total number of available devices.
  - Third, it would query the values for every available device

This resulted in layers reporting 2 vkEnumeratePhysicalDevices call for
every 1 the application made which could get very polluted in output.
It didn't break any functionality, just made things messy.

This change removes that behavior and adds a bunch of test cases to verify
nothing broke in the move.
2022-02-16 08:29:42 -07:00
Charles Giessen
1e882f9ce4 Update build.md and README.md for the tests 2022-02-15 16:51:46 -07:00
Charles Giessen
38b9a27fbc Guard building of live_verification tests
Don't build live verification tests by default. These are meant as manual tests for
developers to run to diagnose issues or verify correctness on a real system.
2022-02-15 16:51:46 -07:00
Mark Young
2b11f6bb5a Switch ASSERT_EQ(false,true) for FAIL() in tests 2022-02-15 14:56:05 -07:00
Mark Young
32e48f5c34 Add explicit layer invalid variant number test 2022-02-15 14:56:05 -07:00
Mark Young
2a012c99be Add a few device layer tests
Since device layers are pretty much ignored, make sure that they don't
change any behavior.
Also add a few "load" entrypoint helper routines based on what was already
done elsewhere in the test system.
2022-02-15 14:56:05 -07:00
Charles Giessen
ae2de33612 Add live_verification tests for runnign with real drivers
Some things need to be verified against real drivers. The supporting code in test_util and
test_environment make it easy to write application code which works against real drivers and
layers. This allows quickly verifying loader behavior out in the wild.
2022-02-15 13:56:21 -07:00
Mark Young
77463c0334 Add a test to verify that VK_INSTANCE_LAYERS behaves properly 2022-02-15 11:24:56 -07:00
Charles Giessen
b53e82543e Expand unknown function handling tests
Add tests for unknown device functions queried with both vkGetDeviceProcAddr
and vkGetInstanceProcAddr. Also loops enough times to exhaust the available
unknown function supply.

Had to fix the vk_layerGetPhysicalDeviceProcAddr in TestLayer to make the tests
pass.

MacOS currently skips tests which use vkGetInstanceProcAddr. This is due to the
need for unknown functions being lower priority and so do not warrent the time
needed to write the assembly necessary to resolve the issue fully.
2022-02-15 10:48:53 -07:00
Charles Giessen
24ce547c83 Update tests function loading implementation
Remove the need for macros and use well crafted helper loading functions which
can figure out the type to convert to based on the type being assigned.
2022-02-15 10:48:53 -07:00
Mark Young
383cf8a6d3 Test layer pre-instance functions
Add tests to verify that the 3 pre-instance functions are properly
intercepted by the layer when everything is well-defined.

Also include two fixes:
 1) Disable environment variable value of 0 should be treated the same as not present
 2) The vkEnumerateInstanceVersion override path was broken, missing a NULL check
2022-02-15 10:47:36 -07:00
Charles Giessen
0a7407b151 Clarify behavior of override_paths + VK_LAYER_PATH
If a meta layer which contains `override_paths` is active, all of the paths in
VK_LAYER_PATH are ignored when searchign for explicit layers. This may be changed
changed in the future but for now is better tested and documented.
2022-02-11 14:16:05 -07:00
Charles Giessen
fcdc9ae5ac Test when there are no devices or device extensions
Adds 2 tests:
* ZeroPhysicalDevices - Return VK_ERROR_INITIALIZATION_FAILED if the driver has zero
physical devices.
* ZeroPhyiscalDeviceExtensions - Return VK_SUCCESS if no physical device extensions are
found.
2022-02-10 16:38:15 -07:00
Mark Young
9ec9ef8d17 Add debug utils loader testing 2022-02-09 13:19:48 -07:00
Mark Young
15d33b4822 Add DebugReport 2022-02-09 13:19:48 -07:00
Charles Giessen
354fc0a1f3 Make vkGetInstanceProcAddr able to get itself
There was a regression with 1.3 that meant vkGetInstanceProcAddr wouldn't be
able to query itself if instance was set for 1.3. This commit makes it possible
to query for vkGetInstanceProcAddr with itself no matter the value of instance.
2022-02-05 19:04:36 -07:00
Mark Young
ddec051dc4 Verify GIPA on device extensions
Verify that using vkGetInstanceProcAddr to get an entrypoint to a device
extension works when the extension is enabled, and crashes when the
extension isn't enabled.

Also, update a copyright notice date for my last commit.
2022-02-03 15:17:17 -07:00
Mark Young
7df1967e40 Add tests to verify extension support in physical devices
Add 2 tests to verify that physical devices supporting instance
and device extensions (which are really physical device extensions)
are properly handled.
2022-02-03 13:00:30 -07:00
Mark Young
cdebcc4ee0 Add a few tests to verify the vkGet***ProcAddr commands
Verify that the loader exported version matches the ones you
receive from vkGet****ProcAddr.
2022-02-02 16:44:55 -07:00
Mark Young
fbea18e178 Add tests to validate layer extensions
We had tests that verified that instance and device extensions defined
in a layer had the non-null pointers returned from the corresponding
vkGetXXXProcAddr functions, but we weren't verifying that the functions
actually got called.
2022-02-01 09:39:39 -07:00
Mark Young
be7c48c0e9 loader log error if a requested layer not loaded
This should throw an error message if a requested layer didn't load.
This could happen if the JSON file is present, but only a library
exists on the system for the wrong target (like 32 vs 64-bit).

If it did fail because of being the wrong bit-type, we report an info
message only, unless it was directly requested by the application.

Modify the improper bit-depth layer loading test so that it is now 4
tests:
 - Verify bad explicit layer generates VK_ERROR_LAYER_NOT_PRESENT error
 - Verify bad implicit layer generates only an info in the loader output
 - Test case with both a bad implicit and explicit layer with INFO logging
   we should see both messages.
 - Test case with both a bad implicit and explicit layer with ERROR logging
   we should see only the explicit failure message.

Report info failure for ICD wrong bit-type as well.

Finally, fixed a small compilation warning for disabled code.
2022-01-31 14:35:07 -07:00
Charles Giessen
393e23f91d Add wrong Variant tests 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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
Charles Giessen
bed7a5c659 Add test for vkGetPhysicalDeviceToolProperties
Basic tests which just makes sure the trampoline + terminator pass the data
through correctly. Data only originates from TestICD, TestLayer has no
support for the extension.
2021-11-09 16:20:03 -07:00
Charles Giessen
5e849b89b4 Add test for unknown physical device functions
Requires adding support in the ICD for unknown instance and physical device
functions separately.
2021-11-08 15:15:31 -07:00
Charles Giessen
73fa8a57d3 Refactor shim function definitions to its own file
The code was written with an assumption that the functions needed to be inlined
so they would appear in the correct places (both the test binaries and shim
library). This can be achieved using static libraries, which is what this
commit does.
2021-11-04 14:53:29 -06:00
Charles Giessen
47b8d7c00a test: Fix compiler warnings in MSVC
Warnings/fixes include:
* strcpy/strncpy/wstrcpy
* Dropping static on inline functions
* Use localtime_s
* Name shadowing
* Use wcstombs_s
* 32<->64 bit int conversion
* Silence spurious C4996 generated in vs2015
2021-11-04 12:19:14 -06:00
Charles Giessen
5a4c691700 Fix vkGetInstanceProcAddr not handling null instance
The issue was that trying to get a non-pre-instance function with a NULL
instance handle would cause a crash. This change also adds a test that
would of caught the oversight.
2021-10-22 16:39:01 -06:00
Eleni Maria Stea
b35527922c loader: include FreeBSD in supported platforms
Added FreeBSD in supported platforms in vk_loader_platform.h, and tests,
defined BSD_VISIBLE and included some necessary header files for
Vulkan-Loader to compile on FreeBSD.

v2: did the same in loader/loader.c (Charles Giessen)
v3: did the same in the tests (Charles Giessen)
v4: applied this downstream patch from Jan Beich because there's no /proc
on FreeBSD: 7caf52e37b/graphics/vulkan-loader/files/patch-loader_vk__loader__platform.h (Jan Beich)
v4: rebased to master and modified tests/loader_regression_tests.cpp,
tests/loader_testing_main.cpp
v5: moved the definition of __BSD_VISIBLE 1 (required for alloca to
work) in CMakeLists.txt from header files (Charles Giessen)
v6: replaced ${CMAKE_SYSTEM_NAME} with CMAKE_SYSTEM_NAME in
loader/CMakeLists.txt to match the style of previous checks (Jan Beich)
v7: replaced add_compile_definitions with target_compile_definitions to
prevent the macro from being applied unnecessarily (Charles Giessen)
2021-10-20 10:29:26 -06:00
Charles Giessen
f524349518 test: Don't add null paths for redirection 2021-10-18 15:14:20 -06:00
Charles Giessen
b9d0a4ffd7 Only return pre-instance functions when instance is NULL
vkGetInstanceProcAddr should only return the pre-instance, aka global
functions, when the VkInstance handle is NULL. This brings the desktop
vulkan loader into alignment on the spec and with the android loader.
https://github.com/KhronosGroup/Vulkan-Docs/issues/1605

The repo previously did follow this rule, but was changes in the
1.0.42 header version timeframe for unknown reasons.
2021-10-15 12:34:50 -06:00