deps: Update volk to commit ec2d513

This commit is contained in:
scribam 2020-01-16 22:29:42 +01:00
parent c731cbcaf8
commit 484a7cdd10
18 changed files with 1003 additions and 3 deletions

2
core/deps/volk/.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
build/
CMakeLists.txt.user

View File

@ -0,0 +1,15 @@
language: cpp
os:
- linux
- osx
- windows
script:
#
# Put the Vulkan headers outside the source directory since CMake
# will not let us export an include path prefixed in the build dir.
#
- pushd ..
- git clone --depth 1 https://github.com/KhronosGroup/Vulkan-Headers
- export VULKAN_SDK=$PWD/Vulkan-Headers
- popd
- test/run_tests.sh

View File

@ -0,0 +1,116 @@
cmake_minimum_required(VERSION 3.0)
cmake_policy(PUSH)
cmake_policy(SET CMP0048 NEW) # project(... VERSION ...) support
project(volk VERSION
# VOLK_GENERATE_VERSION
131
# VOLK_GENERATE_VERSION
LANGUAGES C
)
# CMake 3.12 changes the default behaviour of option() to leave local variables
# unchanged if they exist (which we want), but we must work with older CMake versions.
if(NOT DEFINED VOLK_STATIC_DEFINES)
option(VOLK_STATIC_DEFINES "Additional defines for building the volk static library, e.g. Vulkan platform defines" "")
endif()
if(NOT DEFINED VOLK_PULL_IN_VULKAN)
option(VOLK_PULL_IN_VULKAN "Vulkan as a transitive dependency" ON)
endif()
if(NOT DEFINED VOLK_INSTALL)
option(VOLK_INSTALL "Create installation targets" OFF)
endif()
# -----------------------------------------------------
# Static library
add_library(volk STATIC volk.h volk.c)
target_include_directories(volk PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}>
$<INSTALL_INTERFACE:include>
)
if(VOLK_STATIC_DEFINES)
target_compile_definitions(volk PUBLIC ${VOLK_STATIC_DEFINES})
endif()
if (NOT WIN32)
target_link_libraries(volk PUBLIC dl)
endif()
# -----------------------------------------------------
# Interface library
add_library(volk_headers INTERFACE)
target_include_directories(volk_headers INTERFACE
$<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}>
$<INSTALL_INTERFACE:include>
)
if (NOT WIN32)
target_link_libraries(volk_headers INTERFACE dl)
endif()
# -----------------------------------------------------
# Vulkan transitive dependency
if(VOLK_PULL_IN_VULKAN)
# If CMake has the FindVulkan module and it works, use it.
# Otherwise try the environment variable.
find_package(Vulkan QUIET)
if(TARGET Vulkan::Vulkan)
message(" Vulkan as target")
target_link_libraries(volk PUBLIC Vulkan::Vulkan)
target_link_libraries(volk_headers INTERFACE Vulkan::Vulkan)
elseif(DEFINED ENV{VULKAN_SDK})
message(" Vulkan as path")
target_include_directories(volk PUBLIC "$ENV{VULKAN_SDK}/include")
target_include_directories(volk_headers INTERFACE "$ENV{VULKAN_SDK}/include")
endif()
endif()
# -----------------------------------------------------
# Installation
if(VOLK_INSTALL)
include(GNUInstallDirs)
set(INSTALL_CONFIGDIR ${CMAKE_INSTALL_LIBDIR}/cmake/volk)
# Install files
install(FILES volk.h volk.c DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
# Install library target and add it and any dependencies to export set.
install(TARGETS volk volk_headers
EXPORT volk-targets
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
)
# Actually write exported config w/ imported targets
install(EXPORT volk-targets
FILE volkTargets.cmake
NAMESPACE volk::
DESTINATION ${INSTALL_CONFIGDIR}
)
# Create a ConfigVersion.cmake file:
include(CMakePackageConfigHelpers)
write_basic_package_version_file(
${CMAKE_CURRENT_BINARY_DIR}/volkConfigVersion.cmake
COMPATIBILITY AnyNewerVersion
)
# Configure config file
configure_package_config_file(${CMAKE_CURRENT_LIST_DIR}/cmake/volkConfig.cmake.in
${CMAKE_CURRENT_BINARY_DIR}/volkConfig.cmake
INSTALL_DESTINATION ${INSTALL_CONFIGDIR}
)
# Install the fully generated config and configVersion files
install(FILES
${CMAKE_CURRENT_BINARY_DIR}/volkConfig.cmake
${CMAKE_CURRENT_BINARY_DIR}/volkConfigVersion.cmake
DESTINATION ${INSTALL_CONFIGDIR}
)
endif()
cmake_policy(POP)

19
core/deps/volk/LICENSE.md Normal file
View File

@ -0,0 +1,19 @@
Copyright (c) 2018-2019 Arseny Kapoulkine
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 copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
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.

96
core/deps/volk/README.md Normal file
View File

@ -0,0 +1,96 @@
# 🐺 volk [![Build Status](https://travis-ci.org/zeux/volk.svg?branch=master)](https://travis-ci.org/zeux/volk)
## Purpose
volk is a meta-loader for Vulkan. It allows you to dynamically load entrypoints required to use Vulkan
without linking to vulkan-1.dll or statically linking Vulkan loader. Additionally, volk simplifies the use of Vulkan extensions by automatically loading all associated entrypoints. Finally, volk enables loading
Vulkan entrypoints directly from the driver which can increase performance by skipping loader dispatch overhead.
volk is written in C89 and supports Windows, Linux, Android and macOS (via MoltenVK).
## Building
There are multiple ways to use volk in your project:
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++
VkResult volkInitialize();
```
This will attempt to load Vulkan loader from the system; if this function returns `VK_SUCCESS` you can proceed to create Vulkan instance.
If this function fails, this means Vulkan loader isn't installed on your system.
After creating the Vulkan instance using Vulkan API, call this function:
```c++
void volkLoadInstance(VkInstance instance);
```
This function will load all required Vulkan entrypoints, including all extensions; you can use Vulkan from here on as usual.
## Optimizing device calls
If you use volk as described in the previous section, all device-related function calls, such as `vkCmdDraw`, will go through Vulkan loader dispatch code.
This allows you to transparently support multiple VkDevice objects in the same application, but comes at a price of dispatch overhead which can be as high as 7% depending on the driver and application.
To avoid this, you have one of two options:
1. For applications that use just one VkDevice object, load device-related Vulkan entrypoints directly from the driver with this function:
```c++
void volkLoadDevice(VkDevice device);
```
2. For applications that use multiple VkDevice objects, load device-related Vulkan entrypoints into a table:
```c++
void volkLoadDeviceTable(struct VolkDeviceTable* table, VkDevice device);
```
The second option requires you to change the application code to store one `VolkDeviceTable` per `VkDevice` and call functions from this table instead.
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.
## CMake support
If your project uses CMake, volk provides you with targets corresponding to the different use cases:
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"
```
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.
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
This library is available to anybody free of charge, under the terms of MIT License (see LICENSE.md).

View File

@ -0,0 +1,21 @@
get_filename_component(volk_CMAKE_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH)
if(NOT TARGET volk::volk)
include("${volk_CMAKE_DIR}/volkTargets.cmake")
endif()
# Mirror the default behaviour of the respective option.
if(NOT DEFINED VOLK_PULL_IN_VULKAN)
set(VOLK_PULL_IN_VULKAN ON)
endif()
if(VOLK_PULL_IN_VULKAN)
find_package(Vulkan QUIET)
if(TARGET Vulkan::Vulkan)
add_dependencies(volk::volk Vulkan::Vulkan)
add_dependencies(volk::volk_headers Vulkan::Vulkan)
elseif(DEFINED ENV{VULKAN_SDK})
target_include_directories(volk::volk INTERFACE "$ENV{VULKAN_SDK}/include")
target_include_directories(volk::volk_headers INTERFACE "$ENV{VULKAN_SDK}/include")
endif()
endif()

169
core/deps/volk/generate.py Executable file
View File

@ -0,0 +1,169 @@
#!/usr/bin/python3
# This file is part of volk library; see volk.h for version/license details
from collections import OrderedDict
import sys
import urllib
import xml.etree.ElementTree as etree
import urllib.request
def parse_xml(path):
file = urllib.request.urlopen(path) if path.startswith("http") else open(path, 'r')
with file:
tree = etree.parse(file)
return tree
def patch_file(path, blocks):
result = []
block = None
with open(path, 'r') as file:
for line in file.readlines():
if block:
if line == block:
result.append(line)
block = None
else:
result.append(line)
# C comment marker
if line.strip().startswith('/* VOLK_GENERATE_'):
block = line
result.append(blocks[line.strip()[17:-3]])
# Shell/CMake comment marker
elif line.strip().startswith('# VOLK_GENERATE_'):
block = line
result.append(blocks[line.strip()[16:]])
with open(path, 'w') as file:
for line in result:
file.write(line)
def is_descendant_type(types, name, base):
if name == base:
return True
type = types.get(name)
if not type:
return False
parents = type.get('parent')
if not parents:
return False
return any([is_descendant_type(types, parent, base) for parent in parents.split(',')])
def defined(key):
return 'defined(' + key + ')'
if __name__ == "__main__":
specpath = "https://raw.githubusercontent.com/KhronosGroup/Vulkan-Docs/master/xml/vk.xml"
if len(sys.argv) > 1:
specpath = sys.argv[1]
spec = parse_xml(specpath)
block_keys = ('DEVICE_TABLE', 'PROTOTYPES_H', 'PROTOTYPES_C', 'LOAD_LOADER', 'LOAD_INSTANCE', 'LOAD_DEVICE', 'LOAD_DEVICE_TABLE')
blocks = {}
version = spec.find('types/type[name="VK_HEADER_VERSION"]')
blocks['VERSION'] = version.find('name').tail.strip() + '\n'
blocks['VERSION_DEFINE'] = '#define VOLK_HEADER_VERSION ' + version.find('name').tail.strip() + '\n'
command_groups = OrderedDict()
instance_commands = set()
for feature in spec.findall('feature'):
key = defined(feature.get('name'))
cmdrefs = feature.findall('require/command')
command_groups[key] = [cmdref.get('name') for cmdref in cmdrefs]
for ext in sorted(spec.findall('extensions/extension'), key=lambda ext: ext.get('name')):
supported = ext.get('supported')
if supported == 'disabled':
continue
name = ext.get('name')
type = ext.get('type')
for req in ext.findall('require'):
key = defined(name)
if req.get('feature'):
key += ' && ' + defined(req.get('feature'))
if req.get('extension'):
key += ' && ' + defined(req.get('extension'))
cmdrefs = req.findall('command')
command_groups.setdefault(key, []).extend([cmdref.get('name') for cmdref in cmdrefs])
if type == 'instance':
for cmdref in cmdrefs:
instance_commands.add(cmdref.get('name'))
commands_to_groups = OrderedDict()
for (group, cmdnames) in command_groups.items():
for name in cmdnames:
commands_to_groups.setdefault(name, []).append(group)
for (group, cmdnames) in command_groups.items():
command_groups[group] = [name for name in cmdnames if len(commands_to_groups[name]) == 1]
for (name, groups) in commands_to_groups.items():
if len(groups) == 1:
continue
key = ' || '.join(['(' + g + ')' for g in groups])
command_groups.setdefault(key, []).append(name)
commands = {}
for cmd in spec.findall('commands/command'):
if not cmd.get('alias'):
name = cmd.findtext('proto/name')
commands[name] = cmd
for cmd in spec.findall('commands/command'):
if cmd.get('alias'):
name = cmd.get('name')
commands[name] = commands[cmd.get('alias')]
types = {}
for type in spec.findall('types/type'):
name = type.findtext('name')
if name:
types[name] = type
for key in block_keys:
blocks[key] = ''
for (group, cmdnames) in command_groups.items():
ifdef = '#if ' + group + '\n'
for key in block_keys:
blocks[key] += ifdef
for name in sorted(cmdnames):
cmd = commands[name]
type = cmd.findtext('param[1]/type')
if name == 'vkGetInstanceProcAddr':
type = ''
if name == 'vkGetDeviceProcAddr':
type = 'VkInstance'
if is_descendant_type(types, type, 'VkDevice') and name not in instance_commands:
blocks['LOAD_DEVICE'] += '\t' + name + ' = (PFN_' + name + ')load(context, "' + name + '");\n'
blocks['DEVICE_TABLE'] += '\tPFN_' + name + ' ' + name + ';\n'
blocks['LOAD_DEVICE_TABLE'] += '\ttable->' + name + ' = (PFN_' + name + ')load(context, "' + name + '");\n'
elif is_descendant_type(types, type, 'VkInstance'):
blocks['LOAD_INSTANCE'] += '\t' + name + ' = (PFN_' + name + ')load(context, "' + name + '");\n'
elif type != '':
blocks['LOAD_LOADER'] += '\t' + name + ' = (PFN_' + name + ')load(context, "' + name + '");\n'
blocks['PROTOTYPES_H'] += 'extern PFN_' + name + ' ' + name + ';\n'
blocks['PROTOTYPES_C'] += 'PFN_' + name + ' ' + name + ';\n'
for key in block_keys:
if blocks[key].endswith(ifdef):
blocks[key] = blocks[key][:-len(ifdef)]
else:
blocks[key] += '#endif /* ' + group + ' */\n'
patch_file('volk.h', blocks)
patch_file('volk.c', blocks)
patch_file('CMakeLists.txt', blocks)

View File

@ -0,0 +1,9 @@
cmake_minimum_required(VERSION 3.0)
project(volk_test LANGUAGES C)
# Include volk from a CMake package config.
# CMAKE_PREFIX_PATH or volk_DIR must be set properly.
find_package(volk CONFIG REQUIRED)
add_executable(volk_test main.c)
target_link_libraries(volk_test PRIVATE volk::volk_headers)

View File

@ -0,0 +1,54 @@
/* Set platform defines at build time for volk to pick up. */
#if defined(_WIN32)
# define VK_USE_PLATFORM_WIN32_KHR
#elif defined(__linux__) || defined(__unix__)
# define VK_USE_PLATFORM_XLIB_KHR
#elif defined(__APPLE__)
# define VK_USE_PLATFORM_MACOS_MVK
#else
# error "Platform not supported by this example."
#endif
#define VOLK_IMPLEMENTATION
#include "volk.h"
#include "stdio.h"
#include "stdlib.h"
int main()
{
VkResult r;
uint32_t version;
void* ptr;
/* This won't compile if the appropriate Vulkan platform define isn't set. */
ptr =
#if defined(_WIN32)
&vkCreateWin32SurfaceKHR;
#elif defined(__linux__) || defined(__unix__)
&vkCreateXlibSurfaceKHR;
#elif defined(__APPLE__)
&vkCreateMacOSSurfaceMVK;
#else
/* Platform not recogized for testing. */
NULL;
#endif
/* Try to initialize volk. This might not work on CI builds, but the
* above should have compiled at least. */
r = volkInitialize();
if (r != VK_SUCCESS) {
printf("volkInitialize failed!\n");
return -1;
}
version = volkGetInstanceVersion();
printf("Vulkan version %d.%d.%d initialized.\n",
VK_VERSION_MAJOR(version),
VK_VERSION_MINOR(version),
VK_VERSION_PATCH(version));
return 0;
}

View File

@ -0,0 +1,39 @@
# Compiles the volk sources as part of a user project.
# Volk comes with a volk.c for this purpose.
# Note that for volk to properly handle platform defines,
# those have to be set at build time.
# Also note that this way the Vulkan headers must
# handled by the user project as well as linking to dl on
# non-Windows platforms.
# For these reasons it's recommended to use one of
# the other ways to include volk (see the other examples).
cmake_minimum_required(VERSION 3.0)
project(volk_test LANGUAGES C)
add_executable(volk_test main.c ../../volk.c)
# Set include path for volk.h
target_include_directories(volk_test PRIVATE ../..)
# Set suitable platform defines
if(CMAKE_SYSTEM_NAME STREQUAL Windows)
target_compile_definitions(volk_test PRIVATE VK_USE_PLATFORM_WIN32_KHR)
elseif(CMAKE_SYSTEM_NAME STREQUAL Linux)
target_compile_definitions(volk_test PRIVATE VK_USE_PLATFORM_XLIB_KHR)
elseif(CMAKE_SYSTEM_NAME STREQUAL Darwin)
target_compile_definitions(volk_test PRIVATE VK_USE_PLATFORM_MACOS_MVK)
endif()
# Link requires libraries
if(NOT WIN32)
target_link_libraries(volk_test PRIVATE dl)
endif()
# Get Vulkan dependency
find_package(Vulkan QUIET)
if(TARGET Vulkan::Vulkan)
target_link_libraries(volk_test PRIVATE Vulkan::Vulkan)
elseif(DEFINED ENV{VULKAN_SDK})
target_include_directories(volk_test PRIVATE "$ENV{VULKAN_SDK}/include")
endif()

View File

@ -0,0 +1,41 @@
#include "volk.h"
#include "stdio.h"
#include "stdlib.h"
int main()
{
VkResult r;
uint32_t version;
void* ptr;
/* This won't compile if the appropriate Vulkan platform define isn't set. */
ptr =
#if defined(_WIN32)
&vkCreateWin32SurfaceKHR;
#elif defined(__linux__) || defined(__unix__)
&vkCreateXlibSurfaceKHR;
#elif defined(__APPLE__)
&vkCreateMacOSSurfaceMVK;
#else
/* Platform not recogized for testing. */
NULL;
#endif
/* Try to initialize volk. This might not work on CI builds, but the
* above should have compiled at least. */
r = volkInitialize();
if (r != VK_SUCCESS) {
printf("volkInitialize failed!\n");
return -1;
}
version = volkGetInstanceVersion();
printf("Vulkan version %d.%d.%d initialized.\n",
VK_VERSION_MAJOR(version),
VK_VERSION_MINOR(version),
VK_VERSION_PATCH(version));
return 0;
}

View File

@ -0,0 +1,11 @@
# Include the volk target through add_subdirectory.
cmake_minimum_required(VERSION 3.0)
project(volk_test LANGUAGES C)
# Include volk as part of the build tree to make the target known.
# The two-argument version of add_subdirectory allows adding non-subdirs.
add_subdirectory(../.. volk)
add_executable(volk_test main.c)
target_link_libraries(volk_test PRIVATE volk_headers)

View File

@ -0,0 +1,53 @@
/* Set platform defines at build time for volk to pick up. */
#if defined(_WIN32)
# define VK_USE_PLATFORM_WIN32_KHR
#elif defined(__linux__) || defined(__unix__)
# define VK_USE_PLATFORM_XLIB_KHR
#elif defined(__APPLE__)
# define VK_USE_PLATFORM_MACOS_MVK
#else
# error "Platform not supported by this example."
#endif
#define VOLK_IMPLEMENTATION
#include "volk.h"
#include "stdio.h"
#include "stdlib.h"
int main()
{
VkResult r;
uint32_t version;
void* ptr;
/* This won't compile if the appropriate Vulkan platform define isn't set. */
ptr =
#if defined(_WIN32)
&vkCreateWin32SurfaceKHR;
#elif defined(__linux__) || defined(__unix__)
&vkCreateXlibSurfaceKHR;
#elif defined(__APPLE__)
&vkCreateMacOSSurfaceMVK;
#else
/* Platform not recogized for testing. */
NULL;
#endif
/* Try to initialize volk. This might not work on CI builds, but the
* above should have compiled at least. */
r = volkInitialize();
if (r != VK_SUCCESS) {
printf("volkInitialize failed!\n");
return -1;
}
version = volkGetInstanceVersion();
printf("Vulkan version %d.%d.%d initialized.\n",
VK_VERSION_MAJOR(version),
VK_VERSION_MINOR(version),
VK_VERSION_PATCH(version));
return 0;
}

View File

@ -0,0 +1,22 @@
# Include the volk target through add_subdirectory, use the static lib target.
# We must set platform defines.
# By default, Vulkan is pulled in as transitive dependency if found.
cmake_minimum_required(VERSION 3.0)
project(volk_test LANGUAGES C)
# Set a suitable platform define to compile volk with.
if(CMAKE_SYSTEM_NAME STREQUAL Windows)
set(VOLK_STATIC_DEFINES VK_USE_PLATFORM_WIN32_KHR)
elseif(CMAKE_SYSTEM_NAME STREQUAL Linux)
set(VOLK_STATIC_DEFINES VK_USE_PLATFORM_XLIB_KHR)
elseif(CMAKE_SYSTEM_NAME STREQUAL Darwin)
set(VOLK_STATIC_DEFINES VK_USE_PLATFORM_MACOS_MVK)
endif()
# Include volk as part of the build tree to make the target known.
# The two-argument version of add_subdirectory allows adding non-subdirs.
add_subdirectory(../.. volk)
add_executable(volk_test main.c)
target_link_libraries(volk_test PRIVATE volk)

View File

@ -0,0 +1,41 @@
#include "volk.h"
#include "stdio.h"
#include "stdlib.h"
int main()
{
VkResult r;
uint32_t version;
void* ptr;
/* This won't compile if the appropriate Vulkan platform define isn't set. */
ptr =
#if defined(_WIN32)
&vkCreateWin32SurfaceKHR;
#elif defined(__linux__) || defined(__unix__)
&vkCreateXlibSurfaceKHR;
#elif defined(__APPLE__)
&vkCreateMacOSSurfaceMVK;
#else
/* Platform not recogized for testing. */
NULL;
#endif
/* Try to initialize volk. This might not work on CI builds, but the
* above should have compiled at least. */
r = volkInitialize();
if (r != VK_SUCCESS) {
printf("volkInitialize failed!\n");
return -1;
}
version = volkGetInstanceVersion();
printf("Vulkan version %d.%d.%d initialized.\n",
VK_VERSION_MAJOR(version),
VK_VERSION_MINOR(version),
VK_VERSION_PATCH(version));
return 0;
}

View File

@ -0,0 +1,87 @@
#!/usr/bin/env bash
function reset_build {
for DIR in "_build" "_installed"
do
if [ -d $DIR ]; then
rm -rf $DIR
fi
mkdir -p $DIR
done
}
function run_volk_test {
for FILE in "./volk_test" "./volk_test.exe" "Debug/volk_test.exe" "Release/volk_test.exe"
do
if [ -f $FILE ]; then
echo "Running test:"
$FILE
RC=$?
break
fi
done
echo "volk_test return code: $RC"
}
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
pushd $SCRIPT_DIR/..
reset_build
pushd _build
cmake -DCMAKE_INSTALL_PREFIX=../_installed -DVOLK_INSTALL=ON .. || exit 1
cmake --build . --target install || exit 1
popd
echo
echo "cmake_using_source_directly =======================================>"
echo
pushd test/cmake_using_source_directly
reset_build
pushd _build
cmake .. || exit 1
cmake --build . || exit 1
run_volk_test
popd
popd
echo
echo "cmake_using_subdir_static =======================================>"
echo
pushd test/cmake_using_subdir_static
reset_build
pushd _build
cmake .. || exit 1
cmake --build . || exit 1
run_volk_test
popd
popd
echo
echo "cmake_using_subdir_headers =======================================>"
echo
pushd test/cmake_using_subdir_headers
reset_build
pushd _build
cmake .. || exit 1
cmake --build . || exit 1
run_volk_test
popd
popd
echo
echo "cmake_using_installed_headers =======================================>"
echo
pushd test/cmake_using_installed_headers
reset_build
pushd _build
cmake -DCMAKE_INSTALL_PREFIX=../../../_installed/lib/cmake .. || exit 1
cmake --build . || exit 1
run_volk_test
popd
popd
popd

View File

@ -1,4 +1,5 @@
/* This file is part of volk library; see volk.h for version/license details */
/* clang-format off */
#include "volk.h"
#ifdef _WIN32
@ -23,6 +24,9 @@ __declspec(dllimport) HMODULE __stdcall LoadLibraryA(LPCSTR);
__declspec(dllimport) FARPROC __stdcall GetProcAddress(HMODULE, LPCSTR);
#endif
static VkInstance loadedInstance = VK_NULL_HANDLE;
static VkDevice loadedDevice = VK_NULL_HANDLE;
static void volkGenLoadLoader(void* context, PFN_vkVoidFunction (*load)(void*, const char*));
static void volkGenLoadInstance(void* context, PFN_vkVoidFunction (*load)(void*, const char*));
static void volkGenLoadDevice(void* context, PFN_vkVoidFunction (*load)(void*, const char*));
@ -58,9 +62,9 @@ VkResult volkInitialize(void)
vkGetInstanceProcAddr = (PFN_vkGetInstanceProcAddr)dlsym(module, "vkGetInstanceProcAddr");
#else
void* module = dlopen("libvulkan.so", RTLD_NOW | RTLD_LOCAL);
void* module = dlopen("libvulkan.so.1", RTLD_NOW | RTLD_LOCAL);
if (!module)
module = dlopen("libvulkan.so.1", RTLD_NOW | RTLD_LOCAL);
module = dlopen("libvulkan.so", RTLD_NOW | RTLD_LOCAL);
if (!module)
return VK_ERROR_INITIALIZATION_FAILED;
@ -95,15 +99,33 @@ uint32_t volkGetInstanceVersion(void)
void volkLoadInstance(VkInstance instance)
{
loadedInstance = instance;
volkGenLoadInstance(instance, vkGetInstanceProcAddrStub);
volkGenLoadDevice(instance, vkGetInstanceProcAddrStub);
}
void volkLoadInstanceOnly(VkInstance instance)
{
loadedInstance = instance;
volkGenLoadInstance(instance, vkGetInstanceProcAddrStub);
}
VkInstance volkGetLoadedInstance()
{
return loadedInstance;
}
void volkLoadDevice(VkDevice device)
{
loadedDevice = device;
volkGenLoadDevice(device, vkGetDeviceProcAddrStub);
}
VkDevice volkGetLoadedDevice()
{
return loadedDevice;
}
void volkLoadDeviceTable(struct VolkDeviceTable* table, VkDevice device)
{
volkGenLoadDeviceTable(table, device, vkGetDeviceProcAddrStub);
@ -197,6 +219,9 @@ static void volkGenLoadInstance(void* context, PFN_vkVoidFunction (*load)(void*,
#if defined(VK_EXT_sample_locations)
vkGetPhysicalDeviceMultisamplePropertiesEXT = (PFN_vkGetPhysicalDeviceMultisamplePropertiesEXT)load(context, "vkGetPhysicalDeviceMultisamplePropertiesEXT");
#endif /* defined(VK_EXT_sample_locations) */
#if defined(VK_EXT_tooling_info)
vkGetPhysicalDeviceToolPropertiesEXT = (PFN_vkGetPhysicalDeviceToolPropertiesEXT)load(context, "vkGetPhysicalDeviceToolPropertiesEXT");
#endif /* defined(VK_EXT_tooling_info) */
#if defined(VK_FUCHSIA_imagepipe_surface)
vkCreateImagePipeSurfaceFUCHSIA = (PFN_vkCreateImagePipeSurfaceFUCHSIA)load(context, "vkCreateImagePipeSurfaceFUCHSIA");
#endif /* defined(VK_FUCHSIA_imagepipe_surface) */
@ -246,6 +271,10 @@ static void volkGenLoadInstance(void* context, PFN_vkVoidFunction (*load)(void*,
vkGetPhysicalDeviceSurfaceCapabilities2KHR = (PFN_vkGetPhysicalDeviceSurfaceCapabilities2KHR)load(context, "vkGetPhysicalDeviceSurfaceCapabilities2KHR");
vkGetPhysicalDeviceSurfaceFormats2KHR = (PFN_vkGetPhysicalDeviceSurfaceFormats2KHR)load(context, "vkGetPhysicalDeviceSurfaceFormats2KHR");
#endif /* defined(VK_KHR_get_surface_capabilities2) */
#if defined(VK_KHR_performance_query)
vkEnumeratePhysicalDeviceQueueFamilyPerformanceQueryCountersKHR = (PFN_vkEnumeratePhysicalDeviceQueueFamilyPerformanceQueryCountersKHR)load(context, "vkEnumeratePhysicalDeviceQueueFamilyPerformanceQueryCountersKHR");
vkGetPhysicalDeviceQueueFamilyPerformanceQueryPassesKHR = (PFN_vkGetPhysicalDeviceQueueFamilyPerformanceQueryPassesKHR)load(context, "vkGetPhysicalDeviceQueueFamilyPerformanceQueryPassesKHR");
#endif /* defined(VK_KHR_performance_query) */
#if defined(VK_KHR_surface)
vkDestroySurfaceKHR = (PFN_vkDestroySurfaceKHR)load(context, "vkDestroySurfaceKHR");
vkGetPhysicalDeviceSurfaceCapabilitiesKHR = (PFN_vkGetPhysicalDeviceSurfaceCapabilitiesKHR)load(context, "vkGetPhysicalDeviceSurfaceCapabilitiesKHR");
@ -439,6 +468,21 @@ static void volkGenLoadDevice(void* context, PFN_vkVoidFunction (*load)(void*, c
vkTrimCommandPool = (PFN_vkTrimCommandPool)load(context, "vkTrimCommandPool");
vkUpdateDescriptorSetWithTemplate = (PFN_vkUpdateDescriptorSetWithTemplate)load(context, "vkUpdateDescriptorSetWithTemplate");
#endif /* defined(VK_VERSION_1_1) */
#if defined(VK_VERSION_1_2)
vkCmdBeginRenderPass2 = (PFN_vkCmdBeginRenderPass2)load(context, "vkCmdBeginRenderPass2");
vkCmdDrawIndexedIndirectCount = (PFN_vkCmdDrawIndexedIndirectCount)load(context, "vkCmdDrawIndexedIndirectCount");
vkCmdDrawIndirectCount = (PFN_vkCmdDrawIndirectCount)load(context, "vkCmdDrawIndirectCount");
vkCmdEndRenderPass2 = (PFN_vkCmdEndRenderPass2)load(context, "vkCmdEndRenderPass2");
vkCmdNextSubpass2 = (PFN_vkCmdNextSubpass2)load(context, "vkCmdNextSubpass2");
vkCreateRenderPass2 = (PFN_vkCreateRenderPass2)load(context, "vkCreateRenderPass2");
vkGetBufferDeviceAddress = (PFN_vkGetBufferDeviceAddress)load(context, "vkGetBufferDeviceAddress");
vkGetBufferOpaqueCaptureAddress = (PFN_vkGetBufferOpaqueCaptureAddress)load(context, "vkGetBufferOpaqueCaptureAddress");
vkGetDeviceMemoryOpaqueCaptureAddress = (PFN_vkGetDeviceMemoryOpaqueCaptureAddress)load(context, "vkGetDeviceMemoryOpaqueCaptureAddress");
vkGetSemaphoreCounterValue = (PFN_vkGetSemaphoreCounterValue)load(context, "vkGetSemaphoreCounterValue");
vkResetQueryPool = (PFN_vkResetQueryPool)load(context, "vkResetQueryPool");
vkSignalSemaphore = (PFN_vkSignalSemaphore)load(context, "vkSignalSemaphore");
vkWaitSemaphores = (PFN_vkWaitSemaphores)load(context, "vkWaitSemaphores");
#endif /* defined(VK_VERSION_1_2) */
#if defined(VK_AMD_buffer_marker)
vkCmdWriteBufferMarkerAMD = (PFN_vkCmdWriteBufferMarkerAMD)load(context, "vkCmdWriteBufferMarkerAMD");
#endif /* defined(VK_AMD_buffer_marker) */
@ -537,6 +581,11 @@ static void volkGenLoadDevice(void* context, PFN_vkVoidFunction (*load)(void*, c
vkBindBufferMemory2KHR = (PFN_vkBindBufferMemory2KHR)load(context, "vkBindBufferMemory2KHR");
vkBindImageMemory2KHR = (PFN_vkBindImageMemory2KHR)load(context, "vkBindImageMemory2KHR");
#endif /* defined(VK_KHR_bind_memory2) */
#if defined(VK_KHR_buffer_device_address)
vkGetBufferDeviceAddressKHR = (PFN_vkGetBufferDeviceAddressKHR)load(context, "vkGetBufferDeviceAddressKHR");
vkGetBufferOpaqueCaptureAddressKHR = (PFN_vkGetBufferOpaqueCaptureAddressKHR)load(context, "vkGetBufferOpaqueCaptureAddressKHR");
vkGetDeviceMemoryOpaqueCaptureAddressKHR = (PFN_vkGetDeviceMemoryOpaqueCaptureAddressKHR)load(context, "vkGetDeviceMemoryOpaqueCaptureAddressKHR");
#endif /* defined(VK_KHR_buffer_device_address) */
#if defined(VK_KHR_create_renderpass2)
vkCmdBeginRenderPass2KHR = (PFN_vkCmdBeginRenderPass2KHR)load(context, "vkCmdBeginRenderPass2KHR");
vkCmdEndRenderPass2KHR = (PFN_vkCmdEndRenderPass2KHR)load(context, "vkCmdEndRenderPass2KHR");
@ -595,6 +644,10 @@ static void volkGenLoadDevice(void* context, PFN_vkVoidFunction (*load)(void*, c
#if defined(VK_KHR_maintenance3)
vkGetDescriptorSetLayoutSupportKHR = (PFN_vkGetDescriptorSetLayoutSupportKHR)load(context, "vkGetDescriptorSetLayoutSupportKHR");
#endif /* defined(VK_KHR_maintenance3) */
#if defined(VK_KHR_performance_query)
vkAcquireProfilingLockKHR = (PFN_vkAcquireProfilingLockKHR)load(context, "vkAcquireProfilingLockKHR");
vkReleaseProfilingLockKHR = (PFN_vkReleaseProfilingLockKHR)load(context, "vkReleaseProfilingLockKHR");
#endif /* defined(VK_KHR_performance_query) */
#if defined(VK_KHR_pipeline_executable_properties)
vkGetPipelineExecutableInternalRepresentationsKHR = (PFN_vkGetPipelineExecutableInternalRepresentationsKHR)load(context, "vkGetPipelineExecutableInternalRepresentationsKHR");
vkGetPipelineExecutablePropertiesKHR = (PFN_vkGetPipelineExecutablePropertiesKHR)load(context, "vkGetPipelineExecutablePropertiesKHR");
@ -617,6 +670,11 @@ static void volkGenLoadDevice(void* context, PFN_vkVoidFunction (*load)(void*, c
vkGetSwapchainImagesKHR = (PFN_vkGetSwapchainImagesKHR)load(context, "vkGetSwapchainImagesKHR");
vkQueuePresentKHR = (PFN_vkQueuePresentKHR)load(context, "vkQueuePresentKHR");
#endif /* defined(VK_KHR_swapchain) */
#if defined(VK_KHR_timeline_semaphore)
vkGetSemaphoreCounterValueKHR = (PFN_vkGetSemaphoreCounterValueKHR)load(context, "vkGetSemaphoreCounterValueKHR");
vkSignalSemaphoreKHR = (PFN_vkSignalSemaphoreKHR)load(context, "vkSignalSemaphoreKHR");
vkWaitSemaphoresKHR = (PFN_vkWaitSemaphoresKHR)load(context, "vkWaitSemaphoresKHR");
#endif /* defined(VK_KHR_timeline_semaphore) */
#if defined(VK_NVX_device_generated_commands)
vkCmdProcessCommandsNVX = (PFN_vkCmdProcessCommandsNVX)load(context, "vkCmdProcessCommandsNVX");
vkCmdReserveSpaceForCommandsNVX = (PFN_vkCmdReserveSpaceForCommandsNVX)load(context, "vkCmdReserveSpaceForCommandsNVX");
@ -826,6 +884,21 @@ static void volkGenLoadDeviceTable(struct VolkDeviceTable* table, void* context,
table->vkTrimCommandPool = (PFN_vkTrimCommandPool)load(context, "vkTrimCommandPool");
table->vkUpdateDescriptorSetWithTemplate = (PFN_vkUpdateDescriptorSetWithTemplate)load(context, "vkUpdateDescriptorSetWithTemplate");
#endif /* defined(VK_VERSION_1_1) */
#if defined(VK_VERSION_1_2)
table->vkCmdBeginRenderPass2 = (PFN_vkCmdBeginRenderPass2)load(context, "vkCmdBeginRenderPass2");
table->vkCmdDrawIndexedIndirectCount = (PFN_vkCmdDrawIndexedIndirectCount)load(context, "vkCmdDrawIndexedIndirectCount");
table->vkCmdDrawIndirectCount = (PFN_vkCmdDrawIndirectCount)load(context, "vkCmdDrawIndirectCount");
table->vkCmdEndRenderPass2 = (PFN_vkCmdEndRenderPass2)load(context, "vkCmdEndRenderPass2");
table->vkCmdNextSubpass2 = (PFN_vkCmdNextSubpass2)load(context, "vkCmdNextSubpass2");
table->vkCreateRenderPass2 = (PFN_vkCreateRenderPass2)load(context, "vkCreateRenderPass2");
table->vkGetBufferDeviceAddress = (PFN_vkGetBufferDeviceAddress)load(context, "vkGetBufferDeviceAddress");
table->vkGetBufferOpaqueCaptureAddress = (PFN_vkGetBufferOpaqueCaptureAddress)load(context, "vkGetBufferOpaqueCaptureAddress");
table->vkGetDeviceMemoryOpaqueCaptureAddress = (PFN_vkGetDeviceMemoryOpaqueCaptureAddress)load(context, "vkGetDeviceMemoryOpaqueCaptureAddress");
table->vkGetSemaphoreCounterValue = (PFN_vkGetSemaphoreCounterValue)load(context, "vkGetSemaphoreCounterValue");
table->vkResetQueryPool = (PFN_vkResetQueryPool)load(context, "vkResetQueryPool");
table->vkSignalSemaphore = (PFN_vkSignalSemaphore)load(context, "vkSignalSemaphore");
table->vkWaitSemaphores = (PFN_vkWaitSemaphores)load(context, "vkWaitSemaphores");
#endif /* defined(VK_VERSION_1_2) */
#if defined(VK_AMD_buffer_marker)
table->vkCmdWriteBufferMarkerAMD = (PFN_vkCmdWriteBufferMarkerAMD)load(context, "vkCmdWriteBufferMarkerAMD");
#endif /* defined(VK_AMD_buffer_marker) */
@ -924,6 +997,11 @@ static void volkGenLoadDeviceTable(struct VolkDeviceTable* table, void* context,
table->vkBindBufferMemory2KHR = (PFN_vkBindBufferMemory2KHR)load(context, "vkBindBufferMemory2KHR");
table->vkBindImageMemory2KHR = (PFN_vkBindImageMemory2KHR)load(context, "vkBindImageMemory2KHR");
#endif /* defined(VK_KHR_bind_memory2) */
#if defined(VK_KHR_buffer_device_address)
table->vkGetBufferDeviceAddressKHR = (PFN_vkGetBufferDeviceAddressKHR)load(context, "vkGetBufferDeviceAddressKHR");
table->vkGetBufferOpaqueCaptureAddressKHR = (PFN_vkGetBufferOpaqueCaptureAddressKHR)load(context, "vkGetBufferOpaqueCaptureAddressKHR");
table->vkGetDeviceMemoryOpaqueCaptureAddressKHR = (PFN_vkGetDeviceMemoryOpaqueCaptureAddressKHR)load(context, "vkGetDeviceMemoryOpaqueCaptureAddressKHR");
#endif /* defined(VK_KHR_buffer_device_address) */
#if defined(VK_KHR_create_renderpass2)
table->vkCmdBeginRenderPass2KHR = (PFN_vkCmdBeginRenderPass2KHR)load(context, "vkCmdBeginRenderPass2KHR");
table->vkCmdEndRenderPass2KHR = (PFN_vkCmdEndRenderPass2KHR)load(context, "vkCmdEndRenderPass2KHR");
@ -982,6 +1060,10 @@ static void volkGenLoadDeviceTable(struct VolkDeviceTable* table, void* context,
#if defined(VK_KHR_maintenance3)
table->vkGetDescriptorSetLayoutSupportKHR = (PFN_vkGetDescriptorSetLayoutSupportKHR)load(context, "vkGetDescriptorSetLayoutSupportKHR");
#endif /* defined(VK_KHR_maintenance3) */
#if defined(VK_KHR_performance_query)
table->vkAcquireProfilingLockKHR = (PFN_vkAcquireProfilingLockKHR)load(context, "vkAcquireProfilingLockKHR");
table->vkReleaseProfilingLockKHR = (PFN_vkReleaseProfilingLockKHR)load(context, "vkReleaseProfilingLockKHR");
#endif /* defined(VK_KHR_performance_query) */
#if defined(VK_KHR_pipeline_executable_properties)
table->vkGetPipelineExecutableInternalRepresentationsKHR = (PFN_vkGetPipelineExecutableInternalRepresentationsKHR)load(context, "vkGetPipelineExecutableInternalRepresentationsKHR");
table->vkGetPipelineExecutablePropertiesKHR = (PFN_vkGetPipelineExecutablePropertiesKHR)load(context, "vkGetPipelineExecutablePropertiesKHR");
@ -1004,6 +1086,11 @@ static void volkGenLoadDeviceTable(struct VolkDeviceTable* table, void* context,
table->vkGetSwapchainImagesKHR = (PFN_vkGetSwapchainImagesKHR)load(context, "vkGetSwapchainImagesKHR");
table->vkQueuePresentKHR = (PFN_vkQueuePresentKHR)load(context, "vkQueuePresentKHR");
#endif /* defined(VK_KHR_swapchain) */
#if defined(VK_KHR_timeline_semaphore)
table->vkGetSemaphoreCounterValueKHR = (PFN_vkGetSemaphoreCounterValueKHR)load(context, "vkGetSemaphoreCounterValueKHR");
table->vkSignalSemaphoreKHR = (PFN_vkSignalSemaphoreKHR)load(context, "vkSignalSemaphoreKHR");
table->vkWaitSemaphoresKHR = (PFN_vkWaitSemaphoresKHR)load(context, "vkWaitSemaphoresKHR");
#endif /* defined(VK_KHR_timeline_semaphore) */
#if defined(VK_NVX_device_generated_commands)
table->vkCmdProcessCommandsNVX = (PFN_vkCmdProcessCommandsNVX)load(context, "vkCmdProcessCommandsNVX");
table->vkCmdReserveSpaceForCommandsNVX = (PFN_vkCmdReserveSpaceForCommandsNVX)load(context, "vkCmdReserveSpaceForCommandsNVX");
@ -1244,6 +1331,21 @@ PFN_vkGetPhysicalDeviceSparseImageFormatProperties2 vkGetPhysicalDeviceSparseIma
PFN_vkTrimCommandPool vkTrimCommandPool;
PFN_vkUpdateDescriptorSetWithTemplate vkUpdateDescriptorSetWithTemplate;
#endif /* defined(VK_VERSION_1_1) */
#if defined(VK_VERSION_1_2)
PFN_vkCmdBeginRenderPass2 vkCmdBeginRenderPass2;
PFN_vkCmdDrawIndexedIndirectCount vkCmdDrawIndexedIndirectCount;
PFN_vkCmdDrawIndirectCount vkCmdDrawIndirectCount;
PFN_vkCmdEndRenderPass2 vkCmdEndRenderPass2;
PFN_vkCmdNextSubpass2 vkCmdNextSubpass2;
PFN_vkCreateRenderPass2 vkCreateRenderPass2;
PFN_vkGetBufferDeviceAddress vkGetBufferDeviceAddress;
PFN_vkGetBufferOpaqueCaptureAddress vkGetBufferOpaqueCaptureAddress;
PFN_vkGetDeviceMemoryOpaqueCaptureAddress vkGetDeviceMemoryOpaqueCaptureAddress;
PFN_vkGetSemaphoreCounterValue vkGetSemaphoreCounterValue;
PFN_vkResetQueryPool vkResetQueryPool;
PFN_vkSignalSemaphore vkSignalSemaphore;
PFN_vkWaitSemaphores vkWaitSemaphores;
#endif /* defined(VK_VERSION_1_2) */
#if defined(VK_AMD_buffer_marker)
PFN_vkCmdWriteBufferMarkerAMD vkCmdWriteBufferMarkerAMD;
#endif /* defined(VK_AMD_buffer_marker) */
@ -1346,6 +1448,9 @@ PFN_vkCreateMetalSurfaceEXT vkCreateMetalSurfaceEXT;
PFN_vkCmdSetSampleLocationsEXT vkCmdSetSampleLocationsEXT;
PFN_vkGetPhysicalDeviceMultisamplePropertiesEXT vkGetPhysicalDeviceMultisamplePropertiesEXT;
#endif /* defined(VK_EXT_sample_locations) */
#if defined(VK_EXT_tooling_info)
PFN_vkGetPhysicalDeviceToolPropertiesEXT vkGetPhysicalDeviceToolPropertiesEXT;
#endif /* defined(VK_EXT_tooling_info) */
#if defined(VK_EXT_transform_feedback)
PFN_vkCmdBeginQueryIndexedEXT vkCmdBeginQueryIndexedEXT;
PFN_vkCmdBeginTransformFeedbackEXT vkCmdBeginTransformFeedbackEXT;
@ -1388,6 +1493,11 @@ PFN_vkCreateAndroidSurfaceKHR vkCreateAndroidSurfaceKHR;
PFN_vkBindBufferMemory2KHR vkBindBufferMemory2KHR;
PFN_vkBindImageMemory2KHR vkBindImageMemory2KHR;
#endif /* defined(VK_KHR_bind_memory2) */
#if defined(VK_KHR_buffer_device_address)
PFN_vkGetBufferDeviceAddressKHR vkGetBufferDeviceAddressKHR;
PFN_vkGetBufferOpaqueCaptureAddressKHR vkGetBufferOpaqueCaptureAddressKHR;
PFN_vkGetDeviceMemoryOpaqueCaptureAddressKHR vkGetDeviceMemoryOpaqueCaptureAddressKHR;
#endif /* defined(VK_KHR_buffer_device_address) */
#if defined(VK_KHR_create_renderpass2)
PFN_vkCmdBeginRenderPass2KHR vkCmdBeginRenderPass2KHR;
PFN_vkCmdEndRenderPass2KHR vkCmdEndRenderPass2KHR;
@ -1486,6 +1596,12 @@ PFN_vkTrimCommandPoolKHR vkTrimCommandPoolKHR;
#if defined(VK_KHR_maintenance3)
PFN_vkGetDescriptorSetLayoutSupportKHR vkGetDescriptorSetLayoutSupportKHR;
#endif /* defined(VK_KHR_maintenance3) */
#if defined(VK_KHR_performance_query)
PFN_vkAcquireProfilingLockKHR vkAcquireProfilingLockKHR;
PFN_vkEnumeratePhysicalDeviceQueueFamilyPerformanceQueryCountersKHR vkEnumeratePhysicalDeviceQueueFamilyPerformanceQueryCountersKHR;
PFN_vkGetPhysicalDeviceQueueFamilyPerformanceQueryPassesKHR vkGetPhysicalDeviceQueueFamilyPerformanceQueryPassesKHR;
PFN_vkReleaseProfilingLockKHR vkReleaseProfilingLockKHR;
#endif /* defined(VK_KHR_performance_query) */
#if defined(VK_KHR_pipeline_executable_properties)
PFN_vkGetPipelineExecutableInternalRepresentationsKHR vkGetPipelineExecutableInternalRepresentationsKHR;
PFN_vkGetPipelineExecutablePropertiesKHR vkGetPipelineExecutablePropertiesKHR;
@ -1515,6 +1631,11 @@ PFN_vkDestroySwapchainKHR vkDestroySwapchainKHR;
PFN_vkGetSwapchainImagesKHR vkGetSwapchainImagesKHR;
PFN_vkQueuePresentKHR vkQueuePresentKHR;
#endif /* defined(VK_KHR_swapchain) */
#if defined(VK_KHR_timeline_semaphore)
PFN_vkGetSemaphoreCounterValueKHR vkGetSemaphoreCounterValueKHR;
PFN_vkSignalSemaphoreKHR vkSignalSemaphoreKHR;
PFN_vkWaitSemaphoresKHR vkWaitSemaphoresKHR;
#endif /* defined(VK_KHR_timeline_semaphore) */
#if defined(VK_KHR_wayland_surface)
PFN_vkCreateWaylandSurfaceKHR vkCreateWaylandSurfaceKHR;
PFN_vkGetPhysicalDeviceWaylandPresentationSupportKHR vkGetPhysicalDeviceWaylandPresentationSupportKHR;
@ -1623,3 +1744,4 @@ PFN_vkAcquireNextImage2KHR vkAcquireNextImage2KHR;
#ifdef __cplusplus
}
#endif
/* clang-format on */

View File

@ -6,6 +6,7 @@
*
* This library is distributed under the MIT License. See notice at the end of this file.
*/
/* clang-format off */
#ifndef VOLK_H_
#define VOLK_H_
@ -14,7 +15,7 @@
#endif
/* VOLK_GENERATE_VERSION_DEFINE */
#define VOLK_HEADER_VERSION 121
#define VOLK_HEADER_VERSION 131
/* VOLK_GENERATE_VERSION_DEFINE */
#ifndef VK_NO_PROTOTYPES
@ -80,6 +81,12 @@ uint32_t volkGetInstanceVersion(void);
*/
void volkLoadInstance(VkInstance instance);
/**
* Load global function pointers using application-created VkInstance; call this function after creating the Vulkan instance.
* Skips loading device-based function pointers, requires usage of volkLoadDevice afterwards.
*/
void volkLoadInstanceOnly(VkInstance instance);
/**
* Load global function pointers using application-created VkDevice; call this function after creating the Vulkan device.
*
@ -87,6 +94,18 @@ void volkLoadInstance(VkInstance instance);
*/
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(void);
/**
* 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(void);
/**
* Load function pointers using application-created VkDevice into a table.
* Application should use function pointers from that table instead of using global function pointers.
@ -239,6 +258,21 @@ struct VolkDeviceTable
PFN_vkTrimCommandPool vkTrimCommandPool;
PFN_vkUpdateDescriptorSetWithTemplate vkUpdateDescriptorSetWithTemplate;
#endif /* defined(VK_VERSION_1_1) */
#if defined(VK_VERSION_1_2)
PFN_vkCmdBeginRenderPass2 vkCmdBeginRenderPass2;
PFN_vkCmdDrawIndexedIndirectCount vkCmdDrawIndexedIndirectCount;
PFN_vkCmdDrawIndirectCount vkCmdDrawIndirectCount;
PFN_vkCmdEndRenderPass2 vkCmdEndRenderPass2;
PFN_vkCmdNextSubpass2 vkCmdNextSubpass2;
PFN_vkCreateRenderPass2 vkCreateRenderPass2;
PFN_vkGetBufferDeviceAddress vkGetBufferDeviceAddress;
PFN_vkGetBufferOpaqueCaptureAddress vkGetBufferOpaqueCaptureAddress;
PFN_vkGetDeviceMemoryOpaqueCaptureAddress vkGetDeviceMemoryOpaqueCaptureAddress;
PFN_vkGetSemaphoreCounterValue vkGetSemaphoreCounterValue;
PFN_vkResetQueryPool vkResetQueryPool;
PFN_vkSignalSemaphore vkSignalSemaphore;
PFN_vkWaitSemaphores vkWaitSemaphores;
#endif /* defined(VK_VERSION_1_2) */
#if defined(VK_AMD_buffer_marker)
PFN_vkCmdWriteBufferMarkerAMD vkCmdWriteBufferMarkerAMD;
#endif /* defined(VK_AMD_buffer_marker) */
@ -337,6 +371,11 @@ struct VolkDeviceTable
PFN_vkBindBufferMemory2KHR vkBindBufferMemory2KHR;
PFN_vkBindImageMemory2KHR vkBindImageMemory2KHR;
#endif /* defined(VK_KHR_bind_memory2) */
#if defined(VK_KHR_buffer_device_address)
PFN_vkGetBufferDeviceAddressKHR vkGetBufferDeviceAddressKHR;
PFN_vkGetBufferOpaqueCaptureAddressKHR vkGetBufferOpaqueCaptureAddressKHR;
PFN_vkGetDeviceMemoryOpaqueCaptureAddressKHR vkGetDeviceMemoryOpaqueCaptureAddressKHR;
#endif /* defined(VK_KHR_buffer_device_address) */
#if defined(VK_KHR_create_renderpass2)
PFN_vkCmdBeginRenderPass2KHR vkCmdBeginRenderPass2KHR;
PFN_vkCmdEndRenderPass2KHR vkCmdEndRenderPass2KHR;
@ -395,6 +434,10 @@ struct VolkDeviceTable
#if defined(VK_KHR_maintenance3)
PFN_vkGetDescriptorSetLayoutSupportKHR vkGetDescriptorSetLayoutSupportKHR;
#endif /* defined(VK_KHR_maintenance3) */
#if defined(VK_KHR_performance_query)
PFN_vkAcquireProfilingLockKHR vkAcquireProfilingLockKHR;
PFN_vkReleaseProfilingLockKHR vkReleaseProfilingLockKHR;
#endif /* defined(VK_KHR_performance_query) */
#if defined(VK_KHR_pipeline_executable_properties)
PFN_vkGetPipelineExecutableInternalRepresentationsKHR vkGetPipelineExecutableInternalRepresentationsKHR;
PFN_vkGetPipelineExecutablePropertiesKHR vkGetPipelineExecutablePropertiesKHR;
@ -417,6 +460,11 @@ struct VolkDeviceTable
PFN_vkGetSwapchainImagesKHR vkGetSwapchainImagesKHR;
PFN_vkQueuePresentKHR vkQueuePresentKHR;
#endif /* defined(VK_KHR_swapchain) */
#if defined(VK_KHR_timeline_semaphore)
PFN_vkGetSemaphoreCounterValueKHR vkGetSemaphoreCounterValueKHR;
PFN_vkSignalSemaphoreKHR vkSignalSemaphoreKHR;
PFN_vkWaitSemaphoresKHR vkWaitSemaphoresKHR;
#endif /* defined(VK_KHR_timeline_semaphore) */
#if defined(VK_NVX_device_generated_commands)
PFN_vkCmdProcessCommandsNVX vkCmdProcessCommandsNVX;
PFN_vkCmdReserveSpaceForCommandsNVX vkCmdReserveSpaceForCommandsNVX;
@ -653,6 +701,21 @@ extern PFN_vkGetPhysicalDeviceSparseImageFormatProperties2 vkGetPhysicalDeviceSp
extern PFN_vkTrimCommandPool vkTrimCommandPool;
extern PFN_vkUpdateDescriptorSetWithTemplate vkUpdateDescriptorSetWithTemplate;
#endif /* defined(VK_VERSION_1_1) */
#if defined(VK_VERSION_1_2)
extern PFN_vkCmdBeginRenderPass2 vkCmdBeginRenderPass2;
extern PFN_vkCmdDrawIndexedIndirectCount vkCmdDrawIndexedIndirectCount;
extern PFN_vkCmdDrawIndirectCount vkCmdDrawIndirectCount;
extern PFN_vkCmdEndRenderPass2 vkCmdEndRenderPass2;
extern PFN_vkCmdNextSubpass2 vkCmdNextSubpass2;
extern PFN_vkCreateRenderPass2 vkCreateRenderPass2;
extern PFN_vkGetBufferDeviceAddress vkGetBufferDeviceAddress;
extern PFN_vkGetBufferOpaqueCaptureAddress vkGetBufferOpaqueCaptureAddress;
extern PFN_vkGetDeviceMemoryOpaqueCaptureAddress vkGetDeviceMemoryOpaqueCaptureAddress;
extern PFN_vkGetSemaphoreCounterValue vkGetSemaphoreCounterValue;
extern PFN_vkResetQueryPool vkResetQueryPool;
extern PFN_vkSignalSemaphore vkSignalSemaphore;
extern PFN_vkWaitSemaphores vkWaitSemaphores;
#endif /* defined(VK_VERSION_1_2) */
#if defined(VK_AMD_buffer_marker)
extern PFN_vkCmdWriteBufferMarkerAMD vkCmdWriteBufferMarkerAMD;
#endif /* defined(VK_AMD_buffer_marker) */
@ -755,6 +818,9 @@ extern PFN_vkCreateMetalSurfaceEXT vkCreateMetalSurfaceEXT;
extern PFN_vkCmdSetSampleLocationsEXT vkCmdSetSampleLocationsEXT;
extern PFN_vkGetPhysicalDeviceMultisamplePropertiesEXT vkGetPhysicalDeviceMultisamplePropertiesEXT;
#endif /* defined(VK_EXT_sample_locations) */
#if defined(VK_EXT_tooling_info)
extern PFN_vkGetPhysicalDeviceToolPropertiesEXT vkGetPhysicalDeviceToolPropertiesEXT;
#endif /* defined(VK_EXT_tooling_info) */
#if defined(VK_EXT_transform_feedback)
extern PFN_vkCmdBeginQueryIndexedEXT vkCmdBeginQueryIndexedEXT;
extern PFN_vkCmdBeginTransformFeedbackEXT vkCmdBeginTransformFeedbackEXT;
@ -797,6 +863,11 @@ extern PFN_vkCreateAndroidSurfaceKHR vkCreateAndroidSurfaceKHR;
extern PFN_vkBindBufferMemory2KHR vkBindBufferMemory2KHR;
extern PFN_vkBindImageMemory2KHR vkBindImageMemory2KHR;
#endif /* defined(VK_KHR_bind_memory2) */
#if defined(VK_KHR_buffer_device_address)
extern PFN_vkGetBufferDeviceAddressKHR vkGetBufferDeviceAddressKHR;
extern PFN_vkGetBufferOpaqueCaptureAddressKHR vkGetBufferOpaqueCaptureAddressKHR;
extern PFN_vkGetDeviceMemoryOpaqueCaptureAddressKHR vkGetDeviceMemoryOpaqueCaptureAddressKHR;
#endif /* defined(VK_KHR_buffer_device_address) */
#if defined(VK_KHR_create_renderpass2)
extern PFN_vkCmdBeginRenderPass2KHR vkCmdBeginRenderPass2KHR;
extern PFN_vkCmdEndRenderPass2KHR vkCmdEndRenderPass2KHR;
@ -895,6 +966,12 @@ extern PFN_vkTrimCommandPoolKHR vkTrimCommandPoolKHR;
#if defined(VK_KHR_maintenance3)
extern PFN_vkGetDescriptorSetLayoutSupportKHR vkGetDescriptorSetLayoutSupportKHR;
#endif /* defined(VK_KHR_maintenance3) */
#if defined(VK_KHR_performance_query)
extern PFN_vkAcquireProfilingLockKHR vkAcquireProfilingLockKHR;
extern PFN_vkEnumeratePhysicalDeviceQueueFamilyPerformanceQueryCountersKHR vkEnumeratePhysicalDeviceQueueFamilyPerformanceQueryCountersKHR;
extern PFN_vkGetPhysicalDeviceQueueFamilyPerformanceQueryPassesKHR vkGetPhysicalDeviceQueueFamilyPerformanceQueryPassesKHR;
extern PFN_vkReleaseProfilingLockKHR vkReleaseProfilingLockKHR;
#endif /* defined(VK_KHR_performance_query) */
#if defined(VK_KHR_pipeline_executable_properties)
extern PFN_vkGetPipelineExecutableInternalRepresentationsKHR vkGetPipelineExecutableInternalRepresentationsKHR;
extern PFN_vkGetPipelineExecutablePropertiesKHR vkGetPipelineExecutablePropertiesKHR;
@ -924,6 +1001,11 @@ extern PFN_vkDestroySwapchainKHR vkDestroySwapchainKHR;
extern PFN_vkGetSwapchainImagesKHR vkGetSwapchainImagesKHR;
extern PFN_vkQueuePresentKHR vkQueuePresentKHR;
#endif /* defined(VK_KHR_swapchain) */
#if defined(VK_KHR_timeline_semaphore)
extern PFN_vkGetSemaphoreCounterValueKHR vkGetSemaphoreCounterValueKHR;
extern PFN_vkSignalSemaphoreKHR vkSignalSemaphoreKHR;
extern PFN_vkWaitSemaphoresKHR vkWaitSemaphoresKHR;
#endif /* defined(VK_KHR_timeline_semaphore) */
#if defined(VK_KHR_wayland_surface)
extern PFN_vkCreateWaylandSurfaceKHR vkCreateWaylandSurfaceKHR;
extern PFN_vkGetPhysicalDeviceWaylandPresentationSupportKHR vkGetPhysicalDeviceWaylandPresentationSupportKHR;
@ -1060,3 +1142,4 @@ extern PFN_vkAcquireNextImage2KHR vkAcquireNextImage2KHR;
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
/* clang-format on */