platform/upstream/Vulkan-Loader.git
3 years agoloader: Remove deadstore when breaking from a loop
Charles Giessen [Fri, 21 May 2021 02:33:16 +0000 (20:33 -0600)]
loader: Remove deadstore when breaking from a loop

Change-Id: Ic72cf396cad918ce255b331fa9a9c3a652b8764d

3 years agoloader: Prevent use-after-free in error path.
Charles Giessen [Fri, 21 May 2021 02:19:24 +0000 (20:19 -0600)]
loader: Prevent use-after-free in error path.

When `setup_loader_term_phys_devs` and `setup_loader_term_phys_dev_groups` hit an
error, they attempt to delete all the alocated elements in `new_phys_devs`. However,
the code first may copy elements from another array into it first before hitting
the error. This causes the deletion code to free those 'good' elements which were
copied, leading to use-after-free's.

Additionally, an error message used total_gpu_count instead of total_icd_count, this
is fixed with this commit.

Change-Id: I8f714f699ff09cc99d094cf2ed8190cedcad684b

3 years agoloader: Don't pass null pointer into strcmp
Charles Giessen [Mon, 17 May 2021 23:42:29 +0000 (17:42 -0600)]
loader: Don't pass null pointer into strcmp

strcmp wasn't correctly guarded against a null first parameter when
doing the shallow search in loader_name_in_dev_ext_table and
loader_name_in_phys_dev_ext_table.

Change-Id: Ia751e9860334895930210defa2dcb2becbfd6daa

3 years agoloader: Remove dead store of total_count
Charles Giessen [Mon, 17 May 2021 22:24:23 +0000 (16:24 -0600)]
loader: Remove dead store of total_count

`loaderScanForLayers` total_count is not used after determining
if it is not zero.

Change-Id: I2ff3a1a5d7dde42ce5ad7d57aab63831ccf58156

3 years agoloader: Prevent stack_alloc of 0
Charles Giessen [Mon, 17 May 2021 22:09:27 +0000 (16:09 -0600)]
loader: Prevent stack_alloc of 0

`loader_create_device_chain` would previously attempt to use stack allocations
when `expanded_activated_layer_list.count` was zero, which is undefined behavior

Change-Id: I56fab835a1728914191f1a7adc210dae58afa155

3 years agoloader: Get DeviceGroups early exits if 0 are found
Charles Giessen [Mon, 17 May 2021 22:05:46 +0000 (16:05 -0600)]
loader: Get DeviceGroups early exits if 0 are found

This commit prevents undefined behavior by exiting
`setupLoaderTermPhysDevGroups` if total_count is 0.

Change-Id: Ieef2747724f79ec26a08a74884904bc0e0485c17

3 years agoloader: Remove redundant stores
Charles Giessen [Mon, 17 May 2021 21:17:58 +0000 (15:17 -0600)]
loader: Remove redundant stores

`layer_node = layer_node->next;` is redundant in error paths that goto out.

Change-Id: I889b03c825f896f458a1ed3171b951d64d8827d7

3 years agoloader: assert if trying to malloc 0 bytes
Charles Giessen [Mon, 17 May 2021 20:41:38 +0000 (14:41 -0600)]
loader: assert if trying to malloc 0 bytes

The behavior of malloc is undefined if size is 0. This commit checks for that
and prevents a possible malloc of zero in device extension property enumeration
by only malloc'ing if size is greater than 0.

Change-Id: Id506ab93d404bd4895503c660ef74bcb9c4550a3

3 years agoloader: Format WSI error messages
Charles Giessen [Mon, 17 May 2021 16:56:14 +0000 (10:56 -0600)]
loader: Format WSI error messages

Change-Id: I3040be426a8e70ca41e7beede1fae6b52e1381af

3 years agoloader: Use abort to force a crash where needed
Charles Giessen [Thu, 13 May 2021 22:41:16 +0000 (16:41 -0600)]
loader: Use abort to force a crash where needed

Many places in the loader need to intentionally crash. This commit makes the
loader use `abort();` in those places, including replacing numerous
`assert(false)` statements. Using abort clearly signals intent instead of
having it do a null pointer dereference to cause the crash.

Change-Id: I6874eab5702c94af59b7984fab00f6eaf03f2f45

3 years agoloader: Fix potential memory leak
Charles Giessen [Thu, 13 May 2021 00:20:37 +0000 (18:20 -0600)]
loader: Fix potential memory leak

Also remove a redundant setting of an int to 0

Change-Id: Ia099ad75e9da14aacf9874d75267716c12794305

3 years agoloader: Handle OOM in loader_phys_dev_ext_gpa
Charles Giessen [Wed, 12 May 2021 23:42:00 +0000 (17:42 -0600)]
loader: Handle OOM in loader_phys_dev_ext_gpa

Removing some dead code revealed a case where a potencial OOM situation
was not being handled.

Change-Id: Ibc5ad607f6adc0f590f663ab928c1abca6732d96

3 years agoloader: Make trampolineGetProcAddr snake_case
Charles Giessen [Thu, 9 Sep 2021 16:00:52 +0000 (10:00 -0600)]
loader: Make trampolineGetProcAddr snake_case

3 years agoloader: Move simple terminators to terminator.c
Charles Giessen [Mon, 6 Sep 2021 16:47:34 +0000 (10:47 -0600)]
loader: Move simple terminators to terminator.c

Keeps the complex terminators in loader.c for the time being.

3 years agoloader: Rename SetupLoaderTermPhysDevGroups
Charles Giessen [Mon, 6 Sep 2021 16:16:28 +0000 (10:16 -0600)]
loader: Rename SetupLoaderTermPhysDevGroups

Forgot this name when renaming all the functions.

3 years agogn: Fix gn build for refactor changes
Charles Giessen [Mon, 6 Sep 2021 00:53:57 +0000 (18:53 -0600)]
gn: Fix gn build for refactor changes

3 years agoloader: Move Windows logic to dedicated file
Charles Giessen [Mon, 6 Sep 2021 00:34:10 +0000 (18:34 -0600)]
loader: Move Windows logic to dedicated file

Relocated most windows specific functionality into loader_windows.h/.c
This removes the need for loader.c to include windows specific header files.

3 years agoloader: Move struct declarations into header
Charles Giessen [Sun, 5 Sep 2021 23:20:26 +0000 (17:20 -0600)]
loader: Move struct declarations into header

3 years agoloader: Move init functions closer together
Charles Giessen [Sun, 5 Sep 2021 23:14:47 +0000 (17:14 -0600)]
loader: Move init functions closer together

3 years agoloader: Header include cleanup
Charles Giessen [Sun, 5 Sep 2021 05:23:28 +0000 (23:23 -0600)]
loader: Header include cleanup

Separated headers into common groups, with system headers being first, then
Vulkan API headers, followed by loader headers.

Then alphabetized headers in each group. Due to moving _GNU_SOURCE to being set
by cmake, there isn't any implicit dependency between the include order used.

Made sure headers should be able to be included independently, such as
including the vulkan headers where appropriate.

3 years agoloader: Remove headers from cmake source list
Charles Giessen [Sun, 5 Sep 2021 05:08:26 +0000 (23:08 -0600)]
loader: Remove headers from cmake source list

Headers do not do any functional thing here. Better to remove them so they dont
clutter up or make people thing they need to be there.

3 years agoloader: Make logging and getenv their own headers
Charles Giessen [Sun, 5 Sep 2021 05:06:46 +0000 (23:06 -0600)]
loader: Make logging and getenv their own headers

This commit pulls the logging capabilities into a single log.h/.c file and does
the same for the getenv functionality.

3 years agoloader: Make _GNU_SOURCE a cmake definition
Charles Giessen [Sun, 5 Sep 2021 04:40:36 +0000 (22:40 -0600)]
loader: Make _GNU_SOURCE a cmake definition

Moves the many instances of #define _GNU_SOURCE into a single cmake call which
sets the macro in all translation units for the vulkan library. This way it
cannot be forgotten and makes behavior across the library consistent.

3 years agoloader: Move alloca into allocation.h
Charles Giessen [Sun, 5 Sep 2021 04:31:25 +0000 (22:31 -0600)]
loader: Move alloca into allocation.h

3 years agoloader: Remove duplicate macro defines
Charles Giessen [Sun, 5 Sep 2021 04:28:36 +0000 (22:28 -0600)]
loader: Remove duplicate macro defines

3 years agoloader: Make vk_loader_layer.h a proper header
Charles Giessen [Sun, 5 Sep 2021 04:15:40 +0000 (22:15 -0600)]
loader: Make vk_loader_layer.h a proper header

Makes it possible to include this file without worry of not having the required
headers already included.

3 years agoloader: Remove unneeded parts of loader_common.h
Charles Giessen [Sun, 5 Sep 2021 04:13:51 +0000 (22:13 -0600)]
loader: Remove unneeded parts of loader_common.h

3 years agoloader: Shift around vk_loader_platform headers
Charles Giessen [Sun, 5 Sep 2021 04:10:59 +0000 (22:10 -0600)]
loader: Shift around vk_loader_platform headers

Moved the includes into their own block, instead of living in the block for
each operating system. This way is easier to see what includes are in the file
in its entirety.

Also, _GNU_SOURCE was uncommented since it appears in each source file
individually and is needed for alloca and secure_getenv

3 years agoloader: Dont include C++ libraries in C++ mode
Charles Giessen [Sun, 5 Sep 2021 00:53:54 +0000 (18:53 -0600)]
loader: Dont include C++ libraries in C++ mode

3 years agoloader: Move allocation functions to a header
Charles Giessen [Sat, 4 Sep 2021 21:38:53 +0000 (15:38 -0600)]
loader: Move allocation functions to a header

Functions pertainting to allocation (malloc, realloc, free) have been moved to
their own translation unit for better organizational purposes.

3 years agoloader: Remove TLS
Charles Giessen [Sat, 4 Sep 2021 19:48:37 +0000 (13:48 -0600)]
loader: Remove TLS

The only purpose TLS was serving was as a channel for allocation callbacks to
be useable inside cJSON and dirent_on_windows. TLS didn't solve any specific
threading problem. Instead it served as an information channel. On top of that,
the only time when the TLS was used was inside vkCreateInstance as the
pre-instance calls would have the TLS pointer to loader_instance be set to
NULL.

3 years agoloader: cJSON to use regular heap instead of TLS
Charles Giessen [Sat, 4 Sep 2021 19:33:38 +0000 (13:33 -0600)]
loader: cJSON to use regular heap instead of TLS

Refactored the cJSON library to take an loader_instance pointer everywhere it
allocates memory. This way a TLS loader_instance pointer doesn't need to be
set at initialization and then at vkCreateInstance.

3 years agoloader: Dont use TLS in dirent_on_windows
Charles Giessen [Sat, 4 Sep 2021 17:13:40 +0000 (11:13 -0600)]
loader: Dont use TLS in dirent_on_windows

Loader will now pass in the instance handle directly rather than rely on TLS to
pass it. This makes the loader code simpler to reason about and better since
if a second instance is created on the same thread the TLS wont be overwritten.

3 years agoloader: Add gpa_helper.c
Charles Giessen [Sat, 4 Sep 2021 04:18:51 +0000 (22:18 -0600)]
loader: Add gpa_helper.c

Make gpa_helper.h not contain function definitions, moving them into the
appropriate header file.

3 years agoloader: Move loader struct defs into common file
Charles Giessen [Sat, 4 Sep 2021 04:03:18 +0000 (22:03 -0600)]
loader: Move loader struct defs into common file

This commit separates the structure definitions from the function declarations.
The reason to do this is to allow splitting of loader.h/.c functionality into
individual headers, which may require access to these structs but don't need to
know about the other functions.

3 years agoloader: Update Copyright for 2021
Charles Giessen [Sat, 4 Sep 2021 03:55:09 +0000 (21:55 -0600)]
loader: Update Copyright for 2021

3 years agoloader: Use #pragma once everywhere
Charles Giessen [Sat, 4 Sep 2021 03:41:19 +0000 (21:41 -0600)]
loader: Use #pragma once everywhere

The #pragma once include guard is sufficiently widespread enough to allow
usage of it everywhere.

3 years agoloader: Update Copyright
Charles Giessen [Sat, 4 Sep 2021 03:23:43 +0000 (21:23 -0600)]
loader: Update Copyright

3 years agobuild: Alphabetize loader source file list
Charles Giessen [Sat, 4 Sep 2021 03:22:45 +0000 (21:22 -0600)]
build: Alphabetize loader source file list

3 years agotest: Add test for Override Meta Layer
Charles Giessen [Wed, 8 Sep 2021 21:26:09 +0000 (15:26 -0600)]
test: Add test for Override Meta Layer

3 years agotest: Fix extra } in layer manifest printer
Charles Giessen [Wed, 8 Sep 2021 21:25:37 +0000 (15:25 -0600)]
test: Fix extra } in layer manifest printer

3 years agoloader: Move layer cleanup to a single function
Charles Giessen [Wed, 8 Sep 2021 21:23:22 +0000 (15:23 -0600)]
loader: Move layer cleanup to a single function

Previously the logic to free all the components of loader_layer_properties was spread
across a half dozen different places, resulting in leaks. This commit moves the logic
into a single location, centralizing the process and making it easier to add new
fields to the loader_layer_properties struct.

3 years agobuild: Update to header 1.2.191
Mike Schuchardt [Wed, 8 Sep 2021 22:06:25 +0000 (15:06 -0700)]
build: Update to header 1.2.191

- Update known-good
- Generate source

3 years agotest: Improved Test Wrapper interface
Charles Giessen [Mon, 6 Sep 2021 23:57:08 +0000 (17:57 -0600)]
test: Improved Test Wrapper interface

Made InstanceWrapper and DeviceWrapper simpler to use by moving them to test_environment
then making the Create() member functions and doing the gtest assertions in the function
itself.

Additionally:
Removed the `detail` namespace in the test_environment.
Renamed get_new_test_icd/layer to just `reset_icd/layer`. This is clearer about what it
is doing and makes the interface more expressive with code such as
`env->reset_icd().SetMinInterfaceVersion(5);`

3 years agoloader: Make all loader functions use snake_case
Charles Giessen [Fri, 3 Sep 2021 01:24:19 +0000 (19:24 -0600)]
loader: Make all loader functions use snake_case

Before it was a mix of camelCase, PascalCase, and snake_case.

"Vulkan" functions, like terminator_GetPhysicalDeviceProperties, remain in camelCase.
This way it looks visually similar with the actual vulkan functions they correspond to.

3 years agoFix loader not knowing about extensions enabled in layers
Mark Young [Fri, 27 Aug 2021 15:33:47 +0000 (09:33 -0600)]
Fix loader not knowing about extensions enabled in layers

This change allows the loader to know extensions enabled in the layers
as well as extensions enabled but handled by layers.
This should fix several issues where the enabled extensions is not
known soon enough for layers to use.

3 years agoUpdate XDG paths
Mark Young [Fri, 13 Aug 2021 23:26:04 +0000 (17:26 -0600)]
Update XDG paths

Issue #245 was created because we were not properly using the XDG
paths.
This change updates the path search order to be more correct.
While an argument could be made that the loader really should only
be looking in the DATA folders, we already are looking in the
CONFIG folders.  Therefore, just correct the order and also make
sure the proper _HOME variable for CONFIG and DATA is searched
first (but only in non-superuser mode).

3 years agotest: Add handle_assert helper functions
Charles Giessen [Tue, 31 Aug 2021 20:52:54 +0000 (14:52 -0600)]
test: Add handle_assert helper functions

Added functions which check handle values using GTEST. Includes:
checking for null, not null, equality of two handles, and variants that
operate on vectors and arrays.

3 years agotest: Move DeviceGroup tests to regression suite
Charles Giessen [Tue, 31 Aug 2021 20:08:41 +0000 (14:08 -0600)]
test: Move DeviceGroup tests to regression suite

3 years agotest: Add TestICD DeviceGroup support
Charles Giessen [Tue, 31 Aug 2021 20:05:32 +0000 (14:05 -0600)]
test: Add TestICD DeviceGroup support

Add support for tests which use device groups by adding a new structure that
holds pointes to PhysicalDevice structs and implementing the necessary vulkan
API calls.

This commit also:
 - Formats test_icd.cpp
 - Makes vk_icdGetPhysicalDeviceProcAddr return stuff by refactoring the
   instance procaddr functions

3 years agoscripts: Remove loader_icd_init_entries duplicate
Charles Giessen [Mon, 30 Aug 2021 17:04:55 +0000 (11:04 -0600)]
scripts: Remove loader_icd_init_entries duplicate

Seems to be a copy-paste error that makes the function declaration appear twice.

3 years agobuild: Update to header 1.2.190
Mike Schuchardt [Mon, 30 Aug 2021 16:10:06 +0000 (09:10 -0700)]
build: Update to header 1.2.190

- Update known-good
- Generate source

3 years agobuild: Silence MSVC warning of replacing /GR
Charles Giessen [Mon, 16 Aug 2021 17:50:43 +0000 (11:50 -0600)]
build: Silence MSVC warning of replacing /GR

3 years agotest: Update 32/64 tests to check the log
Charles Giessen [Wed, 25 Aug 2021 22:43:58 +0000 (16:43 -0600)]
test: Update 32/64 tests to check the log

Use the DebugUtilsLogger to verify that the loader is downgrading the error
level of dll/so's from ERROR to INFO

3 years agotest: Add DebugUtilsWrapper
Charles Giessen [Wed, 25 Aug 2021 22:41:59 +0000 (16:41 -0600)]
test: Add DebugUtilsWrapper

This wrapper allows easy reading of the log output through the debug utils
messenger infrastructure. Since getting the stdout/stderr is not well
supported by googletest, this allows tests to be written which check for
specific log messages to be emitted, allowing another way to verify the
loader is behaving as expected.

3 years agoloader: Downgrade wrong arch errors on windows
Charles Giessen [Wed, 25 Aug 2021 22:39:26 +0000 (16:39 -0600)]
loader: Downgrade wrong arch errors on windows

On linux, when the loader fails to load a .so if it was due to being on the
wrong architecture, the loader downgraded the error to INFO level. This
commit does the same thing for windows. Error code 193 is winapi's way to
signify that the dll failed to load cause of the architecture.

3 years agobuild: Update to header 1.2.189
Mike Schuchardt [Tue, 17 Aug 2021 18:03:50 +0000 (11:03 -0700)]
build: Update to header 1.2.189

- Update known-good
- Generate source

3 years agotest: Set VK_LAYER_PATH properly
Charles Giessen [Mon, 16 Aug 2021 23:13:13 +0000 (17:13 -0600)]
test: Set VK_LAYER_PATH properly

3 years agotest: Update Device Layers Match test
Charles Giessen [Mon, 16 Aug 2021 22:41:42 +0000 (16:41 -0600)]
test: Update Device Layers Match test

Move the old EnumerateDeviceLayers.LayersMatch to the new framework,
implementing the necessary components in the TestLayer code path.

3 years agotest: Use proper allocation count in tests
Charles Giessen [Mon, 16 Aug 2021 20:59:10 +0000 (14:59 -0600)]
test: Use proper allocation count in tests

The test used to only keep track of the maximum number of allocations and fail
if it was exceeded, as calling free would decrease this number. Now tests use
the total number of times allocate was called, and realloc was added to this
metric. This should offer better OOM coverage due to failing at each and
every possible OOM place. The code does make sure not to increase the count
if realloc was called to 'downsize' the allocation, which shouldn't cause
OOM to occur ever.

3 years agotest: Add test for PR #639
Charles Giessen [Mon, 16 Aug 2021 17:32:30 +0000 (11:32 -0600)]
test: Add test for PR #639

This test tries to recreate an out of memory condition which causes
a binary of the wrong type to be confused with a valid binary, which
causes VK_ERROR_INCOMPATIBLE_DRIVER to be returned instead of VK_SUCCESS
(Or OOM if the case may be)

3 years agoloader: Fix accidental error propagation
Charles Giessen [Mon, 16 Aug 2021 18:00:26 +0000 (12:00 -0600)]
loader: Fix accidental error propagation

When a dll/so of the wrong architecture is found, the loader would
return ERROR_INCOMPATIBLE_DRIVER from `loader_scanned_icd_add`.
Previously it would return VK_SUCCESS, but that caused the logic to
not skip over the ICD. This commit fixes the issue where the error
code would be propagated out of the function, which shouldn't happen
since there may be other drivers which do successfully load.

3 years agoFix Vulkan CTS testcase bug: "create_instance_device_intentional_alloc_fail"
WenqingLiAMD [Mon, 9 Aug 2021 09:56:13 +0000 (17:56 +0800)]
Fix Vulkan CTS testcase bug: "create_instance_device_intentional_alloc_fail"

In function loader_scanned_icd_add, if open_library fails, VK_SUCCESS
is still returned, which would cause the bad number of good ICDs.

3 years agotest: Simplify wrong arch tests by adding a macro
Charles Giessen [Mon, 16 Aug 2021 03:21:37 +0000 (21:21 -0600)]
test: Simplify wrong arch tests by adding a macro

Added the `CURRENT_PLATFORM_DUMMY_BINARY` macro which thanks to platform
defines contains the path of the binary which is 'wrong' for the current
architecture. EX: compiling with Win64, it points to the Win32 binary, and vice
versa when compiling for Win32. Same logic applies for linux 64/32 bit.

3 years agotest: Add windows 32/64 bit binary tests
Charles Giessen [Fri, 13 Aug 2021 23:00:53 +0000 (17:00 -0600)]
test: Add windows 32/64 bit binary tests

Added both layer and ICD tests. Included lengthy description of why the test
successfully creates an instance even though it really shouldn't.

3 years agotest: Add linux x64 and x86 for wrong binaries
Charles Giessen [Fri, 13 Aug 2021 15:47:54 +0000 (09:47 -0600)]
test: Add linux x64 and x86 for wrong binaries

Test only looks for ICD binaries.

3 years agotest: Add ELF test binaries for 32 and 64 bit
Charles Giessen [Thu, 12 Aug 2021 23:03:14 +0000 (17:03 -0600)]
test: Add ELF test binaries for 32 and 64 bit

These binaries are necessary for testing whether the loader correctly
ignores binaries of the wrong architecture. Since they are data files
more than executables, they are being checked in.

Currently only Unix binaries are added but in the future windows along
with any other platform binaries will be added.

3 years agoloader: Make use of a generated header version
Charles Giessen [Thu, 17 Jun 2021 23:24:57 +0000 (17:24 -0600)]
loader: Make use of a generated header version

This changes the loader to always set the version to the one which was used when
generating the source files that are checked into the repo, instead of using the
version gotten from the Vulkan-Headers find cmake file.

Change-Id: Id0955ddfd10e35e0f358f5a77799d8baa4992b04

3 years agoloader: Reformated loader source code
Charles Giessen [Tue, 10 Aug 2021 20:35:29 +0000 (14:35 -0600)]
loader: Reformated loader source code

Previously, clang-format was required for all new commits but the codebase
itself wasn't conformant. This commit formats the source files in the loader
folder.

3 years agotest: Revamp which linux paths are redirected
Charles Giessen [Tue, 10 Aug 2021 22:07:55 +0000 (16:07 -0600)]
test: Revamp which linux paths are redirected

Adds FALLBACK_DATA_DIRS, FALLBACK_CONFIG_DIRS, SYSCONFDIR, and EXTRASYSCONFDIR
to the list of redirected paths. They were previously 'covered' by manual entries.
This commit makes them responsive to changes in the build system.

This commit also makes sure that the path used for redirection is one searched by
the loader by using the SYSCONFIG variable. Previously it would use /usr/local/etc/
which was only correct on systems where CMAKE_INSTALL_PREFIX was set to /usr/local.

3 years agoFix environment test failure.
Mark Young [Wed, 11 Aug 2021 15:38:58 +0000 (09:38 -0600)]
Fix environment test failure.

It was looking for a specific output for the manifest file search string.
Re-add that string for now.

3 years agobuild: Update to header 1.2.188
Mike Schuchardt [Tue, 10 Aug 2021 18:10:28 +0000 (11:10 -0700)]
build: Update to header 1.2.188

- Update known-good
- Generate source (no change)

3 years agoscripts: Use altlen instead of parsing latexmath
Mike Schuchardt [Tue, 10 Aug 2021 18:01:55 +0000 (11:01 -0700)]
scripts: Use altlen instead of parsing latexmath

KhronosGroup/Vulkan-ValidationLayers switched to this method a while ago
and this syncs the KhronosGroup/Vulkan-Loader version of
helper_file_generator.py to match.

3 years agoAllow "icd" as well as "implem" for VK_LOADER_DEBUG
Mark Young [Wed, 4 Aug 2021 22:33:03 +0000 (16:33 -0600)]
Allow "icd" as well as "implem" for VK_LOADER_DEBUG

3 years agoAdd layer and implementation-specific logging
Mark Young [Tue, 3 Aug 2021 21:56:26 +0000 (15:56 -0600)]
Add layer and implementation-specific logging

Add logging that will allow end-users to specifically just look at
messages for layers and implementations/ICDs.
Setting VK_LOADER_DEBUG to include one of the following:
  - layer        : enables layer-specific logging
  - implem       : enables implementation/ICD-specific logging

3 years agoFix loader_log messages to use LOADER_ log levels
Mark Young [Tue, 3 Aug 2021 18:57:25 +0000 (12:57 -0600)]
Fix loader_log messages to use LOADER_ log levels

The loader_log messages were using the DEBUG_REPORT log levels
which just happened to coincide with the existing LOADER_ log levels.
Going forward, to add layer logging in its own level, this would not
have worked.

3 years agotest: Prevent macro collision
Charles Giessen [Wed, 4 Aug 2021 17:16:40 +0000 (11:16 -0600)]
test: Prevent macro collision

3 years agotest: Make MetaLayer test add extensions
Charles Giessen [Wed, 4 Aug 2021 16:31:40 +0000 (10:31 -0600)]
test: Make MetaLayer test add extensions

Needed to fixup more of the manifest writer in the process

3 years agotest: Make invalid meta layer test more comprehensive
Charles Giessen [Wed, 4 Aug 2021 16:18:33 +0000 (10:18 -0600)]
test: Make invalid meta layer test more comprehensive

This required fixing a few bugsin the Manifest file printing logic

3 years agotest: Add simple invalid-meta layer test
Charles Giessen [Wed, 4 Aug 2021 15:33:54 +0000 (09:33 -0600)]
test: Add simple invalid-meta layer test

Creates a meta layer whose component layers do not exist

3 years agoDeallocate the extension lists when deleting an item from layer list
Samiullah Khawaja [Wed, 4 Aug 2021 13:59:25 +0000 (13:59 +0000)]
Deallocate the extension lists when deleting an item from layer list

Vulkan Loader loads the meta layer list and filters the ones that are
not valid. During filter it deallocates the attributes of the loaded
meta layer but does not deallocate the associated extension list.

3 years agotest: Clear TestICDs before each test
Charles Giessen [Wed, 4 Aug 2021 01:07:12 +0000 (19:07 -0600)]
test: Clear TestICDs before each test

Calling `dlclose` doesn't necessarily mean that the static variables will
be reset nor the libraries destructor gets called. This caused cascading
errors in tests on linux with GCC. By always manually resetting the ICD
or Layer before each test, we prevent any funny business from occuring.

3 years agotest: Update tests/README.md
Charles Giessen [Tue, 3 Aug 2021 21:54:35 +0000 (15:54 -0600)]
test: Update tests/README.md

Include note to always destroy the instance at the end of a test.

3 years agotest: Make all tests call vkDestroyInstance
Charles Giessen [Tue, 3 Aug 2021 21:53:54 +0000 (15:53 -0600)]
test: Make all tests call vkDestroyInstance

This caused spurious failures in other tests due to the dynamic library
not being closed.

3 years agotest: Add CreateInstance.LayerPresent test
Charles Giessen [Tue, 3 Aug 2021 18:09:33 +0000 (12:09 -0600)]
test: Add CreateInstance.LayerPresent test

3 years agotest: Update framework_config to include paths to layer binaries
Charles Giessen [Tue, 3 Aug 2021 18:09:06 +0000 (12:09 -0600)]
test: Update framework_config to include paths to layer binaries

3 years agotest: Add noexcept in test_environment
Charles Giessen [Tue, 3 Aug 2021 18:08:37 +0000 (12:08 -0600)]
test: Add noexcept in test_environment

3 years agotest: add CreateInstance.LayerNotPresent test
Charles Giessen [Fri, 30 Jul 2021 17:43:43 +0000 (11:43 -0600)]
test: add CreateInstance.LayerNotPresent test

Remove the corresponding test in loader_validation_tests.cpp

3 years agotest: Implemente layer create instance/device
Charles Giessen [Fri, 30 Jul 2021 17:42:11 +0000 (11:42 -0600)]
test: Implemente layer create instance/device

Added the necessary bits to make calling create instance and device function,
though it may not work in all circumstances

3 years agobuild: Update to header 1.2.187
Mike Schuchardt [Tue, 3 Aug 2021 19:15:40 +0000 (12:15 -0700)]
build: Update to header 1.2.187

- Update known-good
- Generate source (no change)

3 years agoFix loader debug documentation
Mark Young [Mon, 2 Aug 2021 21:28:02 +0000 (15:28 -0600)]
Fix loader debug documentation

The loader debug environment variable (VK_LOADER_DEBUG) is not inclusive
of higher importance messages, it is exclusive to the types specifically
enabled.

3 years agotest: Add basic threading test
Charles Giessen [Thu, 29 Jul 2021 20:17:37 +0000 (14:17 -0600)]
test: Add basic threading test

Requires adding ability for device to return functions with
vkGetDeviceProcAddr that aren't necessarily useable functions.

Also added checks to make sure that the handle passed in by the loader
to the TestICD is the 'right handle' where necessary, as some functions
do not need to know which device is being called on, just that it is correct.

3 years agobuild: Update to header 1.2.186
Mike Schuchardt [Tue, 27 Jul 2021 19:41:31 +0000 (12:41 -0700)]
build: Update to header 1.2.186

- Update known-good
- Generate source (no change)

Change-Id: I7c0699f8613ecbfefe79981f34faa5e276703324

3 years agobuild: Update to header 1.2.185
Mike Schuchardt [Tue, 20 Jul 2021 16:48:39 +0000 (09:48 -0700)]
build: Update to header 1.2.185

- Update known-good
- Re-enable code generation for VK_HUAWEI_subpass_shading
- Generate source

Change-Id: I6607e1de097d1b8a2f631cd1f11b088204b8bb3a

3 years agobuild: Disable -Wimplicit-fallthrough in GN.
Jamie Madill [Tue, 20 Jul 2021 12:36:30 +0000 (08:36 -0400)]
build: Disable -Wimplicit-fallthrough in GN.

This flag was recently enabled by default in Chrome and ANGLE
and other projects inherit these build settings. Explicitly
dsiable this warning until it is enabled in the non-GN build.

Change-Id: I8f353f8abc3f7857481ff9cc774aff3618eaf35a

3 years agoloader: Dont return OOM on function load failure
Charles Giessen [Wed, 14 Jul 2021 18:12:40 +0000 (12:12 -0600)]
loader: Dont return OOM on function load failure

Win7 does not support D3DKMTEnumAdapters2, as such when the loader goes to
query it, it gets NULL back. Except, instead of just erroring out, it would
return VK_ERROR_OUT_OF_HOST_MEMORY. Problem was that change
73296a04678a07fc4fb1eef50cf4fe2778f059f8
starts checking for OOM, and finding one when running in Win7. This change
alters that behavior so that it doesn't report an OOM when one hasn't occured.

3 years agowindows: update the loader copyright date
Bob Ellison [Tue, 13 Jul 2021 22:30:39 +0000 (16:30 -0600)]
windows: update the loader copyright date

The date, specified in loader/loader.rc, was incorrectly set to 2020.

3 years agoci: Re-add code and commit formatting verification
Charles Giessen [Tue, 18 May 2021 21:56:56 +0000 (15:56 -0600)]
ci: Re-add code and commit formatting verification

Change-Id: I240f912daa03d001f2dbd2527d8374bbf394ac4a

3 years agoUpdate contact information
Mark Young [Tue, 13 Jul 2021 14:12:54 +0000 (08:12 -0600)]
Update contact information

3 years agotest: Move more old tests to new test framework
Charles Giessen [Thu, 8 Jul 2021 23:30:14 +0000 (17:30 -0600)]
test: Move more old tests to new test framework

Remove them from the calling scripts where appropriate. Notably the 'get count
then run tests and pass in count' are now using the framework where that is
completely redundant.

Change-Id: I00d561a85047742a849df48818398b10c62d3b74