platform/upstream/Vulkan-Loader.git
19 months agobuild: Update to header 1.3.240 upstream/1.3.240
Mike Schuchardt [Fri, 27 Jan 2023 17:27:22 +0000 (09:27 -0800)]
build: Update to header 1.3.240

- Update known-good
- Generate source

20 months agoRe-checking loader.rc file
Charles Giessen [Thu, 26 Jan 2023 22:11:25 +0000 (15:11 -0700)]
Re-checking loader.rc file

The loader.rc file is now checked into the source, and is automatically updated
by python whenever the headers are updated so that it contains the version used
to build the loader.

If BUILD_DLL_VERSIONINFO is set in the command line, then the loader will use
that version to configure a new loader.rc and place it in the build directory.
Then it will use that loader.rc rather than the checked in file. This allows
Vulkan Runtimes to be built with an exact version.

The file is checked in to allow builds without modifying the source directory
and allowing GN builds to not need any additional configuration to work.

20 months agoci: Fix CI warnings
Juan Ramos [Thu, 26 Jan 2023 23:47:59 +0000 (16:47 -0700)]
ci: Fix CI warnings

20 months agoFix copyright in windows .rc file
Charles Giessen [Wed, 25 Jan 2023 21:32:41 +0000 (14:32 -0700)]
Fix copyright in windows .rc file

This commit makes the copyright date to be taken from the day of the build
instead of it being hardcoded, which is liable to be out of date.

This commit also makes the loader.rc be generated into the build directory
rather than the source tree. Because this commit modifies the version info to
include the current header version for debug builds, this prevents needing to
update the file whenever the headers update.

20 months agoLog when VK_LAYER_PATH is ignored
Charles Giessen [Tue, 24 Jan 2023 17:52:24 +0000 (10:52 -0700)]
Log when VK_LAYER_PATH is ignored

The current design of the loader make the Override Layer, with its override
paths, take priority over VK_LAYER_PATH. This is fine, but if the override
layer accidentally was left around, it can cause confusion as VK_LAYER_PATH
suddenly stops working for no apparent reason. This commit adds a log message
to indicate that it is being ignored.

20 months agogithub: Use main instead of master
Juan Ramos [Mon, 23 Jan 2023 18:01:28 +0000 (11:01 -0700)]
github: Use main instead of master

closes #1107

20 months agodocs: Notify users about upcoming master to main change
Juan Ramos [Thu, 19 Jan 2023 17:44:08 +0000 (10:44 -0700)]
docs: Notify users about upcoming master to main change

20 months agobuild: Update to header 1.3.239
Mike Schuchardt [Thu, 19 Jan 2023 16:49:15 +0000 (09:49 -0700)]
build: Update to header 1.3.239

- Update known-good
- Generate source

20 months agoAdd Vulkan Loader and Driver Interface Version 7
Charles Giessen [Tue, 17 May 2022 15:51:24 +0000 (09:51 -0600)]
Add Vulkan Loader and Driver Interface Version 7

The changes made by Version 7 are as follows.
If a Driver supports any of the following functions,
they must be exposed by with vk_icdGetInstanceProcAddr:
 * vk_icdNegotiateLoaderICDInterfaceVersion
 * vk_icdGetPhysicalDeviceProcAddr
 * vk_icdEnumerateAdapterPhysicalDevices (Windows only)
This makes it optional for a driver to export these functions. Drivers may still
export them for compatibility with older loaders.

Loader and Driver Interface Version 7 allows for drivers provided through the
VK_LUNARG_direct_driver_loading extension to support the entire Loader and Driver
Interface.

This commit makes many small fixes to the documentation. Main changes are adding
Version 7 of the Loader and Driver Interface, clarifies when the functions
associated with this version must be exported, when they can be optionally exported
and when they must be exposed through vk_icdGetInstanceProcAddr. This also
clarifies LDP_DRIVER_10 to note the exact behavior of drivers that is disallowed.
In the process of these documentation changes, the glossary was amended with
definitions for Exported Functions, Exposed Functions, and Querying Functions.

20 months agobuild: Remove VS2015 support
Juan Ramos [Mon, 16 Jan 2023 21:33:39 +0000 (14:33 -0700)]
build: Remove VS2015 support

20 months agoci: Test CMake minimum
Juan Ramos [Mon, 16 Jan 2023 19:43:24 +0000 (12:43 -0700)]
ci: Test CMake minimum

20 months agoAdd guard for GetPhysDevProcAddr typedef
Charles Giessen [Mon, 16 Jan 2023 05:32:01 +0000 (22:32 -0700)]
Add guard for GetPhysDevProcAddr typedef

vk_layer_dispatch_table.h may be included after vk_icd.h and may cause multiple
definitions. This commit adds a macro guard on whether the type is defined just
in case.

20 months agoTry to catch OOM errors when loading binaries
Charles Giessen [Thu, 8 Dec 2022 00:15:22 +0000 (17:15 -0700)]
Try to catch OOM errors when loading binaries

If there is an error loading a dynamic library, check to see if it is
the result of an OOM condition. Then return the appropriate OOM error
code up the callchain. This commit is the result of an OOM condition
when trying to load the validation layers, which resulted in the return
code VK_ERROR_LAYER_NOT_PRESENT. This is very misleading. If the
loader can catch then report more accurate information, then it should.

20 months agoAdded target condition to vulkan headers
B Marques [Mon, 26 Dec 2022 17:57:02 +0000 (14:57 -0300)]
Added target condition to vulkan headers

20 months agocmake: Fix usage of Vulkan::Registry
Juan Ramos [Tue, 10 Jan 2023 16:57:35 +0000 (09:57 -0700)]
cmake: Fix usage of Vulkan::Registry

Vulkan::Registry was deprecated by Vulkan-Headers

Use 'VULKAN_HEADERS_REGISTRY_DIRECTORY' instead.

closes #1106

20 months agoDocument behavior change in how bundles drivers are used
Charles Giessen [Tue, 6 Dec 2022 21:13:18 +0000 (14:13 -0700)]
Document behavior change in how bundles drivers are used

Document that a bundled driver on macOS will cause the loader to ignore drivers
in system installed locations.

20 months agoAdd macOS bundles support to test framework
Charles Giessen [Tue, 6 Dec 2022 20:45:15 +0000 (13:45 -0700)]
Add macOS bundles support to test framework

Allow basic tests to be written which exercise the bundle discovery and loading logic
in the loader. This allows testing whether drivers found in bundles disables searching
for drivers on the rest of the system.

This commit also inclues fixes for a half dozen non essential spelling mistakes.

20 months agoFix Bundled drivers on MacOS taking precedence
Charles Giessen [Mon, 5 Dec 2022 19:21:59 +0000 (12:21 -0700)]
Fix Bundled drivers on MacOS taking precedence

Previous commits broke the behavior of only using bundled drivers if found,
this commit fixes the condition to make sure the bundled drivers are used while
no other drivers are loaded.

20 months agoAdd Vulkan-Headers version to source
Charles Giessen [Tue, 3 Jan 2023 23:26:23 +0000 (16:26 -0700)]
Add Vulkan-Headers version to source

The version of the Vulkan-Headers used to generate the source code is what should be
used to set the version of the binary, rather than the version of the Vulkan-Headers
that is currently available. This commit checks that version into the repo so that
it is used, and adds the necessary python code to update it.

This behavior was previously in the repo but was broken by the update to use the
version parsing logic from the Vulkan-Headers.

20 months agoFix allocation callback test to start at 0
Charles Giessen [Tue, 3 Jan 2023 23:11:13 +0000 (16:11 -0700)]
Fix allocation callback test to start at 0

While working on the code, it is common to start the allocation tests at a fail_index
greater than zero, usually close to when the issue starts. This was accidentally
checked in, this commit fixes that mistake.

20 months agoRevert asm_offset CMake code to work with 3.10
Charles Giessen [Wed, 28 Dec 2022 01:40:34 +0000 (18:40 -0700)]
Revert asm_offset CMake code to work with 3.10

The revertion of gen_defines.asm generation during cross compilation changed the
form of add_custom_command used, which inadvertently relied on CMake 3.16 support.

From the CMake Docs:
DEPENDS:
...
A target-level dependency is added if any dependency is a byproduct of a target or
any of its build events in the same directory to ensure the byproducts will be
available before this target is built.

21 months agocmake: Use VulkanHeaders_VERSION
Juan Ramos [Tue, 27 Dec 2022 21:37:21 +0000 (14:37 -0700)]
cmake: Use VulkanHeaders_VERSION

Removes need for a bit of python code / parsing.
And it's consistent with VVL's approach.

21 months agobuild: Update to header 1.3.238
Mike Schuchardt [Mon, 19 Dec 2022 15:53:30 +0000 (07:53 -0800)]
build: Update to header 1.3.238

- Update known-good
- Generate source

21 months agoFix for Apple compiler bug
Richard S. Wright Jr [Mon, 12 Dec 2022 18:21:51 +0000 (13:21 -0500)]
Fix for Apple compiler bug

21 months agobuild: Update to header 1.3.237
Mike Schuchardt [Thu, 8 Dec 2022 17:10:30 +0000 (09:10 -0800)]
build: Update to header 1.3.237

- Update known-good
- Generate source

21 months agoDocument interaction of layer env-vars for linux
Charles Giessen [Fri, 2 Dec 2022 21:21:28 +0000 (14:21 -0700)]
Document interaction of layer env-vars for linux

> If `VK_LAYER_PATH` is present, then `VK_ADD_LAYER_PATH` will not be
used by the loader and any values will be ignored.

This was present for the Windows documentation but not for linux and
company.

21 months agoLayers: expand tests to check layer names loaded are expected
phish3y [Wed, 30 Nov 2022 22:28:19 +0000 (14:28 -0800)]
Layers: expand tests to check layer names loaded are expected

21 months agoLayers: update log message and documentation so it is clear that VK_LAYER_PATH does...
phish3y [Wed, 30 Nov 2022 04:24:44 +0000 (20:24 -0800)]
Layers: update log message and documentation so it is clear that VK_LAYER_PATH does not only search directories

21 months agoLayers: modify TestLayerDetails so either files or directories can be set on VK_LAYER...
phish3y [Wed, 30 Nov 2022 04:22:39 +0000 (20:22 -0800)]
Layers: modify TestLayerDetails so either files or directories can be set on VK_LAYER_PATH env var

21 months agoLayers: add tests to verify VK_LAYER_PATH works with full file paths
phish3y [Tue, 29 Nov 2022 03:54:55 +0000 (19:54 -0800)]
Layers: add tests to verify VK_LAYER_PATH works with full file paths

21 months agoLayers: add test to verify VK_LAYER_PATH supports explicit file paths instead of...
phish3y [Tue, 22 Nov 2022 22:55:16 +0000 (14:55 -0800)]
Layers: add test to verify VK_LAYER_PATH supports explicit file paths instead of just directories

21 months agoLayers: update documentation to make it clear the VK_LAYER_PATH supports both explici...
phish3y [Fri, 18 Nov 2022 23:08:46 +0000 (15:08 -0800)]
Layers: update documentation to make it clear the VK_LAYER_PATH supports both explicit directories and files

21 months agoloader: Fix parsing VK_INSTANCE_LAYERS
ziga-lunarg [Fri, 2 Dec 2022 15:08:11 +0000 (16:08 +0100)]
loader: Fix parsing VK_INSTANCE_LAYERS

21 months agobuild: Update to header 1.3.236
Mike Schuchardt [Thu, 1 Dec 2022 17:46:41 +0000 (09:46 -0800)]
build: Update to header 1.3.236

- Update known-good
- Generate source

21 months agoloader: Mark unknown_ext_chain symbols as hidden
John Bauman [Wed, 30 Nov 2022 00:02:50 +0000 (00:02 +0000)]
loader: Mark unknown_ext_chain symbols as hidden

These don't need to be exported from the shared library, as they're just
internal implementation details.

Closes #1079

21 months agoUse integrity_level >= HIGH for is_high_integrity
Charles Giessen [Mon, 21 Nov 2022 22:08:59 +0000 (15:08 -0700)]
Use integrity_level >= HIGH for is_high_integrity

Previously it used integrity_level > MEDIUM, which causes issues since
occasionally windows elevates certain regular user mode processes to
be MEDIUM + 0x100 or similar, causing the `is_high_integrity()` to
return true even though it isn't an admin level process.

21 months agocmake: fix pkgconfig file for absolute install paths
Jan Palus [Mon, 28 Nov 2022 12:29:21 +0000 (13:29 +0100)]
cmake: fix pkgconfig file for absolute install paths

Fixes #1076

22 months agoAdd more OOM handling paths and refactor OOM tests
Charles Giessen [Fri, 18 Nov 2022 00:20:17 +0000 (17:20 -0700)]
Add more OOM handling paths and refactor OOM tests

There were more cases where OOM wasn't being propagated correctly, or
even caught in the first place. This change makes all of those paths
report OOM to the application as is expected. One case was due to linux
sorting erroring out but then leaking memory, which wasn't caught because
the tests didn't create devices that supported PhysDevProps2.

Lastly, since the Allocation tests were taking much longer due to making
many more allocations, the MemoryTracker was rewritten to use
std::unordered_map to speed up insertion and lookup of allocations made.

22 months agobuild: Update to header 1.3.235
Mike Schuchardt [Thu, 17 Nov 2022 17:45:13 +0000 (09:45 -0800)]
build: Update to header 1.3.235

- Update known-good
- Generate source

22 months agoAdd complex json file to allocation tests
Charles Giessen [Wed, 16 Nov 2022 23:29:09 +0000 (16:29 -0700)]
Add complex json file to allocation tests

This helps exercise the cJSON OOM handling code. The json file is
just a copy of the validation layer manifest file.

22 months agoPropagate OOHM error from json parsing
Charles Giessen [Wed, 16 Nov 2022 23:04:59 +0000 (16:04 -0700)]
Propagate OOHM error from json parsing

There was a few places where an out of memory error could be generated
by parsing json but were not passed on upwards, causing CTS tests to fail.

22 months agoFix cases where OOM was handled wrong
Charles Giessen [Wed, 16 Nov 2022 04:16:55 +0000 (21:16 -0700)]
Fix cases where OOM was handled wrong

goto's were replaced by returns erroneously. This caused unfreed memory in
certain OOM scenarios, caught by CTS. The reason the loader tests didn't catch
this was because the fake drivers did not report any extensions, thus no memory
was allocated (which would later be leaked). This commit addressess this
deficiency in the tests as well, which included correctly incrementing the
MemoryTracker's allocation count during realloc.

22 months agoHandle invalid files & symlinks properly
Charles Giessen [Thu, 10 Nov 2022 22:00:04 +0000 (15:00 -0700)]
Handle invalid files & symlinks properly

If loader_get_json fails due to the file missing or the file being a
stale symlink, it returns VK_ERROR_INITIALIZATION_FAILED
which loader_parse_icd_manifest passed upwards. Since the caller of
loader_parse_icd_manifest wasn't expecting that error code, it didn't
skip the ICD, causing an infinite recusion in EnumInstExtProps due
to the call to dlsym("vkEnumerateInstanceExtensionProperties");

This also required changes to callers of loader_get_json which would
propagate VK_ERROR_INITIALIZATION failed during layer searching to
no longer cause vkCreateInstance to abort if any invalid files were
found.

Added tests for symlinks as the origin of this bug is due to 'stale'
symlinks after driver installers

22 months agoRecheck API version in terminator_CreateInstance
Charles Giessen [Thu, 3 Nov 2022 17:37:15 +0000 (11:37 -0600)]
Recheck API version in terminator_CreateInstance

Layers are liable of changing the API version during the call down
vkCreateInstance. Certain layers use the guarantees of 1.1 to allow
using VK_KHR_get_physical_device_properties2 functionality. This
commit checks and assignes a new API version if it was modified.

Add tests for when the application forgets to enable 1.1 and when
a layer enabled 1.1 on behalf of the application.

22 months agoRemove redundant code
Waffl3x [Fri, 11 Nov 2022 06:06:47 +0000 (01:06 -0500)]
Remove redundant code
loader_make_version recently was changed to zero out the patch version, explicitly doing it is no longer necessary.

22 months agocmake: CMake cleanup
Juan Ramos [Thu, 10 Nov 2022 23:46:39 +0000 (16:46 -0700)]
cmake: CMake cleanup

- Use idiom for CMAKE_MODULE_PATH
- find_package(PkgConfig) instead of include(FindPkgConfig)
- Remove CMake 2.X code workaround
- Use CMAKE_CURRENT_BINARY_DIR instead of CMAKE_BINARY_DIR
- CMakeParseArguments is now part of the language

22 months agoAdd macOS-latest CI action
Charles Giessen [Wed, 9 Nov 2022 23:24:05 +0000 (16:24 -0700)]
Add macOS-latest CI action

Re-enables using the macOS-latest github actions runner now that the loader
has been fixed for newer macOS versions.

22 months agobuild: Update to header 1.3.234
Mike Schuchardt [Thu, 10 Nov 2022 16:30:24 +0000 (08:30 -0800)]
build: Update to header 1.3.234

- Update known-good
- Generate source

22 months agoCall both EnumPhysDevs & EnumAdapterPhysDevs on drivers
Charles Giessen [Fri, 14 Oct 2022 23:51:02 +0000 (17:51 -0600)]
Call both EnumPhysDevs & EnumAdapterPhysDevs on drivers

This change is necessary to allow drivers that have both real physical
devices with a LUID and software based physical devices which lack a LUID.
It works by calling both vk_icdEnumerateAdapterPhysicalDevice and
vkEnumeratePhysicalDevice then deduplicating the returned physical devices
using the VkPhysicalDevice handles.

This commit also fixes an issue where tests would erroneously add a layer to the
driver registry.

22 months agoRemove log message of ICD extension lists
Charles Giessen [Sat, 15 Oct 2022 00:08:49 +0000 (18:08 -0600)]
Remove log message of ICD extension lists

22 months agoDont abort when WSI functions are NULL.
Charles Giessen [Sat, 5 Nov 2022 22:12:00 +0000 (16:12 -0600)]
Dont abort when WSI functions are NULL.

Commit d1db6c5bce9ed474ca124f0bffed9aa2468f3973 changed a few WSI functions
to abort when the driver's function was NULL, which is a change of existing
behavior. It should instead return VK_SUCCESS. At least now there is a
warning message.

This commit also adds tests for the above situation and for debug utils
& debug marker functions to make sure the pre-existing behavior is maintained.
This was tested by running the loader with a previous build through the new
tests and verified that they both passed. The tests run the cases of whether
the extensions were enabled, how the functions were queried (GIPA vs GDPA), and
whether the hardware supports the extensions.

22 months agocmake: Use new VulkanHeaders cmake support
Juan Ramos [Tue, 8 Nov 2022 21:04:18 +0000 (14:04 -0700)]
cmake: Use new VulkanHeaders cmake support

Removes need to have FindVulkanHeaders.cmake

22 months agoRemove USE_CCACHE build option
Charles Giessen [Mon, 7 Nov 2022 22:50:00 +0000 (15:50 -0700)]
Remove USE_CCACHE build option

The way to use ccache has changed since this documentation & build
option were added. Update the docs with the new way to enable ccache
and remove the build option.

22 months agoloader/cJSON: replace sprintf calls with snprintf
Mark Mentovai [Mon, 7 Nov 2022 15:11:03 +0000 (10:11 -0500)]
loader/cJSON: replace sprintf calls with snprintf

This makes it possible to build Vulkan-Loader without warnings using the
macOS 13 SDK. Calls to sprintf are replaced with snprintf, passing
appropriate buffer sizes.

It doesn’t appear that any of the changed uses of sprintf were actually
unsafe, so no behavior change is expected aside from SDK compatibility.

The macOS 13 SDK deprecates sprintf as it’s difficult to use safely. The
deprecation warning message is visible when building C++, but it is not
normally visible when building plain C code due to a quirk in how
sprintf is declared in the SDK. However, the deprecation message is
visible when building plain C under Address Sanitizer
(-fsanitize=address). This discrepancy was discovered at
https://crbug.com/1381706 and reported to Apple with a copy at
https://openradar.appspot.com/FB11761475.

The macOS 13 SDK is packaged in Xcode 14.1, released on 2022-11-01. This
also affects the iOS 16 SDK and other 2022-era Apple OS SDKs packaged in
Xcode 14.0, released on 2022-09-12.

Vulkan-Loader is visible to the Chromium build via PDFium, and this
change is needed to allow Chromium to move forward to the macOS 13 SDK.

22 months agoFix vulkan.pc Libs.private for static builds
Charles Giessen [Wed, 26 Oct 2022 18:24:24 +0000 (12:24 -0600)]
Fix vulkan.pc Libs.private for static builds

The Libs.private field shouldn't be present for shared library builds,
so now the field wont be present in that case. For static library builds
it should be present, but the fields should be deduplicated as well.

Additionally, this adds a github actions run for testing the static
build of the loader on MacOS. This requires making the test framework
capable of using a statically built loader, which mainly took making
VulkanFunctions capable of assigning the statically defined functions
instead of loading them with dlsym.

The static build option required changes to the unix_shim.cpp to not
cause infinite loops.

22 months agoFix tests for env-var filtering due to previous commit
Charles Giessen [Thu, 3 Nov 2022 22:18:20 +0000 (16:18 -0600)]
Fix tests for env-var filtering due to previous commit

The previous commit altered vkCreateInstance erroring out if the
application tries to enable an env-var disabled layer, so the tests
need to be revised for it. This commit also makes lot of modifications
to the tests in addition to that.

Also adds tests for when the override layer is present and when
implicit layer's enable-environment variables are present.

22 months agoFix env-var filtering in layer enumeration
Charles Giessen [Tue, 1 Nov 2022 20:45:32 +0000 (14:45 -0600)]
Fix env-var filtering in layer enumeration

Disabled layers would appear in the output of EnumerateInstanceLayers, which was
not intended. Move the removal of layers that are disabled by the env-var to after
the explicit layers are found.

22 months agoAdd the 1.3.224 Header version to the Env-Var documentation
Charles Giessen [Mon, 31 Oct 2022 23:27:29 +0000 (17:27 -0600)]
Add the 1.3.224 Header version to the Env-Var documentation

This way users know exactly which version of the loader contains the
new environment variables.

22 months agoRemove redundant layer searching in term_EnumDevExts
Charles Giessen [Tue, 4 Oct 2022 22:49:24 +0000 (16:49 -0600)]
Remove redundant layer searching in term_EnumDevExts

When terminator_EnumerateDeviceExtensionProperties is called, the app
now only checks that the type flag is implicit rather than building up a new
list of implicit layers, as building a list could cause many suprious log
messages and was unecessary. This commit also removes some redundant copies &
for loops in the function.

22 months agoUpdate and clarify filter documentation
Mark Young [Wed, 7 Sep 2022 19:34:46 +0000 (13:34 -0600)]
Update and clarify filter documentation

Based on review feedback from @hadess

22 months agoPut placeholder for loader version
Mark Young [Wed, 7 Sep 2022 18:57:35 +0000 (12:57 -0600)]
Put placeholder for loader version

TODO: Replace all 1.3.yyyy with appropriate header version after
approval.

22 months agoUpdate so filters apply results to vkEnumInstanceLayerProps
Mark Young [Wed, 7 Sep 2022 18:51:19 +0000 (12:51 -0600)]
Update so filters apply results to vkEnumInstanceLayerProps

Also remove duplication so that common code is used in several places.

22 months agoAdd loader enable/disable env vars
Mark Young [Tue, 26 Jul 2022 19:35:25 +0000 (13:35 -0600)]
Add loader enable/disable env vars

Add new environment variables that will allow the loader to filter
layers and drivers in specific ways.
This control should give developers ways to more quickly narrow down
issues with a layer or driver.
Also, it should give CI environments a mechanism to selectively enable
only drivers and layers that are needed for testing.

Add tests to support validating the new changes.

Add documentation that describes the new changes and also create new
loader debugging markdown document to help people debug issues with
drivers or layers using the new filter enums.

Rename the old get_environment.* source files to loader_environment.*.
Then put all the environment variable helpers from loader.c into the
new files.

22 months agoDo not include vk_sdk_platform.h
Jeremy Gebben [Fri, 4 Nov 2022 15:25:04 +0000 (09:25 -0600)]
Do not include vk_sdk_platform.h

Nothing in this file was being used.

22 months agobuild: Update to header 1.3.233
Mike Schuchardt [Thu, 3 Nov 2022 16:16:39 +0000 (09:16 -0700)]
build: Update to header 1.3.233

- Update known-good
- Generate source

22 months agoDont abort when driver doesn't support debug utils
Charles Giessen [Wed, 2 Nov 2022 19:53:39 +0000 (13:53 -0600)]
Dont abort when driver doesn't support debug utils

A recent change made it so that when either vkDebugMarkerSetObjectTagEXT,
vkDebugMarkerSetObjectNameEXT, vkSetDebugUtilsObjectNameEXT, or
vkSetDebugUtilsObjectTagEXT is called, if a driver doesn't support any
of those functions the loader would abort. This is incorrect because drivers
may not support the debug utils extension while the loader & layers might.
Now the loader only aborts if the Device handle is invalid, and simply
returns VK_SUCCESS if a driver doesn't support those functions.

22 months agoRemove override layer expiration
Charles Giessen [Tue, 1 Nov 2022 03:55:30 +0000 (21:55 -0600)]
Remove override layer expiration

This was an undocumented feature of the override manifest layer.
Since vkconfig is the primary user of the override layer, and vkconfig
makes no effort to include expiration support, this feature is not being
used. Thus, it is best to remove it entirely.

22 months agoRemove implicit fallthroughs; Add warning
Charles Giessen [Tue, 1 Nov 2022 04:37:31 +0000 (22:37 -0600)]
Remove implicit fallthroughs; Add warning

Previously, cJSON used implicit fallthrough in a switch statement. Naked
fallthroughs are a common bug source, and while this use case was well
behaved, it did require disabling the compiler warnings for it. Thus,
converting it to an explicit for loop prevents unnecessary compiler
warning flags being disabled.

22 months agoTest Wrap Layer didn't unwrap in vkGetInstanceProcAddr
Charles Giessen [Mon, 31 Oct 2022 22:38:45 +0000 (16:38 -0600)]
Test Wrap Layer didn't unwrap in vkGetInstanceProcAddr

Wrapping layer should be unwrapping the instance handle inside of GetProcAddr
functions.

22 months agoNull check vk_icdGetPhysicalDeviceProcAddr
Charles Giessen [Mon, 31 Oct 2022 22:37:14 +0000 (16:37 -0600)]
Null check vk_icdGetPhysicalDeviceProcAddr

Forgotten NULL check causes crashes if a driver forgets to export
vk_icdGetPhysicalDeviceProcAddr but does report a 4 or higher
ICD Interface Version.

22 months agoUse macos-11 in github actions to work around bugs
Charles Giessen [Mon, 31 Oct 2022 17:57:42 +0000 (11:57 -0600)]
Use macos-11 in github actions to work around bugs

There seems to be an incompatible change in macos-12 which breaks the loader's test
framework. While this is being resolved, move the github actions runners from the latest
to only using 11.

22 months agoRemove Device functions from ICD Dispatch table
Charles Giessen [Wed, 12 Oct 2022 19:51:17 +0000 (13:51 -0600)]
Remove Device functions from ICD Dispatch table

There are numerous terminators to device level functions that the loader must
insert in the call chain. However, the Device Dispatch Tables contain pointers
to these terminators rather than the driver's function. This was worked around
by storing the driver's functions in the ICD dispatch table and calling those.
This leads to rather confusing code where the application is querying for the
ICD dispatch table inside a device level function.

The solution is to create a bespoke dispatch table for device level functions
that require a terminator, and use that table when required.

23 months agobuild: Update to header 1.3.232
Mike Schuchardt [Thu, 27 Oct 2022 15:25:21 +0000 (08:25 -0700)]
build: Update to header 1.3.232

- Update known-good
- Generate source

23 months agoRevert "Remove vkCreateSwapchainKHR from ICD Dispatch table"
Charles Giessen [Wed, 26 Oct 2022 16:11:45 +0000 (10:11 -0600)]
Revert "Remove vkCreateSwapchainKHR from ICD Dispatch table"

This reverts commit d79e2731d45bf4c81f650f27205e208a023269aa.

23 months agoRevert "Document vk_icdGetInstanceProcAddr querying device functions"
Charles Giessen [Wed, 26 Oct 2022 16:11:45 +0000 (10:11 -0600)]
Revert "Document vk_icdGetInstanceProcAddr querying device functions"

This reverts commit 068e83f5f20e38c3ae1687e7f1aeb59bf6ce3e72.

23 months agoDocument vk_icdGetInstanceProcAddr querying device functions
Charles Giessen [Wed, 12 Oct 2022 19:57:22 +0000 (13:57 -0600)]
Document vk_icdGetInstanceProcAddr querying device functions

vk_icdGetInstanceProcAddr has similar semantics to vkGetInstanceProcAddr.
It was created to prevent dynamic linker issues. It stated that it should support
global & instance level function querying. But this differs from the Vulkan spec
which states that vkGetInstanceProcAddr should be able to query all functions.
This creates confusion about what takes precendence, the spec or the loader's docs.

This commit makes it explicit that it should have the same semanics what the spec
says.

23 months agoRemove vkCreateSwapchainKHR from ICD Dispatch table
Charles Giessen [Wed, 12 Oct 2022 19:51:17 +0000 (13:51 -0600)]
Remove vkCreateSwapchainKHR from ICD Dispatch table

vkCreateSwapchainKHR and vkGetDeviceGroupSurfacePresentModesKHR were added to
the icd dispatch table then loaded with GIPA. While this is possible, for best
performance and consistency, the loader should use the device's dispatch table
for these functions. This required changing the terminators for both functions
so that they checked that the dev pointer isn't null and its dispatch entry for
each function isn't null.

Additionally, various debug marker/util functions checked if an ICD supported
surfaces by checking the ICD's dispatch table for vkCreateSwapchainKHR. These
have been updated to use the device's dispatch table instead.

23 months agoAdd 32 bit github actions CI
Charles Giessen [Wed, 19 Oct 2022 21:08:10 +0000 (15:08 -0600)]
Add 32 bit github actions CI

23 months agoFix linux 32 bit unknown function error handling
Charles Giessen [Fri, 21 Oct 2022 18:01:45 +0000 (12:01 -0600)]
Fix linux 32 bit unknown function error handling

The issue was that passing a string to loader_log wouldn't work, likely due
to relocation issues. Workaround is to create a bespoke function that contained
the format string embedded in it.

Additionally, CMAKE_SYSTEM_PROCESSOR is incorrect in the case of x86 builds on
x64. Checking for sizeof(void*) == 8 allows distinguishing building for 32 bit
and 64 bit, and so the correct gen_defines.asm is created while cross compiling.

Also rename the error to note that its a function which isn't supported, not
an extension.

23 months agoRevert "Don't query vkCreateSwapchainKHR with GIPA"
Charles Giessen [Tue, 25 Oct 2022 20:41:30 +0000 (14:41 -0600)]
Revert "Don't query vkCreateSwapchainKHR with GIPA"

This reverts commit af67fccebe59e8d8e30e8c02b7b0069ce4242fc4.

23 months agoRevert "Document vk_icdGetInstanceProcAddr querying device functions"
Charles Giessen [Tue, 25 Oct 2022 20:41:30 +0000 (14:41 -0600)]
Revert "Document vk_icdGetInstanceProcAddr querying device functions"

This reverts commit e5680db8ae5640dde10b58b8ab45e4a6201ae3e9.

23 months agofix: format code
Danny Zhu [Tue, 25 Oct 2022 14:37:56 +0000 (22:37 +0800)]
fix: format code

23 months agofix: add null pointer checking
Danny Zhu [Tue, 25 Oct 2022 14:30:29 +0000 (22:30 +0800)]
fix: add null pointer checking

23 months agofix: add dev pointer checking
Danny Zhu [Sat, 22 Oct 2022 03:06:31 +0000 (11:06 +0800)]
fix: add dev pointer checking

23 months agofix: add dev pointer checking before using
danny.zhu [Fri, 21 Oct 2022 06:10:16 +0000 (14:10 +0800)]
fix: add dev pointer checking before using

23 months agoDocument vk_icdGetInstanceProcAddr querying device functions
Charles Giessen [Wed, 12 Oct 2022 19:57:22 +0000 (13:57 -0600)]
Document vk_icdGetInstanceProcAddr querying device functions

vk_icdGetInstanceProcAddr has similar semantics to vkGetInstanceProcAddr.
It was created to prevent dynamic linker issues. It stated that it should support
global & instance level function querying. But this differs from the Vulkan spec
which states that vkGetInstanceProcAddr should be able to query all functions.
This creates confusion about what takes precendence, the spec or the loader's docs.

This commit makes it explicit that it should have the same semanics what the spec
says.

23 months agoDon't query vkCreateSwapchainKHR with GIPA
Charles Giessen [Wed, 12 Oct 2022 19:51:17 +0000 (13:51 -0600)]
Don't query vkCreateSwapchainKHR with GIPA

Previously, the loader would initialize vkCreateSwapchainKHR and
vkGetDeviceGroupSurfacePresentModeskHR with vkGetInstanceProcAddr, instead
of what should have happened, which is to use vkGetDeviceProcAddr.

23 months agoUpdate BUILD.md
Charles Giessen [Fri, 21 Oct 2022 18:01:45 +0000 (12:01 -0600)]
Update BUILD.md

Remove references to VS 2015, as it is no longer supported.
Update the build instructions to include UPDATE_DEPS more prominently.
Move mentions of tests to the very end, and to use `ctest`.
Mention Cross Compilation caveats.

23 months agoRestore asm_offset printing code
Charles Giessen [Fri, 21 Oct 2022 17:34:00 +0000 (11:34 -0600)]
Restore asm_offset printing code

The cross compiling workaround for asm_offset requires python, but this meant
that all builds required python. This commit re-adds the removed asm_offset
logic and then only requires python during cross compilation.

23 months agoUse correct allocator in debug_utils.c
Charles Giessen [Fri, 21 Oct 2022 20:44:16 +0000 (14:44 -0600)]
Use correct allocator in debug_utils.c

loader_calloc_with_instance_fallback is used in places where a user can
supply their own allocator, but should default to the allocator used with
the instance otherwise. The issue was that loader_free was being used with
objects created with the instance allocator, but loader_free only takes the
user provided one, leading to leaks.

23 months agoOnly deduplicate driver manifests
Charles Giessen [Mon, 17 Oct 2022 21:26:47 +0000 (15:26 -0600)]
Only deduplicate driver manifests

Code which was originally meant to deduplicate drivers that moved from the old
registry HKEY_LOCAL_MACHINE/SOFTWARE/Khronos/Vulkan/Drivers to PnP locations
was incorrectly applied to layers as well. The issue is that multiple layers
can share the same json file name but not actually contain the same manifest.
Worse, the first layer found would be assumed to be correct, even the file had
been deleted from the file system.

23 months agoWrite gen_defines.asm using a python script
Charles Giessen [Fri, 9 Sep 2022 23:50:14 +0000 (17:50 -0600)]
Write gen_defines.asm using a python script

This allows cross compilation to enable unkonwn function handling as
gen_defines.asm will be generated without needing to run code meant for the
target platform. Previously, asm_offset.c wrote the gen_defines.asm file
by being run. Now, compilers emit their intermediate assembly output that the
parse_asm_values.py script knows how to find the relevant information from.

Additionally set the test framework `framework_config` build option to always
copy, instead of copy_if_different. This is needed since cmake wouldn't update
this file when changing from/to debug & release mode.

23 months agoci: Use MACOS_DEPLOYMENT_TARGET
Juan Ramos [Tue, 18 Oct 2022 17:38:15 +0000 (11:38 -0600)]
ci: Use MACOS_DEPLOYMENT_TARGET

- This approach matches what our SDK release process expect
  - Since setting CMAKE_MACOS_DEPLOYMENT_TARGET ignores env variable which SDK
release process uses, which could will cause issues in the future, if
the version is changed
- CMAKE_MACOS_DEPLOYMENT_TARGET doesn't propogate to dependencies via
  update_deps.py

23 months agobuild: Update to header 1.3.231
Mike Schuchardt [Thu, 13 Oct 2022 14:27:58 +0000 (07:27 -0700)]
build: Update to header 1.3.231

- Update known-good
- Generate source

23 months agoCorrectly handle layers not being loaded in vkCreateDevice
Charles Giessen [Wed, 12 Oct 2022 22:12:58 +0000 (16:12 -0600)]
Correctly handle layers not being loaded in vkCreateDevice

This reverts the previous commit which reverted bad behavior.

23 months agoRevert "Don't load layer libraries in vkCreateDevice"
Charles Giessen [Wed, 12 Oct 2022 21:45:58 +0000 (15:45 -0600)]
Revert "Don't load layer libraries in vkCreateDevice"

This reverts commit cd9b4afed4e556ac88a75371eb7283fed94ca3c6.

23 months agoGuard loader.instances access with mutex.
Charles Giessen [Fri, 20 May 2022 18:18:41 +0000 (12:18 -0600)]
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.

23 months agoFix issue with MSVC 15 failing to compile test code
Charles Giessen [Tue, 11 Oct 2022 18:07:08 +0000 (12:07 -0600)]
Fix issue with MSVC 15 failing to compile test code

Was a basic case of googletest not allowing implicit conversion between
types.

23 months agoDon't abort when drivers don't support WSI calls
Charles Giessen [Mon, 10 Oct 2022 18:24:58 +0000 (12:24 -0600)]
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.

23 months agoEnable cross compile test discovery
Charles Giessen [Thu, 6 Oct 2022 21:18:42 +0000 (15:18 -0600)]
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().