feat(host): vendor PyroWave + minimal Granite subset as crates/pyrowave-sys
Phase 0 of design/pyrowave-codec-plan.md — the opt-in wired-LAN ultra-low- latency codec. Vendored at upstream 509e4f88 (API 0.4.0, Granite 44362775, volk + vulkan-headers pins in PUNKTFUNK-VENDOR.txt), pruned to the 6.6 MB the standalone no-renderer build needs; scripts/vendor-pyrowave.sh reproduces the tree (a pin bump is protocol-affecting, plan §4.2). build.rs drives the wrapper CMakeLists (static archives incl. a static C-API lib upstream only ships shared) + bindgen over pyrowave.h; Linux and Windows only, empty stub elsewhere (Apple gets a native Metal port, §4.7). Offline-safe by construction: no network, no system lib, vendored Vulkan headers — same model as the opus dep (flatpak builder has no network). Phase-0 validation on .21 (RTX 5070 Ti, driver 610.43.03): - upstream pyrowave-c-test + interop test (incl. dmabuf/DRM-modifier Vulkan<->Vulkan) pass, from the pristine AND the pruned tree - GPU kernel times at ~1.6 bpp noise: encode/decode 0.090/0.042 ms @800p, 0.146/0.067 @1080p, 0.226/0.103 @1440p, 0.477/0.201 @4K — order of magnitude under NVENC's 1-2 ms retrieve, CBR lands within ~100 B of target - cargo test -p pyrowave-sys green (static link + API-version pin check) Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
+97
@@ -0,0 +1,97 @@
|
||||
name: build
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- 'master'
|
||||
paths-ignore:
|
||||
- '*.md'
|
||||
pull_request:
|
||||
paths-ignore:
|
||||
- '*.md'
|
||||
|
||||
jobs:
|
||||
build:
|
||||
strategy:
|
||||
matrix:
|
||||
os: [ubuntu, macos, windows]
|
||||
name: ${{matrix.os}}
|
||||
runs-on: ${{matrix.os}}-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
repository: KhronosGroup/Vulkan-Headers
|
||||
ref: main
|
||||
path: Vulkan-Headers
|
||||
fetch-depth: 0
|
||||
fetch-tags: true
|
||||
- name: move sdk
|
||||
shell: bash
|
||||
run: |
|
||||
mv Vulkan-Headers ~/Vulkan-Headers
|
||||
- name: install deps for tests
|
||||
run: sudo apt update && sudo apt install -y xorg-dev
|
||||
if: matrix.os == 'ubuntu'
|
||||
- name: build main
|
||||
shell: bash
|
||||
run: |
|
||||
export VULKAN_SDK=~/Vulkan-Headers
|
||||
git -C ~/Vulkan-Headers checkout main
|
||||
test/run_tests.sh
|
||||
- name: build 1.1.101
|
||||
shell: bash
|
||||
run: |
|
||||
export VULKAN_SDK=~/Vulkan-Headers
|
||||
git -C ~/Vulkan-Headers checkout sdk-1.1.101
|
||||
test/run_tests.sh
|
||||
- name: build 1.2.131
|
||||
shell: bash
|
||||
run: |
|
||||
export VULKAN_SDK=~/Vulkan-Headers
|
||||
git -C ~/Vulkan-Headers checkout sdk-1.2.131
|
||||
test/run_tests.sh
|
||||
- name: build 1.2.182
|
||||
shell: bash
|
||||
run: |
|
||||
export VULKAN_SDK=~/Vulkan-Headers
|
||||
git -C ~/Vulkan-Headers checkout sdk-1.2.182
|
||||
test/run_tests.sh
|
||||
- name: build 1.3.204
|
||||
shell: bash
|
||||
run: |
|
||||
export VULKAN_SDK=~/Vulkan-Headers
|
||||
git -C ~/Vulkan-Headers checkout sdk-1.3.204
|
||||
test/run_tests.sh
|
||||
- name: build 1.3.239
|
||||
shell: bash
|
||||
run: |
|
||||
export VULKAN_SDK=~/Vulkan-Headers
|
||||
git -C ~/Vulkan-Headers checkout sdk-1.3.239
|
||||
test/run_tests.sh
|
||||
- name: build 1.3.268
|
||||
shell: bash
|
||||
run: |
|
||||
export VULKAN_SDK=~/Vulkan-Headers
|
||||
git -C ~/Vulkan-Headers checkout vulkan-sdk-1.3.268
|
||||
test/run_tests.sh
|
||||
- name: build 1.3.296
|
||||
shell: bash
|
||||
run: |
|
||||
export VULKAN_SDK=~/Vulkan-Headers
|
||||
git -C ~/Vulkan-Headers checkout vulkan-sdk-1.3.296
|
||||
test/run_tests.sh
|
||||
android:
|
||||
name: android
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- name: build android arm64
|
||||
shell: bash
|
||||
run: |
|
||||
cmake -S . -B _build/android \
|
||||
-DCMAKE_TOOLCHAIN_FILE="${ANDROID_NDK_ROOT}/build/cmake/android.toolchain.cmake" \
|
||||
-DANDROID_ABI=arm64-v8a \
|
||||
-DANDROID_PLATFORM=21 \
|
||||
-DVOLK_STATIC_DEFINES=VK_USE_PLATFORM_ANDROID_KHR
|
||||
cmake --build _build/android
|
||||
+36
@@ -0,0 +1,36 @@
|
||||
name: update
|
||||
|
||||
on:
|
||||
schedule:
|
||||
- cron: '0 16 * * *'
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
update:
|
||||
if: github.repository == 'zeux/volk'
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
ssh-key: ${{ secrets.SSH_PRIVATE_KEY }}
|
||||
- name: update
|
||||
run: |
|
||||
python3 generate.py >version.txt
|
||||
echo "VOLK_VERSION=`cat version.txt`" >> $GITHUB_ENV
|
||||
rm version.txt
|
||||
- name: create pr
|
||||
uses: peter-evans/create-pull-request@v6
|
||||
with:
|
||||
branch: update/${{env.VOLK_VERSION}}
|
||||
delete-branch: true
|
||||
commit-message: Update to 1.4.${{env.VOLK_VERSION}}
|
||||
title: Update to 1.4.${{env.VOLK_VERSION}}
|
||||
author: GitHub <noreply@github.com>
|
||||
token: ${{ secrets.REPO_SCOPED_TOKEN }}
|
||||
- name: enable pr automerge
|
||||
run: |
|
||||
sleep 60
|
||||
gh pr merge --merge --auto ${{env.PULL_REQUEST_NUMBER}}
|
||||
env:
|
||||
GH_TOKEN: ${{ github.token }}
|
||||
continue-on-error: true
|
||||
@@ -0,0 +1,145 @@
|
||||
cmake_minimum_required(VERSION 3.5...3.30)
|
||||
|
||||
project(volk VERSION
|
||||
# VOLK_GENERATE_VERSION
|
||||
352
|
||||
# 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)
|
||||
set(VOLK_STATIC_DEFINES "" CACHE STRING "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()
|
||||
if(NOT DEFINED VOLK_NAMESPACE)
|
||||
option(VOLK_NAMESPACE "Use C++ namespace for vk* functions" OFF)
|
||||
endif()
|
||||
if(NOT DEFINED VOLK_HEADERS_ONLY)
|
||||
option(VOLK_HEADERS_ONLY "Add interface library only" OFF)
|
||||
endif()
|
||||
if(NOT DEFINED VULKAN_HEADERS_INSTALL_DIR)
|
||||
set(VULKAN_HEADERS_INSTALL_DIR "" CACHE PATH "Where to get the Vulkan headers")
|
||||
endif()
|
||||
|
||||
# -----------------------------------------------------
|
||||
# Static library
|
||||
|
||||
if(NOT VOLK_HEADERS_ONLY OR VOLK_INSTALL)
|
||||
add_library(volk STATIC volk.h volk.c)
|
||||
add_library(volk::volk ALIAS volk)
|
||||
target_include_directories(volk PUBLIC
|
||||
$<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}>
|
||||
$<INSTALL_INTERFACE:include>
|
||||
)
|
||||
if(VOLK_NAMESPACE)
|
||||
target_compile_definitions(volk PUBLIC VOLK_NAMESPACE)
|
||||
set_source_files_properties(volk.c PROPERTIES LANGUAGE CXX)
|
||||
endif()
|
||||
if(VOLK_STATIC_DEFINES)
|
||||
target_compile_definitions(volk PUBLIC ${VOLK_STATIC_DEFINES})
|
||||
endif()
|
||||
if (NOT WIN32)
|
||||
target_link_libraries(volk PUBLIC ${CMAKE_DL_LIBS})
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# -----------------------------------------------------
|
||||
# Interface library
|
||||
|
||||
add_library(volk_headers INTERFACE)
|
||||
add_library(volk::volk_headers ALIAS volk_headers)
|
||||
target_include_directories(volk_headers INTERFACE
|
||||
$<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}>
|
||||
$<INSTALL_INTERFACE:include>
|
||||
)
|
||||
if (NOT WIN32)
|
||||
target_link_libraries(volk_headers INTERFACE ${CMAKE_DL_LIBS})
|
||||
endif()
|
||||
|
||||
# -----------------------------------------------------
|
||||
# Vulkan transitive dependency
|
||||
|
||||
if(VOLK_PULL_IN_VULKAN)
|
||||
# Try an explicit CMake variable first, then any Vulkan paths
|
||||
# discovered by FindVulkan.cmake, then the $VULKAN_SDK environment
|
||||
# variable if nothing else works.
|
||||
if(VULKAN_HEADERS_INSTALL_DIR)
|
||||
message("volk: using VULKAN_HEADERS_INSTALL_DIR option")
|
||||
set(VOLK_INCLUDES "${VULKAN_HEADERS_INSTALL_DIR}/include")
|
||||
else()
|
||||
# If CMake has the FindVulkan module and it works, use it.
|
||||
find_package(Vulkan QUIET)
|
||||
if(Vulkan_INCLUDE_DIRS)
|
||||
message("volk: using Vulkan_INCLUDE_DIRS from FindVulkan module")
|
||||
set(VOLK_INCLUDES "${Vulkan_INCLUDE_DIRS}")
|
||||
elseif(DEFINED ENV{VULKAN_SDK})
|
||||
message("volk: using VULKAN_SDK environment variable")
|
||||
set(VOLK_INCLUDES "$ENV{VULKAN_SDK}/include")
|
||||
elseif(TARGET Vulkan-Headers)
|
||||
message("volk: using Vulkan-Headers include directories")
|
||||
get_target_property(VOLK_INCLUDES Vulkan-Headers INTERFACE_INCLUDE_DIRECTORIES)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(VOLK_INCLUDES)
|
||||
if(TARGET volk)
|
||||
target_include_directories(volk PUBLIC "${VOLK_INCLUDES}")
|
||||
endif()
|
||||
target_include_directories(volk_headers INTERFACE "${VOLK_INCLUDES}")
|
||||
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()
|
||||
@@ -0,0 +1,19 @@
|
||||
Copyright (c) 2018-2026 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.
|
||||
@@ -0,0 +1,105 @@
|
||||
# 🐺 volk [](https://github.com/zeux/volk/actions)
|
||||
|
||||
## 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 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 provided CMake files, with the usage detailed below.
|
||||
3. You can use volk in header-only fashion. Include `volk.h` wherever 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 - however, `volk.c` must still be in the same directory as `volk.h`. This method of integrating volk makes it possible to set the platform defines mentioned above with arbitrary (preprocessor) logic in your code.
|
||||
|
||||
## 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. It's also important to make sure that `vulkan-1` is not linked into the application, as this results in symbol name conflicts as well.
|
||||
|
||||
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 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.
|
||||
|
||||
Since `volkLoadDevice` overwrites some function pointers with device-specific versions, you can choose to use `volkLoadInstanceOnly` instead of `volkLoadInstance`; when using table-based interface this can also help enforce the usage of the function tables as `volkLoadInstanceOnly` will leave device-specific functions as `NULL`.
|
||||
|
||||
## 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 enabled 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`.
|
||||
|
||||
## Configuration
|
||||
|
||||
By default, volk is compiled as a C library and exposes all Vulkan function pointers as globals. This can result in symbol conflicts if some libraries in the application are still linking to Vulkan libraries directly. While generally speaking it's desirable to not mix & match volk with direct usage of Vulkan - for example, mixed usage means the application still links directly to Vulkan libraries and will fail to launch if Vulkan is not available on the user's system - it's possible to enable `VOLK_NAMESPACE` CMake option (or `VOLK_NAMESPACE` define when building volk manually), which places all volk symbols into `volk::` namespace. This requires compiling `volk.c` in C++ mode, which happens automatically when using CMake, but doesn'trequire any other changes.
|
||||
|
||||
Device level functions can be hidden by defining `VOLK_NO_DEVICE_PROTOTYPES`. When using `volkLoadInstanceOnly` and `volkLoadDeviceTable` the device level functions are never loaded and when not used correctly would trigger a runtime error. By hiding the device prototypes mistakes can be checked by the compiler.
|
||||
|
||||
## License
|
||||
|
||||
This library is available to anybody free of charge, under the terms of MIT License (see LICENSE.md).
|
||||
+21
@@ -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()
|
||||
+239
@@ -0,0 +1,239 @@
|
||||
#!/usr/bin/python3
|
||||
# This file is part of volk library; see volk.h for version/license details
|
||||
|
||||
from collections import OrderedDict
|
||||
import re
|
||||
import sys
|
||||
import urllib
|
||||
import xml.etree.ElementTree as etree
|
||||
import urllib.request
|
||||
import zlib
|
||||
|
||||
cmdversions = {
|
||||
"vkCmdSetDiscardRectangleEnableEXT": 2,
|
||||
"vkCmdSetDiscardRectangleModeEXT": 2,
|
||||
"vkCmdSetExclusiveScissorEnableNV": 2,
|
||||
"vkGetImageViewAddressNVX": 2,
|
||||
"vkGetImageViewHandle64NVX": 3,
|
||||
"vkGetDeviceCombinedImageSamplerIndexNVX": 4,
|
||||
"vkGetDeviceSubpassShadingMaxWorkgroupSizeHUAWEI": 2,
|
||||
"vkCmdSetDispatchParametersARM": 2,
|
||||
}
|
||||
|
||||
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', newline='\n') 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 type is None:
|
||||
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 + ')'
|
||||
|
||||
def cdepends(key):
|
||||
return re.sub(r'[a-zA-Z0-9_]+', lambda m: defined(m.group(0)), key).replace(',', ' || ').replace('+', ' && ')
|
||||
|
||||
if __name__ == "__main__":
|
||||
specpath = "https://raw.githubusercontent.com/KhronosGroup/Vulkan-Docs/main/xml/vk.xml"
|
||||
|
||||
if len(sys.argv) > 1:
|
||||
specpath = sys.argv[1]
|
||||
|
||||
spec = parse_xml(specpath)
|
||||
|
||||
block_keys = ('INSTANCE_TABLE', 'DEVICE_TABLE', 'PROTOTYPES_H', 'PROTOTYPES_H_DEVICE', 'PROTOTYPES_C', 'LOAD_LOADER', 'LOAD_INSTANCE', 'LOAD_INSTANCE_TABLE', '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'):
|
||||
api = feature.get('api')
|
||||
if 'vulkan' not in api.split(','):
|
||||
continue
|
||||
name = feature.get('name')
|
||||
name = re.sub(r'VK_(BASE|COMPUTE|GRAPHICS)_VERSION_', 'VK_VERSION_', name) # strip Vulkan Base prefixes for compatibility
|
||||
key = defined(name)
|
||||
cmdrefs = feature.findall('require/command')
|
||||
command_groups.setdefault(key, []).extend([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 'vulkan' not in supported.split(','):
|
||||
continue
|
||||
name = ext.get('name')
|
||||
type = ext.get('type')
|
||||
for req in ext.findall('require'):
|
||||
key = defined(name)
|
||||
if req.get('feature'): # old-style XML depends specification
|
||||
for i in req.get('feature').split(','):
|
||||
key += ' && ' + defined(i)
|
||||
if req.get('extension'): # old-style XML depends specification
|
||||
for i in req.get('extension').split(','):
|
||||
key += ' && ' + defined(i)
|
||||
if req.get('depends'): # new-style XML depends specification
|
||||
dep = cdepends(req.get('depends'))
|
||||
key += ' && ' + ('(' + dep + ')' if '||' in dep else dep)
|
||||
cmdrefs = req.findall('command')
|
||||
for cmdref in cmdrefs:
|
||||
ver = cmdversions.get(cmdref.get('name'))
|
||||
if ver:
|
||||
command_groups.setdefault(key + ' && ' + name.upper() + '_SPEC_VERSION >= ' + str(ver), []).append(cmdref.get('name'))
|
||||
else:
|
||||
command_groups.setdefault(key, []).append(cmdref.get('name'))
|
||||
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] = ''
|
||||
|
||||
devp = {}
|
||||
instp = {}
|
||||
|
||||
for (group, cmdnames) in command_groups.items():
|
||||
ifdef = '#if ' + group + '\n'
|
||||
|
||||
for key in block_keys:
|
||||
blocks[key] += ifdef
|
||||
|
||||
devt = 0
|
||||
devo = len(blocks['DEVICE_TABLE'])
|
||||
instt = 0
|
||||
insto = len(blocks['INSTANCE_TABLE'])
|
||||
|
||||
for name in sorted(cmdnames):
|
||||
cmd = commands[name]
|
||||
type = cmd.findtext('param[1]/type')
|
||||
|
||||
if name == 'vkGetInstanceProcAddr':
|
||||
type = ''
|
||||
if name == 'vkGetDeviceProcAddr':
|
||||
type = 'VkInstance'
|
||||
|
||||
extern_fn = 'extern PFN_' + name + ' ' + name + ';\n'
|
||||
load_fn = '\t' + name + ' = (PFN_' + name + ')load(context, "' + name + '");\n'
|
||||
def_table = '\tPFN_' + name + ' ' + name + ';\n'
|
||||
load_table = '\ttable->' + name + ' = (PFN_' + name + ')load(context, "' + name + '");\n'
|
||||
|
||||
if is_descendant_type(types, type, 'VkDevice') and name not in instance_commands:
|
||||
blocks['LOAD_DEVICE'] += load_fn
|
||||
blocks['DEVICE_TABLE'] += def_table
|
||||
blocks['LOAD_DEVICE_TABLE'] += load_table
|
||||
blocks['PROTOTYPES_H_DEVICE'] += extern_fn
|
||||
devt += 1
|
||||
elif is_descendant_type(types, type, 'VkInstance'):
|
||||
blocks['LOAD_INSTANCE'] += load_fn
|
||||
blocks['PROTOTYPES_H'] += extern_fn
|
||||
blocks['INSTANCE_TABLE'] += def_table
|
||||
blocks['LOAD_INSTANCE_TABLE'] += load_table
|
||||
instt += 1
|
||||
elif type != '':
|
||||
blocks['LOAD_LOADER'] += load_fn
|
||||
blocks['PROTOTYPES_H'] += extern_fn
|
||||
else:
|
||||
blocks['PROTOTYPES_H'] += extern_fn
|
||||
|
||||
blocks['PROTOTYPES_C'] += 'PFN_' + name + ' ' + name + ';\n'
|
||||
|
||||
for key in block_keys:
|
||||
if blocks[key].endswith(ifdef):
|
||||
blocks[key] = blocks[key][:-len(ifdef)]
|
||||
elif key == 'DEVICE_TABLE':
|
||||
devh = zlib.crc32(blocks[key][devo:].encode())
|
||||
assert(devh not in devp)
|
||||
devp[devh] = True
|
||||
|
||||
blocks[key] += '#else\n'
|
||||
blocks[key] += f'\tPFN_vkVoidFunction padding_{devh:x}[{devt}];\n'
|
||||
blocks[key] += '#endif /* ' + group + ' */\n'
|
||||
elif key == 'INSTANCE_TABLE':
|
||||
insth = zlib.crc32(blocks[key][insto:].encode())
|
||||
assert(insth not in instp)
|
||||
instp[insth] = True
|
||||
|
||||
blocks[key] += '#else\n'
|
||||
blocks[key] += f'\tPFN_vkVoidFunction padding_{insth:x}[{instt}];\n'
|
||||
blocks[key] += '#endif /* ' + group + ' */\n'
|
||||
else:
|
||||
blocks[key] += '#endif /* ' + group + ' */\n'
|
||||
|
||||
patch_file('volk.h', blocks)
|
||||
patch_file('volk.c', blocks)
|
||||
patch_file('CMakeLists.txt', blocks)
|
||||
|
||||
print(version.find('name').tail.strip())
|
||||
crates/pyrowave-sys/vendor/pyrowave/Granite/third_party/volk/test/cmake_cpp_namespace/CMakeLists.txt
Vendored
+26
@@ -0,0 +1,26 @@
|
||||
# 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.
|
||||
# Also use C++ namespace feature to make it so that volk doesn't override vk* symbols
|
||||
|
||||
cmake_minimum_required(VERSION 3.5...3.30)
|
||||
project(volk_test LANGUAGES CXX)
|
||||
|
||||
# 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()
|
||||
|
||||
# Enable volk C++ namespace feature; this only works when volk is compiled and used from C++
|
||||
set(VOLK_NAMESPACE ON)
|
||||
|
||||
# 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.cpp)
|
||||
target_link_libraries(volk_test PRIVATE volk)
|
||||
Vendored
+41
@@ -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;
|
||||
}
|
||||
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
cmake_minimum_required(VERSION 3.5...3.30)
|
||||
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)
|
||||
+54
@@ -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;
|
||||
}
|
||||
|
||||
+40
@@ -0,0 +1,40 @@
|
||||
# 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.5...3.30)
|
||||
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)
|
||||
# Note: We don't use target_link_libraries for Vulkan::Vulkan to avoid a static dependency on libvulkan1
|
||||
target_include_directories(volk_test PRIVATE ${Vulkan_INCLUDE_DIRS})
|
||||
elseif(DEFINED ENV{VULKAN_SDK})
|
||||
target_include_directories(volk_test PRIVATE "$ENV{VULKAN_SDK}/include")
|
||||
endif()
|
||||
crates/pyrowave-sys/vendor/pyrowave/Granite/third_party/volk/test/cmake_using_source_directly/main.c
Vendored
+41
@@ -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;
|
||||
}
|
||||
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
# Include the volk target through add_subdirectory.
|
||||
|
||||
cmake_minimum_required(VERSION 3.5...3.30)
|
||||
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)
|
||||
Vendored
+53
@@ -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;
|
||||
}
|
||||
|
||||
+22
@@ -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.5...3.30)
|
||||
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)
|
||||
Vendored
+41
@@ -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;
|
||||
}
|
||||
|
||||
+100
@@ -0,0 +1,100 @@
|
||||
#!/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
|
||||
|
||||
echo
|
||||
echo "cmake_cpp_namespace =================================================>"
|
||||
echo
|
||||
|
||||
pushd test/cmake_cpp_namespace
|
||||
reset_build
|
||||
pushd _build
|
||||
cmake .. || exit 1
|
||||
cmake --build . || exit 1
|
||||
run_volk_test
|
||||
popd
|
||||
popd
|
||||
|
||||
popd
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user