Commit 99c274ba by Tobin Ehlis Committed by Commit Bot

Vulkan:Roll volk

All ANGLE volk changes have been upstreamed to volk repo so rolling volk to sync with latest. Going forward we can just roll when/if we need newer versions of Vulkan Header supported by volk. Bug: angleproject:4225 Change-Id: I6132a94010bbc5f3356ebb0b7e2b2b661ecc68b2 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/1991722Reviewed-by: 's avatarCourtney Goeltzenleuchter <courtneygo@google.com> Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Commit-Queue: Tobin Ehlis <tobine@google.com>
parent b84cdffe
......@@ -16,4 +16,4 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
\ No newline at end of file
SOFTWARE.
......@@ -15,7 +15,4 @@ from the driver which can increase performance by skipping loader
dispatch overhead.
Local Modifications:
Added static variables to track VkInstance and VkDevice that were last loaded by volk.
This data is then used by ANGLE renderer to make sure that the current device/instance
match up with previously loaded values. When they don't match, we re-load vk* function
pointers.
NONE
......@@ -18,13 +18,17 @@ volk is written in C89 and supports Windows, Linux, Android and macOS (via Molte
## Building
volk comes with one header and source file; to build it, just add the source file, `volk.c`, to your build system.
There are multiple ways to use volk in your project:
To use volk, you have to include `volk.h` instead of `vulkan/vulkan.h`; this is necessary to use function definitions from volk.
If some files in your application include `vulkan/vulkan.h` and don't include `volk.h`, this can result in symbol conflicts; consider defining `VK_NO_PROTOTYPES` when compiling code that uses Vulkan to make sure this doesn't happen.
1. You can just add `volk.c` to your build system. Note that the usual preprocessor defines that enable Vulkan's platform-specific functions (VK_USE_PLATFORM_WIN32_KHR, VK_USE_PLATFORM_XLIB_KHR, VK_USE_PLATFORM_MACOS_MVK, etc) must be passed as desired to the compiler when building `volk.c`.
2. You can use volk in header-only fashion. Include `volk.h` whereever you want to use Vulkan functions. In exactly one source file, define `VOLK_IMPLEMENTATION` before including `volk.h`. Do not build `volk.c` at all in this case. This method of integrating volk makes it possible to set the platform defines mentioned above with arbitrary (preprocessor) logic in your code.
3. You can use provided CMake files, with the usage detailed below.
## Basic usage
To use volk, you have to include `volk.h` instead of `vulkan/vulkan.h`; this is necessary to use function definitions from volk.
If some files in your application include `vulkan/vulkan.h` and don't include `volk.h`, this can result in symbol conflicts; consider defining `VK_NO_PROTOTYPES` when compiling code that uses Vulkan to make sure this doesn't happen.
To initialize volk, call this function first:
```c++
......@@ -65,26 +69,36 @@ The second option requires you to change the application code to store one `Volk
Device entrypoints are loaded using `vkGetDeviceProcAddr`; when no layers are present, this commonly results in most function pointers pointing directly at the driver functions, minimizing the call overhead. When layers are loaded, the entrypoints will point at the implementations in the first applicable layer, so this is compatible with any layers including validation layers.
## License
## CMake support
This library is available to anybody free of charge, under the terms of MIT License:
If your project uses CMake, volk provides you with targets corresponding to the different use cases:
Copyright (c) 2018-2019 Arseny Kapoulkine
1. Target `volk` is a static library. Any platform defines can be passed to the compiler by setting `VOLK_STATIC_DEFINES`. Example:
```cmake
if (WIN32)
set(VOLK_STATIC_DEFINES VK_USE_PLATFORM_WIN32_KHR)
elseif()
...
endif()
add_subdirectory(volk)
target_link_library(my_application PRIVATE volk)
```
2. Target `volk_headers` is an interface target for the header-only style. Example:
```cmake
add_subdirectory(volk)
target_link_library(my_application PRIVATE volk_headers)
```
and in the code:
```c
/* ...any logic setting VK_USE_PLATFORM_WIN32_KHR and friends... */
#define VOLK_IMPLEMENTATION
#include "volk.h"
```
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above example use `add_subdirectory` to include volk into CMake's build tree. This is a good choice if you copy the volk files into your project tree or as a git submodule.
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
Volk also supports installation and config-file packages. Installation is disabled by default (so as to not pollute user projects with install rules), and can be disabled by passing `-DVOLK_INSTALL=ON` to CMake. Once installed, do something like `find_package(volk CONFIG REQUIRED)` in your project's CMakeLists.txt. The imported volk targets are called `volk::volk` and `volk::volk_headers`.
## License
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
This library is available to anybody free of charge, under the terms of MIT License (see LICENSE.md).
......@@ -78,27 +78,34 @@ uint32_t volkGetInstanceVersion(void);
/**
* Load global function pointers using application-created VkInstance; call this function after creating the Vulkan instance.
* If global function pointers are already currently loaded for this instance, no action is taken.
*/
void volkLoadInstance(VkInstance instance);
/**
* Load global function pointers using application-created VkDevice; call this function after creating the Vulkan device.
* If global function pointers are already currently loaded for this device, no action is taken.
*
* Note: this is not suitable for applications that want to use multiple VkDevice objects concurrently.
*/
void volkLoadDevice(VkDevice device);
/**
* Return last VkInstance for which global function pointers have been loaded via volkLoadInstance(),
* or VK_NULL_HANDLE if volkLoadInstance() has not been called.
*/
VkInstance volkGetLoadedInstance();
/**
* Return last VkDevice for which global function pointers have been loaded via volkLoadDevice(),
* or VK_NULL_HANDLE if volkLoadDevice() has not been called.
*/
VkDevice volkGetLoadedDevice();
/**
* Load function pointers using application-created VkDevice into a table.
* Application should use function pointers from that table instead of using global function pointers.
*/
void volkLoadDeviceTable(struct VolkDeviceTable* table, VkDevice device);
VkInstance volkGetLoadedInstance();
VkDevice volkGetLoadedDevice();
/**
* Device-specific function pointer table
*/
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment