platform/upstream/Vulkan-Loader.git
21 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.

21 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.

21 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.

21 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.

22 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

22 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

22 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

22 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.

22 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

22 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

22 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

22 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

22 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

22 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

22 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

22 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

22 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

22 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.

22 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.

23 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

23 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.

23 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.

23 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.

23 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

23 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.

23 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.

23 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

23 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.

23 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

23 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.

23 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

23 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.

23 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

23 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.

23 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.

23 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.

23 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.

23 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.

23 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.

23 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.

23 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

23 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.

23 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.

23 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.

23 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.

23 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

23 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.

23 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.

23 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.

23 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.

23 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.

23 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.

23 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.

2 years 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.

2 years 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.

2 years 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

2 years 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

2 years 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.

2 years 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.

2 years 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.

2 years 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.

2 years 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.

2 years 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().

2 years agoDon't load layer libraries in vkCreateDevice
Charles Giessen [Tue, 4 Oct 2022 17:24:39 +0000 (11:24 -0600)]
Don't load layer libraries in vkCreateDevice

These libraries will always be loaded in vkCreateInstance, so we don't
need to load them again in vkCreateDevice. This has the added benefit
of not printing 'unloading library X' twice in the log.

2 years agobuild: Fix CMake warnings
Juan Ramos [Mon, 3 Oct 2022 23:12:50 +0000 (17:12 -0600)]
build: Fix CMake warnings

- CMAKE_GENERATOR_PLATFORM is only valid on Visual Studio generators
- Remove FindWayland since it's no longer needed. See this discussion for details: https://github.com/KhronosGroup/Vulkan-Docs/pull/1905

2 years agobuild: Update to header 1.3.230
Mike Schuchardt [Thu, 29 Sep 2022 17:26:54 +0000 (10:26 -0700)]
build: Update to header 1.3.230

- Update known-good
- Generate source

2 years agoloader: fix log message
PaperChalice [Sat, 24 Sep 2022 06:52:56 +0000 (14:52 +0800)]
loader: fix log message

2 years agoci: Do apt update before install to fix 404 errors
Mike Schuchardt [Thu, 22 Sep 2022 16:48:57 +0000 (09:48 -0700)]
ci: Do apt update before install to fix 404 errors

2 years agobuild: Update to header 1.3.229
Mike Schuchardt [Thu, 22 Sep 2022 16:16:10 +0000 (09:16 -0700)]
build: Update to header 1.3.229

- Update known-good
- Generate source

2 years agobuild: Update to header 1.3.228
Mike Schuchardt [Thu, 15 Sep 2022 15:47:25 +0000 (08:47 -0700)]
build: Update to header 1.3.228

- Update known-good
- Generate source

2 years agoMake old layer with new app API version warning clearer
Charles Giessen [Mon, 12 Sep 2022 17:53:34 +0000 (11:53 -0600)]
Make old layer with new app API version warning clearer

The previous message incorrectly labled all layes as Explicit layers
and didn't indicate what the 'warning' was about very well.

2 years agoAllow implicit layers for all API versions
Charles Giessen [Thu, 8 Sep 2022 17:50:29 +0000 (11:50 -0600)]
Allow implicit layers for all API versions

This change makes the loader conform to the latests specification
update, 1.3.227, which removes the requirement that implicit layers
API version is at least as high as the application provided API
version.

This change reduces friction for layer developers and API users.

2 years agobuild: Update to header 1.3.227
Mike Schuchardt [Thu, 8 Sep 2022 16:07:10 +0000 (09:07 -0700)]
build: Update to header 1.3.227

- Update known-good
- Generate source

2 years agobuild: Also include XCB header path
Brad Smith [Fri, 2 Sep 2022 23:00:53 +0000 (19:00 -0400)]
build: Also include XCB header path

2 years agofix typo in CMakeLists
Steve Lhomme [Tue, 30 Aug 2022 06:08:25 +0000 (08:08 +0200)]
fix typo in CMakeLists

2 years agoFix the pkg-config import library name with mingw-w64
Steve Lhomme [Tue, 30 Aug 2022 06:17:51 +0000 (08:17 +0200)]
Fix the pkg-config import library name with mingw-w64

The common name for import libraries in mingw-w64 ends with .dll.a so we need
to use it so the pkg-config file ends up use -lvulkan-1.dll.

2 years agoGenerate the same DLL name with mingw-w64 as with MSVC
Steve Lhomme [Tue, 30 Aug 2022 05:42:27 +0000 (07:42 +0200)]
Generate the same DLL name with mingw-w64 as with MSVC

It should be the same name so mingw-w64 toolchains can generate/use the same
DLLs as the MSVC toolchains. The DLL and import libraries are compatible both
ways.

Fixes #997

2 years agoloader: Only use alloca.h if it exists otherwise fallback to stdlib.h
Brad Smith [Fri, 2 Sep 2022 22:55:12 +0000 (18:55 -0400)]
loader: Only use alloca.h if it exists otherwise fallback to stdlib.h

Check for the existence of the alloca.h header and only use it it exists,
otherwise fallback to stdlib.h. Some OS's like macOS and QNX have both
headers and can use either (stdlib.h includes alloca.h), some OS's like
OpenBSD / FreeBSD / NetBSD do not have the alloca.h header and require
the stdlib.h header.

2 years agoloader: Fix CMake detection of OpenBSD/FreeBSD / amd64
Brad Smith [Thu, 1 Sep 2022 07:05:12 +0000 (03:05 -0400)]
loader: Fix CMake detection of OpenBSD/FreeBSD / amd64

2 years agoRemove unneeded exports in test_wrap_layers
Charles Giessen [Thu, 25 Aug 2022 16:19:06 +0000 (10:19 -0600)]
Remove unneeded exports in test_wrap_layers

Some functions in the wrapping test layer exported functions that are not necessary.
This caused some warnings in builds. Removing them fixes the warnings.