Vendor vulkan-tools

This commit is contained in:
Luke Street 2022-05-09 00:42:07 -04:00
parent 71969bda5f
commit c948b26cc5
156 changed files with 58852 additions and 1 deletions

View File

@ -20,7 +20,6 @@ rm -rf third_party/vulkan_memory_allocator
rm -rf third_party/vulkan-deps/glslang rm -rf third_party/vulkan-deps/glslang
rm -rf third_party/vulkan-deps/spirv-cross rm -rf third_party/vulkan-deps/spirv-cross
rm -rf third_party/vulkan-deps/vulkan-loader rm -rf third_party/vulkan-deps/vulkan-loader
rm -rf third_party/vulkan-deps/vulkan-tools
rm -rf third_party/vulkan-deps/vulkan-validation-layers rm -rf third_party/vulkan-deps/vulkan-validation-layers
rm -rf third_party/webgpu-cts rm -rf third_party/webgpu-cts
rm -rf third_party/zlib rm -rf third_party/zlib

View File

@ -0,0 +1,14 @@
Name: Khronos Vulkan Tools Components
Short Name: Vulkan Tools
Version: N/A
URL: https://github.com/KhronosGroup/Vulkan-Tools
SOURCE CODE: git clone https://github.com/KhronosGroup/Vulkan-Tools.git
Revision: HEAD
Security Critical: no
License: Apache 2.0
License File: src/LICENSE.txt
Description:
The Khronos Vulkan Tools Components contain the Vulkan Mock Installable
Client Driver (ICD) as well as the vulkaninfo utility.

View File

@ -0,0 +1,8 @@
---
# Use defaults from the Google style with the following exceptions:
BasedOnStyle: Google
IndentWidth: 4
AccessModifierOffset: -2
ColumnLimit: 132
SortIncludes: false
...

View File

@ -0,0 +1,34 @@
# Configuration for cmake-format (v0.4.1, circa Jul 2018)
# https://github.com/cheshirekow/cmake_format
# How wide to allow formatted cmake files
line_width = 132
# How many spaces to tab for indent
tab_size = 4
# If arglists are longer than this, break them always
max_subargs_per_line = 3
# If true, separate flow control names from their parentheses with a space
separate_ctrl_name_with_space = False
# If true, separate function names from parentheses with a space
separate_fn_name_with_space = False
# If a statement is wrapped to more than one line, than dangle the closing
# parenthesis on it's own line
dangle_parens = False
# What character to use for bulleted lists
bullet_char = u'*'
# What character to use as punctuation after numerals in an enumerated list
enum_char = u'.'
# What style line endings to use in the output.
line_ending = u'unix'
# Format command names consistently as 'lower' or 'upper' case
command_case = u'lower'

View File

@ -0,0 +1,20 @@
# See https://git-scm.com/docs/gitattributes
# See https://help.github.com/articles/dealing-with-line-endings/
# Default behavior, if core.autocrlf is unset.
* text=auto
# Files to be converted to native line endings on checkout.
*.cpp text
*.h text
# Text files to always have CRLF (dos) line endings on checkout.
*.bat text eol=crlf
# Text files to always have LF (unix) line endings on checkout.
*.sh text eol=lf
# Generated source files will always have LF (unix) line endings on checkout.
icd/generated/*.cpp text eol=lf
icd/generated/*.h text eol=lf
vulkaninfo/generated/*.hpp text eol=lf

View File

@ -0,0 +1,160 @@
# Copyright (c) 2021 Valve Corporation
# Copyright (c) 2021 LunarG, Inc.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# Author: Jeremy Kniager <jeremyk@lunarg.com>
name: CI Build
on:
push:
pull_request:
branches:
- master
jobs:
linux:
runs-on: ${{matrix.os}}
strategy:
matrix:
cc: [ gcc, clang ]
cxx: [ g++, clang++ ]
config: [ Debug, Release ]
os: [ ubuntu-18.04, ubuntu-20.04 ]
exclude:
- cc: gcc
cxx: clang++
- cc: clang
cxx: g++
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
with:
python-version: '3.7'
- run: |
sudo apt-get -qq update
sudo apt install libxkbcommon-dev libwayland-dev libmirclient-dev libxrandr-dev libx11-xcb-dev wayland-protocols
- name: Fetch and install headers
run: python scripts/update_deps.py --dir external
- name: Generate build files
run: cmake -S. -Bbuild -DCMAKE_BUILD_TYPE=${{matrix.config}} -Cexternal/helper.cmake
env:
CC: ${{matrix.cc}}
CXX: ${{matrix.cxx}}
- name: Build the tools
run: make -C build
- name: Verify generated source files
run: python scripts/generate_source.py --verify external/Vulkan-Headers/registry
windows:
runs-on: ${{matrix.os}}
strategy:
matrix:
arch: [ Win32, x64 ]
config: [ Debug, Release ]
os: [ windows-latest ]
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
with:
python-version: '3.7'
- name: Fetch and install headers
run: python scripts/update_deps.py --dir external
- name: Generate build files
run: cmake -S. -Bbuild -A${{matrix.arch}} "-Cexternal/helper.cmake"
- name: Build the tools
run: cmake --build ./build --config ${{matrix.config}}
- name: Verify generated source files
run: python scripts/generate_source.py --verify external/Vulkan-Headers/registry
mac:
runs-on: macos-latest
strategy:
matrix:
config: [ Debug, Release ]
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
with:
python-version: '3.7'
- name: Fetch and install headers
run: python scripts/update_deps.py --dir external
- name: Generate build files
run: cmake -S. -Bbuild -DCMAKE_BUILD_TYPE=${{matrix.config}} -Cexternal/helper.cmake
- name: Build the tools
run: make -C build
- name: Verify generated source files
run: python scripts/generate_source.py --verify external/Vulkan-Headers/registry
gn:
runs-on: ubuntu-18.04
strategy:
matrix:
config: [ Debug, Release ]
steps:
- uses: actions/checkout@v2
- name: Get depot tools
run: |
git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git depot_tools
echo "$GITHUB_WORKSPACE/depot_tools" >> $GITHUB_PATH
- name: Fetch and install headers
run: ./build-gn/update_deps.sh
- name: Generate build files
run: gn gen out/${{matrix.config}} --args="is_debug=true"
if: matrix.config != 'Release'
- name: Generate build files
run: gn gen out/${{matrix.config}} --args="is_debug=false"
if: matrix.config == 'Release'
- name: Build the tools
run: ninja -C out/${{matrix.config}}
android:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
- name: Setup Environment
run: |
echo "ANDROID_SDK_HOME=$ANDROID_SDK_ROOT" >> $GITHUB_ENV
echo "$ANDROID_SDK_ROOT/build-tools/31.0.0" >> $GITHUB_PATH
echo "$ANDROID_NDK_ROOT" >> $GITHUB_PATH
$ANDROID_SDK_ROOT/tools/bin/sdkmanager "platforms;android-23"
keytool -genkey -v -keystore $HOME/.android/debug.keystore -storepass android -alias androiddebugkey -keypass android -keyalg RSA -keysize 2048 -validity 10000 -dname "C=US, O=Android, CN=Android Debug"
- name: Build vkcube
run: |
cd build-android
./build_all.sh

View File

@ -0,0 +1,30 @@
CMakeCache.txt
CMakeLists.txt.user
CMakeFiles/
cmake_install.cmake
Makefile
glslang/*
scripts/__pycache__
*.so
*.so.*
_out64
out32/*
out64/*
*.pyc
*.vcproj
*.sln
*.suo
*.vcxproj
*.sdf
*.filters
build
build32
dbuild
build-android/external
*.config
*.creator
*.creator.user
*.files
*.includes
.vscode/
.DS_Store

View File

@ -0,0 +1,22 @@
# Copyright (C) 2019 LunarG, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
buildconfig = "//build/config/BUILDCONFIG.gn"
secondary_source = "//build-gn/secondary/"
default_args = {
clang_use_chrome_plugins = false
use_custom_libcxx = false
}

View File

@ -0,0 +1,102 @@
# Copyright (C) 2018-2019 The ANGLE Project Authors.
# Copyright (C) 2019 LunarG, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import("//build_overrides/build.gni")
import("//build_overrides/vulkan_tools.gni")
# Vulkan-tools isn't ported to Fuchsia yet.
# TODO(spang): Port mock ICD to Fuchsia.
assert(!is_fuchsia)
vulkan_undefine_configs = []
if (is_win && build_with_chromium) {
vulkan_undefine_configs += [
"//build/config/win:nominmax",
"//build/config/win:unicode",
]
}
raw_vulkan_icd_dir = rebase_path("icd", root_build_dir)
vulkan_data_dir = "$root_out_dir/$vulkan_data_subdir"
raw_vulkan_data_dir = rebase_path(vulkan_data_dir, root_build_dir)
config("vulkan_internal_config") {
defines = [ "VULKAN_NON_CMAKE_BUILD" ]
if (is_clang || !is_win) {
cflags = [ "-Wno-unused-function" ]
}
if (is_linux || is_chromeos) {
defines += [
"SYSCONFDIR=\"/etc\"",
"FALLBACK_CONFIG_DIRS=\"/etc/xdg\"",
"FALLBACK_DATA_DIRS=\"/usr/local/share:/usr/share\"",
]
}
}
# Vulkan tool generated utility headers
source_set("vulkan_tools_headers") {
public_deps = [ "$vulkan_headers_dir:vulkan_headers" ]
sources = [
"icd/generated/vk_typemap_helper.h",
]
}
if (!is_android) {
# Vulkan Mock ICD
# ---------------
shared_library("VkICD_mock_icd") {
configs -= vulkan_undefine_configs
deps = [ ":vulkan_tools_headers" ]
public_deps = [ "$vulkan_headers_dir:vulkan_headers" ]
data_deps = [ ":vulkan_gen_icd_json_file" ]
sources = [
"icd/generated/mock_icd.cpp",
"icd/generated/mock_icd.h",
]
if (is_win) {
sources += [ "icd/VkICD_mock_icd.def" ]
}
if (build_with_chromium) {
configs -= [ "//build/config/compiler:chromium_code" ]
configs += [ "//build/config/compiler:no_chromium_code" ]
}
}
action("vulkan_gen_icd_json_file") {
script = "build-gn/generate_vulkan_layers_json.py"
public_deps = [ "$vulkan_headers_dir:vulkan_headers" ]
sources = [ "$vulkan_headers_dir/include/vulkan/vulkan_core.h" ]
args = [ "--icd" ]
if (is_win) {
sources += [ "icd/windows/VkICD_mock_icd.json" ]
args += [ "$raw_vulkan_icd_dir/windows" ]
}
if (is_linux || is_chromeos) {
sources += [ "icd/linux/VkICD_mock_icd.json" ]
args += [ "$raw_vulkan_icd_dir/linux" ]
}
if (is_mac) {
sources += [ "icd/macos/VkICD_mock_icd.json" ]
args += [ "$raw_vulkan_icd_dir/macos" ]
}
# The layer JSON files are part of the necessary data deps.
outputs = [ "$vulkan_data_dir/VkICD_mock_icd.json" ]
data = outputs
args += [ raw_vulkan_data_dir ] + rebase_path(sources, root_build_dir)
}
}

View File

@ -0,0 +1,786 @@
# Build Instructions
Instructions for building this repository on Linux, Windows, Android, and MacOS.
## Index
1. [Contributing](#contributing-to-the-repository)
1. [Repository Content](#repository-content)
1. [Repository Set-Up](#repository-set-up)
1. [Windows Build](#building-on-windows)
1. [Linux Build](#building-on-linux)
1. [Android Build](#building-on-android)
1. [MacOS build](#building-on-macos)
## Contributing to the Repository
If you intend to contribute, the preferred work flow is for you to develop
your contribution in a fork of this repository in your GitHub account and then
submit a pull request. Please see the [CONTRIBUTING.md](CONTRIBUTING.md) file
in this repository for more details.
## Repository Content
This repository contains the source code necessary to build the following components:
- vulkaninfo
- vkcube and vkcubepp demos
- mock ICD
### Installed Files
The `install` target installs the following files under the directory
indicated by *install_dir*:
- *install_dir*`/bin` : The vulkaninfo, vkcube and vkcubepp executables
- *install_dir*`/lib` : The mock ICD library and JSON (Windows) (If INSTALL_ICD=ON)
- *install_dir*`/share/vulkan/icd.d` : mock ICD JSON (Linux/MacOS) (If INSTALL_ICD=ON)
The `uninstall` target can be used to remove the above files from the install
directory.
## Repository Set-Up
### Display Drivers
This repository does not contain a Vulkan-capable driver. You will need to
obtain and install a Vulkan driver from your graphics hardware vendor or from
some other suitable source if you intend to run Vulkan applications.
### Download the Repository
To create your local git repository:
git clone https://github.com/KhronosGroup/Vulkan-Tools.git
### Repository Dependencies
This repository attempts to resolve some of its dependencies by using
components found from the following places, in this order:
1. CMake or Environment variable overrides (e.g., -DVULKAN_HEADERS_INSTALL_DIR)
1. LunarG Vulkan SDK, located by the `VULKAN_SDK` environment variable
1. System-installed packages, mostly applicable on Linux
Dependencies that cannot be resolved by the SDK or installed packages must be
resolved with the "install directory" override and are listed below. The
"install directory" override can also be used to force the use of a specific
version of that dependency.
#### Vulkan-Headers
This repository has a required dependency on the
[Vulkan Headers repository](https://github.com/KhronosGroup/Vulkan-Headers).
You must clone the headers repository and build its `install` target before
building this repository. The Vulkan-Headers repository is required because it
contains the Vulkan API definition files (registry) that are required to build
the mock ICD. You must also take note of the headers install directory and
pass it on the CMake command line for building this repository, as described
below.
Note that this dependency can be ignored if not building the mock ICD
(CMake option: `-DBUILD_ICD=OFF`).
#### glslang
This repository has a required dependency on the `glslangValidator` (shader
compiler) for compiling the shader programs for the vkcube demos.
The CMake code in this repository downloads release binaries of glslang if a
build glslang repository is not provided. The glslangValidator is obtained
from this set of release binaries.
If you don't wish the CMake code to download these binaries, then you must
clone the [glslang repository](https://github.com/KhronosGroup/glslang) and
build its `install` target. Follow the build instructions in the glslang
[README.md](https://github.com/KhronosGroup/glslang/blob/master/README.md)
file. Ensure that the `update_glslang_sources.py` script has been run as part
of building glslang. You must also take note of the glslang install directory
and pass it on the CMake command line for building this repository, as
described below.
Note that this dependency can be ignored if not building the vkcube demo
(CMake option: `-DBUILD_CUBE=OFF`).
### Build and Install Directories
A common convention is to place the build directory in the top directory of
the repository with a name of `build` and place the install directory as a
child of the build directory with the name `install`. The remainder of these
instructions follow this convention, although you can use any name for these
directories and place them in any location.
### Building Dependent Repositories with Known-Good Revisions
There is a Python utility script, `scripts/update_deps.py`, that you can use to
gather and build the dependent repositories mentioned above. This script uses
information stored in the `scripts/known_good.json` file to check out dependent
repository revisions that are known to be compatible with the revision of this
repository that you currently have checked out. As such, this script is useful
as a quick-start tool for common use cases and default configurations.
For all platforms, start with:
git clone git@github.com:KhronosGroup/Vulkan-Tools.git
cd Vulkan-Tools
mkdir build
cd build
For 64-bit Linux and MacOS, continue with:
../scripts/update_deps.py
cmake -C helper.cmake ..
cmake --build .
For 64-bit Windows, continue with:
..\scripts\update_deps.py --arch x64
cmake -A x64 -C helper.cmake ..
cmake --build .
For 32-bit Windows, continue with:
..\scripts\update_deps.py --arch Win32
cmake -A Win32 -C helper.cmake ..
cmake --build .
Please see the more detailed build information later in this file if you have
specific requirements for configuring and building these components.
#### Notes
- You may need to adjust some of the CMake options based on your platform. See
the platform-specific sections later in this document.
- The `update_deps.py` script fetches and builds the dependent repositories in
the current directory when it is invoked. In this case, they are built in
the `build` directory.
- The `build` directory is also being used to build this
(Vulkan-Tools) repository. But there shouldn't be any conflicts
inside the `build` directory between the dependent repositories and the
build files for this repository.
- The `--dir` option for `update_deps.py` can be used to relocate the
dependent repositories to another arbitrary directory using an absolute or
relative path.
- The `update_deps.py` script generates a file named `helper.cmake` and places
it in the same directory as the dependent repositories (`build` in this
case). This file contains CMake commands to set the CMake `*_INSTALL_DIR`
variables that are used to point to the install artifacts of the dependent
repositories. You can use this file with the `cmake -C` option to set these
variables when you generate your build files with CMake. This lets you avoid
entering several `*_INSTALL_DIR` variable settings on the CMake command line.
- If using "MINGW" (Git For Windows), you may wish to run
`winpty update_deps.py` in order to avoid buffering all of the script's
"print" output until the end and to retain the ability to interrupt script
execution.
- Please use `update_deps.py --help` to list additional options and read the
internal documentation in `update_deps.py` for further information.
### Generated source code
This repository contains generated source code in the `icd/generated`
directory which is not intended to be modified directly. Instead, changes should be
made to the corresponding generator in the `scripts` directory. The source files can
then be regenerated using `scripts/generate_source.py`:
python3 scripts/generate_source.py PATH_TO_VULKAN_HEADERS_REGISTRY_DIR
A helper CMake target `VulkanTools_generated_source` is also provided to simplify
the invocation of `scripts/generate_source.py` from the build directory:
cmake --build . --target VulkanTools_generated_source
### Build Options
When generating native platform build files through CMake, several options can
be specified to customize the build. Some of the options are binary on/off
options, while others take a string as input. The following is a table of all
on/off options currently supported by this repository:
| Option | Platform | Default | Description |
| ------ | -------- | ------- | ----------- |
| BUILD_CUBE | All | `ON` | Controls whether or not the vkcube demo is built. |
| BUILD_VULKANINFO | All | `ON` | Controls whether or not the vulkaninfo utility is built. |
| BUILD_ICD | All | `ON` | Controls whether or not the mock ICD is built. |
| INSTALL_ICD | All | `OFF` | Controls whether or not the mock ICD is installed as part of the install target. |
| BUILD_WSI_XCB_SUPPORT | Linux | `ON` | Build the components with XCB support. |
| BUILD_WSI_XLIB_SUPPORT | Linux | `ON` | Build the components with Xlib support. |
| BUILD_WSI_WAYLAND_SUPPORT | Linux | `ON` | Build the components with Wayland support. |
| BUILD_WSI_DIRECTFB_SUPPORT | Linux | `OFF` | Build the components with DirectFB support. |
| USE_CCACHE | Linux | `OFF` | Enable caching with the CCache program. |
The following is a table of all string options currently supported by this repository:
| Option | Platform | Default | Description |
| ------ | -------- | ------- | ----------- |
| CMAKE_OSX_DEPLOYMENT_TARGET | MacOS | `10.12` | The minimum version of MacOS for loader deployment. |
| VULKANINFO_BUILD_DLL_VERSIONINFO | Windows | `""` | Set the Windows specific version information for Vulkaninfo. Format is "major.minor.patch.build". |
These variables should be set using the `-D` option when invoking CMake to
generate the native platform files.
## Building On Windows
### Windows Development Environment Requirements
- Windows
- Any Personal Computer version supported by Microsoft
- Microsoft [Visual Studio](https://www.visualstudio.com/)
- Versions
- [2013 (update 4)](https://www.visualstudio.com/vs/older-downloads/)
- [2015](https://www.visualstudio.com/vs/older-downloads/)
- [2017](https://www.visualstudio.com/vs/downloads/)
- The Community Edition of each of the above versions is sufficient, as
well as any more capable edition.
- [CMake 3.10.2](https://cmake.org/files/v3.10/cmake-3.10.2-win64-x64.zip) is recommended.
- Use the installer option to add CMake to the system PATH
- Git Client Support
- [Git for Windows](http://git-scm.com/download/win) is a popular solution
for Windows
- Some IDEs (e.g., [Visual Studio](https://www.visualstudio.com/),
[GitHub Desktop](https://desktop.github.com/)) have integrated
Git client support
### Windows Build - Microsoft Visual Studio
The general approach is to run CMake to generate the Visual Studio project
files. Then either run CMake with the `--build` option to build from the
command line or use the Visual Studio IDE to open the generated solution and
work with the solution interactively.
#### Windows Quick Start
cd Vulkan-Tools
mkdir build
cd build
cmake -A x64 -DVULKAN_HEADERS_INSTALL_DIR=absolute_path_to_install_dir
cmake --build .
The above commands instruct CMake to find and use the default Visual Studio
installation to generate a Visual Studio solution and projects for the x64
architecture. The second CMake command builds the Debug (default)
configuration of the solution.
See below for the details.
#### Use `CMake` to Create the Visual Studio Project Files
Change your current directory to the top of the cloned repository directory,
create a build directory and generate the Visual Studio project files:
cd Vulkan-Tools
mkdir build
cd build
cmake -A x64 -DVULKAN_HEADERS_INSTALL_DIR=absolute_path_to_install_dir
> Note: The `..` parameter tells `cmake` the location of the top of the
> repository. If you place your build directory someplace else, you'll need to
> specify the location of the repository top differently.
The `-A` option is used to select either the "Win32" or "x64" architecture.
If a generator for a specific version of Visual Studio is required, you can
specify it for Visual Studio 2015, for example, with:
64-bit: -G "Visual Studio 14 2015 Win64"
32-bit: -G "Visual Studio 14 2015"
See this [list](#cmake-visual-studio-generators) of other possible generators
for Visual Studio.
When generating the project files, the absolute path to a Vulkan-Headers
install directory must be provided. This can be done by setting the
`VULKAN_HEADERS_INSTALL_DIR` environment variable or by setting the
`VULKAN_HEADERS_INSTALL_DIR` CMake variable with the `-D` CMake option. In
either case, the variable should point to the installation directory of a
Vulkan-Headers repository built with the install target.
The above steps create a Windows solution file named
`Vulkan-Tools.sln` in the build directory.
At this point, you can build the solution from the command line or open the
generated solution with Visual Studio.
#### Build the Solution From the Command Line
While still in the build directory:
cmake --build .
to build the Debug configuration (the default), or:
cmake --build . --config Release
to make a Release build.
#### Build the Solution With Visual Studio
Launch Visual Studio and open the "Vulkan-Tools.sln" solution file in the
build folder. You may select "Debug" or "Release" from the Solution
Configurations drop-down list. Start a build by selecting the Build->Build
Solution menu item.
#### Windows Install Target
The CMake project also generates an "install" target that you can use to copy
the primary build artifacts to a specific location using a "bin, include, lib"
style directory structure. This may be useful for collecting the artifacts and
providing them to another project that is dependent on them.
The default location is `$CMAKE_BINARY_DIR\install`, but can be changed with
the `CMAKE_INSTALL_PREFIX` variable when first generating the project build
files with CMake.
You can build the install target from the command line with:
cmake --build . --config Release --target install
or build the `INSTALL` target from the Visual Studio solution explorer.
#### Using a Loader Built from a Repository
If you do need to build and use your own loader, build the Vulkan-Loader
repository with the install target and modify your CMake invocation to add the
location of the loader's install directory:
cmake -A x64 -DVULKAN_HEADERS_INSTALL_DIR=absolute_path_to_install_dir \
-DVULKAN_LOADER_INSTALL_DIR=absolute_path_to_install_dir ..
#### Using glslang Built from a Repository
If you do need to build and use your own glslang, build the glslang repository
with the install target and modify your CMake invocation to add the location
of the glslang's install directory:
cmake -A x64 -DVULKAN_HEADERS_INSTALL_DIR=absolute_path_to_install_dir \
-DGLSLANG_INSTALL_DIR=absolute_path_to_install_dir ..
### Windows Notes
#### CMake Visual Studio Generators
The chosen generator should match one of the Visual Studio versions that you
have installed. Generator strings that correspond to versions of Visual Studio
include:
| Build Platform | 64-bit Generator | 32-bit Generator |
|------------------------------|-------------------------------|-------------------------|
| Microsoft Visual Studio 2013 | "Visual Studio 12 2013 Win64" | "Visual Studio 12 2013" |
| Microsoft Visual Studio 2015 | "Visual Studio 14 2015 Win64" | "Visual Studio 14 2015" |
| Microsoft Visual Studio 2017 | "Visual Studio 15 2017 Win64" | "Visual Studio 15 2017" |
## Building On Linux
### Linux Build Requirements
This repository has been built and tested on the two most recent Ubuntu LTS
versions. Currently, the oldest supported version is Ubuntu 16.04, meaning
that the minimum officially supported C++11 compiler version is GCC 5.4.0,
although earlier versions may work. It should be straightforward to adapt this
repository to other Linux distributions.
[CMake 3.10.2](https://cmake.org/files/v3.10/cmake-3.10.2-Linux-x86_64.tar.gz) is recommended.
#### Required Package List
sudo apt-get install git cmake build-essential libx11-xcb-dev \
libxkbcommon-dev libwayland-dev libxrandr-dev wayland-protocols
### Linux Build
The general approach is to run CMake to generate make files. Then either run
CMake with the `--build` option or `make` to build from the command line.
#### Linux Quick Start
cd Vulkan-Tools
mkdir build
cd build
cmake -DVULKAN_HEADERS_INSTALL_DIR=absolute_path_to_install_dir ..
make
See below for the details.
#### Use CMake to Create the Make Files
Change your current directory to the top of the cloned repository directory,
create a build directory and generate the make files.
cd Vulkan-Tools
mkdir build
cd build
cmake -DCMAKE_BUILD_TYPE=Debug \
-DVULKAN_HEADERS_INSTALL_DIR=absolute_path_to_install_dir \
-DCMAKE_INSTALL_PREFIX=install ..
> Note: The `..` parameter tells `cmake` the location of the top of the
> repository. If you place your `build` directory someplace else, you'll need
> to specify the location of the repository top differently.
Use `-DCMAKE_BUILD_TYPE` to specify a Debug or Release build.
When generating the project files, the absolute path to a Vulkan-Headers
install directory must be provided. This can be done by setting the
`VULKAN_HEADERS_INSTALL_DIR` environment variable or by setting the
`VULKAN_HEADERS_INSTALL_DIR` CMake variable with the `-D` CMake option. In
either case, the variable should point to the installation directory of a
Vulkan-Headers repository built with the install target.
> Note: For Linux, the default value for `CMAKE_INSTALL_PREFIX` is
> `/usr/local`, which would be used if you do not specify
> `CMAKE_INSTALL_PREFIX`. In this case, you may need to use `sudo` to install
> to system directories later when you run `make install`.
#### Build the Project
You can just run `make` to begin the build.
To speed up the build on a multi-core machine, use the `-j` option for `make`
to specify the number of cores to use for the build. For example:
make -j4
You can also use
cmake --build .
If your build system supports ccache, you can enable that via CMake option `-DUSE_CCACHE=On`
### Linux Notes
#### WSI Support Build Options
By default, the repository components are built with support for the
Vulkan-defined WSI display servers: Xcb, Xlib, and Wayland. It is recommended
to build the repository components with support for these display servers to
maximize their usability across Linux platforms. If it is necessary to build
these modules without support for one of the display servers, the appropriate
CMake option of the form `BUILD_WSI_xxx_SUPPORT` can be set to `OFF`.
Note vulkaninfo currently only supports Xcb and Xlib WSI display servers. See
the CMakeLists.txt file in `Vulkan-Tools/vulkaninfo` for more info.
You can select which WSI subsystem is used to execute the vkcube applications
using a CMake option called CUBE_WSI_SELECTION. Supported options are XCB
(default), XLIB, and WAYLAND. Note that you must build using the corresponding
BUILD_WSI_*_SUPPORT enabled at the base repository level. For instance,
creating a build that will use Xlib when running the vkcube demos, your CMake
command line might look like:
cmake -DCMAKE_BUILD_TYPE=Debug -DCUBE_WSI_SELECTION=XLIB ..
#### Linux Install to System Directories
Installing the files resulting from your build to the systems directories is
optional since environment variables can usually be used instead to locate the
binaries. There are also risks with interfering with binaries installed by
packages. If you are certain that you would like to install your binaries to
system directories, you can proceed with these instructions.
Assuming that you've built the code as described above and the current
directory is still `build`, you can execute:
sudo make install
This command installs files to `/usr/local` if no `CMAKE_INSTALL_PREFIX` is
specified when creating the build files with CMake.
You may need to run `ldconfig` in order to refresh the system loader search
cache on some Linux systems.
You can further customize the installation location by setting additional
CMake variables to override their defaults. For example, if you would like to
install to `/tmp/build` instead of `/usr/local`, on your CMake command line
specify:
-DCMAKE_INSTALL_PREFIX=/tmp/build
Then run `make install` as before. The install step places the files in
`/tmp/build`. This may be useful for collecting the artifacts and providing
them to another project that is dependent on them.
Note: The Mock ICD is not installed by default since it is a "null" driver
that does not render anything and is used for testing purposes. Installing it
to system directories may cause some applications to discover and use this
driver instead of other full drivers installed on the system. If you really
want to install this null driver, use:
-DINSTALL_ICD=ON
See the CMake documentation for more details on using these variables to
further customize your installation.
Also see the `LoaderAndLayerInterface` document in the `loader` folder of the
Vulkan-Loader repository for more information about loader and layer
operation.
#### Linux Uninstall
To uninstall the files from the system directories, you can execute:
sudo make uninstall
### Linux Tests
After making any changes to the repository, you should perform some quick
sanity tests, such as running the vkcube demo with validation enabled.
To run the **vkcube application** with validation, in a terminal change to the
`build/cube` directory and run:
VK_LAYER_PATH=../path/to/validation/layers ./vkcube --validate
If you have an SDK installed and have run the setup script to set the
`VULKAN_SDK` environment variable, it may be unnecessary to specify a
`VK_LAYER_PATH`.
#### Linux 32-bit support
Usage of the contents of this repository in 32-bit Linux environments is not
officially supported. However, since this repository is supported on 32-bit
Windows, these modules should generally work on 32-bit Linux.
Here are some notes for building 32-bit targets on a 64-bit Ubuntu "reference"
platform:
If not already installed, install the following 32-bit development libraries:
`gcc-multilib g++-multilib libx11-dev:i386`
This list may vary depending on your distribution and which windowing systems
you are building for.
Set up your environment for building 32-bit targets:
export ASFLAGS=--32
export CFLAGS=-m32
export CXXFLAGS=-m32
export PKG_CONFIG_LIBDIR=/usr/lib/i386-linux-gnu
Again, your PKG_CONFIG configuration may be different, depending on your
distribution.
Finally, rebuild the repository using `cmake` and `make`, as explained above.
## Building On Android
Install the required tools for Linux and Windows covered above, then add the
following.
### Android Build Requirements
- Install [Android Studio 2.3](https://developer.android.com/studio/index.html) or later.
- From the "Welcome to Android Studio" splash screen, add the following components using
Configure > SDK Manager:
- SDK Platforms > Android 6.0 and newer
- SDK Tools > Android SDK Build-Tools
- SDK Tools > Android SDK Platform-Tools
- SDK Tools > NDK (Side by side)
#### Add Android specifics to environment
For each of the below, you may need to specify a different build-tools and ndk
versions, as Android Studio will roll them forward fairly regularly.
On Linux:
export ANDROID_SDK_HOME=$HOME/Android/sdk
export ANDROID_NDK_HOME=$HOME/Android/sdk/ndk/23.0.7599858
export PATH=$ANDROID_NDK_HOME:$PATH
export PATH=$ANDROID_SDK_HOME/platform-tools:$PATH
export PATH=$ANDROID_SDK_HOME/build-tools/31.0.0:$PATH
On Windows:
set ANDROID_SDK_HOME=%LOCALAPPDATA%\Android\sdk
set ANDROID_NDK_HOME=%LOCALAPPDATA%\Android\sdk\ndk\23.0.7599858
set PATH=%ANDROID_NDK_HOME%;%PATH%
set PATH=%ANDROID_SDK_HOME%\platform-tools;%PATH%
set PATH=%ANDROID_SDK_HOME%\build-tools\31.0.0;%PATH%
On OSX:
export ANDROID_SDK_HOME=$HOME/Library/Android/sdk
export ANDROID_NDK_HOME=$HOME/Library/Android/sdk/ndk/23.0.7599858
export PATH=$ANDROID_NDK_PATH:$PATH
export PATH=$ANDROID_SDK_HOME/platform-tools:$PATH
export PATH=$ANDROID_SDK_HOME/build-tools/31.0.0:$PATH
Note: If `jarsigner` is missing from your platform, you can find it in the
Android Studio install or in your Java installation. If you do not have Java,
you can get it with something like the following:
sudo apt-get install openjdk-8-jdk
### Android Build
Use the following script to build the vkcube demo for Android:
cd build-android
./build_all.sh
The APK can be installed on production devices with:
./install_all.sh [-s <serial number>]
Note that there are no equivalent scripts on Windows yet, that work needs to
be completed.
### Run vkcube
Use the following command to run vkcube for Android:
adb shell am start com.example.VkCube/android.app.NativeActivity
## Building on MacOS
### MacOS Build Requirements
Tested on OSX version 10.12.6
- [CMake 3.10.2](https://cmake.org/files/v3.10/cmake-3.10.2-Darwin-x86_64.tar.gz) is recommended.
Setup Homebrew and components
- Follow instructions on [brew.sh](http://brew.sh) to get Homebrew installed.
/usr/bin/ruby -e "$(curl -fsSL \
https://raw.githubusercontent.com/Homebrew/install/master/install)"
- Ensure Homebrew is at the beginning of your PATH:
export PATH=/usr/local/bin:$PATH
- Add packages with the following (may need refinement)
brew install python python3 git
### Clone the Repository
Clone the Vulkan-Tools repository as defined above in the [Download the Repository](#download-the-repository)
section.
### Get the External Libraries
[MoltenVK](https://github.com/KhronosGroup/MoltenVK) Library
- Building the vkcube and vulkaninfo applications require linking to the
MoltenVK Library (libMoltenVK.dylib)
- The following option should be used on the cmake command line to specify a
vulkan loader library: MOLTENVK_REPO_ROOT=/absolute_path_to/MoltenVK
making sure to specify an absolute path, like so: cmake
-DMOLTENVK_REPO_ROOT=/absolute_path_to/MoltenVK ....
Vulkan Loader Library
- Building the vkcube and vulkaninfo applications require linking to the Vulkan
Loader Library (libvulkan.1.dylib)
- The following option should be used on the cmake command line to specify a
vulkan loader library:
VULKAN_LOADER_INSTALL_DIR=/absolute_path_to/Vulkan-Loader_install_dir
making sure to specify an absolute path.
### MacOS build
#### CMake Generators
This repository uses CMake to generate build or project files that are then
used to build the repository. The CMake generators explicitly supported in
this repository are:
- Unix Makefiles
- Xcode
#### Building with the Unix Makefiles Generator
This generator is the default generator, so all that is needed for a debug
build is:
mkdir build
cd build
cmake -DCMAKE_BUILD_TYPE=Debug \
-DVULKAN_LOADER_INSTALL_DIR=/absolute_path_to/Vulkan-Loader_install_dir \
-DMOLTENVK_REPO_ROOT=/absolute_path_to/MoltenVK \
-DCMAKE_INSTALL_PREFIX=install ..
make
To speed up the build on a multi-core machine, use the `-j` option for `make`
to specify the number of cores to use for the build. For example:
make -j4
You can now run the demo applications from the command line:
open cube/vkcube.app
open cube/vkcubepp.app
open vulkaninfo/vulkaninfo.app
Or you can locate them from `Finder` and launch them from there.
##### The Install Target and RPATH
The applications you just built are "bundled applications", but the
executables are using the `RPATH` mechanism to locate runtime dependencies
that are still in your build tree.
To see this, run this command from your `build` directory:
otool -l cube/cube.app/Contents/MacOS/vkcube
and note that the `vkcube` executable contains loader commands:
- `LC_LOAD_DYLIB` to load `libvulkan.1.dylib` via an `@rpath`
- `LC_RPATH` that contains an absolute path to the build location of the Vulkan loader
This makes the bundled application "non-transportable", meaning that it won't
run unless the Vulkan loader is on that specific absolute path. This is useful
for debugging the loader or other components built in this repository, but not
if you want to move the application to another machine or remove your build
tree.
To address this problem, run:
make install
This step copies the bundled applications to the location specified by
CMAKE_INSTALL_PREFIX and "cleans up" the `RPATH` to remove any external
references and performs other bundle fix-ups. After running `make install`,
run the `otool` command again from the `build/install` directory and note:
- `LC_LOAD_DYLIB` is now `@executable_path/../MacOS/libvulkan.1.dylib`
- `LC_RPATH` is no longer present
The "bundle fix-up" operation also puts a copy of the Vulkan loader into the
bundle, making the bundle completely self-contained and self-referencing.
##### The Non-bundled vulkaninfo Application
There is also a non-bundled version of the `vulkaninfo` application that you
can run from the command line:
vulkaninfo/vulkaninfo
If you run this from the build directory, vulkaninfo's RPATH is already
set to point to the Vulkan loader in the build tree, so it has no trouble
finding it. But the loader will not find the MoltenVK driver and you'll see a
message about an incompatible driver. To remedy this:
VK_ICD_FILENAMES=<path-to>/MoltenVK/Package/Latest/MoltenVK/macOS/MoltenVK_icd.json vulkaninfo/vulkaninfo
If you run `vulkaninfo` from the install directory, the `RPATH` in the
`vulkaninfo` application got removed and the OS needs extra help to locate
the Vulkan loader:
DYLD_LIBRARY_PATH=<path-to>/Vulkan-Loader/loader VK_ICD_FILENAMES=<path-to>/MoltenVK/Package/Latest/MoltenVK/macOS/MoltenVK_icd.json vulkaninfo/vulkaninfo
#### Building with the Xcode Generator
To create and open an Xcode project:
mkdir build-xcode
cd build-xcode
cmake -DVULKAN_LOADER_INSTALL_DIR=/absolute_path_to/Vulkan-Loader_install_dir -DMOLTENVK_REPO_ROOT=/absolute_path_to/MoltenVK -GXcode ..
open VULKAN.xcodeproj
Within Xcode, you can select Debug or Release builds in the project's Build
Settings. You can also select individual schemes for working with specific
applications like `vkcube`.

View File

@ -0,0 +1,205 @@
# ~~~
# Copyright (c) 2014-2018 Valve Corporation
# Copyright (c) 2014-2018 LunarG, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# ~~~
# CMake project initialization ---------------------------------------------------------------------------------------------------
# This section contains pre-project() initialization, and ends with the project() command.
cmake_minimum_required(VERSION 3.10.2)
# Apple: Must be set before enable_language() or project() as it may influence configuration of the toolchain and flags.
set(CMAKE_OSX_DEPLOYMENT_TARGET "10.12" CACHE STRING "Minimum OS X deployment version")
project(Vulkan-Tools)
# find_package(), include() and global project settings --------------------------------------------------------------------------
find_package(PythonInterp 3 QUIET)
# User-interface declarations ----------------------------------------------------------------------------------------------------
# This section contains variables that affect development GUIs (e.g. CMake GUI and IDEs), such as option(), folders, and variables
# with the CACHE property.
# Enable beta Vulkan extensions
add_definitions(-DVK_ENABLE_BETA_EXTENSIONS)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
option(BUILD_CUBE "Build cube" ON)
option(BUILD_VULKANINFO "Build vulkaninfo" ON)
option(BUILD_ICD "Build icd" ON)
# Installing the Mock ICD to system directories is probably not desired since this ICD is not a very complete implementation.
# Require the user to ask that it be installed if they really want it.
option(INSTALL_ICD "Install icd" OFF)
if(WIN32)
# Optional: Allow specify the exact version used in the vulkaninfo executable
# Format is major.minor.patch.build
set(VULKANINFO_BUILD_DLL_VERSIONINFO "" CACHE STRING "Set the version to be used in the vulkaninfo.rc file. Default value is 1.0.1111.2222")
endif()
# Enable IDE GUI folders
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
# "Helper" targets that don't have interesting source code should set their FOLDER property to this
set(TOOLS_HELPER_FOLDER "Helper Targets")
option(USE_CCACHE "Use ccache" OFF)
if(USE_CCACHE)
find_program(CCACHE_FOUND ccache)
if(CCACHE_FOUND)
set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE ccache)
endif()
endif()
# ~~~
# Find Vulkan Headers and Loader
# Search order:
# User-supplied CMAKE_PREFIX_PATH containing paths to the header and/or loader install dirs
# CMake options VULKAN_HEADERS_INSTALL_DIR and/or VULKAN_LOADER_INSTALL_DIR
# Env vars VULKAN_HEADERS_INSTALL_DIR and/or VULKAN_LOADER_INSTALL_DIR
# If on MacOS
# CMake option MOTLENVK_REPO_ROOT
# Env vars MOLTENVK_REPO_ROOT
# Fallback to FindVulkan operation using SDK install or system installed components.
# ~~~
set(VULKAN_HEADERS_INSTALL_DIR "HEADERS-NOTFOUND" CACHE PATH "Absolute path to a Vulkan-Headers install directory")
set(VULKAN_LOADER_INSTALL_DIR "LOADER-NOTFOUND" CACHE PATH "Absolute path to a Vulkan-Loader install directory")
if(WIN32 AND "${VULKAN_LOADER_INSTALL_DIR}" STREQUAL "LOADER-NOTFOUND")
if(CMAKE_CL_64)
set(VULKAN_LOADER_INSTALL_DIR "${CMAKE_CURRENT_SOURCE_DIR}/external/x64")
else()
set(VULKAN_LOADER_INSTALL_DIR "${CMAKE_CURRENT_SOURCE_DIR}/external/x86")
endif()
endif()
set(CMAKE_PREFIX_PATH ${CMAKE_PREFIX_PATH};${VULKAN_HEADERS_INSTALL_DIR};${VULKAN_LOADER_INSTALL_DIR};
$ENV{VULKAN_HEADERS_INSTALL_DIR};$ENV{VULKAN_LOADER_INSTALL_DIR})
if(APPLE)
set(MOLTENVK_REPO_ROOT "MOLTENVK-NOTFOUND" CACHE PATH "Absolute path to a MoltenVK repo directory")
if(NOT MOLTENVK_REPO_ROOT AND NOT DEFINED ENV{MOLTENVK_REPO_ROOT})
message(FATAL_ERROR "Must define location of MoltenVK repo -- see BUILD.md")
endif()
if(NOT MOLTENVK_REPO_ROOT)
set(MOLTENVK_REPO_ROOT $ENV{MOLTENVK_REPO_ROOT})
endif()
message(STATUS "Using MoltenVK repo location at ${MOLTENVK_REPO_ROOT}")
endif()
message(STATUS "Using find_package to locate Vulkan")
find_package(Vulkan)
find_package(VulkanHeaders)
get_filename_component(Vulkan_LIBRARY_DIR ${Vulkan_LIBRARY} DIRECTORY)
message(STATUS "Vulkan FOUND = ${Vulkan_FOUND}")
message(STATUS "Vulkan Lib Dir = ${Vulkan_LIBRARY_DIR}")
message(STATUS "Vulkan Lib = ${Vulkan_LIBRARY}")
message(STATUS "Vulkan Headers Include = ${VulkanHeaders_INCLUDE_DIR}")
message(STATUS "Vulkan Headers Registry = ${VulkanRegistry_DIR}")
include(GNUInstallDirs)
if(WIN32 AND CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
# Windows: if install locations not set by user, set install prefix to "<build_dir>\install".
set(CMAKE_INSTALL_PREFIX "${CMAKE_BINARY_DIR}/install" CACHE PATH "default install path" FORCE)
endif()
# uninstall target
if(NOT TARGET uninstall)
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/cmake/cmake_uninstall.cmake.in"
"${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake"
IMMEDIATE
@ONLY)
add_custom_target(uninstall COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake)
set_target_properties(uninstall PROPERTIES FOLDER ${TOOLS_HELPER_FOLDER})
endif()
if(APPLE)
# CMake versions 3 or later need CMAKE_MACOSX_RPATH defined. This avoids the CMP0042 policy message.
set(CMAKE_MACOSX_RPATH 1)
endif()
option(BUILD_WERROR "Treat compiler warnings as errors" ON)
if(CMAKE_COMPILER_IS_GNUCC OR CMAKE_C_COMPILER_ID MATCHES "Clang")
set(COMMON_COMPILE_FLAGS "-Wall -Wextra -Wno-unused-parameter -Wno-missing-field-initializers")
set(COMMON_COMPILE_FLAGS "${COMMON_COMPILE_FLAGS} -fno-strict-aliasing -fno-builtin-memcmp")
if(MAKE_C_COMPILER_ID MATCHES "Clang")
set(COMMON_COMPILE_FLAGS "${COMMON_COMPILE_FLAGS} -Wno-sign-conversion -Wno-shorten-64-to-32 -Wno-string-conversion -Wno-implicit-in-conversion -Wno-enum-enum-conversion")
endif()
if(BUILD_WERROR)
if((CMAKE_COMPILER_IS_GNUCXX AND NOT (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 7.3.0)) OR
(("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") AND (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 6.0.0)))
set(COMMON_COMPILE_FLAGS "${COMMON_COMPILE_FLAGS} -Werror")
endif()
endif()
# For GCC version 7.1 or greater, we need to disable the implicit fallthrough warning since there's no consistent way to satisfy
# all compilers until they all accept the C++17 standard
if(CMAKE_COMPILER_IS_GNUCC AND NOT (CMAKE_CXX_COMPILER_VERSION LESS 7.1))
set(COMMON_COMPILE_FLAGS "${COMMON_COMPILE_FLAGS} -Wimplicit-fallthrough=0")
endif()
if(APPLE)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${COMMON_COMPILE_FLAGS}")
else()
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c99 ${COMMON_COMPILE_FLAGS}")
endif()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${COMMON_COMPILE_FLAGS} -std=c++11 -fno-rtti")
if(UNIX)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fvisibility=hidden")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fvisibility=hidden")
endif()
elseif(MSVC)
if(BUILD_WERROR)
add_compile_options("/WX")
endif()
# Warn about nested declarations
add_compile_options("/w34456")
# Warn about potentially uninitialized variables
add_compile_options("/w34701")
add_compile_options("/w34703")
# Warn about different indirection types.
add_compile_options("/w34057")
# Warn about signed/unsigned mismatch.
add_compile_options("/w34245")
endif()
# Optional codegen target
if(PYTHONINTERP_FOUND)
add_custom_target(VulkanTools_generated_source
COMMAND ${PYTHON_EXECUTABLE} ${PROJECT_SOURCE_DIR}/scripts/generate_source.py
${VulkanRegistry_DIR} --incremental
)
else()
message("WARNING: VulkanTools_generated_source target requires python 3")
endif()
if(APPLE)
include(mac_common.cmake)
endif()
if(BUILD_CUBE)
add_subdirectory(cube)
endif()
if(BUILD_VULKANINFO)
add_subdirectory(vulkaninfo)
endif()
if(BUILD_ICD)
add_subdirectory(icd)
endif()

View File

@ -0,0 +1 @@
A reminder that this issue tracker is managed by the Khronos Group. Interactions here should follow the Khronos Code of Conduct (https://www.khronos.org/developers/code-of-conduct), which prohibits aggressive or derogatory language. Please keep the discussion friendly and civil.

View File

@ -0,0 +1,130 @@
# How to Contribute to Vulkan Source Repositories
## **The Repository**
The source code for The Vulkan-Tools components is sponsored by Khronos and LunarG.
* [Khronos Vulkan-Tools](https://github.com/KhronosGroup/Vulkan-Tools)
Repository Issue labels:
* _Bug_: These issues refer to invalid or broken functionality and are the highest priority.
* _Enhancement_: These issues refer to ideas for extending or improving tools and utilities
It is the maintainers goal for all issues to be assigned within one business day of their submission. If you choose
to work on an issue that is assigned, simply coordinate with the current assignee.
### **How to Submit Fixes**
* **Ensure that the bug was not already reported or fixed** by searching on GitHub under Issues
and Pull Requests.
* Use the existing GitHub forking and pull request process.
This will involve [forking the repository](https://help.github.com/articles/fork-a-repo/),
creating a branch with your commits, and then [submitting a pull request](https://help.github.com/articles/using-pull-requests/).
* Please read and adhere to the style and process [guidelines ](#coding-conventions-and-formatting) enumerated below.
* Please base your fixes on the master branch. SDK branches are generally not updated except for critical fixes needed to repair an SDK release.
* The resulting Pull Request will be assigned to a repository maintainer. It is the maintainer's responsibility to ensure the Pull Request
passes the Google/LunarG internal CI processes. Once the Pull Request has been approved and is passing internal CI, a repository maintainer
will merge the PR.
#### **Coding Conventions and Formatting**
* Use the **[Google style guide](https://google.github.io/styleguide/cppguide.html)** for source code with the following exceptions:
* The column limit is 132 (as opposed to the default value 80). The clang-format tool will handle this. See below.
* The indent is 4 spaces instead of the default 2 spaces. Again, the clang-format tool will handle this.
* If you can justify a reason for violating a rule in the guidelines, then you are free to do so. Be prepared to defend your
decision during code review. This should be used responsibly. An example of a bad reason is "I don't like that rule." An example of
a good reason is "This violates the style guide, but it improves type safety."
* Run **clang-format** on your changes to maintain consistent formatting
* There are `.clang-format` files present in the repository to define clang-format settings
which are found and used automatically by clang-format.
* **clang-format** binaries are available from the LLVM orginization, here: [LLVM](https://clang.llvm.org/). Our CI system (Travis-CI)
currently uses clang-format version 7.0.0 to check that the lines of code you have changed are formatted properly. It is
recommended that you use the same version to format your code prior to submission.
* A sample git workflow may look like:
> # Make changes to the source.
> $ git add -u .
> $ git clang-format --style=file
> # Check to see if clang-format made any changes and if they are OK.
> $ git add -u .
> $ git commit
* **Commit Messages**
* Limit the subject line to 50 characters -- this allows the information to display correctly in git/Github logs
* Begin subject line with a one-word component description followed by a colon (e.g. loader, layers, tests, etc.)
* Separate subject from body with a blank line
* Wrap the body at 72 characters
* Capitalize the subject line
* Do not end the subject line with a period
* Use the body to explain what and why vs. how
* Use the imperative mode in the subject line. This just means to write it as a command (e.g. Fix the sprocket)
Strive for commits that implement a single or related set of functionality, using as many commits as is necessary (more is better).
That said, please ensure that the repository compiles and passes tests without error for each commit in your pull request. Note
that to be accepted into the repository, the pull request must [pass all tests](#testing your changes) on all supported platforms
-- the automatic Github Travis and AppVeyor continuous integration features will assist in enforcing this requirement.
#### Generated Source Code
The `icd/generated` directory contains source code that is created by several
generator scripts in the `scripts` directory. All changes to these scripts _must_ be submitted with the
corresponding generated output to keep the repository self-consistent. This requirement is enforced by both
Travis CI and AppVeyor test configurations. Regenerate source files after modifying any of the generator
scripts and before building and testing your changes. More details can be found in
[BUILD.md](https://github.com/KhronosGroup/Vulkan-Tools/blob/master/BUILD.md#generated-source-code).
#### **Testing Your Changes**
* Run the repository components with the Vulkan Validation Layers before and after each of your commits to check for any regressions.
(These instructions are for Linux)
* In the `cube` directory, run:
> vkcube
> vkcube --validate
* In the `vulkaninfo` directory, run:
> vulkaninfo
* If you are adding or changing JSON output, please read
[Validating vulkaninfo JSON output](https://github.com/KhronosGroup/Vulkan-Tools/blob/master/vulkaninfo/json_validation_process.md).
**Note:** When adding new output to vulkaninfo, do NOT add JSON output unless the formmatting is defined by a schema.
* Run tests that explicitly exercise your changes.
* Feel free to subject your code changes to other tests as well!
#### Coding Conventions for [CMake](http://cmake.org) files
* When editing configuration files for CMake, follow the style conventions of the surrounding code.
* The column limit is 132.
* The indent is 4 spaces.
* CMake functions are lower-case.
* Variable and keyword names are upper-case.
* The format is defined by
[cmake-format](https://github.com/cheshirekow/cmake_format)
using the `.cmake-format.py` file in the repository to define the settings.
See the cmake-format page for information about its simple markup for comments.
* Disable reformatting of a block of comment lines by inserting
a `# ~~~` comment line before and after that block.
* Disable any formatting of a block of lines by surrounding that block with
`# cmake-format: off` and `# cmake-format: on` comment lines.
* To install: `sudo pip install cmake_format`
* To run: `cmake-format --in-place $FILENAME`
* **IMPORTANT (June 2018)** cmake-format v0.3.6 has a
[bug]( https://github.com/cheshirekow/cmake_format/issues/50)
that can corrupt the formatting of comment lines in CMake files.
A workaround is to use the following command _before_ running cmake-format:
`sed --in-place='' 's/^ *#/#/' $FILENAME`
### **Contributor License Agreement (CLA)**
You will be prompted with a one-time "click-through" CLA dialog as part of submitting your pull request
or other contribution to GitHub.
### **License and Copyrights**
All contributions made to the Vulkan-Tools repository are Khronos branded and as such,
any new files need to have the Khronos license (Apache 2.0 style) and copyright included.
Please see an existing file in this repository for an example.
All contributions made to the LunarG repositories are to be made under the Apache 2.0 license
and any new files need to include this license and any applicable copyrights.
You can include your individual copyright after any existing copyrights.

View File

@ -0,0 +1,51 @@
## Khronos Group Vulkan-Tools Repository Management
# **Open Source Project Objectives**
* Assist Vulkan Users
- The goal is for tool and utility behavior to assist in the development of vulkan applications.
- [Core Specification](https://www.khronos.org/registry/vulkan/specs/1.0/html/vkspec.html)
- [Header Files](https://www.khronos.org/registry/vulkan/#headers)
- [SDK Resources](https://vulkan.lunarg.com)
* ISV Enablement
- Updates of tools and utilities should be available in a timely fashion
- Every effort will be made to be responsive to ISV issues
* Cross Platform Compatibility
- Google and LunarG collaboration:
- Google: Monitor for Android
- LunarG: Monitor for desktop (Windows, Linux, and MacOS)
- Continuous Integration: HW test farms operated by Google and LunarG monitor various hardware/software platforms
* Repo Quality
- Repo remains in healthy state with all tests passing and good-quality, consistent codebase
- Continuous Integration: Along with Github, HW test farms operated by Google and LunarG perform pre-commit cloud testing
on pull-requests
# **Roles and Definitions**
* Contributor, Commenter, User
- Submitting contributions, creating issues, or using the contents of the repository
* Approver
- Experienced project members who have made significant technical contributions
- Write control: Approve pull/merge requests (verify submissions vs. acceptance criteria)
* Technical Project Leads
- Lead the project in terms of versioning, quality assurance, and overarching objectives
- Monitor github issues and drive timely resolution
- Designate new approvers
- Ensure project information such as the Readme, Contributing docs, wiki, etc., kept up-to-date
- Act as a facilitator in resolving technical conflicts
- Is a point-of-contact for project-related questions
The technical project leads for this repository are:
* **Jeremy Kniager** [jeremyk@lunarg.com](mailto:jeremyk@lunarg.com)
# **Acceptance Criteria and Process**
- All source code to include Khronos copyright and license (Apache 2.0).
- Additional copyrights of contributors appended
- Contributions are via pull requests
- Project leads will assigning approvers to contributor pull requests
- Approvers can self-assign their reviewers
- For complex or invasive contributions, Project Leads may request approval from specific reviewers
- At least one review approval is required to complete a pull request
- The goal is to be responsive to contributors while ensuring acceptance criteria is met and to facilitate their submissions
- Approval is dependent upon adherence to the guidelines in [CONTRIBUTING.md](CONTRIBUTING.md), and alignment with
repository goals of maintainability, completeness, and quality
- Conflicts or questions will ultimately be resolved by the project leads

View File

@ -0,0 +1,202 @@
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "[]"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright [yyyy] [name of copyright owner]
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

View File

@ -0,0 +1,51 @@
# Vulkan Ecosystem Components
This project provides Khronos official Vulkan Tools and Utilities for Windows, Linux, Android, and MacOS.
## CI Build Status
[![Build Status](https://github.com/KhronosGroup/Vulkan-Tools/workflows/CI%20Build/badge.svg?branch=master)](https://github.com/KhronosGroup/Vulkan-Tools/actions)
## Introduction
This project provides Vulkan tools and utilities that can assist development by enabling developers to
verify their applications correct use of the Vulkan API.
The following components are available in this repository:
- [*Mock ICD*](icd/)
- [*Vkcube and Vkcube++ Demo*](cube/)
- [*VulkanInfo*](vulkaninfo/)
- [*Windows Runtime*](windows-runtime-installer/)
## Contact Information
* [Tobin Ehlis](mailto:tobine@google.com)
* [Mark Lobodzinski](mailto:mark@lunarg.com)
## Information for Developing or Contributing:
Please see the [CONTRIBUTING.md](CONTRIBUTING.md) file in this repository for more details.
Please see the [GOVERNANCE.md](GOVERNANCE.md) file in this repository for repository management details.
## How to Build and Run
[BUILD.md](BUILD.md)
Includes directions for building all components as well as running the vkcube demo applications.
## Version Tagging Scheme
Updates to the `Vulkan-Tools` repository which correspond to a new Vulkan specification release are tagged using the following format: `v<`_`version`_`>` (e.g., `v1.1.96`).
**Note**: Marked version releases have undergone thorough testing but do not imply the same quality level as SDK tags. SDK tags follow the `sdk-<`_`version`_`>.<`_`patch`_`>` format (e.g., `sdk-1.1.92.0`).
This scheme was adopted following the 1.1.96 Vulkan specification release.
## License
This work is released as open source under a Apache-style license from Khronos including a Khronos copyright.
See COPYRIGHT.txt for a full list of licenses used in this repository.
## Acknowledgements
While this project has been developed primarily by LunarG, Inc., there are many other
companies and individuals making this possible: Valve Corporation, funding
project development; Google providing significant contributions to the validation layers;
Khronos providing oversight and hosting of the project.

View File

@ -0,0 +1,73 @@
#!/bin/bash
# Copyright 2017 The Android Open Source Project
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
if [ -z "${ANDROID_SDK_HOME}" ];
then echo "Please set ANDROID_SDK_HOME, exiting"; exit 1;
else echo "ANDROID_SDK_HOME is ${ANDROID_SDK_HOME}";
fi
if [ -z "${ANDROID_NDK_HOME}" ];
then echo "Please set ANDROID_NDK_HOME, exiting"; exit 1;
else echo "ANDROID_NDK_HOME is ${ANDROID_NDK_HOME}";
fi
if [[ $(uname) == "Linux" ]]; then
cores=$(nproc) || echo 4
elif [[ $(uname) == "Darwin" ]]; then
cores=$(sysctl -n hw.ncpu) || echo 4
fi
function findtool() {
if [[ ! $(type -t $1) ]]; then
echo Command $1 not found, see ../BUILD.md;
exit 1;
fi
}
# Check for dependencies
findtool aapt
findtool zipalign
findtool jarsigner
set -ev
DEMO_BUILD_DIR=$PWD/../cube/android
echo DEMO_BUILD_DIR="${DEMO_BUILD_DIR}"
function create_APK() {
aapt package -f -M AndroidManifest.xml -I "$ANDROID_SDK_HOME/platforms/android-23/android.jar" -S res -F bin/$1-unaligned.apk bin/libs
# update this logic to detect if key is already there. If so, use it, otherwise create it.
jarsigner -verbose -keystore ~/.android/debug.keystore -storepass android -keypass android bin/$1-unaligned.apk androiddebugkey
zipalign -f 4 bin/$1-unaligned.apk bin/$1.apk
}
./update_external_sources_android.sh --no-build
#
# build vkcube APK
#
(
pushd $DEMO_BUILD_DIR
ndk-build -j $cores
mkdir -p $DEMO_BUILD_DIR/cube/bin/libs/lib
cp -r $DEMO_BUILD_DIR/libs/* $DEMO_BUILD_DIR/cube/bin/libs/lib/
cd $DEMO_BUILD_DIR/cube
create_APK vkcube
popd
)
echo Builds succeeded
exit 0

View File

@ -0,0 +1,76 @@
#!/bin/bash
# Copyright 2017 The Android Open Source Project
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
set -e
#
# Parse parameters
#
function printUsage {
echo "Supported parameters are:"
echo " -s|--serial <target device serial number> (optional)"
echo
echo "i.e. ${0##*/} -s <serial number>"
exit 1
}
if [[ $(($# % 2)) -ne 0 ]]
then
echo Parameters must be provided in pairs.
echo parameter count = $#
echo
printUsage
exit 1
fi
while [[ $# -gt 0 ]]
do
case $1 in
-s|--serial)
# include the flag, because we need to leave it off if not provided
serial="$2"
shift 2
;;
-*)
# unknown option
echo Unknown option: $1
echo
printUsage
exit 1
;;
esac
done
if [[ $serial ]]; then
echo serial = "${serial}"
serialFlag="-s $serial"
if [[ $(adb devices) != *"$serial"* ]]
then
echo Device not found: "${serial}"
echo
printUsage
exit 1
fi
else
echo Using device $(adb get-serialno)
fi
# Install everything built by build_all.sh
echo "adb $serialFlag install -r ../cube/android/cube/bin/vkcube.apk"
adb $serialFlag install -r ../cube/android/cube/bin/vkcube.apk
exit $?

View File

@ -0,0 +1,134 @@
@echo off
REM Update source for vulkan-headers
REM
REM Copyright 2016 The Android Open Source Project
REM Copyright (C) 2015 Valve Corporation
REM
REM Licensed under the Apache License, Version 2.0 (the "License");
REM you may not use this file except in compliance with the License.
REM You may obtain a copy of the License at
REM
REM http://www.apache.org/licenses/LICENSE-2.0
REM
REM Unless required by applicable law or agreed to in writing, software
REM distributed under the License is distributed on an "AS IS" BASIS,
REM WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
REM See the License for the specific language governing permissions and
REM limitations under the License.
REM
setlocal EnableDelayedExpansion
set errorCode=0
set ANDROID_BUILD_DIR=%~dp0
set BUILD_DIR=%ANDROID_BUILD_DIR%
set BASE_DIR=%BUILD_DIR%\third_party
set VULKAN_HEADERS_DIR=%BASE_DIR%\Vulkan-Headers
for %%X in (where.exe) do (set FOUND=%%~$PATH:X)
if not defined FOUND (
echo Dependency check failed:
echo where.exe not found
echo This script requires Windows Vista or later, which includes where.exe.
set errorCode=1
)
where /q git.exe
if %ERRORLEVEL% equ 1 (
echo Dependency check failed:
echo git.exe not found
echo Git for Windows can be downloaded here: https://git-scm.com/download/win
echo Install and ensure git.exe makes it into your PATH
set errorCode=1
)
where /q ndk-build.cmd
if %ERRORLEVEL% equ 1 (
echo Dependency check failed:
echo ndk-build.cmd not found
echo Android NDK can be downloaded here: http://developer.android.com/ndk/guides/setup.html
echo Install and ensure ndk-build.cmd makes it into your PATH
set errorCode=1
)
REM ensure where is working with below false test
REM where /q foo
REM if %ERRORLEVEL% equ 1 (
REM echo foo
REM )
:main
if %errorCode% neq 0 (goto:error)
REM Read the target versions from external file, which is shared with Linux script
if not exist %ANDROID_BUILD_DIR%\vulkan-headers_revision_android (
echo.
echo Missing vulkan-headers_revision_android file. Place it in %ANDROID_BUILD_DIR%
set errorCode=1
goto:error
)
set /p VULKAN_HEADERS_REVISION= < vulkan-headers_revision_android
echo VULKAN_HEADERS_REVISION=%VULKAN_HEADERS_REVISION%
echo Creating vulkan-headers in %BASE_DIR%
set sync-vulkan-headers=1
if %sync-vulkan-headers% equ 1 (
if %ERRORLEVEL% neq 0 (goto:error)
if not exist %VULKAN_HEADERS_DIR% (
call:create_vulkan-headers
)
if %errorCode% neq 0 (goto:error)
call:update_vulkan-headers
if %errorCode% neq 0 (goto:error)
)
echo.
echo Exiting
goto:finish
:error
echo.
echo Halting due to error
goto:finish
:finish
if not "%cd%\" == "%BUILD_DIR%" ( cd %BUILD_DIR% )
endlocal
REM This needs a fix to return error, something like exit %errorCode%
REM Right now it is returning 0
goto:eof
REM // ======== Functions ======== //
:create_vulkan-headers
echo.
echo Creating local vulkan-headers repository %VULKAN_HEADERS_DIR%
if not exist "%VULKAN_HEADERS_DIR%\" mkdir %VULKAN_HEADERS_DIR%
cd %VULKAN_HEADERS_DIR%
git clone https://github.com/KhronosGroup/Vulkan-Headers.git .
git checkout %VULKAN_HEADERS_REVISION%
if not exist %VULKAN_HEADERS_DIR%\registry (
echo vulkan-headers source download failed!
set errorCode=1
)
goto:eof
:update_vulkan-headers
echo.
echo Updating %VULKAN_HEADERS_DIR%
cd %VULKAN_HEADERS_DIR%
git fetch --all
git checkout %VULKAN_HEADERS_REVISION%
if not exist %VULKAN_HEADERS_DIR%\registry (
echo vulkan-headers source update failed!
set errorCode=1
)
goto:eof

View File

@ -0,0 +1,115 @@
#!/bin/bash
# Update source for vulkan-headers
# Copyright 2016 The Android Open Source Project
# Copyright (C) 2015 Valve Corporation
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
set -e
sync_vulkan_headers=1
ANDROIDBUILDDIR=$PWD
BUILDDIR=$ANDROIDBUILDDIR
BASEDIR=$BUILDDIR/third_party
VULKAN_HEADERS_REVISION=$(cat $ANDROIDBUILDDIR/vulkan-headers_revision_android)
echo "VULKAN_HEADERS_REVISION=$VULKAN_HEADERS_REVISION"
VULKAN_HEADERS_URL=$(cat $ANDROIDBUILDDIR/vulkan-headers_url_android)
if [[ $(uname) == "Linux" ]]; then
cores="$(nproc || echo 4)"
elif [[ $(uname) == "Darwin" ]]; then
cores=$(sysctl -n hw.ncpu)
fi
#
# Parse parameters
#
function printUsage {
echo "Supported parameters are:"
echo " --abi <abi> (optional)"
echo " --no-build (optional)"
echo
echo "i.e. ${0##*/} --abi arm64-v8a \\"
exit 1
}
while [[ $# -gt 0 ]]
do
case $1 in
--abi)
abi="$2"
shift 2
;;
--no-build)
nobuild=1
shift 1
;;
*)
# unknown option
echo Unknown option: $1
echo
printUsage
exit 1
;;
esac
done
echo abi=$abi
if [[ -z $abi ]]
then
echo No abi provided, so building for all supported abis.
fi
echo no-build=$nobuild
if [[ $nobuild ]]
then
echo Skipping build.
fi
function create_vulkan-headers () {
rm -rf $BASEDIR/Vulkan-Headers
echo "Creating local Vulkan-Headers repository ($BASEDIR/Vulkan-Headers)."
mkdir -p $BASEDIR/Vulkan-Headers
cd $BASEDIR/Vulkan-Headers
git clone $VULKAN_HEADERS_URL .
git checkout $VULKAN_HEADERS_REVISION
}
function update_vulkan-headers () {
echo "Updating $BASEDIR/Vulkan-Headers"
cd $BASEDIR/Vulkan-Headers
if [[ $(git config --get remote.origin.url) != $VULKAN_HEADERS_URL ]]; then
echo "Vulkan-Headers URL mismatch, recreating local repo"
create_vulkan-headers
return
fi
git fetch --all
git checkout $VULKAN_HEADERS_REVISION
}
if [ $sync_vulkan_headers -eq 1 ]; then
if [ ! -d "$BASEDIR/Vulkan-Headers" -o ! -d "$BASEDIR/Vulkan-Headers/.git" ]; then
create_vulkan-headers
fi
update_vulkan-headers
fi
echo ""
echo "${0##*/} finished."

View File

@ -0,0 +1 @@
v1.3.212

View File

@ -0,0 +1 @@
https://github.com/KhronosGroup/Vulkan-Headers.git

View File

@ -0,0 +1,57 @@
vars = {
'chromium_git': 'https://chromium.googlesource.com',
}
deps = {
'./build': {
'url': '{chromium_git}/chromium/src/build.git@a660b0b9174e3a808f620222017566e8d1b2669b',
},
'./buildtools': {
'url': '{chromium_git}/chromium/src/buildtools.git@459baaf66bee809f6eb288e0215cf524f4d2429a',
},
'./testing': {
'url': '{chromium_git}/chromium/src/testing@083d633e752e7a57cbe62a468a06e51e28c49ee9',
},
'./tools/clang': {
'url': '{chromium_git}/chromium/src/tools/clang.git@3114fbc11f9644c54dd0a4cdbfa867bac50ff983',
},
}
hooks = [
# Pull clang-format binaries using checked-in hashes.
{
'name': 'clang_format_linux',
'pattern': '.',
'condition': 'host_os == "linux"',
'action': [ 'download_from_google_storage',
'--no_resume',
'--platform=linux*',
'--no_auth',
'--bucket', 'chromium-clang-format',
'-s', './buildtools/linux64/clang-format.sha1',
],
},
{
'name': 'sysroot_x64',
'pattern': '.',
'condition': 'checkout_linux and checkout_x64',
'action': ['python', './build/linux/sysroot_scripts/install-sysroot.py',
'--arch=x64'],
},
{
# Note: On Win, this should run after win_toolchain, as it may use it.
'name': 'clang',
'pattern': '.',
'action': ['python', './tools/clang/scripts/update.py'],
},
]
recursedeps = [
# buildtools provides clang_format.
'./buildtools',
]

View File

@ -0,0 +1,128 @@
#!/usr/bin/env python
# Copyright (C) 2016 The ANGLE Project Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""Generate copies of the Vulkan layers JSON files, with no paths, forcing
Vulkan to use the default search path to look for layers."""
from __future__ import print_function
import argparse
import glob
import json
import os
import platform
import sys
def glob_slash(dirname):
"""Like regular glob but replaces \ with / in returned paths."""
return [s.replace('\\', '/') for s in glob.glob(dirname)]
def main():
parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument('--icd', action='store_true')
parser.add_argument('source_dir')
parser.add_argument('target_dir')
parser.add_argument('version_header', help='path to vulkan_core.h')
parser.add_argument('json_files', nargs='*')
args = parser.parse_args()
source_dir = args.source_dir
target_dir = args.target_dir
json_files = [j for j in args.json_files if j.endswith('.json')]
json_in_files = [j for j in args.json_files if j.endswith('.json.in')]
data_key = 'ICD' if args.icd else 'layer'
if not os.path.isdir(source_dir):
print(source_dir + ' is not a directory.', file=sys.stderr)
return 1
if not os.path.exists(target_dir):
os.makedirs(target_dir)
# Copy the *.json files from source dir to target dir
if (set(glob_slash(os.path.join(source_dir, '*.json'))) != set(json_files)):
print(glob.glob(os.path.join(source_dir, '*.json')))
print('.json list in gn file is out-of-date', file=sys.stderr)
return 1
for json_fname in json_files:
if not json_fname.endswith('.json'):
continue
with open(json_fname) as infile:
data = json.load(infile)
# Update the path.
if not data_key in data:
raise Exception(
"Could not find '%s' key in %s" % (data_key, json_fname))
# The standard validation layer has no library path.
if 'library_path' in data[data_key]:
prev_name = os.path.basename(data[data_key]['library_path'])
data[data_key]['library_path'] = prev_name
target_fname = os.path.join(target_dir, os.path.basename(json_fname))
with open(target_fname, 'w') as outfile:
json.dump(data, outfile)
# Get the Vulkan version from the vulkan_core.h file
vk_header_filename = args.version_header
vk_version = None
with open(vk_header_filename) as vk_header_file:
for line in vk_header_file:
if line.startswith('#define VK_HEADER_VERSION'):
vk_version = line.split()[-1]
break
if not vk_version:
print('failed to extract vk_version', file=sys.stderr)
return 1
# Set json file prefix and suffix for generating files, default to Linux.
relative_path_prefix = '../lib'
file_type_suffix = '.so'
if platform.system() == 'Windows':
relative_path_prefix = r'..\\' # json-escaped, hence two backslashes.
file_type_suffix = '.dll'
elif platform.system() == 'Darwin':
file_type_suffix = '.dylib'
# For each *.json.in template files in source dir generate actual json file
# in target dir
if (set(glob_slash(os.path.join(source_dir, '*.json.in'))) !=
set(json_in_files)):
print('.json.in list in gn file is out-of-date', file=sys.stderr)
return 1
for json_in_name in json_in_files:
if not json_in_name.endswith('.json.in'):
continue
json_in_fname = os.path.basename(json_in_name)
layer_name = json_in_fname[:-len('.json.in')]
layer_lib_name = layer_name + file_type_suffix
json_out_fname = os.path.join(target_dir, json_in_fname[:-len('.in')])
with open(json_out_fname,'w') as json_out_file, \
open(json_in_name) as infile:
for line in infile:
line = line.replace('@RELATIVE_LAYER_BINARY@',
relative_path_prefix + layer_lib_name)
line = line.replace('@VK_VERSION@', '1.1.' + vk_version)
json_out_file.write(line)
if __name__ == '__main__':
sys.exit(main())

View File

@ -0,0 +1,18 @@
# Copyright (c) 2019 LunarG, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
build_with_chromium = false
ignore_elf32_limitations = true
linux_use_bundled_binutils_override = false
use_system_xcode = true

View File

@ -0,0 +1,15 @@
# Copyright (c) 2020 LunarG, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
vulkan_use_x11 = true

View File

@ -0,0 +1,21 @@
# Copyright (c) 2019 LunarG, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# Paths to vulkan tools dependencies
vulkan_headers_dir = "//external/Vulkan-Headers"
# Subdirectories for generated files
vulkan_data_subdir = ""
vulkan_gen_subdir = ""

View File

@ -0,0 +1,37 @@
#!/bin/sh
# Copyright (c) 2019 LunarG, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# Execute at repo root
cd "$(dirname $0)/.."
# Use update_deps.py to update source dependencies from /scripts/known_good.json
scripts/update_deps.py --dir="external" --no-build
# Use gclient to update toolchain dependencies from /build-gn/DEPS (from chromium)
cat << EOF >> .gclient
solutions = [
{ "name" : ".",
"url" : "https://github.com/KhronosGroup/Vulkan-Tools",
"deps_file" : "build-gn/DEPS",
"managed" : False,
"custom_deps" : {
},
"custom_vars": {},
},
]
EOF
gclient sync

View File

@ -0,0 +1,126 @@
CMake - Cross Platform Makefile Generator
Copyright 2000-2018 Kitware, Inc. and Contributors
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the name of Kitware, Inc. nor the names of Contributors
may be used to endorse or promote products derived from this
software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
------------------------------------------------------------------------------
The following individuals and institutions are among the Contributors:
* Aaron C. Meadows <cmake@shadowguarddev.com>
* Adriaan de Groot <groot@kde.org>
* Aleksey Avdeev <solo@altlinux.ru>
* Alexander Neundorf <neundorf@kde.org>
* Alexander Smorkalov <alexander.smorkalov@itseez.com>
* Alexey Sokolov <sokolov@google.com>
* Alex Turbov <i.zaufi@gmail.com>
* Andreas Pakulat <apaku@gmx.de>
* Andreas Schneider <asn@cryptomilk.org>
* André Rigland Brodtkorb <Andre.Brodtkorb@ifi.uio.no>
* Axel Huebl, Helmholtz-Zentrum Dresden - Rossendorf
* Benjamin Eikel
* Bjoern Ricks <bjoern.ricks@gmail.com>
* Brad Hards <bradh@kde.org>
* Christopher Harvey
* Christoph Grüninger <foss@grueninger.de>
* Clement Creusot <creusot@cs.york.ac.uk>
* Daniel Blezek <blezek@gmail.com>
* Daniel Pfeifer <daniel@pfeifer-mail.de>
* Enrico Scholz <enrico.scholz@informatik.tu-chemnitz.de>
* Eran Ifrah <eran.ifrah@gmail.com>
* Esben Mose Hansen, Ange Optimization ApS
* Geoffrey Viola <geoffrey.viola@asirobots.com>
* Google Inc
* Gregor Jasny
* Helio Chissini de Castro <helio@kde.org>
* Ilya Lavrenov <ilya.lavrenov@itseez.com>
* Insight Software Consortium <insightsoftwareconsortium.org>
* Jan Woetzel
* Kelly Thompson <kgt@lanl.gov>
* Konstantin Podsvirov <konstantin@podsvirov.pro>
* Mario Bensi <mbensi@ipsquad.net>
* Mathieu Malaterre <mathieu.malaterre@gmail.com>
* Matthaeus G. Chajdas
* Matthias Kretz <kretz@kde.org>
* Matthias Maennich <matthias@maennich.net>
* Michael Stürmer
* Miguel A. Figueroa-Villanueva
* Mike Jackson
* Mike McQuaid <mike@mikemcquaid.com>
* Nicolas Bock <nicolasbock@gmail.com>
* Nicolas Despres <nicolas.despres@gmail.com>
* Nikita Krupen'ko <krnekit@gmail.com>
* NVIDIA Corporation <www.nvidia.com>
* OpenGamma Ltd. <opengamma.com>
* Patrick Stotko <stotko@cs.uni-bonn.de>
* Per Øyvind Karlsen <peroyvind@mandriva.org>
* Peter Collingbourne <peter@pcc.me.uk>
* Petr Gotthard <gotthard@honeywell.com>
* Philip Lowman <philip@yhbt.com>
* Philippe Proulx <pproulx@efficios.com>
* Raffi Enficiaud, Max Planck Society
* Raumfeld <raumfeld.com>
* Roger Leigh <rleigh@codelibre.net>
* Rolf Eike Beer <eike@sf-mail.de>
* Roman Donchenko <roman.donchenko@itseez.com>
* Roman Kharitonov <roman.kharitonov@itseez.com>
* Ruslan Baratov
* Sebastian Holtermann <sebholt@xwmw.org>
* Stephen Kelly <steveire@gmail.com>
* Sylvain Joubert <joubert.sy@gmail.com>
* Thomas Sondergaard <ts@medical-insight.com>
* Tobias Hunger <tobias.hunger@qt.io>
* Todd Gamblin <tgamblin@llnl.gov>
* Tristan Carel
* University of Dundee
* Vadim Zhukov
* Will Dicharry <wdicharry@stellarscience.com>
See version control history for details of individual contributions.
The above copyright and license notice applies to distributions of
CMake in source and binary form. Third-party software packages supplied
with CMake under compatible licenses provide their own copyright notices
documented in corresponding subdirectories or source files.
------------------------------------------------------------------------------
CMake was initially developed by Kitware with the following sponsorship:
* National Library of Medicine at the National Institutes of Health
as part of the Insight Segmentation and Registration Toolkit (ITK).
* US National Labs (Los Alamos, Livermore, Sandia) ASC Parallel
Visualization Initiative.
* National Alliance for Medical Image Computing (NAMIC) is funded by the
National Institutes of Health through the NIH Roadmap for Medical Research,
Grant U54 EB005149.
* Kitware, Inc.

View File

@ -0,0 +1,28 @@
# Try to find DirectFB
#
# This will define:
#
# DIRECTFB_FOUND - True if DirectFB is found
# DIRECTFB_LIBRARIES - Link these to use DirectFB
# DIRECTFB_INCLUDE_DIR - Include directory for DirectFB
# DIRECTFB_DEFINITIONS - Compiler flags for using DirectFB
#
# Redistribution and use is allowed according to the terms of the BSD license.
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
IF (NOT WIN32)
FIND_PACKAGE(PkgConfig)
PKG_CHECK_MODULES(PKG_DIRECTFB QUIET directfb)
SET(DIRECTFB_DEFINITIONS ${PKG_DIRECTFB_CFLAGS})
FIND_PATH(DIRECTFB_INCLUDE_DIR NAMES directfb.h HINTS ${PKG_DIRECTFB_INCLUDE_DIRS})
FIND_LIBRARY(DIRECTFB_LIBRARIES NAMES directfb HINTS ${PKG_DIRECTFB_LIBRARY_DIRS})
include(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(DIRECTFB DEFAULT_MSG DIRECTFB_LIBRARIES DIRECTFB_INCLUDE_DIR)
MARK_AS_ADVANCED(DIRECTFB_INCLUDE_DIR DIRECTFB_LIBRARIES)
ENDIF ()

View File

@ -0,0 +1,80 @@
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
# file Copyright.txt or https://cmake.org/licensing for details.
#.rst:
# FindVulkan
# ----------
#
# Try to find Vulkan
#
# IMPORTED Targets
# ^^^^^^^^^^^^^^^^
#
# This module defines :prop_tgt:`IMPORTED` target ``Vulkan::Vulkan``, if
# Vulkan has been found.
#
# Result Variables
# ^^^^^^^^^^^^^^^^
#
# This module defines the following variables::
#
# Vulkan_FOUND - True if Vulkan was found
# Vulkan_INCLUDE_DIRS - include directories for Vulkan
# Vulkan_LIBRARIES - link against this library to use Vulkan
#
# The module will also define two cache variables::
#
# Vulkan_INCLUDE_DIR - the Vulkan include directory
# Vulkan_LIBRARY - the path to the Vulkan library
#
if(WIN32)
find_path(Vulkan_INCLUDE_DIR
NAMES vulkan/vulkan.h
PATHS
"$ENV{VULKAN_SDK}/Include"
)
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
find_library(Vulkan_LIBRARY
NAMES vulkan-1
PATHS
"$ENV{VULKAN_SDK}/Lib"
"$ENV{VULKAN_SDK}/Bin"
)
elseif(CMAKE_SIZEOF_VOID_P EQUAL 4)
find_library(Vulkan_LIBRARY
NAMES vulkan-1
PATHS
"$ENV{VULKAN_SDK}/Lib32"
"$ENV{VULKAN_SDK}/Bin32"
NO_SYSTEM_ENVIRONMENT_PATH
)
endif()
else()
find_path(Vulkan_INCLUDE_DIR
NAMES vulkan/vulkan.h
PATHS
"$ENV{VULKAN_SDK}/include")
find_library(Vulkan_LIBRARY
NAMES vulkan
PATHS
"$ENV{VULKAN_SDK}/lib")
endif()
set(Vulkan_LIBRARIES ${Vulkan_LIBRARY})
set(Vulkan_INCLUDE_DIRS ${Vulkan_INCLUDE_DIR})
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(Vulkan
DEFAULT_MSG
Vulkan_LIBRARY Vulkan_INCLUDE_DIR)
mark_as_advanced(Vulkan_INCLUDE_DIR Vulkan_LIBRARY)
if(Vulkan_FOUND AND NOT TARGET Vulkan::Vulkan)
add_library(Vulkan::Vulkan UNKNOWN IMPORTED)
set_target_properties(Vulkan::Vulkan PROPERTIES
IMPORTED_LOCATION "${Vulkan_LIBRARIES}"
INTERFACE_INCLUDE_DIRECTORIES "${Vulkan_INCLUDE_DIRS}")
endif()

View File

@ -0,0 +1,71 @@
#.rst:
# FindVulkanHeaders
# -----------------
#
# Try to find Vulkan Headers and Registry.
#
# This module is intended to be used by projects that build Vulkan
# "system" components such as the loader and layers.
# Vulkan applications should instead use the FindVulkan (or similar)
# find module that locates the headers and the loader library.
#
# When using this find module to locate the headers and registry
# in a Vulkan-Headers repository, the Vulkan-Headers repository
# should be built with 'install' target and the following environment
# or CMake variable set to the location of the install directory.
#
# VULKAN_HEADERS_INSTALL_DIR
#
# IMPORTED Targets
# ^^^^^^^^^^^^^^^^
#
# This module defines no IMPORTED targets
#
# Result Variables
# ^^^^^^^^^^^^^^^^
#
# This module defines the following variables::
#
# VulkanHeaders_FOUND - True if VulkanHeaders was found
# VulkanHeaders_INCLUDE_DIRS - include directories for VulkanHeaders
#
# VulkanRegistry_FOUND - True if VulkanRegistry was found
# VulkanRegistry_DIRS - directories for VulkanRegistry
#
# The module will also define two cache variables::
#
# VulkanHeaders_INCLUDE_DIR - the VulkanHeaders include directory
# VulkanRegistry_DIR - the VulkanRegistry directory
#
# Use HINTS instead of PATH to search these locations before
# searching system environment variables like $PATH that may
# contain SDK directories.
find_path(VulkanHeaders_INCLUDE_DIR
NAMES vulkan/vulkan.h
HINTS
${VULKAN_HEADERS_INSTALL_DIR}/include
"$ENV{VULKAN_HEADERS_INSTALL_DIR}/include"
"$ENV{VULKAN_SDK}/include")
if(VulkanHeaders_INCLUDE_DIR)
get_filename_component(VULKAN_REGISTRY_PATH_HINT ${VulkanHeaders_INCLUDE_DIR} DIRECTORY)
find_path(VulkanRegistry_DIR
NAMES vk.xml
HINTS "${VULKAN_REGISTRY_PATH_HINT}/share/vulkan/registry")
endif()
set(VulkanHeaders_INCLUDE_DIRS ${VulkanHeaders_INCLUDE_DIR})
set(VulkanRegistry_DIRS ${VulkanRegistry_DIR})
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(VulkanHeaders
DEFAULT_MSG
VulkanHeaders_INCLUDE_DIR)
set(FPHSA_NAME_MISMATCHED TRUE)
find_package_handle_standard_args(VulkanRegistry
DEFAULT_MSG
VulkanRegistry_DIR)
unset(FPHSA_NAME_MISMATCHED)
mark_as_advanced(VulkanHeaders_INCLUDE_DIR VulkanRegistry_DIR)

View File

@ -0,0 +1,66 @@
# Try to find Wayland on a Unix system
#
# This will define:
#
# WAYLAND_FOUND - True if Wayland is found
# WAYLAND_LIBRARIES - Link these to use Wayland
# WAYLAND_INCLUDE_DIR - Include directory for Wayland
# WAYLAND_DEFINITIONS - Compiler flags for using Wayland
#
# In addition the following more fine grained variables will be defined:
#
# WAYLAND_CLIENT_FOUND WAYLAND_CLIENT_INCLUDE_DIR WAYLAND_CLIENT_LIBRARIES
# WAYLAND_SERVER_FOUND WAYLAND_SERVER_INCLUDE_DIR WAYLAND_SERVER_LIBRARIES
# WAYLAND_EGL_FOUND WAYLAND_EGL_INCLUDE_DIR WAYLAND_EGL_LIBRARIES
#
# Copyright (c) 2013 Martin Gräßlin <mgraesslin@kde.org>
#
# Redistribution and use is allowed according to the terms of the BSD license.
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
IF (NOT WIN32)
IF (WAYLAND_INCLUDE_DIR AND WAYLAND_LIBRARIES)
# In the cache already
SET(WAYLAND_FIND_QUIETLY TRUE)
ENDIF ()
# Use pkg-config to get the directories and then use these values
# in the FIND_PATH() and FIND_LIBRARY() calls
FIND_PACKAGE(PkgConfig)
PKG_CHECK_MODULES(PKG_WAYLAND QUIET wayland-client wayland-server wayland-egl wayland-cursor)
SET(WAYLAND_DEFINITIONS ${PKG_WAYLAND_CFLAGS})
FIND_PATH(WAYLAND_CLIENT_INCLUDE_DIR NAMES wayland-client.h HINTS ${PKG_WAYLAND_INCLUDE_DIRS})
FIND_PATH(WAYLAND_SERVER_INCLUDE_DIR NAMES wayland-server.h HINTS ${PKG_WAYLAND_INCLUDE_DIRS})
FIND_PATH(WAYLAND_EGL_INCLUDE_DIR NAMES wayland-egl.h HINTS ${PKG_WAYLAND_INCLUDE_DIRS})
FIND_PATH(WAYLAND_CURSOR_INCLUDE_DIR NAMES wayland-cursor.h HINTS ${PKG_WAYLAND_INCLUDE_DIRS})
FIND_LIBRARY(WAYLAND_CLIENT_LIBRARIES NAMES wayland-client HINTS ${PKG_WAYLAND_LIBRARY_DIRS})
FIND_LIBRARY(WAYLAND_SERVER_LIBRARIES NAMES wayland-server HINTS ${PKG_WAYLAND_LIBRARY_DIRS})
FIND_LIBRARY(WAYLAND_EGL_LIBRARIES NAMES wayland-egl HINTS ${PKG_WAYLAND_LIBRARY_DIRS})
FIND_LIBRARY(WAYLAND_CURSOR_LIBRARIES NAMES wayland-cursor HINTS ${PKG_WAYLAND_LIBRARY_DIRS})
set(WAYLAND_INCLUDE_DIR ${WAYLAND_CLIENT_INCLUDE_DIR} ${WAYLAND_SERVER_INCLUDE_DIR} ${WAYLAND_EGL_INCLUDE_DIR} ${WAYLAND_CURSOR_INCLUDE_DIR})
set(WAYLAND_LIBRARIES ${WAYLAND_CLIENT_LIBRARIES} ${WAYLAND_SERVER_LIBRARIES} ${WAYLAND_EGL_LIBRARIES} ${WAYLAND_CURSOR_LIBRARIES})
list(REMOVE_DUPLICATES WAYLAND_INCLUDE_DIR)
include(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(WAYLAND_CLIENT DEFAULT_MSG WAYLAND_CLIENT_LIBRARIES WAYLAND_CLIENT_INCLUDE_DIR)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(WAYLAND_SERVER DEFAULT_MSG WAYLAND_SERVER_LIBRARIES WAYLAND_SERVER_INCLUDE_DIR)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(WAYLAND_EGL DEFAULT_MSG WAYLAND_EGL_LIBRARIES WAYLAND_EGL_INCLUDE_DIR)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(WAYLAND_CURSOR DEFAULT_MSG WAYLAND_CURSOR_LIBRARIES WAYLAND_CURSOR_INCLUDE_DIR)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(WAYLAND DEFAULT_MSG WAYLAND_LIBRARIES WAYLAND_INCLUDE_DIR)
MARK_AS_ADVANCED(
WAYLAND_INCLUDE_DIR WAYLAND_LIBRARIES
WAYLAND_CLIENT_INCLUDE_DIR WAYLAND_CLIENT_LIBRARIES
WAYLAND_SERVER_INCLUDE_DIR WAYLAND_SERVER_LIBRARIES
WAYLAND_EGL_INCLUDE_DIR WAYLAND_EGL_LIBRARIES
WAYLAND_CURSOR_INCLUDE_DIR WAYLAND_CURSOR_LIBRARIES
)
ENDIF ()

View File

@ -0,0 +1,14 @@
# Wayland protocols Defines:
#
# * WAYLAND_PROTOCOLS_FOUND True if the wayland-protocols data path is found
# * WAYLAND_PROTOCOLS_PATH Path to the wayland-scanner executable
#
if(NOT WIN32)
find_package(PkgConfig)
pkg_check_modules(WAYLAND_PROTOCOLS_PATH REQUIRED wayland-protocols)
execute_process(COMMAND ${PKG_CONFIG_EXECUTABLE} --variable=pkgdatadir wayland-protocols
OUTPUT_VARIABLE WAYLAND_PROTOCOLS_PATH OUTPUT_STRIP_TRAILING_WHITESPACE)
find_package_handle_standard_args(WAYLAND DEFAULT_MSG WAYLAND_PROTOCOLS_PATH)
mark_as_advanced(WAYLAND_PROTOCOLS_PATH)
endif()

View File

@ -0,0 +1,14 @@
# Wayland scanner Defines:
#
# * WAYLAND_SCANNER_FOUND True if wayland-scanner is found
# * WAYLAND_SCANNER_EXECUTABLE Path to the wayland-scanner executable
#
if(NOT WIN32)
# Delegate to pkg-config for our first guess
find_package(PkgConfig)
pkg_check_modules(PKG_WAYLAND_SCANNER QUIET wayland-scanner)
find_program(WAYLAND_SCANNER_EXECUTABLE wayland-scanner ${PKG_WAYLAND_SCANNER_PREFIX}/bin/wayland-scanner)
find_package_handle_standard_args(WAYLAND DEFAULT_MSG WAYLAND_SCANNER_EXECUTABLE)
mark_as_advanced(WAYLAND_SCANNER_EXECUTABLE)
endif()

View File

@ -0,0 +1,32 @@
# - Try to find libX11-xcb
# Once done this will define
#
# X11_XCB_FOUND - system has libX11-xcb
# X11_XCB_LIBRARIES - Link these to use libX11-xcb
# X11_XCB_INCLUDE_DIR - the libX11-xcb include dir
# X11_XCB_DEFINITIONS - compiler switches required for using libX11-xcb
# Copyright (c) 2011 Fredrik Höglund <fredrik@kde.org>
# Copyright (c) 2008 Helio Chissini de Castro, <helio@kde.org>
# Copyright (c) 2007 Matthias Kretz, <kretz@kde.org>
#
# Redistribution and use is allowed according to the terms of the BSD license.
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
IF (NOT WIN32)
# use pkg-config to get the directories and then use these values
# in the FIND_PATH() and FIND_LIBRARY() calls
FIND_PACKAGE(PkgConfig)
PKG_CHECK_MODULES(PKG_X11_XCB QUIET x11-xcb)
SET(X11_XCB_DEFINITIONS ${PKG_X11_XCB_CFLAGS})
FIND_PATH(X11_XCB_INCLUDE_DIR NAMES X11/Xlib-xcb.h HINTS ${PKG_X11_XCB_INCLUDE_DIRS})
FIND_LIBRARY(X11_XCB_LIBRARIES NAMES X11-xcb HINTS ${PKG_X11_XCB_LIBRARY_DIRS})
include(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(X11_XCB DEFAULT_MSG X11_XCB_LIBRARIES X11_XCB_INCLUDE_DIR)
MARK_AS_ADVANCED(X11_XCB_INCLUDE_DIR X11_XCB_LIBRARIES)
ENDIF (NOT WIN32)

View File

@ -0,0 +1,51 @@
# - FindXCB
#
# Copyright (C) 2015 Valve Corporation
find_package(PkgConfig)
if(NOT XCB_FIND_COMPONENTS)
set(XCB_FIND_COMPONENTS xcb)
endif()
include(FindPackageHandleStandardArgs)
set(XCB_FOUND true)
set(XCB_INCLUDE_DIRS "")
set(XCB_LIBRARIES "")
foreach(comp ${XCB_FIND_COMPONENTS})
# component name
string(TOUPPER ${comp} compname)
string(REPLACE "-" "_" compname ${compname})
# header name
string(REPLACE "xcb-" "" headername xcb/${comp}.h)
# library name
set(libname ${comp})
pkg_check_modules(PC_${comp} QUIET ${comp})
find_path(${compname}_INCLUDE_DIR NAMES ${headername}
HINTS
${PC_${comp}_INCLUDEDIR}
${PC_${comp}_INCLUDE_DIRS}
)
find_library(${compname}_LIBRARY NAMES ${libname}
HINTS
${PC_${comp}_LIBDIR}
${PC_${comp}_LIBRARY_DIRS}
)
find_package_handle_standard_args(${compname}
FOUND_VAR ${compname}_FOUND
REQUIRED_VARS ${compname}_INCLUDE_DIR ${compname}_LIBRARY)
mark_as_advanced(${compname}_INCLUDE_DIR ${compname}_LIBRARY)
list(APPEND XCB_INCLUDE_DIRS ${${compname}_INCLUDE_DIR})
list(APPEND XCB_LIBRARIES ${${compname}_LIBRARY})
if(NOT ${compname}_FOUND)
set(XCB_FOUND false)
endif()
endforeach()
list(REMOVE_DUPLICATES XCB_INCLUDE_DIRS)

View File

@ -0,0 +1,21 @@
if(NOT EXISTS "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt")
message(FATAL_ERROR "Cannot find install manifest: @CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt")
endif(NOT EXISTS "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt")
file(READ "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt" files)
string(REGEX REPLACE "\n" ";" files "${files}")
foreach(file ${files})
message(STATUS "Uninstalling $ENV{DESTDIR}${file}")
if(IS_SYMLINK "$ENV{DESTDIR}${file}" OR EXISTS "$ENV{DESTDIR}${file}")
exec_program(
"@CMAKE_COMMAND@" ARGS "-E remove \"$ENV{DESTDIR}${file}\""
OUTPUT_VARIABLE rm_out
RETURN_VALUE rm_retval
)
if(NOT "${rm_retval}" STREQUAL 0)
message(FATAL_ERROR "Problem when removing $ENV{DESTDIR}${file}")
endif(NOT "${rm_retval}" STREQUAL 0)
else(IS_SYMLINK "$ENV{DESTDIR}${file}" OR EXISTS "$ENV{DESTDIR}${file}")
message(STATUS "File $ENV{DESTDIR}${file} does not exist.")
endif(IS_SYMLINK "$ENV{DESTDIR}${file}" OR EXISTS "$ENV{DESTDIR}${file}")
endforeach(file)

View File

@ -0,0 +1,28 @@
# Generating vulkan_wrapper
The script for generating the vulkan_wrapper is based on the work done by @olvaffe for Hologram's dispatch table:
https://github.com/LunarG/VulkanSamples/blob/master/Sample-Programs/Hologram/generate-dispatch-table
The wrapper is used to support applications that don't want to link directly against libvulkan.so, which is not
present on Android before 7.0 (Nougat).
The wrapper only contains core functions and WSI extensions.
To regenerate the wrappers:
cd scripts
pushd ../Vulkan-Headers/include/vulkan
../../../scripts/generate_vulkan_wrapper.py parse vulkan.h > parsed_header
Copy contents of parsed_header into generate_vulkan_wrapper.py between the sections that read:
# generated by "generate_vulkan_wrapper.py parse vulkan.h"
# end of generated code
Then run the script:
popd
./generate_vulkan_wrapper.py ../common/vulkan_wrapper.h
./generate_vulkan_wrapper.py ../common/vulkan_wrapper.cpp
clang-format -i vulkan_wrapper.h
clang-format -i vulkan_wrapper.cpp

View File

@ -0,0 +1,84 @@
/*
* Copyright (c) 2016 Google, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* Relicensed from the WTFPL (http://www.wtfpl.net/faq/).
*/
#include "android_util.h"
#include <android_native_app_glue.h>
#include <cassert>
#include <cstring>
#include <vector>
#include <string>
#include <sstream>
#include <stdlib.h>
extern "C" {
// Convert Intents to arg list, returning argc and argv
// Note that this C routine mallocs memory that the caller must free
char **get_args(struct android_app *app, const char *intent_extra_data_key, const char *appTag, int *count) {
std::vector<std::string> args;
JavaVM &vm = *app->activity->vm;
JNIEnv *p_env;
if (vm.AttachCurrentThread(&p_env, nullptr) != JNI_OK) return nullptr;
JNIEnv &env = *p_env;
jobject activity = app->activity->clazz;
jmethodID get_intent_method = env.GetMethodID(env.GetObjectClass(activity), "getIntent", "()Landroid/content/Intent;");
jobject intent = env.CallObjectMethod(activity, get_intent_method);
jmethodID get_string_extra_method =
env.GetMethodID(env.GetObjectClass(intent), "getStringExtra", "(Ljava/lang/String;)Ljava/lang/String;");
jvalue get_string_extra_args;
get_string_extra_args.l = env.NewStringUTF(intent_extra_data_key);
jstring extra_str = static_cast<jstring>(env.CallObjectMethodA(intent, get_string_extra_method, &get_string_extra_args));
std::string args_str;
if (extra_str) {
const char *extra_utf = env.GetStringUTFChars(extra_str, nullptr);
args_str = extra_utf;
env.ReleaseStringUTFChars(extra_str, extra_utf);
env.DeleteLocalRef(extra_str);
}
env.DeleteLocalRef(get_string_extra_args.l);
env.DeleteLocalRef(intent);
vm.DetachCurrentThread();
// split args_str
std::stringstream ss(args_str);
std::string arg;
while (std::getline(ss, arg, ' ')) {
if (!arg.empty()) args.push_back(arg);
}
// Convert our STL results to C friendly constructs
assert(count != nullptr);
*count = args.size() + 1;
char **vector = (char **)malloc(*count * sizeof(char *));
const char *appName = appTag ? appTag : (const char *)"appTag";
vector[0] = (char *)malloc(strlen(appName) * sizeof(char));
strcpy(vector[0], appName);
for (uint32_t i = 0; i < args.size(); i++) {
vector[i + 1] = (char *)malloc(strlen(args[i].c_str()) * sizeof(char));
strcpy(vector[i + 1], args[i].c_str());
}
return vector;
}
} // extern "C"

View File

@ -0,0 +1,32 @@
/*
* Copyright (c) 2016 Google, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* Relicensed from the WTFPL (http://www.wtfpl.net/faq/).
*/
#ifndef ANDROID_UTIL_H
#define ANDROID_UTIL_H
#ifdef __cplusplus
extern "C" {
#endif
char **get_args(struct android_app *app, const char *intent_extra_data_key, const char *appTag, int *count);
#ifdef __cplusplus
}
#endif
#endif

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,540 @@
/*
* Copyright 2018 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// This file is generated.
#ifndef VULKAN_WRAPPER_H
#define VULKAN_WRAPPER_H
#ifdef __cplusplus
extern "C" {
#endif
#define VK_NO_PROTOTYPES 1
#include <vulkan/vulkan.h>
/* Initialize the Vulkan function pointer variables declared in this header.
* Returns 0 if vulkan is not available, non-zero if it is available.
*/
int InitVulkan(void);
// VK_core_0
extern PFN_vkCreateInstance vkCreateInstance;
extern PFN_vkDestroyInstance vkDestroyInstance;
extern PFN_vkEnumeratePhysicalDevices vkEnumeratePhysicalDevices;
extern PFN_vkGetPhysicalDeviceFeatures vkGetPhysicalDeviceFeatures;
extern PFN_vkGetPhysicalDeviceFormatProperties vkGetPhysicalDeviceFormatProperties;
extern PFN_vkGetPhysicalDeviceImageFormatProperties vkGetPhysicalDeviceImageFormatProperties;
extern PFN_vkGetPhysicalDeviceProperties vkGetPhysicalDeviceProperties;
extern PFN_vkGetPhysicalDeviceQueueFamilyProperties vkGetPhysicalDeviceQueueFamilyProperties;
extern PFN_vkGetPhysicalDeviceMemoryProperties vkGetPhysicalDeviceMemoryProperties;
extern PFN_vkGetInstanceProcAddr vkGetInstanceProcAddr;
extern PFN_vkGetDeviceProcAddr vkGetDeviceProcAddr;
extern PFN_vkCreateDevice vkCreateDevice;
extern PFN_vkDestroyDevice vkDestroyDevice;
extern PFN_vkEnumerateInstanceExtensionProperties vkEnumerateInstanceExtensionProperties;
extern PFN_vkEnumerateDeviceExtensionProperties vkEnumerateDeviceExtensionProperties;
extern PFN_vkEnumerateInstanceLayerProperties vkEnumerateInstanceLayerProperties;
extern PFN_vkEnumerateDeviceLayerProperties vkEnumerateDeviceLayerProperties;
extern PFN_vkGetDeviceQueue vkGetDeviceQueue;
extern PFN_vkQueueSubmit vkQueueSubmit;
extern PFN_vkQueueWaitIdle vkQueueWaitIdle;
extern PFN_vkDeviceWaitIdle vkDeviceWaitIdle;
extern PFN_vkAllocateMemory vkAllocateMemory;
extern PFN_vkFreeMemory vkFreeMemory;
extern PFN_vkMapMemory vkMapMemory;
extern PFN_vkUnmapMemory vkUnmapMemory;
extern PFN_vkFlushMappedMemoryRanges vkFlushMappedMemoryRanges;
extern PFN_vkInvalidateMappedMemoryRanges vkInvalidateMappedMemoryRanges;
extern PFN_vkGetDeviceMemoryCommitment vkGetDeviceMemoryCommitment;
extern PFN_vkBindBufferMemory vkBindBufferMemory;
extern PFN_vkBindImageMemory vkBindImageMemory;
extern PFN_vkGetBufferMemoryRequirements vkGetBufferMemoryRequirements;
extern PFN_vkGetImageMemoryRequirements vkGetImageMemoryRequirements;
extern PFN_vkGetImageSparseMemoryRequirements vkGetImageSparseMemoryRequirements;
extern PFN_vkGetPhysicalDeviceSparseImageFormatProperties vkGetPhysicalDeviceSparseImageFormatProperties;
extern PFN_vkQueueBindSparse vkQueueBindSparse;
extern PFN_vkCreateFence vkCreateFence;
extern PFN_vkDestroyFence vkDestroyFence;
extern PFN_vkResetFences vkResetFences;
extern PFN_vkGetFenceStatus vkGetFenceStatus;
extern PFN_vkWaitForFences vkWaitForFences;
extern PFN_vkCreateSemaphore vkCreateSemaphore;
extern PFN_vkDestroySemaphore vkDestroySemaphore;
extern PFN_vkCreateEvent vkCreateEvent;
extern PFN_vkDestroyEvent vkDestroyEvent;
extern PFN_vkGetEventStatus vkGetEventStatus;
extern PFN_vkSetEvent vkSetEvent;
extern PFN_vkResetEvent vkResetEvent;
extern PFN_vkCreateQueryPool vkCreateQueryPool;
extern PFN_vkDestroyQueryPool vkDestroyQueryPool;
extern PFN_vkGetQueryPoolResults vkGetQueryPoolResults;
extern PFN_vkCreateBuffer vkCreateBuffer;
extern PFN_vkDestroyBuffer vkDestroyBuffer;
extern PFN_vkCreateBufferView vkCreateBufferView;
extern PFN_vkDestroyBufferView vkDestroyBufferView;
extern PFN_vkCreateImage vkCreateImage;
extern PFN_vkDestroyImage vkDestroyImage;
extern PFN_vkGetImageSubresourceLayout vkGetImageSubresourceLayout;
extern PFN_vkCreateImageView vkCreateImageView;
extern PFN_vkDestroyImageView vkDestroyImageView;
extern PFN_vkCreateShaderModule vkCreateShaderModule;
extern PFN_vkDestroyShaderModule vkDestroyShaderModule;
extern PFN_vkCreatePipelineCache vkCreatePipelineCache;
extern PFN_vkDestroyPipelineCache vkDestroyPipelineCache;
extern PFN_vkGetPipelineCacheData vkGetPipelineCacheData;
extern PFN_vkMergePipelineCaches vkMergePipelineCaches;
extern PFN_vkCreateGraphicsPipelines vkCreateGraphicsPipelines;
extern PFN_vkCreateComputePipelines vkCreateComputePipelines;
extern PFN_vkDestroyPipeline vkDestroyPipeline;
extern PFN_vkCreatePipelineLayout vkCreatePipelineLayout;
extern PFN_vkDestroyPipelineLayout vkDestroyPipelineLayout;
extern PFN_vkCreateSampler vkCreateSampler;
extern PFN_vkDestroySampler vkDestroySampler;
extern PFN_vkCreateDescriptorSetLayout vkCreateDescriptorSetLayout;
extern PFN_vkDestroyDescriptorSetLayout vkDestroyDescriptorSetLayout;
extern PFN_vkCreateDescriptorPool vkCreateDescriptorPool;
extern PFN_vkDestroyDescriptorPool vkDestroyDescriptorPool;
extern PFN_vkResetDescriptorPool vkResetDescriptorPool;
extern PFN_vkAllocateDescriptorSets vkAllocateDescriptorSets;
extern PFN_vkFreeDescriptorSets vkFreeDescriptorSets;
extern PFN_vkUpdateDescriptorSets vkUpdateDescriptorSets;
extern PFN_vkCreateFramebuffer vkCreateFramebuffer;
extern PFN_vkDestroyFramebuffer vkDestroyFramebuffer;
extern PFN_vkCreateRenderPass vkCreateRenderPass;
extern PFN_vkDestroyRenderPass vkDestroyRenderPass;
extern PFN_vkGetRenderAreaGranularity vkGetRenderAreaGranularity;
extern PFN_vkCreateCommandPool vkCreateCommandPool;
extern PFN_vkDestroyCommandPool vkDestroyCommandPool;
extern PFN_vkResetCommandPool vkResetCommandPool;
extern PFN_vkAllocateCommandBuffers vkAllocateCommandBuffers;
extern PFN_vkFreeCommandBuffers vkFreeCommandBuffers;
extern PFN_vkBeginCommandBuffer vkBeginCommandBuffer;
extern PFN_vkEndCommandBuffer vkEndCommandBuffer;
extern PFN_vkResetCommandBuffer vkResetCommandBuffer;
extern PFN_vkCmdBindPipeline vkCmdBindPipeline;
extern PFN_vkCmdSetViewport vkCmdSetViewport;
extern PFN_vkCmdSetScissor vkCmdSetScissor;
extern PFN_vkCmdSetLineWidth vkCmdSetLineWidth;
extern PFN_vkCmdSetDepthBias vkCmdSetDepthBias;
extern PFN_vkCmdSetBlendConstants vkCmdSetBlendConstants;
extern PFN_vkCmdSetDepthBounds vkCmdSetDepthBounds;
extern PFN_vkCmdSetStencilCompareMask vkCmdSetStencilCompareMask;
extern PFN_vkCmdSetStencilWriteMask vkCmdSetStencilWriteMask;
extern PFN_vkCmdSetStencilReference vkCmdSetStencilReference;
extern PFN_vkCmdBindDescriptorSets vkCmdBindDescriptorSets;
extern PFN_vkCmdBindIndexBuffer vkCmdBindIndexBuffer;
extern PFN_vkCmdBindVertexBuffers vkCmdBindVertexBuffers;
extern PFN_vkCmdDraw vkCmdDraw;
extern PFN_vkCmdDrawIndexed vkCmdDrawIndexed;
extern PFN_vkCmdDrawIndirect vkCmdDrawIndirect;
extern PFN_vkCmdDrawIndexedIndirect vkCmdDrawIndexedIndirect;
extern PFN_vkCmdDispatch vkCmdDispatch;
extern PFN_vkCmdDispatchIndirect vkCmdDispatchIndirect;
extern PFN_vkCmdCopyBuffer vkCmdCopyBuffer;
extern PFN_vkCmdCopyImage vkCmdCopyImage;
extern PFN_vkCmdBlitImage vkCmdBlitImage;
extern PFN_vkCmdCopyBufferToImage vkCmdCopyBufferToImage;
extern PFN_vkCmdCopyImageToBuffer vkCmdCopyImageToBuffer;
extern PFN_vkCmdUpdateBuffer vkCmdUpdateBuffer;
extern PFN_vkCmdFillBuffer vkCmdFillBuffer;
extern PFN_vkCmdClearColorImage vkCmdClearColorImage;
extern PFN_vkCmdClearDepthStencilImage vkCmdClearDepthStencilImage;
extern PFN_vkCmdClearAttachments vkCmdClearAttachments;
extern PFN_vkCmdResolveImage vkCmdResolveImage;
extern PFN_vkCmdSetEvent vkCmdSetEvent;
extern PFN_vkCmdResetEvent vkCmdResetEvent;
extern PFN_vkCmdWaitEvents vkCmdWaitEvents;
extern PFN_vkCmdPipelineBarrier vkCmdPipelineBarrier;
extern PFN_vkCmdBeginQuery vkCmdBeginQuery;
extern PFN_vkCmdEndQuery vkCmdEndQuery;
extern PFN_vkCmdResetQueryPool vkCmdResetQueryPool;
extern PFN_vkCmdWriteTimestamp vkCmdWriteTimestamp;
extern PFN_vkCmdCopyQueryPoolResults vkCmdCopyQueryPoolResults;
extern PFN_vkCmdPushConstants vkCmdPushConstants;
extern PFN_vkCmdBeginRenderPass vkCmdBeginRenderPass;
extern PFN_vkCmdNextSubpass vkCmdNextSubpass;
extern PFN_vkCmdEndRenderPass vkCmdEndRenderPass;
extern PFN_vkCmdExecuteCommands vkCmdExecuteCommands;
// VK_core_1
extern PFN_vkEnumerateInstanceVersion vkEnumerateInstanceVersion;
extern PFN_vkBindBufferMemory2 vkBindBufferMemory2;
extern PFN_vkBindImageMemory2 vkBindImageMemory2;
extern PFN_vkGetDeviceGroupPeerMemoryFeatures vkGetDeviceGroupPeerMemoryFeatures;
extern PFN_vkCmdSetDeviceMask vkCmdSetDeviceMask;
extern PFN_vkCmdDispatchBase vkCmdDispatchBase;
extern PFN_vkEnumeratePhysicalDeviceGroups vkEnumeratePhysicalDeviceGroups;
extern PFN_vkGetImageMemoryRequirements2 vkGetImageMemoryRequirements2;
extern PFN_vkGetBufferMemoryRequirements2 vkGetBufferMemoryRequirements2;
extern PFN_vkGetImageSparseMemoryRequirements2 vkGetImageSparseMemoryRequirements2;
extern PFN_vkGetPhysicalDeviceFeatures2 vkGetPhysicalDeviceFeatures2;
extern PFN_vkGetPhysicalDeviceProperties2 vkGetPhysicalDeviceProperties2;
extern PFN_vkGetPhysicalDeviceFormatProperties2 vkGetPhysicalDeviceFormatProperties2;
extern PFN_vkGetPhysicalDeviceImageFormatProperties2 vkGetPhysicalDeviceImageFormatProperties2;
extern PFN_vkGetPhysicalDeviceQueueFamilyProperties2 vkGetPhysicalDeviceQueueFamilyProperties2;
extern PFN_vkGetPhysicalDeviceMemoryProperties2 vkGetPhysicalDeviceMemoryProperties2;
extern PFN_vkGetPhysicalDeviceSparseImageFormatProperties2 vkGetPhysicalDeviceSparseImageFormatProperties2;
extern PFN_vkTrimCommandPool vkTrimCommandPool;
extern PFN_vkGetDeviceQueue2 vkGetDeviceQueue2;
extern PFN_vkCreateSamplerYcbcrConversion vkCreateSamplerYcbcrConversion;
extern PFN_vkDestroySamplerYcbcrConversion vkDestroySamplerYcbcrConversion;
extern PFN_vkCreateDescriptorUpdateTemplate vkCreateDescriptorUpdateTemplate;
extern PFN_vkDestroyDescriptorUpdateTemplate vkDestroyDescriptorUpdateTemplate;
extern PFN_vkUpdateDescriptorSetWithTemplate vkUpdateDescriptorSetWithTemplate;
extern PFN_vkGetPhysicalDeviceExternalBufferProperties vkGetPhysicalDeviceExternalBufferProperties;
extern PFN_vkGetPhysicalDeviceExternalFenceProperties vkGetPhysicalDeviceExternalFenceProperties;
extern PFN_vkGetPhysicalDeviceExternalSemaphoreProperties vkGetPhysicalDeviceExternalSemaphoreProperties;
extern PFN_vkGetDescriptorSetLayoutSupport vkGetDescriptorSetLayoutSupport;
// VK_core_2
extern PFN_vkCmdDrawIndirectCount vkCmdDrawIndirectCount;
extern PFN_vkCmdDrawIndexedIndirectCount vkCmdDrawIndexedIndirectCount;
extern PFN_vkCreateRenderPass2 vkCreateRenderPass2;
extern PFN_vkCmdBeginRenderPass2 vkCmdBeginRenderPass2;
extern PFN_vkCmdNextSubpass2 vkCmdNextSubpass2;
extern PFN_vkCmdEndRenderPass2 vkCmdEndRenderPass2;
extern PFN_vkResetQueryPool vkResetQueryPool;
extern PFN_vkGetSemaphoreCounterValue vkGetSemaphoreCounterValue;
extern PFN_vkWaitSemaphores vkWaitSemaphores;
extern PFN_vkSignalSemaphore vkSignalSemaphore;
extern PFN_vkGetBufferDeviceAddress vkGetBufferDeviceAddress;
extern PFN_vkGetBufferOpaqueCaptureAddress vkGetBufferOpaqueCaptureAddress;
extern PFN_vkGetDeviceMemoryOpaqueCaptureAddress vkGetDeviceMemoryOpaqueCaptureAddress;
// VK_core_3
extern PFN_vkGetPhysicalDeviceToolProperties vkGetPhysicalDeviceToolProperties;
extern PFN_vkCreatePrivateDataSlot vkCreatePrivateDataSlot;
extern PFN_vkDestroyPrivateDataSlot vkDestroyPrivateDataSlot;
extern PFN_vkSetPrivateData vkSetPrivateData;
extern PFN_vkGetPrivateData vkGetPrivateData;
extern PFN_vkCmdSetEvent2 vkCmdSetEvent2;
extern PFN_vkCmdResetEvent2 vkCmdResetEvent2;
extern PFN_vkCmdWaitEvents2 vkCmdWaitEvents2;
extern PFN_vkCmdPipelineBarrier2 vkCmdPipelineBarrier2;
extern PFN_vkCmdWriteTimestamp2 vkCmdWriteTimestamp2;
extern PFN_vkQueueSubmit2 vkQueueSubmit2;
extern PFN_vkCmdCopyBuffer2 vkCmdCopyBuffer2;
extern PFN_vkCmdCopyImage2 vkCmdCopyImage2;
extern PFN_vkCmdCopyBufferToImage2 vkCmdCopyBufferToImage2;
extern PFN_vkCmdCopyImageToBuffer2 vkCmdCopyImageToBuffer2;
extern PFN_vkCmdBlitImage2 vkCmdBlitImage2;
extern PFN_vkCmdResolveImage2 vkCmdResolveImage2;
extern PFN_vkCmdBeginRendering vkCmdBeginRendering;
extern PFN_vkCmdEndRendering vkCmdEndRendering;
extern PFN_vkCmdSetCullMode vkCmdSetCullMode;
extern PFN_vkCmdSetFrontFace vkCmdSetFrontFace;
extern PFN_vkCmdSetPrimitiveTopology vkCmdSetPrimitiveTopology;
extern PFN_vkCmdSetViewportWithCount vkCmdSetViewportWithCount;
extern PFN_vkCmdSetScissorWithCount vkCmdSetScissorWithCount;
extern PFN_vkCmdBindVertexBuffers2 vkCmdBindVertexBuffers2;
extern PFN_vkCmdSetDepthTestEnable vkCmdSetDepthTestEnable;
extern PFN_vkCmdSetDepthWriteEnable vkCmdSetDepthWriteEnable;
extern PFN_vkCmdSetDepthCompareOp vkCmdSetDepthCompareOp;
extern PFN_vkCmdSetDepthBoundsTestEnable vkCmdSetDepthBoundsTestEnable;
extern PFN_vkCmdSetStencilTestEnable vkCmdSetStencilTestEnable;
extern PFN_vkCmdSetStencilOp vkCmdSetStencilOp;
extern PFN_vkCmdSetRasterizerDiscardEnable vkCmdSetRasterizerDiscardEnable;
extern PFN_vkCmdSetDepthBiasEnable vkCmdSetDepthBiasEnable;
extern PFN_vkCmdSetPrimitiveRestartEnable vkCmdSetPrimitiveRestartEnable;
extern PFN_vkGetDeviceBufferMemoryRequirements vkGetDeviceBufferMemoryRequirements;
extern PFN_vkGetDeviceImageMemoryRequirements vkGetDeviceImageMemoryRequirements;
extern PFN_vkGetDeviceImageSparseMemoryRequirements vkGetDeviceImageSparseMemoryRequirements;
// VK_KHR_surface
extern PFN_vkDestroySurfaceKHR vkDestroySurfaceKHR;
extern PFN_vkGetPhysicalDeviceSurfaceSupportKHR vkGetPhysicalDeviceSurfaceSupportKHR;
extern PFN_vkGetPhysicalDeviceSurfaceCapabilitiesKHR vkGetPhysicalDeviceSurfaceCapabilitiesKHR;
extern PFN_vkGetPhysicalDeviceSurfaceFormatsKHR vkGetPhysicalDeviceSurfaceFormatsKHR;
extern PFN_vkGetPhysicalDeviceSurfacePresentModesKHR vkGetPhysicalDeviceSurfacePresentModesKHR;
// VK_KHR_swapchain
extern PFN_vkCreateSwapchainKHR vkCreateSwapchainKHR;
extern PFN_vkDestroySwapchainKHR vkDestroySwapchainKHR;
extern PFN_vkGetSwapchainImagesKHR vkGetSwapchainImagesKHR;
extern PFN_vkAcquireNextImageKHR vkAcquireNextImageKHR;
extern PFN_vkQueuePresentKHR vkQueuePresentKHR;
extern PFN_vkGetDeviceGroupPresentCapabilitiesKHR vkGetDeviceGroupPresentCapabilitiesKHR;
extern PFN_vkGetDeviceGroupSurfacePresentModesKHR vkGetDeviceGroupSurfacePresentModesKHR;
extern PFN_vkGetPhysicalDevicePresentRectanglesKHR vkGetPhysicalDevicePresentRectanglesKHR;
extern PFN_vkAcquireNextImage2KHR vkAcquireNextImage2KHR;
// VK_KHR_display
extern PFN_vkGetPhysicalDeviceDisplayPropertiesKHR vkGetPhysicalDeviceDisplayPropertiesKHR;
extern PFN_vkGetPhysicalDeviceDisplayPlanePropertiesKHR vkGetPhysicalDeviceDisplayPlanePropertiesKHR;
extern PFN_vkGetDisplayPlaneSupportedDisplaysKHR vkGetDisplayPlaneSupportedDisplaysKHR;
extern PFN_vkGetDisplayModePropertiesKHR vkGetDisplayModePropertiesKHR;
extern PFN_vkCreateDisplayModeKHR vkCreateDisplayModeKHR;
extern PFN_vkGetDisplayPlaneCapabilitiesKHR vkGetDisplayPlaneCapabilitiesKHR;
extern PFN_vkCreateDisplayPlaneSurfaceKHR vkCreateDisplayPlaneSurfaceKHR;
// VK_KHR_display_swapchain
extern PFN_vkCreateSharedSwapchainsKHR vkCreateSharedSwapchainsKHR;
// VK_KHR_dynamic_rendering
extern PFN_vkCmdBeginRenderingKHR vkCmdBeginRenderingKHR;
extern PFN_vkCmdEndRenderingKHR vkCmdEndRenderingKHR;
// VK_KHR_get_physical_device_properties2
extern PFN_vkGetPhysicalDeviceFeatures2KHR vkGetPhysicalDeviceFeatures2KHR;
extern PFN_vkGetPhysicalDeviceProperties2KHR vkGetPhysicalDeviceProperties2KHR;
extern PFN_vkGetPhysicalDeviceFormatProperties2KHR vkGetPhysicalDeviceFormatProperties2KHR;
extern PFN_vkGetPhysicalDeviceImageFormatProperties2KHR vkGetPhysicalDeviceImageFormatProperties2KHR;
extern PFN_vkGetPhysicalDeviceQueueFamilyProperties2KHR vkGetPhysicalDeviceQueueFamilyProperties2KHR;
extern PFN_vkGetPhysicalDeviceMemoryProperties2KHR vkGetPhysicalDeviceMemoryProperties2KHR;
extern PFN_vkGetPhysicalDeviceSparseImageFormatProperties2KHR vkGetPhysicalDeviceSparseImageFormatProperties2KHR;
// VK_KHR_device_group
extern PFN_vkGetDeviceGroupPeerMemoryFeaturesKHR vkGetDeviceGroupPeerMemoryFeaturesKHR;
extern PFN_vkCmdSetDeviceMaskKHR vkCmdSetDeviceMaskKHR;
extern PFN_vkCmdDispatchBaseKHR vkCmdDispatchBaseKHR;
// VK_KHR_maintenance1
extern PFN_vkTrimCommandPoolKHR vkTrimCommandPoolKHR;
// VK_KHR_device_group_creation
extern PFN_vkEnumeratePhysicalDeviceGroupsKHR vkEnumeratePhysicalDeviceGroupsKHR;
// VK_KHR_external_memory_capabilities
extern PFN_vkGetPhysicalDeviceExternalBufferPropertiesKHR vkGetPhysicalDeviceExternalBufferPropertiesKHR;
// VK_KHR_external_memory_fd
extern PFN_vkGetMemoryFdKHR vkGetMemoryFdKHR;
extern PFN_vkGetMemoryFdPropertiesKHR vkGetMemoryFdPropertiesKHR;
// VK_KHR_external_semaphore_capabilities
extern PFN_vkGetPhysicalDeviceExternalSemaphorePropertiesKHR vkGetPhysicalDeviceExternalSemaphorePropertiesKHR;
// VK_KHR_external_semaphore_fd
extern PFN_vkImportSemaphoreFdKHR vkImportSemaphoreFdKHR;
extern PFN_vkGetSemaphoreFdKHR vkGetSemaphoreFdKHR;
// VK_KHR_push_descriptor
extern PFN_vkCmdPushDescriptorSetKHR vkCmdPushDescriptorSetKHR;
extern PFN_vkCmdPushDescriptorSetWithTemplateKHR vkCmdPushDescriptorSetWithTemplateKHR;
// VK_KHR_descriptor_update_template
extern PFN_vkCreateDescriptorUpdateTemplateKHR vkCreateDescriptorUpdateTemplateKHR;
extern PFN_vkDestroyDescriptorUpdateTemplateKHR vkDestroyDescriptorUpdateTemplateKHR;
extern PFN_vkUpdateDescriptorSetWithTemplateKHR vkUpdateDescriptorSetWithTemplateKHR;
// VK_KHR_create_renderpass2
extern PFN_vkCreateRenderPass2KHR vkCreateRenderPass2KHR;
extern PFN_vkCmdBeginRenderPass2KHR vkCmdBeginRenderPass2KHR;
extern PFN_vkCmdNextSubpass2KHR vkCmdNextSubpass2KHR;
extern PFN_vkCmdEndRenderPass2KHR vkCmdEndRenderPass2KHR;
// VK_KHR_shared_presentable_image
extern PFN_vkGetSwapchainStatusKHR vkGetSwapchainStatusKHR;
// VK_KHR_external_fence_capabilities
extern PFN_vkGetPhysicalDeviceExternalFencePropertiesKHR vkGetPhysicalDeviceExternalFencePropertiesKHR;
// VK_KHR_external_fence_fd
extern PFN_vkImportFenceFdKHR vkImportFenceFdKHR;
extern PFN_vkGetFenceFdKHR vkGetFenceFdKHR;
// VK_KHR_performance_query
extern PFN_vkEnumeratePhysicalDeviceQueueFamilyPerformanceQueryCountersKHR
vkEnumeratePhysicalDeviceQueueFamilyPerformanceQueryCountersKHR;
extern PFN_vkGetPhysicalDeviceQueueFamilyPerformanceQueryPassesKHR vkGetPhysicalDeviceQueueFamilyPerformanceQueryPassesKHR;
extern PFN_vkAcquireProfilingLockKHR vkAcquireProfilingLockKHR;
extern PFN_vkReleaseProfilingLockKHR vkReleaseProfilingLockKHR;
// VK_KHR_get_surface_capabilities2
extern PFN_vkGetPhysicalDeviceSurfaceCapabilities2KHR vkGetPhysicalDeviceSurfaceCapabilities2KHR;
extern PFN_vkGetPhysicalDeviceSurfaceFormats2KHR vkGetPhysicalDeviceSurfaceFormats2KHR;
// VK_KHR_get_display_properties2
extern PFN_vkGetPhysicalDeviceDisplayProperties2KHR vkGetPhysicalDeviceDisplayProperties2KHR;
extern PFN_vkGetPhysicalDeviceDisplayPlaneProperties2KHR vkGetPhysicalDeviceDisplayPlaneProperties2KHR;
extern PFN_vkGetDisplayModeProperties2KHR vkGetDisplayModeProperties2KHR;
extern PFN_vkGetDisplayPlaneCapabilities2KHR vkGetDisplayPlaneCapabilities2KHR;
// VK_KHR_get_memory_requirements2
extern PFN_vkGetImageMemoryRequirements2KHR vkGetImageMemoryRequirements2KHR;
extern PFN_vkGetBufferMemoryRequirements2KHR vkGetBufferMemoryRequirements2KHR;
extern PFN_vkGetImageSparseMemoryRequirements2KHR vkGetImageSparseMemoryRequirements2KHR;
// VK_KHR_sampler_ycbcr_conversion
extern PFN_vkCreateSamplerYcbcrConversionKHR vkCreateSamplerYcbcrConversionKHR;
extern PFN_vkDestroySamplerYcbcrConversionKHR vkDestroySamplerYcbcrConversionKHR;
// VK_KHR_bind_memory2
extern PFN_vkBindBufferMemory2KHR vkBindBufferMemory2KHR;
extern PFN_vkBindImageMemory2KHR vkBindImageMemory2KHR;
// VK_KHR_maintenance3
extern PFN_vkGetDescriptorSetLayoutSupportKHR vkGetDescriptorSetLayoutSupportKHR;
// VK_KHR_draw_indirect_count
extern PFN_vkCmdDrawIndirectCountKHR vkCmdDrawIndirectCountKHR;
extern PFN_vkCmdDrawIndexedIndirectCountKHR vkCmdDrawIndexedIndirectCountKHR;
// VK_KHR_timeline_semaphore
extern PFN_vkGetSemaphoreCounterValueKHR vkGetSemaphoreCounterValueKHR;
extern PFN_vkWaitSemaphoresKHR vkWaitSemaphoresKHR;
extern PFN_vkSignalSemaphoreKHR vkSignalSemaphoreKHR;
// VK_KHR_fragment_shading_rate
extern PFN_vkGetPhysicalDeviceFragmentShadingRatesKHR vkGetPhysicalDeviceFragmentShadingRatesKHR;
extern PFN_vkCmdSetFragmentShadingRateKHR vkCmdSetFragmentShadingRateKHR;
// VK_KHR_present_wait
extern PFN_vkWaitForPresentKHR vkWaitForPresentKHR;
// VK_KHR_buffer_device_address
extern PFN_vkGetBufferDeviceAddressKHR vkGetBufferDeviceAddressKHR;
extern PFN_vkGetBufferOpaqueCaptureAddressKHR vkGetBufferOpaqueCaptureAddressKHR;
extern PFN_vkGetDeviceMemoryOpaqueCaptureAddressKHR vkGetDeviceMemoryOpaqueCaptureAddressKHR;
// VK_KHR_deferred_host_operations
extern PFN_vkCreateDeferredOperationKHR vkCreateDeferredOperationKHR;
extern PFN_vkDestroyDeferredOperationKHR vkDestroyDeferredOperationKHR;
extern PFN_vkGetDeferredOperationMaxConcurrencyKHR vkGetDeferredOperationMaxConcurrencyKHR;
extern PFN_vkGetDeferredOperationResultKHR vkGetDeferredOperationResultKHR;
extern PFN_vkDeferredOperationJoinKHR vkDeferredOperationJoinKHR;
// VK_KHR_pipeline_executable_properties
extern PFN_vkGetPipelineExecutablePropertiesKHR vkGetPipelineExecutablePropertiesKHR;
extern PFN_vkGetPipelineExecutableStatisticsKHR vkGetPipelineExecutableStatisticsKHR;
extern PFN_vkGetPipelineExecutableInternalRepresentationsKHR vkGetPipelineExecutableInternalRepresentationsKHR;
// VK_KHR_synchronization2
extern PFN_vkCmdSetEvent2KHR vkCmdSetEvent2KHR;
extern PFN_vkCmdResetEvent2KHR vkCmdResetEvent2KHR;
extern PFN_vkCmdWaitEvents2KHR vkCmdWaitEvents2KHR;
extern PFN_vkCmdPipelineBarrier2KHR vkCmdPipelineBarrier2KHR;
extern PFN_vkCmdWriteTimestamp2KHR vkCmdWriteTimestamp2KHR;
extern PFN_vkQueueSubmit2KHR vkQueueSubmit2KHR;
extern PFN_vkCmdWriteBufferMarker2AMD vkCmdWriteBufferMarker2AMD;
extern PFN_vkGetQueueCheckpointData2NV vkGetQueueCheckpointData2NV;
// VK_KHR_copy_commands2
extern PFN_vkCmdCopyBuffer2KHR vkCmdCopyBuffer2KHR;
extern PFN_vkCmdCopyImage2KHR vkCmdCopyImage2KHR;
extern PFN_vkCmdCopyBufferToImage2KHR vkCmdCopyBufferToImage2KHR;
extern PFN_vkCmdCopyImageToBuffer2KHR vkCmdCopyImageToBuffer2KHR;
extern PFN_vkCmdBlitImage2KHR vkCmdBlitImage2KHR;
extern PFN_vkCmdResolveImage2KHR vkCmdResolveImage2KHR;
// VK_KHR_maintenance4
extern PFN_vkGetDeviceBufferMemoryRequirementsKHR vkGetDeviceBufferMemoryRequirementsKHR;
extern PFN_vkGetDeviceImageMemoryRequirementsKHR vkGetDeviceImageMemoryRequirementsKHR;
extern PFN_vkGetDeviceImageSparseMemoryRequirementsKHR vkGetDeviceImageSparseMemoryRequirementsKHR;
// VK_KHR_acceleration_structure
extern PFN_vkCreateAccelerationStructureKHR vkCreateAccelerationStructureKHR;
extern PFN_vkDestroyAccelerationStructureKHR vkDestroyAccelerationStructureKHR;
extern PFN_vkCmdBuildAccelerationStructuresKHR vkCmdBuildAccelerationStructuresKHR;
extern PFN_vkCmdBuildAccelerationStructuresIndirectKHR vkCmdBuildAccelerationStructuresIndirectKHR;
extern PFN_vkBuildAccelerationStructuresKHR vkBuildAccelerationStructuresKHR;
extern PFN_vkCopyAccelerationStructureKHR vkCopyAccelerationStructureKHR;
extern PFN_vkCopyAccelerationStructureToMemoryKHR vkCopyAccelerationStructureToMemoryKHR;
extern PFN_vkCopyMemoryToAccelerationStructureKHR vkCopyMemoryToAccelerationStructureKHR;
extern PFN_vkWriteAccelerationStructuresPropertiesKHR vkWriteAccelerationStructuresPropertiesKHR;
extern PFN_vkCmdCopyAccelerationStructureKHR vkCmdCopyAccelerationStructureKHR;
extern PFN_vkCmdCopyAccelerationStructureToMemoryKHR vkCmdCopyAccelerationStructureToMemoryKHR;
extern PFN_vkCmdCopyMemoryToAccelerationStructureKHR vkCmdCopyMemoryToAccelerationStructureKHR;
extern PFN_vkGetAccelerationStructureDeviceAddressKHR vkGetAccelerationStructureDeviceAddressKHR;
extern PFN_vkCmdWriteAccelerationStructuresPropertiesKHR vkCmdWriteAccelerationStructuresPropertiesKHR;
extern PFN_vkGetDeviceAccelerationStructureCompatibilityKHR vkGetDeviceAccelerationStructureCompatibilityKHR;
extern PFN_vkGetAccelerationStructureBuildSizesKHR vkGetAccelerationStructureBuildSizesKHR;
// VK_KHR_ray_tracing_pipeline
extern PFN_vkCmdTraceRaysKHR vkCmdTraceRaysKHR;
extern PFN_vkCreateRayTracingPipelinesKHR vkCreateRayTracingPipelinesKHR;
extern PFN_vkGetRayTracingCaptureReplayShaderGroupHandlesKHR vkGetRayTracingCaptureReplayShaderGroupHandlesKHR;
extern PFN_vkCmdTraceRaysIndirectKHR vkCmdTraceRaysIndirectKHR;
extern PFN_vkGetRayTracingShaderGroupStackSizeKHR vkGetRayTracingShaderGroupStackSizeKHR;
extern PFN_vkCmdSetRayTracingPipelineStackSizeKHR vkCmdSetRayTracingPipelineStackSizeKHR;
#ifdef VK_USE_PLATFORM_ANDROID_KHR
// VK_KHR_android_surface
extern PFN_vkCreateAndroidSurfaceKHR vkCreateAndroidSurfaceKHR;
#endif
#ifdef VK_USE_PLATFORM_WAYLAND_KHR
// VK_KHR_wayland_surface
extern PFN_vkCreateWaylandSurfaceKHR vkCreateWaylandSurfaceKHR;
extern PFN_vkGetPhysicalDeviceWaylandPresentationSupportKHR vkGetPhysicalDeviceWaylandPresentationSupportKHR;
#endif
#ifdef VK_USE_PLATFORM_WIN32_KHR
// VK_KHR_win32_surface
extern PFN_vkCreateWin32SurfaceKHR vkCreateWin32SurfaceKHR;
extern PFN_vkGetPhysicalDeviceWin32PresentationSupportKHR vkGetPhysicalDeviceWin32PresentationSupportKHR;
#endif
#ifdef VK_USE_PLATFORM_WIN32_KHR
// VK_KHR_external_memory_win32
extern PFN_vkGetMemoryWin32HandleKHR vkGetMemoryWin32HandleKHR;
extern PFN_vkGetMemoryWin32HandlePropertiesKHR vkGetMemoryWin32HandlePropertiesKHR;
#endif
#ifdef VK_USE_PLATFORM_WIN32_KHR
// VK_KHR_external_semaphore_win32
extern PFN_vkImportSemaphoreWin32HandleKHR vkImportSemaphoreWin32HandleKHR;
extern PFN_vkGetSemaphoreWin32HandleKHR vkGetSemaphoreWin32HandleKHR;
#endif
#ifdef VK_USE_PLATFORM_WIN32_KHR
// VK_KHR_external_fence_win32
extern PFN_vkImportFenceWin32HandleKHR vkImportFenceWin32HandleKHR;
extern PFN_vkGetFenceWin32HandleKHR vkGetFenceWin32HandleKHR;
#endif
#ifdef VK_USE_PLATFORM_XCB_KHR
// VK_KHR_xcb_surface
extern PFN_vkCreateXcbSurfaceKHR vkCreateXcbSurfaceKHR;
extern PFN_vkGetPhysicalDeviceXcbPresentationSupportKHR vkGetPhysicalDeviceXcbPresentationSupportKHR;
#endif
#ifdef VK_USE_PLATFORM_XLIB_KHR
// VK_KHR_xlib_surface
extern PFN_vkCreateXlibSurfaceKHR vkCreateXlibSurfaceKHR;
extern PFN_vkGetPhysicalDeviceXlibPresentationSupportKHR vkGetPhysicalDeviceXlibPresentationSupportKHR;
#endif
#ifdef VK_ENABLE_BETA_EXTENSIONS
// VK_KHR_video_queue
extern PFN_vkGetPhysicalDeviceVideoCapabilitiesKHR vkGetPhysicalDeviceVideoCapabilitiesKHR;
extern PFN_vkGetPhysicalDeviceVideoFormatPropertiesKHR vkGetPhysicalDeviceVideoFormatPropertiesKHR;
extern PFN_vkCreateVideoSessionKHR vkCreateVideoSessionKHR;
extern PFN_vkDestroyVideoSessionKHR vkDestroyVideoSessionKHR;
extern PFN_vkGetVideoSessionMemoryRequirementsKHR vkGetVideoSessionMemoryRequirementsKHR;
extern PFN_vkBindVideoSessionMemoryKHR vkBindVideoSessionMemoryKHR;
extern PFN_vkCreateVideoSessionParametersKHR vkCreateVideoSessionParametersKHR;
extern PFN_vkUpdateVideoSessionParametersKHR vkUpdateVideoSessionParametersKHR;
extern PFN_vkDestroyVideoSessionParametersKHR vkDestroyVideoSessionParametersKHR;
extern PFN_vkCmdBeginVideoCodingKHR vkCmdBeginVideoCodingKHR;
extern PFN_vkCmdEndVideoCodingKHR vkCmdEndVideoCodingKHR;
extern PFN_vkCmdControlVideoCodingKHR vkCmdControlVideoCodingKHR;
#endif
#ifdef VK_ENABLE_BETA_EXTENSIONS
// VK_KHR_video_decode_queue
extern PFN_vkCmdDecodeVideoKHR vkCmdDecodeVideoKHR;
#endif
#ifdef VK_ENABLE_BETA_EXTENSIONS
// VK_KHR_video_encode_queue
extern PFN_vkCmdEncodeVideoKHR vkCmdEncodeVideoKHR;
#endif
#ifdef __cplusplus
}
#endif
#endif // VULKAN_WRAPPER_H

View File

@ -0,0 +1,355 @@
# ~~~
# Copyright (c) 2018 Valve Corporation
# Copyright (c) 2018 LunarG, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# ~~~
set(CUBE_INCLUDE_DIRS ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_BINARY_DIR}/.. ${VulkanHeaders_INCLUDE_DIR})
set(SCRIPTS_DIR "${PROJECT_SOURCE_DIR}/scripts")
if (NOT GLSLANG_INSTALL_DIR AND DEFINED ENV{GLSLANG_INSTALL_DIR})
set(GLSLANG_INSTALL_DIR $ENV{GLSLANG_INSTALL_DIR})
endif()
if(GLSLANG_INSTALL_DIR)
message(STATUS "Using GLSLANG_INSTALL_DIR to look for glslangValidator")
find_program(GLSLANG_VALIDATOR names glslangValidator HINTS "${GLSLANG_INSTALL_DIR}/bin")
else()
set(GLSLANG_VALIDATOR_NAME "glslangValidator")
message(STATUS "Using cmake find_program to look for glslangValidator")
if(WIN32)
execute_process(
COMMAND ${PYTHON_EXECUTABLE} ${SCRIPTS_DIR}/fetch_glslangvalidator.py glslang-master-windows-x64-Release.zip)
set(GLSLANG_VALIDATOR_NAME "glslangValidator.exe")
elseif(APPLE)
execute_process(COMMAND ${PYTHON_EXECUTABLE} ${SCRIPTS_DIR}/fetch_glslangvalidator.py glslang-master-osx-Release.zip)
elseif(UNIX AND NOT APPLE) # i.e. Linux
execute_process(COMMAND ${PYTHON_EXECUTABLE} ${SCRIPTS_DIR}/fetch_glslangvalidator.py glslang-master-linux-Release.zip)
endif()
if (WIN32)
set(PLATFORM_DIR "${PROJECT_SOURCE_DIR}/glslang/windows/bin")
elseif(APPLE)
set(PLATFORM_DIR "${PROJECT_SOURCE_DIR}/glslang/darwin/bin")
else()
set(PLATFORM_DIR "${PROJECT_SOURCE_DIR}/glslang/linux/bin")
endif()
find_program(GLSLANG_VALIDATOR NAMES ${GLSLANG_VALIDATOR_NAME} HINTS ${PLATFORM_DIR})
endif()
if(UNIX AND NOT APPLE) # i.e. Linux
include(FindPkgConfig)
option(BUILD_WSI_XCB_SUPPORT "Build XCB WSI support" ON)
option(BUILD_WSI_XLIB_SUPPORT "Build Xlib WSI support" ON)
option(BUILD_WSI_WAYLAND_SUPPORT "Build Wayland WSI support" ON)
option(BUILD_WSI_DIRECTFB_SUPPORT "Build DirectFB WSI support" OFF)
set(CUBE_WSI_SELECTION "XCB" CACHE STRING "Select WSI target for vkcube (XCB, XLIB, WAYLAND, DIRECTFB, DISPLAY)")
if(BUILD_WSI_XCB_SUPPORT)
find_package(XCB REQUIRED)
endif()
if(BUILD_WSI_XLIB_SUPPORT)
find_package(X11 REQUIRED)
endif()
if(BUILD_WSI_WAYLAND_SUPPORT)
find_package(Wayland REQUIRED)
find_package(WaylandScanner REQUIRED)
find_package(WaylandProtocols REQUIRED)
include_directories(${WAYLAND_CLIENT_INCLUDE_DIR})
set(XDG_SHELL_PROTOCOL ${WAYLAND_PROTOCOLS_PATH}/stable/xdg-shell/xdg-shell.xml)
add_custom_command(COMMENT "Generating xdg-shell protocol dispatch data"
OUTPUT xdg-shell-code.c
COMMAND ${WAYLAND_SCANNER_EXECUTABLE}
private-code
${XDG_SHELL_PROTOCOL}
${CMAKE_CURRENT_BINARY_DIR}/xdg-shell-code.c
MAIN_DEPENDENCY ${XDG_SHELL_PROTOCOL}
DEPENDS ${XDG_SHELL_PROTOCOL} ${WAYLAND_SCANNER_EXECUTABLE})
add_custom_command(COMMENT "Generating xdg-shell protocol header"
OUTPUT xdg-shell-client-header.h
COMMAND ${WAYLAND_SCANNER_EXECUTABLE}
client-header
${XDG_SHELL_PROTOCOL}
${CMAKE_CURRENT_BINARY_DIR}/xdg-shell-client-header.h
MAIN_DEPENDENCY ${XDG_SHELL_PROTOCOL}
DEPENDS ${XDG_SHELL_PROTOCOL} ${WAYLAND_SCANNER_EXECUTABLE})
set(XDG_DECORATION_PROTOCOL ${WAYLAND_PROTOCOLS_PATH}/unstable/xdg-decoration/xdg-decoration-unstable-v1.xml)
add_custom_command(COMMENT "Generating xdg-decoration protocol dispatch data"
OUTPUT xdg-decoration-code.c
COMMAND ${WAYLAND_SCANNER_EXECUTABLE}
private-code
${XDG_DECORATION_PROTOCOL}
${CMAKE_CURRENT_BINARY_DIR}/xdg-decoration-code.c
MAIN_DEPENDENCY ${XDG_DECORATION_PROTOCOL}
DEPENDS ${XDG_DECORATION_PROTOCOL} ${WAYLAND_SCANNER_EXECUTABLE})
add_custom_command(COMMENT "Generating xdg-decoration protocol header"
OUTPUT xdg-decoration-client-header.h
COMMAND ${WAYLAND_SCANNER_EXECUTABLE}
client-header
${XDG_DECORATION_PROTOCOL}
${CMAKE_CURRENT_BINARY_DIR}/xdg-decoration-client-header.h
MAIN_DEPENDENCY ${XDG_DECORATION_PROTOCOL}
DEPENDS ${XDG_DECORATION_PROTOCOL} ${WAYLAND_SCANNER_EXECUTABLE})
endif()
if(BUILD_WSI_DIRECTFB_SUPPORT)
find_package(DirectFB REQUIRED)
include_directories(${DIRECTFB_INCLUDE_DIR})
endif()
endif()
if(WIN32)
add_definitions(-DVK_USE_PLATFORM_WIN32_KHR -DWIN32_LEAN_AND_MEAN)
if(MSVC AND NOT MSVC_VERSION LESS 1900)
# If MSVC, Enable control flow guard
message(STATUS "Building vkcube with control flow guard")
add_compile_options("$<$<CXX_COMPILER_ID:MSVC>:/guard:cf>")
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} /guard:cf")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /guard:cf")
endif()
elseif(ANDROID)
add_definitions(-DVK_USE_PLATFORM_ANDROID_KHR)
elseif(APPLE)
add_definitions(-DVK_USE_PLATFORM_METAL_EXT)
elseif(UNIX AND NOT APPLE) # i.e. Linux
if(NOT CUBE_WSI_SELECTION)
set(CUBE_WSI_SELECTION "XCB")
endif()
if(CUBE_WSI_SELECTION STREQUAL "XCB")
if(NOT BUILD_WSI_XCB_SUPPORT)
message(FATAL_ERROR "Selected XCB for vkcube build but not building Xcb support")
endif()
set(CUBE_INCLUDE_DIRS ${XCB_INCLUDE_DIRS} ${CUBE_INCLUDE_DIRS})
link_libraries(${XCB_LIBRARIES})
set(CUBE_PLATFORM VK_USE_PLATFORM_XCB_KHR)
elseif(CUBE_WSI_SELECTION STREQUAL "XLIB")
if(NOT BUILD_WSI_XLIB_SUPPORT)
message(FATAL_ERROR "Selected XLIB for vkcube build but not building Xlib support")
endif()
set(CUBE_INCLUDE_DIRS ${X11_INCLUDE_DIR} ${CUBE_INCLUDE_DIRS})
link_libraries(${X11_LIBRARIES})
set(CUBE_PLATFORM VK_USE_PLATFORM_XLIB_KHR)
elseif(CUBE_WSI_SELECTION STREQUAL "WAYLAND")
if(NOT BUILD_WSI_WAYLAND_SUPPORT)
message(FATAL_ERROR "Selected Wayland for vkcube build but not building Wayland support")
endif()
set(CUBE_INCLUDE_DIRS ${WAYLAND_CLIENT_INCLUDE_DIR} ${CUBE_INCLUDE_DIRS})
link_libraries(${WAYLAND_CLIENT_LIBRARIES})
set(CUBE_PLATFORM VK_USE_PLATFORM_WAYLAND_KHR)
set(XDG_SHELL_PROTOCOL ${WAYLAND_PROTOCOLS_PATH}/stable/xdg-shell/xdg-shell.xml)
set(OPTIONAL_WAYLAND_DATA_FILES
${CMAKE_CURRENT_BINARY_DIR}/xdg-shell-code.c
${CMAKE_CURRENT_BINARY_DIR}/xdg-shell-client-header.h
${CMAKE_CURRENT_BINARY_DIR}/xdg-decoration-code.c
${CMAKE_CURRENT_BINARY_DIR}/xdg-decoration-client-header.h)
include_directories(${CMAKE_CURRENT_BINARY_DIR})
elseif(CUBE_WSI_SELECTION STREQUAL "DIRECTFB")
if(NOT BUILD_WSI_DIRECTFB_SUPPORT)
message(FATAL_ERROR "Selected DIRECTFB for vkcube build but not building DirectFB support")
endif()
set(CUBE_INCLUDE_DIRS ${DIRECTFB_INCLUDE_DIR} ${CUBE_INCLUDE_DIRS})
link_libraries(${DIRECTFB_LIBRARIES})
set(CUBE_PLATFORM VK_USE_PLATFORM_DIRECTFB_EXT)
elseif(CUBE_WSI_SELECTION STREQUAL "DISPLAY")
set(CUBE_PLATFORM VK_USE_PLATFORM_DISPLAY_KHR)
else()
message(FATAL_ERROR "Unrecognized value for CUBE_WSI_SELECTION: ${CUBE_WSI_SELECTION}")
endif()
link_libraries(${API_LOWERCASE} m)
else()
message(FATAL_ERROR "Unsupported Platform!")
endif()
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
if(WIN32)
# Use static MSVCRT libraries
foreach(configuration
in
CMAKE_C_FLAGS_DEBUG
CMAKE_C_FLAGS_MINSIZEREL
CMAKE_C_FLAGS_RELEASE
CMAKE_C_FLAGS_RELWITHDEBINFO
CMAKE_CXX_FLAGS_DEBUG
CMAKE_CXX_FLAGS_MINSIZEREL
CMAKE_CXX_FLAGS_RELEASE
CMAKE_CXX_FLAGS_RELWITHDEBINFO)
if(${configuration} MATCHES "/MD")
string(REGEX
REPLACE "/MD"
"/MT"
${configuration}
"${${configuration}}")
endif()
endforeach()
endif()
add_custom_command(COMMENT "Compiling cube vertex shader"
OUTPUT cube.vert.inc
COMMAND ${GLSLANG_VALIDATOR} -V -x -o ${CMAKE_CURRENT_BINARY_DIR}/cube.vert.inc
${PROJECT_SOURCE_DIR}/cube/cube.vert
MAIN_DEPENDENCY ${PROJECT_SOURCE_DIR}/cube/cube.vert
DEPENDS ${PROJECT_SOURCE_DIR}/cube/cube.vert ${GLSLANG_VALIDATOR})
add_custom_command(COMMENT "Compiling cube fragment shader"
OUTPUT cube.frag.inc
COMMAND ${GLSLANG_VALIDATOR} -V -x -o ${CMAKE_CURRENT_BINARY_DIR}/cube.frag.inc
${PROJECT_SOURCE_DIR}/cube/cube.frag
MAIN_DEPENDENCY ${PROJECT_SOURCE_DIR}/cube/cube.frag
DEPENDS ${PROJECT_SOURCE_DIR}/cube/cube.frag ${GLSLANG_VALIDATOR})
include_directories(${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR})
if(WIN32)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D_CRT_SECURE_NO_WARNINGS -D_USE_MATH_DEFINES")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D_CRT_SECURE_NO_WARNINGS -D_USE_MATH_DEFINES")
endif()
include_directories(${CUBE_INCLUDE_DIRS})
# ----------------------------------------------------------------------------
# vkcube
if(APPLE)
include(macOS/cube/cube.cmake)
elseif(NOT WIN32)
if(${CMAKE_SYSTEM_PROCESSOR} STREQUAL ${CMAKE_HOST_SYSTEM_PROCESSOR})
add_executable(vkcube
cube.c
${PROJECT_SOURCE_DIR}/cube/cube.vert
${PROJECT_SOURCE_DIR}/cube/cube.frag
cube.vert.inc
cube.frag.inc
${OPTIONAL_WAYLAND_DATA_FILES})
target_link_libraries(vkcube Vulkan::Vulkan)
target_compile_definitions(vkcube PUBLIC ${CUBE_PLATFORM})
include(CheckLibraryExists)
CHECK_LIBRARY_EXISTS("rt" clock_gettime "" NEED_RT)
if (NEED_RT)
target_link_libraries(vkcube rt)
endif()
endif()
else()
if(CMAKE_CL_64)
set(LIB_DIR "Win64")
else()
set(LIB_DIR "Win32")
endif()
add_executable(vkcube
WIN32
cube.c
${PROJECT_SOURCE_DIR}/cube/cube.vert
${PROJECT_SOURCE_DIR}/cube/cube.frag
cube.vert.inc
cube.frag.inc)
target_link_libraries(vkcube Vulkan::Vulkan)
endif()
if(APPLE)
# Keep RPATH so fixup_bundle can use it to find libraries
set_target_properties(vkcube PROPERTIES INSTALL_RPATH_USE_LINK_PATH TRUE)
install(TARGETS vkcube BUNDLE DESTINATION "cube")
# Fix up the library references to be self-contained within the bundle.
install(CODE "
include(BundleUtilities)
fixup_bundle(\${CMAKE_INSTALL_PREFIX}/cube/vkcube.app \"\" \"${Vulkan_LIBRARY_DIR}\")
")
else()
install(TARGETS vkcube RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
endif()
# ----------------------------------------------------------------------------
# vkcubepp
if(APPLE)
include(macOS/cubepp/cubepp.cmake)
elseif(NOT WIN32)
if(${CMAKE_SYSTEM_PROCESSOR} STREQUAL ${CMAKE_HOST_SYSTEM_PROCESSOR})
add_executable(vkcubepp
cube.cpp
${PROJECT_SOURCE_DIR}/cube/cube.vert
${PROJECT_SOURCE_DIR}/cube/cube.frag
cube.vert.inc
cube.frag.inc
${OPTIONAL_WAYLAND_DATA_FILES})
target_link_libraries(vkcubepp Vulkan::Vulkan)
target_compile_definitions(vkcubepp PUBLIC ${CUBE_PLATFORM})
endif()
else()
if(CMAKE_CL_64)
set(LIB_DIR "Win64")
else()
set(LIB_DIR "Win32")
endif()
add_executable(vkcubepp
WIN32
cube.cpp
${PROJECT_SOURCE_DIR}/cube/cube.vert
${PROJECT_SOURCE_DIR}/cube/cube.frag
cube.vert.inc
cube.frag.inc)
target_link_libraries(vkcubepp Vulkan::Vulkan)
endif()
if(APPLE)
# Keep RPATH so fixup_bundle can use it to find libraries
set_target_properties(vkcubepp PROPERTIES INSTALL_RPATH_USE_LINK_PATH TRUE)
install(TARGETS vkcubepp BUNDLE DESTINATION "cube")
# Fix up the library references to be self-contained within the bundle.
install(CODE "
include(BundleUtilities)
fixup_bundle(\${CMAKE_INSTALL_PREFIX}/cube/vkcubepp.app \"\" \"${Vulkan_LIBRARY_DIR}\")
")
else()
install(TARGETS vkcubepp RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
endif()
# ----------------------------------------------------------------------------
# vkcube-wayland
if(UNIX AND NOT APPLE) # i.e. Linux
if(BUILD_WSI_WAYLAND_SUPPORT AND EXISTS ${WAYLAND_PROTOCOLS_PATH}/unstable/xdg-decoration/xdg-decoration-unstable-v1.xml)
set(CUBE_INCLUDE_DIRS ${WAYLAND_CLIENT_INCLUDE_DIR} ${CUBE_INCLUDE_DIRS})
link_libraries(${WAYLAND_CLIENT_LIBRARIES})
set(OPTIONAL_WAYLAND_DATA_FILES
${CMAKE_CURRENT_BINARY_DIR}/xdg-shell-code.c
${CMAKE_CURRENT_BINARY_DIR}/xdg-shell-client-header.h
${CMAKE_CURRENT_BINARY_DIR}/xdg-decoration-code.c
${CMAKE_CURRENT_BINARY_DIR}/xdg-decoration-client-header.h)
include_directories(${CMAKE_CURRENT_BINARY_DIR})
if(${CMAKE_SYSTEM_PROCESSOR} STREQUAL ${CMAKE_HOST_SYSTEM_PROCESSOR})
add_executable(vkcube-wayland
cube.c
${PROJECT_SOURCE_DIR}/cube/cube.vert
${PROJECT_SOURCE_DIR}/cube/cube.frag
cube.vert.inc
cube.frag.inc
${OPTIONAL_WAYLAND_DATA_FILES})
target_link_libraries(vkcube-wayland Vulkan::Vulkan)
target_compile_definitions(vkcube-wayland PUBLIC VK_USE_PLATFORM_WAYLAND_KHR)
include(CheckLibraryExists)
CHECK_LIBRARY_EXISTS("rt" clock_gettime "" NEED_RT)
if (NEED_RT)
target_link_libraries(vkcube-wayland rt)
endif()
endif()
install(TARGETS vkcube-wayland RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
endif()
endif()

View File

@ -0,0 +1,27 @@
<?xml version="1.0"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.example.VkCubeWithLayers" android:versionCode="1" android:versionName="1.0">
<!-- Allow this app to read and write files (for use by tracing libraries). -->
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.INTERNET"/>
<!-- This is the platform API where NativeActivity was introduced. -->
<uses-sdk android:minSdkVersion="23" android:targetSdkVersion="23"/>
<!-- This .apk has no Java code itself, so set hasCode to false. -->
<application android:label="@string/app_name" android:hasCode="false" android:debuggable='true'>
<!-- Our activity is the built-in NativeActivity framework class.
This will take care of integrating with our NDK code. -->
<activity android:name="android.app.NativeActivity" android:label="@string/app_name" android:exported="true">
<!-- Tell NativeActivity the name of or .so -->
<meta-data android:name="android.app.lib_name" android:value="VkCube"/>
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
</application>
</manifest>

View File

@ -0,0 +1,25 @@
<?xml version="1.0" encoding="UTF-8"?>
<project name="NativeActivity" default="help">
<property name="cubeWithLayersDir" location="../libs-with-layers" />
<property name="cubeDir" location="../libs" />
<property name="layersDir" location="../../../build-android/libs" />
<echo>VkCubeWithLayers: Creating libs-with-layers</echo>
<mkdir dir="${cubeWithLayersDir}"/>
<echo>VkCubeWithLayers: Copying libs from demos/android</echo>
<copy todir="${cubeWithLayersDir}">
<fileset dir="${cubeDir}"/>
</copy>
<echo>VkCubeWithLayers: Copying layers from build-android</echo>
<copy todir="${cubeWithLayersDir}">
<fileset dir="${layersDir}"/>
</copy>
<!-- Point ndk-build at the libs-with-layers common dir -->
<echo>VkCubeWithLayers: Overriding native.libs.absolute.dir with ${cubeWithLayersDir}</echo>
<property name="native.libs.absolute.dir" location="${cubeWithLayersDir}" />
</project>

View File

@ -0,0 +1,24 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright 2013 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<!-- This file contains resource definitions for displayed strings, allowing
them to be changed based on the locale and options. -->
<resources>
<!-- Simple strings. -->
<string name="app_name">VkCubeWithLayers</string>
</resources>

View File

@ -0,0 +1,27 @@
<?xml version="1.0"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.example.VkCube" android:versionCode="1" android:versionName="1.0">
<!-- Allow this app to read and write files (for use by tracing libraries). -->
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.INTERNET"/>
<!-- This is the platform API where NativeActivity was introduced. -->
<uses-sdk android:minSdkVersion="23" android:targetSdkVersion="23"/>
<!-- This .apk has no Java code itself, so set hasCode to false. -->
<application android:label="@string/app_name" android:hasCode="false" android:debuggable='true'>
<!-- Our activity is the built-in NativeActivity framework class.
This will take care of integrating with our NDK code. -->
<activity android:name="android.app.NativeActivity" android:label="@string/app_name" android:exported="true">
<!-- Tell NativeActivity the name of or .so -->
<meta-data android:name="android.app.lib_name" android:value="VkCube"/>
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
</application>
</manifest>

View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project name="NativeActivity" default="help">
<!-- Point ndk-build at the libs created in common dir -->
<echo>vkcube: Overriding native.libs.absolute.dir with ../libs</echo>
<property name="native.libs.absolute.dir" location="../libs" />
</project>

View File

@ -0,0 +1,24 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright 2013 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<!-- This file contains resource definitions for displayed strings, allowing
them to be changed based on the locale and options. -->
<resources>
<!-- Simple strings. -->
<string name="app_name">VkCube</string>
</resources>

View File

@ -0,0 +1,73 @@
#include <stdint.h>
#if 0
../cube.frag
Warning, version 400 is not yet complete; most version-specific features are present, but some are missing.
Linked fragment stage:
// Module Version 10000
// Generated by (magic number): 80001
// Id's are bound by 21
Capability Shader
1: ExtInstImport "GLSL.std.450"
MemoryModel Logical GLSL450
EntryPoint Fragment 4 "main" 9 16
ExecutionMode 4 OriginUpperLeft
Source GLSL 400
SourceExtension "GL_ARB_separate_shader_objects"
SourceExtension "GL_ARB_shading_language_420pack"
Name 4 "main"
Name 9 "uFragColor"
Name 13 "tex"
Name 16 "texcoord"
Decorate 9(uFragColor) Location 0
Decorate 13(tex) DescriptorSet 0
Decorate 13(tex) Binding 1
Decorate 16(texcoord) Location 0
2: TypeVoid
3: TypeFunction 2
6: TypeFloat 32
7: TypeVector 6(float) 4
8: TypePointer Output 7(fvec4)
9(uFragColor): 8(ptr) Variable Output
10: TypeImage 6(float) 2D sampled format:Unknown
11: TypeSampledImage 10
12: TypePointer UniformConstant 11
13(tex): 12(ptr) Variable UniformConstant
15: TypePointer Input 7(fvec4)
16(texcoord): 15(ptr) Variable Input
17: TypeVector 6(float) 2
4(main): 2 Function None 3
5: Label
14: 11 Load 13(tex)
18: 7(fvec4) Load 16(texcoord)
19: 17(fvec2) VectorShuffle 18 18 0 1
20: 7(fvec4) ImageSampleImplicitLod 14 19
Store 9(uFragColor) 20
Return
FunctionEnd
#endif
static const uint32_t cube_frag[164] = {
0x07230203, 0x00010000, 0x00080001, 0x00000015, 0x00000000, 0x00020011, 0x00000001, 0x0006000b, 0x00000001, 0x4c534c47,
0x6474732e, 0x3035342e, 0x00000000, 0x0003000e, 0x00000000, 0x00000001, 0x0007000f, 0x00000004, 0x00000004, 0x6e69616d,
0x00000000, 0x00000009, 0x00000010, 0x00030010, 0x00000004, 0x00000007, 0x00030003, 0x00000002, 0x00000190, 0x00090004,
0x415f4c47, 0x735f4252, 0x72617065, 0x5f657461, 0x64616873, 0x6f5f7265, 0x63656a62, 0x00007374, 0x00090004, 0x415f4c47,
0x735f4252, 0x69646168, 0x6c5f676e, 0x75676e61, 0x5f656761, 0x70303234, 0x006b6361, 0x00040005, 0x00000004, 0x6e69616d,
0x00000000, 0x00050005, 0x00000009, 0x61724675, 0x6c6f4367, 0x0000726f, 0x00030005, 0x0000000d, 0x00786574, 0x00050005,
0x00000010, 0x63786574, 0x64726f6f, 0x00000000, 0x00040047, 0x00000009, 0x0000001e, 0x00000000, 0x00040047, 0x0000000d,
0x00000022, 0x00000000, 0x00040047, 0x0000000d, 0x00000021, 0x00000001, 0x00040047, 0x00000010, 0x0000001e, 0x00000000,
0x00020013, 0x00000002, 0x00030021, 0x00000003, 0x00000002, 0x00030016, 0x00000006, 0x00000020, 0x00040017, 0x00000007,
0x00000006, 0x00000004, 0x00040020, 0x00000008, 0x00000003, 0x00000007, 0x0004003b, 0x00000008, 0x00000009, 0x00000003,
0x00090019, 0x0000000a, 0x00000006, 0x00000001, 0x00000000, 0x00000000, 0x00000000, 0x00000001, 0x00000000, 0x0003001b,
0x0000000b, 0x0000000a, 0x00040020, 0x0000000c, 0x00000000, 0x0000000b, 0x0004003b, 0x0000000c, 0x0000000d, 0x00000000,
0x00040020, 0x0000000f, 0x00000001, 0x00000007, 0x0004003b, 0x0000000f, 0x00000010, 0x00000001, 0x00040017, 0x00000011,
0x00000006, 0x00000002, 0x00050036, 0x00000002, 0x00000004, 0x00000000, 0x00000003, 0x000200f8, 0x00000005, 0x0004003d,
0x0000000b, 0x0000000e, 0x0000000d, 0x0004003d, 0x00000007, 0x00000012, 0x00000010, 0x0007004f, 0x00000011, 0x00000013,
0x00000012, 0x00000012, 0x00000000, 0x00000001, 0x00050057, 0x00000007, 0x00000014, 0x0000000e, 0x00000013, 0x0003003e,
0x00000009, 0x00000014, 0x000100fd, 0x00010038,
};

View File

@ -0,0 +1,22 @@
// Overload400-PrecQual.2000 12-Apr-2017
0x07230203,0x00010000,0x00080002,0x00000015,0x00000000,0x00020011,0x00000001,0x0006000b,
0x00000001,0x4c534c47,0x6474732e,0x3035342e,0x00000000,0x0003000e,0x00000000,0x00000001,
0x0007000f,0x00000004,0x00000004,0x6e69616d,0x00000000,0x00000009,0x00000010,0x00030010,
0x00000004,0x00000007,0x00030003,0x00000002,0x00000190,0x00090004,0x415f4c47,0x735f4252,
0x72617065,0x5f657461,0x64616873,0x6f5f7265,0x63656a62,0x00007374,0x00090004,0x415f4c47,
0x735f4252,0x69646168,0x6c5f676e,0x75676e61,0x5f656761,0x70303234,0x006b6361,0x00040005,
0x00000004,0x6e69616d,0x00000000,0x00050005,0x00000009,0x61724675,0x6c6f4367,0x0000726f,
0x00030005,0x0000000d,0x00786574,0x00050005,0x00000010,0x63786574,0x64726f6f,0x00000000,
0x00040047,0x00000009,0x0000001e,0x00000000,0x00040047,0x0000000d,0x00000022,0x00000000,
0x00040047,0x0000000d,0x00000021,0x00000001,0x00040047,0x00000010,0x0000001e,0x00000000,
0x00020013,0x00000002,0x00030021,0x00000003,0x00000002,0x00030016,0x00000006,0x00000020,
0x00040017,0x00000007,0x00000006,0x00000004,0x00040020,0x00000008,0x00000003,0x00000007,
0x0004003b,0x00000008,0x00000009,0x00000003,0x00090019,0x0000000a,0x00000006,0x00000001,
0x00000000,0x00000000,0x00000000,0x00000001,0x00000000,0x0003001b,0x0000000b,0x0000000a,
0x00040020,0x0000000c,0x00000000,0x0000000b,0x0004003b,0x0000000c,0x0000000d,0x00000000,
0x00040020,0x0000000f,0x00000001,0x00000007,0x0004003b,0x0000000f,0x00000010,0x00000001,
0x00040017,0x00000011,0x00000006,0x00000002,0x00050036,0x00000002,0x00000004,0x00000000,
0x00000003,0x000200f8,0x00000005,0x0004003d,0x0000000b,0x0000000e,0x0000000d,0x0004003d,
0x00000007,0x00000012,0x00000010,0x0007004f,0x00000011,0x00000013,0x00000012,0x00000012,
0x00000000,0x00000001,0x00050057,0x00000007,0x00000014,0x0000000e,0x00000013,0x0003003e,
0x00000009,0x00000014,0x000100fd,0x00010038

View File

@ -0,0 +1,149 @@
#include <stdint.h>
#if 0
../cube.vert
Warning, version 400 is not yet complete; most version-specific features are present, but some are missing.
Linked vertex stage:
// Module Version 10000
// Generated by (magic number): 80001
// Id's are bound by 55
Capability Shader
1: ExtInstImport "GLSL.std.450"
MemoryModel Logical GLSL450
EntryPoint Vertex 4 "main" 9 21 28
Source GLSL 400
SourceExtension "GL_ARB_separate_shader_objects"
SourceExtension "GL_ARB_shading_language_420pack"
Name 4 "main"
Name 9 "texcoord"
Name 15 "buf"
MemberName 15(buf) 0 "MVP"
MemberName 15(buf) 1 "position"
MemberName 15(buf) 2 "attr"
Name 17 "ubuf"
Name 21 "gl_VertexIndex"
Name 26 "gl_PerVertex"
MemberName 26(gl_PerVertex) 0 "gl_Position"
Name 28 ""
Decorate 9(texcoord) Location 0
Decorate 13 ArrayStride 16
Decorate 14 ArrayStride 16
MemberDecorate 15(buf) 0 ColMajor
MemberDecorate 15(buf) 0 Offset 0
MemberDecorate 15(buf) 0 MatrixStride 16
MemberDecorate 15(buf) 1 Offset 64
MemberDecorate 15(buf) 2 Offset 640
Decorate 15(buf) Block
Decorate 17(ubuf) DescriptorSet 0
Decorate 17(ubuf) Binding 0
Decorate 21(gl_VertexIndex) BuiltIn VertexIndex
MemberDecorate 26(gl_PerVertex) 0 BuiltIn Position
Decorate 26(gl_PerVertex) Block
2: TypeVoid
3: TypeFunction 2
6: TypeFloat 32
7: TypeVector 6(float) 4
8: TypePointer Output 7(fvec4)
9(texcoord): 8(ptr) Variable Output
10: TypeMatrix 7(fvec4) 4
11: TypeInt 32 0
12: 11(int) Constant 36
13: TypeArray 7(fvec4) 12
14: TypeArray 7(fvec4) 12
15(buf): TypeStruct 10 13 14
16: TypePointer Uniform 15(buf)
17(ubuf): 16(ptr) Variable Uniform
18: TypeInt 32 1
19: 18(int) Constant 2
20: TypePointer Input 18(int)
21(gl_VertexIndex): 20(ptr) Variable Input
23: TypePointer Uniform 7(fvec4)
26(gl_PerVertex): TypeStruct 7(fvec4)
27: TypePointer Output 26(gl_PerVertex)
28: 27(ptr) Variable Output
29: 18(int) Constant 0
30: TypePointer Uniform 10
33: 18(int) Constant 1
39: 11(int) Constant 1
40: TypePointer Output 6(float)
45: 11(int) Constant 2
48: 11(int) Constant 3
52: 6(float) Constant 1073741824
4(main): 2 Function None 3
5: Label
22: 18(int) Load 21(gl_VertexIndex)
24: 23(ptr) AccessChain 17(ubuf) 19 22
25: 7(fvec4) Load 24
Store 9(texcoord) 25
31: 30(ptr) AccessChain 17(ubuf) 29
32: 10 Load 31
34: 18(int) Load 21(gl_VertexIndex)
35: 23(ptr) AccessChain 17(ubuf) 33 34
36: 7(fvec4) Load 35
37: 7(fvec4) MatrixTimesVector 32 36
38: 8(ptr) AccessChain 28 29
Store 38 37
41: 40(ptr) AccessChain 28 29 39
42: 6(float) Load 41
43: 6(float) FNegate 42
44: 40(ptr) AccessChain 28 29 39
Store 44 43
46: 40(ptr) AccessChain 28 29 45
47: 6(float) Load 46
49: 40(ptr) AccessChain 28 29 48
50: 6(float) Load 49
51: 6(float) FAdd 47 50
53: 6(float) FDiv 51 52
54: 40(ptr) AccessChain 28 29 45
Store 54 53
Return
FunctionEnd
#endif
static const uint32_t cube_vert[396] = {
0x07230203, 0x00010000, 0x00080001, 0x00000037, 0x00000000, 0x00020011, 0x00000001, 0x0006000b, 0x00000001, 0x4c534c47,
0x6474732e, 0x3035342e, 0x00000000, 0x0003000e, 0x00000000, 0x00000001, 0x0008000f, 0x00000000, 0x00000004, 0x6e69616d,
0x00000000, 0x00000009, 0x00000015, 0x0000001c, 0x00030003, 0x00000002, 0x00000190, 0x00090004, 0x415f4c47, 0x735f4252,
0x72617065, 0x5f657461, 0x64616873, 0x6f5f7265, 0x63656a62, 0x00007374, 0x00090004, 0x415f4c47, 0x735f4252, 0x69646168,
0x6c5f676e, 0x75676e61, 0x5f656761, 0x70303234, 0x006b6361, 0x00040005, 0x00000004, 0x6e69616d, 0x00000000, 0x00050005,
0x00000009, 0x63786574, 0x64726f6f, 0x00000000, 0x00030005, 0x0000000f, 0x00667562, 0x00040006, 0x0000000f, 0x00000000,
0x0050564d, 0x00060006, 0x0000000f, 0x00000001, 0x69736f70, 0x6e6f6974, 0x00000000, 0x00050006, 0x0000000f, 0x00000002,
0x72747461, 0x00000000, 0x00040005, 0x00000011, 0x66756275, 0x00000000, 0x00060005, 0x00000015, 0x565f6c67, 0x65747265,
0x646e4978, 0x00007865, 0x00060005, 0x0000001a, 0x505f6c67, 0x65567265, 0x78657472, 0x00000000, 0x00060006, 0x0000001a,
0x00000000, 0x505f6c67, 0x7469736f, 0x006e6f69, 0x00030005, 0x0000001c, 0x00000000, 0x00040047, 0x00000009, 0x0000001e,
0x00000000, 0x00040047, 0x0000000d, 0x00000006, 0x00000010, 0x00040047, 0x0000000e, 0x00000006, 0x00000010, 0x00040048,
0x0000000f, 0x00000000, 0x00000005, 0x00050048, 0x0000000f, 0x00000000, 0x00000023, 0x00000000, 0x00050048, 0x0000000f,
0x00000000, 0x00000007, 0x00000010, 0x00050048, 0x0000000f, 0x00000001, 0x00000023, 0x00000040, 0x00050048, 0x0000000f,
0x00000002, 0x00000023, 0x00000280, 0x00030047, 0x0000000f, 0x00000002, 0x00040047, 0x00000011, 0x00000022, 0x00000000,
0x00040047, 0x00000011, 0x00000021, 0x00000000, 0x00040047, 0x00000015, 0x0000000b, 0x0000002a, 0x00050048, 0x0000001a,
0x00000000, 0x0000000b, 0x00000000, 0x00030047, 0x0000001a, 0x00000002, 0x00020013, 0x00000002, 0x00030021, 0x00000003,
0x00000002, 0x00030016, 0x00000006, 0x00000020, 0x00040017, 0x00000007, 0x00000006, 0x00000004, 0x00040020, 0x00000008,
0x00000003, 0x00000007, 0x0004003b, 0x00000008, 0x00000009, 0x00000003, 0x00040018, 0x0000000a, 0x00000007, 0x00000004,
0x00040015, 0x0000000b, 0x00000020, 0x00000000, 0x0004002b, 0x0000000b, 0x0000000c, 0x00000024, 0x0004001c, 0x0000000d,
0x00000007, 0x0000000c, 0x0004001c, 0x0000000e, 0x00000007, 0x0000000c, 0x0005001e, 0x0000000f, 0x0000000a, 0x0000000d,
0x0000000e, 0x00040020, 0x00000010, 0x00000002, 0x0000000f, 0x0004003b, 0x00000010, 0x00000011, 0x00000002, 0x00040015,
0x00000012, 0x00000020, 0x00000001, 0x0004002b, 0x00000012, 0x00000013, 0x00000002, 0x00040020, 0x00000014, 0x00000001,
0x00000012, 0x0004003b, 0x00000014, 0x00000015, 0x00000001, 0x00040020, 0x00000017, 0x00000002, 0x00000007, 0x0003001e,
0x0000001a, 0x00000007, 0x00040020, 0x0000001b, 0x00000003, 0x0000001a, 0x0004003b, 0x0000001b, 0x0000001c, 0x00000003,
0x0004002b, 0x00000012, 0x0000001d, 0x00000000, 0x00040020, 0x0000001e, 0x00000002, 0x0000000a, 0x0004002b, 0x00000012,
0x00000021, 0x00000001, 0x0004002b, 0x0000000b, 0x00000027, 0x00000001, 0x00040020, 0x00000028, 0x00000003, 0x00000006,
0x0004002b, 0x0000000b, 0x0000002d, 0x00000002, 0x0004002b, 0x0000000b, 0x00000030, 0x00000003, 0x0004002b, 0x00000006,
0x00000034, 0x40000000, 0x00050036, 0x00000002, 0x00000004, 0x00000000, 0x00000003, 0x000200f8, 0x00000005, 0x0004003d,
0x00000012, 0x00000016, 0x00000015, 0x00060041, 0x00000017, 0x00000018, 0x00000011, 0x00000013, 0x00000016, 0x0004003d,
0x00000007, 0x00000019, 0x00000018, 0x0003003e, 0x00000009, 0x00000019, 0x00050041, 0x0000001e, 0x0000001f, 0x00000011,
0x0000001d, 0x0004003d, 0x0000000a, 0x00000020, 0x0000001f, 0x0004003d, 0x00000012, 0x00000022, 0x00000015, 0x00060041,
0x00000017, 0x00000023, 0x00000011, 0x00000021, 0x00000022, 0x0004003d, 0x00000007, 0x00000024, 0x00000023, 0x00050091,
0x00000007, 0x00000025, 0x00000020, 0x00000024, 0x00050041, 0x00000008, 0x00000026, 0x0000001c, 0x0000001d, 0x0003003e,
0x00000026, 0x00000025, 0x00060041, 0x00000028, 0x00000029, 0x0000001c, 0x0000001d, 0x00000027, 0x0004003d, 0x00000006,
0x0000002a, 0x00000029, 0x0004007f, 0x00000006, 0x0000002b, 0x0000002a, 0x00060041, 0x00000028, 0x0000002c, 0x0000001c,
0x0000001d, 0x00000027, 0x0003003e, 0x0000002c, 0x0000002b, 0x00060041, 0x00000028, 0x0000002e, 0x0000001c, 0x0000001d,
0x0000002d, 0x0004003d, 0x00000006, 0x0000002f, 0x0000002e, 0x00060041, 0x00000028, 0x00000031, 0x0000001c, 0x0000001d,
0x00000030, 0x0004003d, 0x00000006, 0x00000032, 0x00000031, 0x00050081, 0x00000006, 0x00000033, 0x0000002f, 0x00000032,
0x00050088, 0x00000006, 0x00000035, 0x00000033, 0x00000034, 0x00060041, 0x00000028, 0x00000036, 0x0000001c, 0x0000001d,
0x0000002d, 0x0003003e, 0x00000036, 0x00000035, 0x000100fd, 0x00010038,
};

View File

@ -0,0 +1,45 @@
// Overload400-PrecQual.2000 12-Apr-2017
0x07230203,0x00010000,0x00080002,0x00000029,0x00000000,0x00020011,0x00000001,0x0006000b,
0x00000001,0x4c534c47,0x6474732e,0x3035342e,0x00000000,0x0003000e,0x00000000,0x00000001,
0x0008000f,0x00000000,0x00000004,0x6e69616d,0x00000000,0x00000009,0x00000015,0x0000001e,
0x00030003,0x00000002,0x00000190,0x00090004,0x415f4c47,0x735f4252,0x72617065,0x5f657461,
0x64616873,0x6f5f7265,0x63656a62,0x00007374,0x00090004,0x415f4c47,0x735f4252,0x69646168,
0x6c5f676e,0x75676e61,0x5f656761,0x70303234,0x006b6361,0x00040005,0x00000004,0x6e69616d,
0x00000000,0x00050005,0x00000009,0x63786574,0x64726f6f,0x00000000,0x00030005,0x0000000f,
0x00667562,0x00040006,0x0000000f,0x00000000,0x0050564d,0x00060006,0x0000000f,0x00000001,
0x69736f70,0x6e6f6974,0x00000000,0x00050006,0x0000000f,0x00000002,0x72747461,0x00000000,
0x00040005,0x00000011,0x66756275,0x00000000,0x00060005,0x00000015,0x565f6c67,0x65747265,
0x646e4978,0x00007865,0x00060005,0x0000001c,0x505f6c67,0x65567265,0x78657472,0x00000000,
0x00060006,0x0000001c,0x00000000,0x505f6c67,0x7469736f,0x006e6f69,0x00070006,0x0000001c,
0x00000001,0x505f6c67,0x746e696f,0x657a6953,0x00000000,0x00070006,0x0000001c,0x00000002,
0x435f6c67,0x4470696c,0x61747369,0x0065636e,0x00030005,0x0000001e,0x00000000,0x00040047,
0x00000009,0x0000001e,0x00000000,0x00040047,0x0000000d,0x00000006,0x00000010,0x00040047,
0x0000000e,0x00000006,0x00000010,0x00040048,0x0000000f,0x00000000,0x00000005,0x00050048,
0x0000000f,0x00000000,0x00000023,0x00000000,0x00050048,0x0000000f,0x00000000,0x00000007,
0x00000010,0x00050048,0x0000000f,0x00000001,0x00000023,0x00000040,0x00050048,0x0000000f,
0x00000002,0x00000023,0x00000280,0x00030047,0x0000000f,0x00000002,0x00040047,0x00000011,
0x00000022,0x00000000,0x00040047,0x00000011,0x00000021,0x00000000,0x00040047,0x00000015,
0x0000000b,0x0000002a,0x00050048,0x0000001c,0x00000000,0x0000000b,0x00000000,0x00050048,
0x0000001c,0x00000001,0x0000000b,0x00000001,0x00050048,0x0000001c,0x00000002,0x0000000b,
0x00000003,0x00030047,0x0000001c,0x00000002,0x00020013,0x00000002,0x00030021,0x00000003,
0x00000002,0x00030016,0x00000006,0x00000020,0x00040017,0x00000007,0x00000006,0x00000004,
0x00040020,0x00000008,0x00000003,0x00000007,0x0004003b,0x00000008,0x00000009,0x00000003,
0x00040018,0x0000000a,0x00000007,0x00000004,0x00040015,0x0000000b,0x00000020,0x00000000,
0x0004002b,0x0000000b,0x0000000c,0x00000024,0x0004001c,0x0000000d,0x00000007,0x0000000c,
0x0004001c,0x0000000e,0x00000007,0x0000000c,0x0005001e,0x0000000f,0x0000000a,0x0000000d,
0x0000000e,0x00040020,0x00000010,0x00000002,0x0000000f,0x0004003b,0x00000010,0x00000011,
0x00000002,0x00040015,0x00000012,0x00000020,0x00000001,0x0004002b,0x00000012,0x00000013,
0x00000002,0x00040020,0x00000014,0x00000001,0x00000012,0x0004003b,0x00000014,0x00000015,
0x00000001,0x00040020,0x00000017,0x00000002,0x00000007,0x0004002b,0x0000000b,0x0000001a,
0x00000001,0x0004001c,0x0000001b,0x00000006,0x0000001a,0x0005001e,0x0000001c,0x00000007,
0x00000006,0x0000001b,0x00040020,0x0000001d,0x00000003,0x0000001c,0x0004003b,0x0000001d,
0x0000001e,0x00000003,0x0004002b,0x00000012,0x0000001f,0x00000000,0x00040020,0x00000020,
0x00000002,0x0000000a,0x0004002b,0x00000012,0x00000023,0x00000001,0x00050036,0x00000002,
0x00000004,0x00000000,0x00000003,0x000200f8,0x00000005,0x0004003d,0x00000012,0x00000016,
0x00000015,0x00060041,0x00000017,0x00000018,0x00000011,0x00000013,0x00000016,0x0004003d,
0x00000007,0x00000019,0x00000018,0x0003003e,0x00000009,0x00000019,0x00050041,0x00000020,
0x00000021,0x00000011,0x0000001f,0x0004003d,0x0000000a,0x00000022,0x00000021,0x0004003d,
0x00000012,0x00000024,0x00000015,0x00060041,0x00000017,0x00000025,0x00000011,0x00000023,
0x00000024,0x0004003d,0x00000007,0x00000026,0x00000025,0x00050091,0x00000007,0x00000027,
0x00000022,0x00000026,0x00050041,0x00000008,0x00000028,0x0000001e,0x0000001f,0x0003003e,
0x00000028,0x00000027,0x000100fd,0x00010038

View File

@ -0,0 +1,36 @@
# Copyright 2015 The Android Open Source Project
# Copyright (C) 2015 Valve Corporation
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# http://www.apache.org/licenses/LICENSE-2.0
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
LOCAL_PATH := $(abspath $(call my-dir))
SRC_DIR := $(LOCAL_PATH)/../../..
DEMO_DIR := $(SRC_DIR)/cube
include $(CLEAR_VARS)
LOCAL_MODULE := VkCube
LOCAL_SRC_FILES += $(DEMO_DIR)/cube.c \
$(SRC_DIR)/common/vulkan_wrapper.cpp \
$(SRC_DIR)/common/android_util.cpp
LOCAL_C_INCLUDES += $(SRC_DIR)/build-android/third_party/Vulkan-Headers/include \
$(DEMO_DIR)/android/include \
$(SRC_DIR)/libs \
$(SRC_DIR)/common \
$(SRC_DIR)/build-android/generated/include
LOCAL_CFLAGS += -DVK_USE_PLATFORM_ANDROID_KHR --include=$(SRC_DIR)/common/vulkan_wrapper.h
LOCAL_WHOLE_STATIC_LIBRARIES += android_native_app_glue
LOCAL_LDLIBS := -llog -landroid
LOCAL_LDFLAGS := -u ANativeActivity_onCreate
include $(BUILD_SHARED_LIBRARY)
$(call import-module,android/native_app_glue)

View File

@ -0,0 +1,22 @@
# Copyright 2015 The Android Open Source Project
# Copyright (C) 2015 Valve Corporation
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# http://www.apache.org/licenses/LICENSE-2.0
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
APP_ABI := armeabi-v7a arm64-v8a x86 x86_64
APP_PLATFORM := android-23
APP_STL := c++_static
APP_MODULES := VkCube
APP_CPPFLAGS += -std=c++11 -fexceptions -Wall -Werror -Wextra -Wno-unused-parameter -DVK_NO_PROTOTYES -DGLM_FORCE_RADIANS
APP_CFLAGS += -Wall -Werror -Wextra -Wno-unused-parameter -DVK_NO_PROTOTYES -DGLM_FORCE_RADIANS
NDK_TOOLCHAIN_VERSION := clang

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,38 @@
/*
* Copyright (c) 2015-2016 The Khronos Group Inc.
* Copyright (c) 2015-2016 Valve Corporation
* Copyright (c) 2015-2016 LunarG, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*
* Fragment shader for cube demo
*/
#version 400
#extension GL_ARB_separate_shader_objects : enable
#extension GL_ARB_shading_language_420pack : enable
layout (binding = 1) uniform sampler2D tex;
layout (location = 0) in vec4 texcoord;
layout (location = 1) in vec3 frag_pos;
layout (location = 0) out vec4 uFragColor;
const vec3 lightDir= vec3(0.424, 0.566, 0.707);
void main() {
vec3 dX = dFdx(frag_pos);
vec3 dY = dFdy(frag_pos);
vec3 normal = normalize(cross(dX,dY));
float light = max(0.0, dot(lightDir, normal));
uFragColor = light * texture(tex, texcoord.xy);
}

View File

@ -0,0 +1,38 @@
/*
* Copyright (c) 2015-2016 The Khronos Group Inc.
* Copyright (c) 2015-2016 Valve Corporation
* Copyright (c) 2015-2016 LunarG, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*
* Vertex shader used by Cube demo.
*/
#version 400
#extension GL_ARB_separate_shader_objects : enable
#extension GL_ARB_shading_language_420pack : enable
layout(std140, binding = 0) uniform buf {
mat4 MVP;
vec4 position[12*3];
vec4 attr[12*3];
} ubuf;
layout (location = 0) out vec4 texcoord;
layout (location = 1) out vec3 frag_pos;
void main()
{
texcoord = ubuf.attr[gl_VertexIndex];
gl_Position = ubuf.MVP * ubuf.position[gl_VertexIndex];
frag_pos = gl_Position.xyz;
}

View File

@ -0,0 +1,77 @@
/**************************************************************************
*
* Copyright 2014, 2017 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* Ported from drawElements Utility Library (Google, Inc.)
* Port done by: Ian Elliott <ianelliott@google.com>
**************************************************************************/
#include <time.h>
#include <assert.h>
#include <vulkan/vk_platform.h>
#if defined(_WIN32)
#include <windows.h>
#elif defined(__unix__) || defined(__linux) || defined(__linux__) || defined(__FreeBSD__) || defined(__ANDROID__) || defined(__EPOC32__) || defined(__QNX__)
#include <time.h>
#elif defined(__APPLE__)
#include <sys/time.h>
#endif
uint64_t getTimeInNanoseconds(void) {
const long long ns_in_us = 1000;
const long long ns_in_ms = 1000 * ns_in_us;
const long long ns_in_s = 1000 * ns_in_ms;
#if defined(_WIN32)
LARGE_INTEGER freq;
LARGE_INTEGER count;
QueryPerformanceCounter(&count);
QueryPerformanceFrequency(&freq);
assert(freq.LowPart != 0 || freq.HighPart != 0);
if (count.QuadPart < MAXLONGLONG / ns_in_s) {
assert(freq.QuadPart != 0);
return count.QuadPart * ns_in_s / freq.QuadPart;
} else {
assert(freq.QuadPart >= ns_in_s);
return count.QuadPart / (freq.QuadPart / ns_in_s);
}
#elif defined(__unix__) || defined(__linux) || defined(__linux__) || defined(__ANDROID__) || defined(__QNX__)
struct timespec currTime;
clock_gettime(CLOCK_MONOTONIC, &currTime);
return (uint64_t)currTime.tv_sec * ns_in_s + (uint64_t)currTime.tv_nsec;
#elif defined(__EPOC32__)
struct timespec currTime;
/* Symbian supports only realtime clock for clock_gettime. */
clock_gettime(CLOCK_REALTIME, &currTime);
return (uint64_t)currTime.tv_sec * ns_in_s + (uint64_t)currTime.tv_nsec;
#elif defined(__APPLE__)
struct timeval currTime;
gettimeofday(&currTime, NULL);
return (uint64_t)currTime.tv_sec * ns_in_s + (uint64_t)currTime.tv_usec * ns_in_us;
#else
#error getTimeInNanoseconds Not implemented for target OS
#endif
}

View File

@ -0,0 +1,501 @@
/*
* Copyright (c) 2015-2016 The Khronos Group Inc.
* Copyright (c) 2015-2016 Valve Corporation
* Copyright (c) 2015-2016 LunarG, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* Relicensed from the WTFPL (http://www.wtfpl.net/faq/).
*/
#ifndef LINMATH_H
#define LINMATH_H
#include <math.h>
// Converts degrees to radians.
#define degreesToRadians(angleDegrees) (angleDegrees * M_PI / 180.0)
// Converts radians to degrees.
#define radiansToDegrees(angleRadians) (angleRadians * 180.0 / M_PI)
typedef float vec3[3];
static inline void vec3_add(vec3 r, vec3 const a, vec3 const b) {
int i;
for (i = 0; i < 3; ++i) r[i] = a[i] + b[i];
}
static inline void vec3_sub(vec3 r, vec3 const a, vec3 const b) {
int i;
for (i = 0; i < 3; ++i) r[i] = a[i] - b[i];
}
static inline void vec3_scale(vec3 r, vec3 const v, float const s) {
int i;
for (i = 0; i < 3; ++i) r[i] = v[i] * s;
}
static inline float vec3_mul_inner(vec3 const a, vec3 const b) {
float p = 0.f;
int i;
for (i = 0; i < 3; ++i) p += b[i] * a[i];
return p;
}
static inline void vec3_mul_cross(vec3 r, vec3 const a, vec3 const b) {
r[0] = a[1] * b[2] - a[2] * b[1];
r[1] = a[2] * b[0] - a[0] * b[2];
r[2] = a[0] * b[1] - a[1] * b[0];
}
static inline float vec3_len(vec3 const v) { return sqrtf(vec3_mul_inner(v, v)); }
static inline void vec3_norm(vec3 r, vec3 const v) {
float k = 1.f / vec3_len(v);
vec3_scale(r, v, k);
}
static inline void vec3_reflect(vec3 r, vec3 const v, vec3 const n) {
float p = 2.f * vec3_mul_inner(v, n);
int i;
for (i = 0; i < 3; ++i) r[i] = v[i] - p * n[i];
}
typedef float vec4[4];
static inline void vec4_add(vec4 r, vec4 const a, vec4 const b) {
int i;
for (i = 0; i < 4; ++i) r[i] = a[i] + b[i];
}
static inline void vec4_sub(vec4 r, vec4 const a, vec4 const b) {
int i;
for (i = 0; i < 4; ++i) r[i] = a[i] - b[i];
}
static inline void vec4_scale(vec4 r, vec4 v, float s) {
int i;
for (i = 0; i < 4; ++i) r[i] = v[i] * s;
}
static inline float vec4_mul_inner(vec4 a, vec4 b) {
float p = 0.f;
int i;
for (i = 0; i < 4; ++i) p += b[i] * a[i];
return p;
}
static inline void vec4_mul_cross(vec4 r, vec4 a, vec4 b) {
r[0] = a[1] * b[2] - a[2] * b[1];
r[1] = a[2] * b[0] - a[0] * b[2];
r[2] = a[0] * b[1] - a[1] * b[0];
r[3] = 1.f;
}
static inline float vec4_len(vec4 v) { return sqrtf(vec4_mul_inner(v, v)); }
static inline void vec4_norm(vec4 r, vec4 v) {
float k = 1.f / vec4_len(v);
vec4_scale(r, v, k);
}
static inline void vec4_reflect(vec4 r, vec4 v, vec4 n) {
float p = 2.f * vec4_mul_inner(v, n);
int i;
for (i = 0; i < 4; ++i) r[i] = v[i] - p * n[i];
}
typedef vec4 mat4x4[4];
static inline void mat4x4_identity(mat4x4 M) {
int i, j;
for (i = 0; i < 4; ++i)
for (j = 0; j < 4; ++j) M[i][j] = i == j ? 1.f : 0.f;
}
static inline void mat4x4_dup(mat4x4 M, mat4x4 N) {
int i, j;
for (i = 0; i < 4; ++i)
for (j = 0; j < 4; ++j) M[i][j] = N[i][j];
}
static inline void mat4x4_row(vec4 r, mat4x4 M, int i) {
int k;
for (k = 0; k < 4; ++k) r[k] = M[k][i];
}
static inline void mat4x4_col(vec4 r, mat4x4 M, int i) {
int k;
for (k = 0; k < 4; ++k) r[k] = M[i][k];
}
static inline void mat4x4_transpose(mat4x4 M, mat4x4 N) {
int i, j;
for (j = 0; j < 4; ++j)
for (i = 0; i < 4; ++i) M[i][j] = N[j][i];
}
static inline void mat4x4_add(mat4x4 M, mat4x4 a, mat4x4 b) {
int i;
for (i = 0; i < 4; ++i) vec4_add(M[i], a[i], b[i]);
}
static inline void mat4x4_sub(mat4x4 M, mat4x4 a, mat4x4 b) {
int i;
for (i = 0; i < 4; ++i) vec4_sub(M[i], a[i], b[i]);
}
static inline void mat4x4_scale(mat4x4 M, mat4x4 a, float k) {
int i;
for (i = 0; i < 4; ++i) vec4_scale(M[i], a[i], k);
}
static inline void mat4x4_scale_aniso(mat4x4 M, mat4x4 a, float x, float y, float z) {
int i;
vec4_scale(M[0], a[0], x);
vec4_scale(M[1], a[1], y);
vec4_scale(M[2], a[2], z);
for (i = 0; i < 4; ++i) {
M[3][i] = a[3][i];
}
}
static inline void mat4x4_mul(mat4x4 M, mat4x4 a, mat4x4 b) {
int k, r, c;
for (c = 0; c < 4; ++c)
for (r = 0; r < 4; ++r) {
M[c][r] = 0.f;
for (k = 0; k < 4; ++k) M[c][r] += a[k][r] * b[c][k];
}
}
static inline void mat4x4_mul_vec4(vec4 r, mat4x4 M, vec4 v) {
int i, j;
for (j = 0; j < 4; ++j) {
r[j] = 0.f;
for (i = 0; i < 4; ++i) r[j] += M[i][j] * v[i];
}
}
static inline void mat4x4_translate(mat4x4 T, float x, float y, float z) {
mat4x4_identity(T);
T[3][0] = x;
T[3][1] = y;
T[3][2] = z;
}
static inline void mat4x4_translate_in_place(mat4x4 M, float x, float y, float z) {
vec4 t = {x, y, z, 0};
vec4 r;
int i;
for (i = 0; i < 4; ++i) {
mat4x4_row(r, M, i);
M[3][i] += vec4_mul_inner(r, t);
}
}
static inline void mat4x4_from_vec3_mul_outer(mat4x4 M, vec3 a, vec3 b) {
int i, j;
for (i = 0; i < 4; ++i)
for (j = 0; j < 4; ++j) M[i][j] = i < 3 && j < 3 ? a[i] * b[j] : 0.f;
}
static inline void mat4x4_rotate(mat4x4 R, mat4x4 M, float x, float y, float z, float angle) {
float s = sinf(angle);
float c = cosf(angle);
vec3 u = {x, y, z};
if (vec3_len(u) > 1e-4) {
vec3_norm(u, u);
mat4x4 T;
mat4x4_from_vec3_mul_outer(T, u, u);
mat4x4 S = {{0, u[2], -u[1], 0}, {-u[2], 0, u[0], 0}, {u[1], -u[0], 0, 0}, {0, 0, 0, 0}};
mat4x4_scale(S, S, s);
mat4x4 C;
mat4x4_identity(C);
mat4x4_sub(C, C, T);
mat4x4_scale(C, C, c);
mat4x4_add(T, T, C);
mat4x4_add(T, T, S);
T[3][3] = 1.;
mat4x4_mul(R, M, T);
} else {
mat4x4_dup(R, M);
}
}
static inline void mat4x4_rotate_X(mat4x4 Q, mat4x4 M, float angle) {
float s = sinf(angle);
float c = cosf(angle);
mat4x4 R = {{1.f, 0.f, 0.f, 0.f}, {0.f, c, s, 0.f}, {0.f, -s, c, 0.f}, {0.f, 0.f, 0.f, 1.f}};
mat4x4_mul(Q, M, R);
}
static inline void mat4x4_rotate_Y(mat4x4 Q, mat4x4 M, float angle) {
float s = sinf(angle);
float c = cosf(angle);
mat4x4 R = {{c, 0.f, s, 0.f}, {0.f, 1.f, 0.f, 0.f}, {-s, 0.f, c, 0.f}, {0.f, 0.f, 0.f, 1.f}};
mat4x4_mul(Q, M, R);
}
static inline void mat4x4_rotate_Z(mat4x4 Q, mat4x4 M, float angle) {
float s = sinf(angle);
float c = cosf(angle);
mat4x4 R = {{c, s, 0.f, 0.f}, {-s, c, 0.f, 0.f}, {0.f, 0.f, 1.f, 0.f}, {0.f, 0.f, 0.f, 1.f}};
mat4x4_mul(Q, M, R);
}
static inline void mat4x4_invert(mat4x4 T, mat4x4 M) {
float s[6];
float c[6];
s[0] = M[0][0] * M[1][1] - M[1][0] * M[0][1];
s[1] = M[0][0] * M[1][2] - M[1][0] * M[0][2];
s[2] = M[0][0] * M[1][3] - M[1][0] * M[0][3];
s[3] = M[0][1] * M[1][2] - M[1][1] * M[0][2];
s[4] = M[0][1] * M[1][3] - M[1][1] * M[0][3];
s[5] = M[0][2] * M[1][3] - M[1][2] * M[0][3];
c[0] = M[2][0] * M[3][1] - M[3][0] * M[2][1];
c[1] = M[2][0] * M[3][2] - M[3][0] * M[2][2];
c[2] = M[2][0] * M[3][3] - M[3][0] * M[2][3];
c[3] = M[2][1] * M[3][2] - M[3][1] * M[2][2];
c[4] = M[2][1] * M[3][3] - M[3][1] * M[2][3];
c[5] = M[2][2] * M[3][3] - M[3][2] * M[2][3];
/* Assumes it is invertible */
float idet = 1.0f / (s[0] * c[5] - s[1] * c[4] + s[2] * c[3] + s[3] * c[2] - s[4] * c[1] + s[5] * c[0]);
T[0][0] = (M[1][1] * c[5] - M[1][2] * c[4] + M[1][3] * c[3]) * idet;
T[0][1] = (-M[0][1] * c[5] + M[0][2] * c[4] - M[0][3] * c[3]) * idet;
T[0][2] = (M[3][1] * s[5] - M[3][2] * s[4] + M[3][3] * s[3]) * idet;
T[0][3] = (-M[2][1] * s[5] + M[2][2] * s[4] - M[2][3] * s[3]) * idet;
T[1][0] = (-M[1][0] * c[5] + M[1][2] * c[2] - M[1][3] * c[1]) * idet;
T[1][1] = (M[0][0] * c[5] - M[0][2] * c[2] + M[0][3] * c[1]) * idet;
T[1][2] = (-M[3][0] * s[5] + M[3][2] * s[2] - M[3][3] * s[1]) * idet;
T[1][3] = (M[2][0] * s[5] - M[2][2] * s[2] + M[2][3] * s[1]) * idet;
T[2][0] = (M[1][0] * c[4] - M[1][1] * c[2] + M[1][3] * c[0]) * idet;
T[2][1] = (-M[0][0] * c[4] + M[0][1] * c[2] - M[0][3] * c[0]) * idet;
T[2][2] = (M[3][0] * s[4] - M[3][1] * s[2] + M[3][3] * s[0]) * idet;
T[2][3] = (-M[2][0] * s[4] + M[2][1] * s[2] - M[2][3] * s[0]) * idet;
T[3][0] = (-M[1][0] * c[3] + M[1][1] * c[1] - M[1][2] * c[0]) * idet;
T[3][1] = (M[0][0] * c[3] - M[0][1] * c[1] + M[0][2] * c[0]) * idet;
T[3][2] = (-M[3][0] * s[3] + M[3][1] * s[1] - M[3][2] * s[0]) * idet;
T[3][3] = (M[2][0] * s[3] - M[2][1] * s[1] + M[2][2] * s[0]) * idet;
}
static inline void mat4x4_orthonormalize(mat4x4 R, mat4x4 M) {
mat4x4_dup(R, M);
float s = 1.;
vec3 h;
vec3_norm(R[2], R[2]);
s = vec3_mul_inner(R[1], R[2]);
vec3_scale(h, R[2], s);
vec3_sub(R[1], R[1], h);
vec3_norm(R[2], R[2]);
s = vec3_mul_inner(R[1], R[2]);
vec3_scale(h, R[2], s);
vec3_sub(R[1], R[1], h);
vec3_norm(R[1], R[1]);
s = vec3_mul_inner(R[0], R[1]);
vec3_scale(h, R[1], s);
vec3_sub(R[0], R[0], h);
vec3_norm(R[0], R[0]);
}
static inline void mat4x4_frustum(mat4x4 M, float l, float r, float b, float t, float n, float f) {
M[0][0] = 2.f * n / (r - l);
M[0][1] = M[0][2] = M[0][3] = 0.f;
M[1][1] = 2.f * n / (t - b);
M[1][0] = M[1][2] = M[1][3] = 0.f;
M[2][0] = (r + l) / (r - l);
M[2][1] = (t + b) / (t - b);
M[2][2] = -(f + n) / (f - n);
M[2][3] = -1.f;
M[3][2] = -2.f * (f * n) / (f - n);
M[3][0] = M[3][1] = M[3][3] = 0.f;
}
static inline void mat4x4_ortho(mat4x4 M, float l, float r, float b, float t, float n, float f) {
M[0][0] = 2.f / (r - l);
M[0][1] = M[0][2] = M[0][3] = 0.f;
M[1][1] = 2.f / (t - b);
M[1][0] = M[1][2] = M[1][3] = 0.f;
M[2][2] = -2.f / (f - n);
M[2][0] = M[2][1] = M[2][3] = 0.f;
M[3][0] = -(r + l) / (r - l);
M[3][1] = -(t + b) / (t - b);
M[3][2] = -(f + n) / (f - n);
M[3][3] = 1.f;
}
static inline void mat4x4_perspective(mat4x4 m, float y_fov, float aspect, float n, float f) {
/* NOTE: Degrees are an unhandy unit to work with.
* linmath.h uses radians for everything! */
float const a = (float)(1.f / tan(y_fov / 2.f));
m[0][0] = a / aspect;
m[0][1] = 0.f;
m[0][2] = 0.f;
m[0][3] = 0.f;
m[1][0] = 0.f;
m[1][1] = a;
m[1][2] = 0.f;
m[1][3] = 0.f;
m[2][0] = 0.f;
m[2][1] = 0.f;
m[2][2] = -((f + n) / (f - n));
m[2][3] = -1.f;
m[3][0] = 0.f;
m[3][1] = 0.f;
m[3][2] = -((2.f * f * n) / (f - n));
m[3][3] = 0.f;
}
static inline void mat4x4_look_at(mat4x4 m, vec3 eye, vec3 center, vec3 up) {
/* Adapted from Android's OpenGL Matrix.java. */
/* See the OpenGL GLUT documentation for gluLookAt for a description */
/* of the algorithm. We implement it in a straightforward way: */
/* TODO: The negation of of can be spared by swapping the order of
* operands in the following cross products in the right way. */
vec3 f;
vec3_sub(f, center, eye);
vec3_norm(f, f);
vec3 s;
vec3_mul_cross(s, f, up);
vec3_norm(s, s);
vec3 t;
vec3_mul_cross(t, s, f);
m[0][0] = s[0];
m[0][1] = t[0];
m[0][2] = -f[0];
m[0][3] = 0.f;
m[1][0] = s[1];
m[1][1] = t[1];
m[1][2] = -f[1];
m[1][3] = 0.f;
m[2][0] = s[2];
m[2][1] = t[2];
m[2][2] = -f[2];
m[2][3] = 0.f;
m[3][0] = 0.f;
m[3][1] = 0.f;
m[3][2] = 0.f;
m[3][3] = 1.f;
mat4x4_translate_in_place(m, -eye[0], -eye[1], -eye[2]);
}
typedef float quat[4];
static inline void quat_identity(quat q) {
q[0] = q[1] = q[2] = 0.f;
q[3] = 1.f;
}
static inline void quat_add(quat r, quat a, quat b) {
int i;
for (i = 0; i < 4; ++i) r[i] = a[i] + b[i];
}
static inline void quat_sub(quat r, quat a, quat b) {
int i;
for (i = 0; i < 4; ++i) r[i] = a[i] - b[i];
}
static inline void quat_mul(quat r, quat p, quat q) {
vec3 w;
vec3_mul_cross(r, p, q);
vec3_scale(w, p, q[3]);
vec3_add(r, r, w);
vec3_scale(w, q, p[3]);
vec3_add(r, r, w);
r[3] = p[3] * q[3] - vec3_mul_inner(p, q);
}
static inline void quat_scale(quat r, quat v, float s) {
int i;
for (i = 0; i < 4; ++i) r[i] = v[i] * s;
}
static inline float quat_inner_product(quat a, quat b) {
float p = 0.f;
int i;
for (i = 0; i < 4; ++i) p += b[i] * a[i];
return p;
}
static inline void quat_conj(quat r, quat q) {
int i;
for (i = 0; i < 3; ++i) r[i] = -q[i];
r[3] = q[3];
}
#define quat_norm vec4_norm
static inline void quat_mul_vec3(vec3 r, quat q, vec3 v) {
quat v_ = {v[0], v[1], v[2], 0.f};
quat_conj(r, q);
quat_norm(r, r);
quat_mul(r, v_, r);
quat_mul(r, q, r);
}
static inline void mat4x4_from_quat(mat4x4 M, quat q) {
float a = q[3];
float b = q[0];
float c = q[1];
float d = q[2];
float a2 = a * a;
float b2 = b * b;
float c2 = c * c;
float d2 = d * d;
M[0][0] = a2 + b2 - c2 - d2;
M[0][1] = 2.f * (b * c + a * d);
M[0][2] = 2.f * (b * d - a * c);
M[0][3] = 0.f;
M[1][0] = 2 * (b * c - a * d);
M[1][1] = a2 - b2 + c2 - d2;
M[1][2] = 2.f * (c * d + a * b);
M[1][3] = 0.f;
M[2][0] = 2.f * (b * d + a * c);
M[2][1] = 2.f * (c * d - a * b);
M[2][2] = a2 - b2 - c2 + d2;
M[2][3] = 0.f;
M[3][0] = M[3][1] = M[3][2] = 0.f;
M[3][3] = 1.f;
}
static inline void mat4x4o_mul_quat(mat4x4 R, mat4x4 M, quat q) {
/* XXX: The way this is written only works for othogonal matrices. */
/* TODO: Take care of non-orthogonal case. */
quat_mul_vec3(R[0], q, M[0]);
quat_mul_vec3(R[1], q, M[1]);
quat_mul_vec3(R[2], q, M[2]);
R[3][0] = R[3][1] = R[3][2] = 0.f;
R[3][3] = 1.f;
}
static inline void quat_from_mat4x4(quat q, mat4x4 M) {
float r = 0.f;
int i;
int perm[] = {0, 1, 2, 0, 1};
int *p = perm;
for (i = 0; i < 3; i++) {
float m = M[i][i];
if (m < r) continue;
m = r;
p = &perm[i];
}
r = sqrtf(1.f + M[p[0]][p[0]] - M[p[1]][p[1]] - M[p[2]][p[2]]);
if (r < 1e-6) {
q[0] = 1.f;
q[1] = q[2] = q[3] = 0.f;
return;
}
q[0] = r / 2.f;
q[1] = (M[p[0]][p[1]] - M[p[1]][p[0]]) / (2.f * r);
q[2] = (M[p[2]][p[0]] - M[p[0]][p[2]]) / (2.f * r);
q[3] = (M[p[2]][p[1]] - M[p[1]][p[2]]) / (2.f * r);
}
#endif

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,23 @@
/*
* AppDelegate.h
*
* Copyright (c) 2014-2018 The Brenwill Workshop Ltd. (http://www.brenwill.com)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#import <Cocoa/Cocoa.h>
@interface AppDelegate : NSObject<NSApplicationDelegate>
@end

View File

@ -0,0 +1,48 @@
/*
* AppDelegate.m
*
* Copyright (c) 2014-2018 The Brenwill Workshop Ltd. (http://www.brenwill.com)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#import "AppDelegate.h"
#import "DemoViewController.h"
@interface AppDelegate ()
@end
@implementation AppDelegate
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification {
// Insert code here to initialize your application
}
- (void)applicationWillTerminate:(NSNotification *)aNotification {
NSApplication *app = aNotification.object;
NSArray<NSWindow *> *windows = app.windows;
for (NSUInteger i = 0; i < windows.count; ++i) {
NSViewController *viewController = windows[i].contentViewController;
if ([viewController isKindOfClass:[DemoViewController class]]) {
[(DemoViewController *)viewController quit];
break;
}
}
}
- (BOOL)applicationShouldTerminateAfterLastWindowClosed:(NSApplication *)sender {
return YES;
}
@end

View File

@ -0,0 +1,36 @@
/*
* DemoViewController.h
*
* Copyright (c) 2014-2018 The Brenwill Workshop Ltd. (http://www.brenwill.com)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#import <AppKit/AppKit.h>
#pragma mark -
#pragma mark DemoViewController
/** The main view controller for the demo storyboard. */
@interface DemoViewController : NSViewController
- (void)quit;
@end
#pragma mark -
#pragma mark DemoView
/** The Metal-compatibile view for the demo Storyboard. */
@interface DemoView : NSView
@end

View File

@ -0,0 +1,121 @@
/*
* DemoViewController.m
*
* Copyright (c) 2014-2018 The Brenwill Workshop Ltd. (http://www.brenwill.com)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#import "DemoViewController.h"
#import <QuartzCore/CAMetalLayer.h>
#include <MoltenVK/mvk_vulkan.h>
#include "cube.c"
#pragma mark -
#pragma mark DemoViewController
@implementation DemoViewController {
CVDisplayLinkRef _displayLink;
struct demo demo;
NSTimer* _timer;
}
- (void)dealloc {
[self quit];
[super dealloc];
}
- (void)quit {
CVDisplayLinkRelease(_displayLink);
demo_cleanup(&demo);
}
/** Since this is a single-view app, initialize Vulkan during view loading. */
- (void)viewDidLoad {
[super viewDidLoad];
self.view.wantsLayer = YES; // Back the view with a layer created by the makeBackingLayer method.
// Convert incoming args to "C" argc/argv strings
NSArray *args = [[NSProcessInfo processInfo] arguments];
const char** argv = (const char**) alloca(sizeof(char*) * args.count);
for(unsigned int i = 0; i < args.count; i++) {
NSString *s = args[i];
argv[i] = s.UTF8String;
}
demo_main(&demo, self.view.layer, args.count, argv);
// Monitor the rendering loop for a quit condition
_timer = [NSTimer scheduledTimerWithTimeInterval: 0.2
target: self
selector: @selector(onTick:)
userInfo: self
repeats: YES];
// Start the rendering loop
CVDisplayLinkCreateWithActiveCGDisplays(&_displayLink);
CVDisplayLinkSetOutputCallback(_displayLink, &DisplayLinkCallback, &demo);
CVDisplayLinkStart(_displayLink);
}
// Close the window if the demo is in a Quit state
-(void)onTick:(NSTimer*)timer {
if (demo.quit) {
[[[self view] window] close];
}
}
#pragma mark Display loop callback function
/** Rendering loop callback function for use with a CVDisplayLink. */
static CVReturn DisplayLinkCallback(CVDisplayLinkRef displayLink, const CVTimeStamp* now,
const CVTimeStamp* outputTime,
CVOptionFlags flagsIn, CVOptionFlags* flagsOut, void* target) {
struct demo* demo = (struct demo*)target;
demo_run(demo);
if (demo->quit) {
CVDisplayLinkStop(displayLink);
}
return kCVReturnSuccess;
}
@end
#pragma mark -
#pragma mark DemoView
@implementation DemoView
/** Indicates that the view wants to draw using the backing layer instead of using drawRect:. */
- (BOOL)wantsUpdateLayer {
return YES;
}
/** Returns a Metal-compatible layer. */
+ (Class)layerClass {
return [CAMetalLayer class];
}
/** If the wantsLayer property is set to YES, this method will be invoked to return a layer instance. */
- (CALayer*)makeBackingLayer {
CALayer* layer = [self.class.layerClass layer];
CGSize viewScale = [self convertSizeToBacking:CGSizeMake(1.0, 1.0)];
layer.contentsScale = MIN(viewScale.width, viewScale.height);
return layer;
}
@end

View File

@ -0,0 +1,38 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>English</string>
<key>CFBundleExecutable</key>
<string>${MACOSX_BUNDLE_EXECUTABLE_NAME}</string>
<key>CFBundleGetInfoString</key>
<string>VkCube</string>
<key>CFBundleIconFile</key>
<string>VulkanIcon.icns</string>
<key>CFBundleIdentifier</key>
<string>com.lunarg.vkcube</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleLongVersionString</key>
<string>1.0</string>
<key>CFBundleName</key>
<string>VkCube</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>1.0</string>
<key>CSResourcesFileMapped</key>
<true/>
<key>NSHumanReadableCopyright</key>
<string>Copyright (c) 2018 The Khronos Group Inc. LunarG Inc. All rights reserved.</string>
<key>NSMainStoryboardFile</key>
<string>Main</string>
<key>NSPrincipalClass</key>
<string>NSApplication</string>
</dict>
</plist>

View File

@ -0,0 +1,131 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.Cocoa.Storyboard.XIB" version="3.0" toolsVersion="10117" systemVersion="15G26a" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" initialViewController="B8D-0N-5wS">
<dependencies>
<deployment identifier="macosx"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="10117"/>
</dependencies>
<scenes>
<!--Application-->
<scene sceneID="JPo-4y-FX3">
<objects>
<application id="hnw-xV-0zn" sceneMemberID="viewController">
<menu key="mainMenu" title="Main Menu" systemMenu="main" id="AYu-sK-qS6">
<items>
<menuItem title="MoltenVK Demo" id="1Xt-HY-uBw">
<modifierMask key="keyEquivalentModifierMask"/>
<menu key="submenu" title="MoltenVK Demo" systemMenu="apple" id="uQy-DD-JDr">
<items>
<menuItem title="About Demo" id="5kV-Vb-QxS">
<modifierMask key="keyEquivalentModifierMask"/>
<connections>
<action selector="orderFrontStandardAboutPanel:" target="Ady-hI-5gd" id="Exp-CZ-Vem"/>
</connections>
</menuItem>
<menuItem isSeparatorItem="YES" id="VOq-y0-SEH"/>
<menuItem title="Hide Demo" keyEquivalent="h" id="Olw-nP-bQN">
<connections>
<action selector="hide:" target="Ady-hI-5gd" id="PnN-Uc-m68"/>
</connections>
</menuItem>
<menuItem title="Hide Others" keyEquivalent="h" id="Vdr-fp-XzO">
<modifierMask key="keyEquivalentModifierMask" option="YES" command="YES"/>
<connections>
<action selector="hideOtherApplications:" target="Ady-hI-5gd" id="VT4-aY-XCT"/>
</connections>
</menuItem>
<menuItem title="Show All" id="Kd2-mp-pUS">
<modifierMask key="keyEquivalentModifierMask"/>
<connections>
<action selector="unhideAllApplications:" target="Ady-hI-5gd" id="Dhg-Le-xox"/>
</connections>
</menuItem>
<menuItem isSeparatorItem="YES" id="kCx-OE-vgT"/>
<menuItem title="Quit Demo" keyEquivalent="q" id="4sb-4s-VLi">
<connections>
<action selector="terminate:" target="Ady-hI-5gd" id="Te7-pn-YzF"/>
</connections>
</menuItem>
</items>
</menu>
</menuItem>
<menuItem title="Window" id="aUF-d1-5bR">
<modifierMask key="keyEquivalentModifierMask"/>
<menu key="submenu" title="Window" systemMenu="window" id="Td7-aD-5lo">
<items>
<menuItem title="Minimize" keyEquivalent="m" id="OY7-WF-poV">
<connections>
<action selector="performMiniaturize:" target="Ady-hI-5gd" id="VwT-WD-YPe"/>
</connections>
</menuItem>
<menuItem title="Zoom" id="R4o-n2-Eq4">
<modifierMask key="keyEquivalentModifierMask"/>
<connections>
<action selector="performZoom:" target="Ady-hI-5gd" id="DIl-cC-cCs"/>
</connections>
</menuItem>
<menuItem isSeparatorItem="YES" id="eu3-7i-yIM"/>
<menuItem title="Bring All to Front" id="LE2-aR-0XJ">
<modifierMask key="keyEquivalentModifierMask"/>
<connections>
<action selector="arrangeInFront:" target="Ady-hI-5gd" id="DRN-fu-gQh"/>
</connections>
</menuItem>
</items>
</menu>
</menuItem>
<menuItem title="Help" id="wpr-3q-Mcd">
<modifierMask key="keyEquivalentModifierMask"/>
<menu key="submenu" title="Help" systemMenu="help" id="F2S-fz-NVQ">
<items>
<menuItem title="MoltenVK Demo Help" keyEquivalent="?" id="FKE-Sm-Kum">
<connections>
<action selector="showHelp:" target="Ady-hI-5gd" id="y7X-2Q-9no"/>
</connections>
</menuItem>
</items>
</menu>
</menuItem>
</items>
</menu>
<connections>
<outlet property="delegate" destination="Voe-Tx-rLC" id="PrD-fu-P6m"/>
</connections>
</application>
<customObject id="Voe-Tx-rLC" customClass="AppDelegate"/>
<customObject id="Ady-hI-5gd" userLabel="First Responder" customClass="NSResponder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="83.5" y="-47"/>
</scene>
<!--Window Controller-->
<scene sceneID="R2V-B0-nI4">
<objects>
<windowController id="B8D-0N-5wS" sceneMemberID="viewController">
<window key="window" title="MoltenVK Demo" allowsToolTipsWhenApplicationIsInactive="NO" autorecalculatesKeyViewLoop="NO" oneShot="NO" releasedWhenClosed="NO" showsToolbarButton="NO" visibleAtLaunch="NO" animationBehavior="default" id="IQv-IB-iLA">
<windowStyleMask key="styleMask" titled="YES" closable="YES" miniaturizable="YES" resizable="YES"/>
<rect key="contentRect" x="1051" y="656" width="300" height="200"/>
<rect key="screenRect" x="0.0" y="0.0" width="2560" height="1417"/>
<value key="minSize" type="size" width="300" height="200"/>
</window>
<connections>
<segue destination="XfG-lQ-9wD" kind="relationship" relationship="window.shadowedContentViewController" id="cq2-FE-JQM"/>
</connections>
</windowController>
<customObject id="Oky-zY-oP4" userLabel="First Responder" customClass="NSResponder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="83" y="146"/>
</scene>
<!--Demo View Controller-->
<scene sceneID="hIz-AP-VOD">
<objects>
<viewController id="XfG-lQ-9wD" customClass="DemoViewController" sceneMemberID="viewController">
<view key="view" id="m2S-Jp-Qdl" customClass="DemoView">
<rect key="frame" x="0.0" y="0.0" width="400" height="300"/>
<autoresizingMask key="autoresizingMask"/>
</view>
</viewController>
<customObject id="rPt-NT-nkU" userLabel="First Responder" customClass="NSResponder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="83" y="564"/>
</scene>
</scenes>
</document>

View File

@ -0,0 +1,83 @@
# ~~~
# Copyright (c) 2018 Valve Corporation
# Copyright (c) 2018 LunarG, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# ~~~
# VkCube Application Bundle
set(cube_SRCS
${CMAKE_CURRENT_SOURCE_DIR}/macOS/cube/main.m
${CMAKE_CURRENT_SOURCE_DIR}/macOS/cube/AppDelegate.m
${CMAKE_CURRENT_SOURCE_DIR}/macOS/cube/DemoViewController.m)
set(cube_HDRS ${CMAKE_CURRENT_SOURCE_DIR}/macOS/cube/AppDelegate.h ${CMAKE_CURRENT_SOURCE_DIR}/macOS/cube/DemoViewController.h)
set(cube_RESOURCES ${CMAKE_BINARY_DIR}/staging-json/MoltenVK_icd.json
${CMAKE_CURRENT_SOURCE_DIR}/macOS/cube/Resources/VulkanIcon.icns)
# Have Xcode handle the Storyboard
if(${CMAKE_GENERATOR} MATCHES "^Xcode.*")
set(cube_RESOURCES ${cube_RESOURCES} ${CMAKE_CURRENT_SOURCE_DIR}/macOS/cube/Resources/Main.storyboard)
endif()
add_executable(vkcube MACOSX_BUNDLE ${cube_SRCS} ${cube_HDRS} ${cube_RESOURCES} cube.vert.inc cube.frag.inc)
# Handle the Storyboard ourselves
if(NOT ${CMAKE_GENERATOR} MATCHES "^Xcode.*")
# Compile the storyboard file with the ibtool.
add_custom_command(TARGET vkcube POST_BUILD
COMMAND ${IBTOOL}
--errors
--warnings
--notices
--output-format human-readable-text
--compile ${CMAKE_CURRENT_BINARY_DIR}/vkcube.app/Contents/Resources/Main.storyboardc
${CMAKE_CURRENT_SOURCE_DIR}/macOS/cube/Resources/Main.storyboard
COMMENT "Compiling storyboard")
endif()
add_dependencies(vkcube MoltenVK_icd-staging-json)
# Include demo source code dir because the MacOS cube's Objective-C source includes the "original" cube application C source code.
# Also include the MoltenVK helper files.
target_include_directories(vkcube PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} ${MOLTENVK_DIR}/MoltenVK/include)
# We do this so vulkaninfo is linked to an individual library and NOT a framework.
target_link_libraries(vkcube ${Vulkan_LIBRARY} "-framework Cocoa -framework QuartzCore")
set_target_properties(vkcube PROPERTIES MACOSX_BUNDLE_INFO_PLIST ${CMAKE_CURRENT_SOURCE_DIR}/macOS/cube/Info.plist)
# The RESOURCE target property cannot be used in conjunction with the MACOSX_PACKAGE_LOCATION property. We need fine-grained
# control over the Resource directory, so we have to specify the destination of all the resource files on a per-destination-
# directory basis. If all the files went into the top-level Resource directory, then we could simply set the RESOURCE property to a
# list of all the resource files.
set_source_files_properties(${cube_RESOURCES} PROPERTIES MACOSX_PACKAGE_LOCATION "Resources")
set_source_files_properties("${CMAKE_BINARY_DIR}/staging-json/MoltenVK_icd.json"
PROPERTIES
MACOSX_PACKAGE_LOCATION
"Resources/vulkan/icd.d")
# Copy the MoltenVK lib into the bundle.
if(${CMAKE_GENERATOR} MATCHES "^Xcode.*")
add_custom_command(TARGET vkcube POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy "${MOLTENVK_DIR}/MoltenVK/dylib/macOS/libMoltenVK.dylib"
${CMAKE_CURRENT_BINARY_DIR}/$<CONFIG>/vkcube.app/Contents/Frameworks/libMoltenVK.dylib
DEPENDS vulkan)
else()
add_custom_command(TARGET vkcube POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy "${MOLTENVK_DIR}/MoltenVK/dylib/macOS/libMoltenVK.dylib"
${CMAKE_CURRENT_BINARY_DIR}/vkcube.app/Contents/Frameworks/libMoltenVK.dylib
DEPENDS vulkan)
endif()

View File

@ -0,0 +1,21 @@
/*
* main.m
*
* Copyright (c) 2014-2018 The Brenwill Workshop Ltd. (http://www.brenwill.com)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#import <Cocoa/Cocoa.h>
int main(int argc, const char* argv[]) { return NSApplicationMain(argc, argv); }

View File

@ -0,0 +1,23 @@
/*
* AppDelegate.h
*
* Copyright (c) 2014-2018 The Brenwill Workshop Ltd. (http://www.brenwill.com)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#import <Cocoa/Cocoa.h>
@interface AppDelegate : NSObject<NSApplicationDelegate>
@end

View File

@ -0,0 +1,48 @@
/*
* AppDelegate.m
*
* Copyright (c) 2014-2018 The Brenwill Workshop Ltd. (http://www.brenwill.com)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#import "AppDelegate.h"
#import "DemoViewController.h"
@interface AppDelegate ()
@end
@implementation AppDelegate
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification {
// Insert code here to initialize your application
}
- (void)applicationWillTerminate:(NSNotification *)aNotification {
NSApplication *app = aNotification.object;
NSArray<NSWindow *> *windows = app.windows;
for (NSUInteger i = 0; i < windows.count; ++i) {
NSViewController *viewController = windows[i].contentViewController;
if ([viewController isKindOfClass:[DemoViewController class]]) {
[(DemoViewController *)viewController quit];
break;
}
}
}
- (BOOL)applicationShouldTerminateAfterLastWindowClosed:(NSApplication *)sender {
return YES;
}
@end

View File

@ -0,0 +1,36 @@
/*
* DemoViewController.h
*
* Copyright (c) 2014-2018 The Brenwill Workshop Ltd. (http://www.brenwill.com)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#import <AppKit/AppKit.h>
#pragma mark -
#pragma mark DemoViewController
/** The main view controller for the demo storyboard. */
@interface DemoViewController : NSViewController
- (void)quit;
@end
#pragma mark -
#pragma mark DemoView
/** The Metal-compatibile view for the demo Storyboard. */
@interface DemoView : NSView
@end

View File

@ -0,0 +1,120 @@
/*
* DemoViewController.m
*
* Copyright (c) 2014-2018 The Brenwill Workshop Ltd. (http://www.brenwill.com)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#import "DemoViewController.h"
#import <QuartzCore/CAMetalLayer.h>
#include <MoltenVK/mvk_vulkan.h>
#include "cube.cpp"
#pragma mark -
#pragma mark DemoViewController
@implementation DemoViewController {
CVDisplayLinkRef _displayLink;
struct Demo demo;
NSTimer* _timer;
}
- (void)dealloc {
[self quit];
[super dealloc];
}
- (void)quit {
CVDisplayLinkRelease(_displayLink);
demo.cleanup();
}
/** Since this is a single-view app, initialize Vulkan during view loading. */
- (void)viewDidLoad {
[super viewDidLoad];
self.view.wantsLayer = YES; // Back the view with a layer created by the makeBackingLayer method.
// Convert incoming args to "C" argc/argv strings
NSArray *args = [[NSProcessInfo processInfo] arguments];
const char** argv = (const char**) alloca(sizeof(char*) * args.count);
for(unsigned int i = 0; i < args.count; i++) {
NSString *s = args[i];
argv[i] = s.UTF8String;
}
demo_main(demo, self.view.layer, args.count, argv);
// Monitor the rendering loop for a quit condition
_timer = [NSTimer scheduledTimerWithTimeInterval: 0.2
target: self
selector: @selector(onTick:)
userInfo: self
repeats: YES];
// Start the rendering loop
CVDisplayLinkCreateWithActiveCGDisplays(&_displayLink);
CVDisplayLinkSetOutputCallback(_displayLink, &DisplayLinkCallback, &demo);
CVDisplayLinkStart(_displayLink);
}
// Close the window if the demo is in a Quit state
-(void)onTick:(NSTimer*)timer {
if (demo.quit) {
[[[self view] window] close];
}
}
#pragma mark Display loop callback function
/** Rendering loop callback function for use with a CVDisplayLink. */
static CVReturn DisplayLinkCallback(CVDisplayLinkRef displayLink, const CVTimeStamp* now,
const CVTimeStamp* outputTime,
CVOptionFlags flagsIn, CVOptionFlags* flagsOut, void* target) {
struct Demo* demo = (struct Demo*)target;
demo->run();
if (demo->quit) {
CVDisplayLinkStop(displayLink);
}
return kCVReturnSuccess;
}
@end
#pragma mark -
#pragma mark DemoView
@implementation DemoView
/** Indicates that the view wants to draw using the backing layer instead of using drawRect:. */
- (BOOL)wantsUpdateLayer {
return YES;
}
/** Returns a Metal-compatible layer. */
+ (Class)layerClass {
return [CAMetalLayer class];
}
/** If the wantsLayer property is set to YES, this method will be invoked to return a layer instance. */
- (CALayer*)makeBackingLayer {
CALayer* layer = [self.class.layerClass layer];
CGSize viewScale = [self convertSizeToBacking:CGSizeMake(1.0, 1.0)];
layer.contentsScale = MIN(viewScale.width, viewScale.height);
return layer;
}
@end

View File

@ -0,0 +1,38 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>English</string>
<key>CFBundleExecutable</key>
<string>${MACOSX_BUNDLE_EXECUTABLE_NAME}</string>
<key>CFBundleGetInfoString</key>
<string>VkCubepp</string>
<key>CFBundleIconFile</key>
<string>VulkanIcon.icns</string>
<key>CFBundleIdentifier</key>
<string>com.lunarg.cubepp</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleLongVersionString</key>
<string>1.0</string>
<key>CFBundleName</key>
<string>VkCubepp</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>1.0</string>
<key>CSResourcesFileMapped</key>
<true/>
<key>NSHumanReadableCopyright</key>
<string>Copyright (c) 2018 The Khronos Group Inc. LunarG Inc. All rights reserved.</string>
<key>NSMainStoryboardFile</key>
<string>Main</string>
<key>NSPrincipalClass</key>
<string>NSApplication</string>
</dict>
</plist>

View File

@ -0,0 +1,131 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.Cocoa.Storyboard.XIB" version="3.0" toolsVersion="10117" systemVersion="15G26a" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" initialViewController="B8D-0N-5wS">
<dependencies>
<deployment identifier="macosx"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="10117"/>
</dependencies>
<scenes>
<!--Application-->
<scene sceneID="JPo-4y-FX3">
<objects>
<application id="hnw-xV-0zn" sceneMemberID="viewController">
<menu key="mainMenu" title="Main Menu" systemMenu="main" id="AYu-sK-qS6">
<items>
<menuItem title="MoltenVK Demo" id="1Xt-HY-uBw">
<modifierMask key="keyEquivalentModifierMask"/>
<menu key="submenu" title="MoltenVK Demo" systemMenu="apple" id="uQy-DD-JDr">
<items>
<menuItem title="About Demo" id="5kV-Vb-QxS">
<modifierMask key="keyEquivalentModifierMask"/>
<connections>
<action selector="orderFrontStandardAboutPanel:" target="Ady-hI-5gd" id="Exp-CZ-Vem"/>
</connections>
</menuItem>
<menuItem isSeparatorItem="YES" id="VOq-y0-SEH"/>
<menuItem title="Hide Demo" keyEquivalent="h" id="Olw-nP-bQN">
<connections>
<action selector="hide:" target="Ady-hI-5gd" id="PnN-Uc-m68"/>
</connections>
</menuItem>
<menuItem title="Hide Others" keyEquivalent="h" id="Vdr-fp-XzO">
<modifierMask key="keyEquivalentModifierMask" option="YES" command="YES"/>
<connections>
<action selector="hideOtherApplications:" target="Ady-hI-5gd" id="VT4-aY-XCT"/>
</connections>
</menuItem>
<menuItem title="Show All" id="Kd2-mp-pUS">
<modifierMask key="keyEquivalentModifierMask"/>
<connections>
<action selector="unhideAllApplications:" target="Ady-hI-5gd" id="Dhg-Le-xox"/>
</connections>
</menuItem>
<menuItem isSeparatorItem="YES" id="kCx-OE-vgT"/>
<menuItem title="Quit Demo" keyEquivalent="q" id="4sb-4s-VLi">
<connections>
<action selector="terminate:" target="Ady-hI-5gd" id="Te7-pn-YzF"/>
</connections>
</menuItem>
</items>
</menu>
</menuItem>
<menuItem title="Window" id="aUF-d1-5bR">
<modifierMask key="keyEquivalentModifierMask"/>
<menu key="submenu" title="Window" systemMenu="window" id="Td7-aD-5lo">
<items>
<menuItem title="Minimize" keyEquivalent="m" id="OY7-WF-poV">
<connections>
<action selector="performMiniaturize:" target="Ady-hI-5gd" id="VwT-WD-YPe"/>
</connections>
</menuItem>
<menuItem title="Zoom" id="R4o-n2-Eq4">
<modifierMask key="keyEquivalentModifierMask"/>
<connections>
<action selector="performZoom:" target="Ady-hI-5gd" id="DIl-cC-cCs"/>
</connections>
</menuItem>
<menuItem isSeparatorItem="YES" id="eu3-7i-yIM"/>
<menuItem title="Bring All to Front" id="LE2-aR-0XJ">
<modifierMask key="keyEquivalentModifierMask"/>
<connections>
<action selector="arrangeInFront:" target="Ady-hI-5gd" id="DRN-fu-gQh"/>
</connections>
</menuItem>
</items>
</menu>
</menuItem>
<menuItem title="Help" id="wpr-3q-Mcd">
<modifierMask key="keyEquivalentModifierMask"/>
<menu key="submenu" title="Help" systemMenu="help" id="F2S-fz-NVQ">
<items>
<menuItem title="MoltenVK Demo Help" keyEquivalent="?" id="FKE-Sm-Kum">
<connections>
<action selector="showHelp:" target="Ady-hI-5gd" id="y7X-2Q-9no"/>
</connections>
</menuItem>
</items>
</menu>
</menuItem>
</items>
</menu>
<connections>
<outlet property="delegate" destination="Voe-Tx-rLC" id="PrD-fu-P6m"/>
</connections>
</application>
<customObject id="Voe-Tx-rLC" customClass="AppDelegate"/>
<customObject id="Ady-hI-5gd" userLabel="First Responder" customClass="NSResponder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="83.5" y="-47"/>
</scene>
<!--Window Controller-->
<scene sceneID="R2V-B0-nI4">
<objects>
<windowController id="B8D-0N-5wS" sceneMemberID="viewController">
<window key="window" title="MoltenVK Demo" allowsToolTipsWhenApplicationIsInactive="NO" autorecalculatesKeyViewLoop="NO" oneShot="NO" releasedWhenClosed="NO" showsToolbarButton="NO" visibleAtLaunch="NO" animationBehavior="default" id="IQv-IB-iLA">
<windowStyleMask key="styleMask" titled="YES" closable="YES" miniaturizable="YES" resizable="YES"/>
<rect key="contentRect" x="1051" y="656" width="300" height="200"/>
<rect key="screenRect" x="0.0" y="0.0" width="2560" height="1417"/>
<value key="minSize" type="size" width="300" height="200"/>
</window>
<connections>
<segue destination="XfG-lQ-9wD" kind="relationship" relationship="window.shadowedContentViewController" id="cq2-FE-JQM"/>
</connections>
</windowController>
<customObject id="Oky-zY-oP4" userLabel="First Responder" customClass="NSResponder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="83" y="146"/>
</scene>
<!--Demo View Controller-->
<scene sceneID="hIz-AP-VOD">
<objects>
<viewController id="XfG-lQ-9wD" customClass="DemoViewController" sceneMemberID="viewController">
<view key="view" id="m2S-Jp-Qdl" customClass="DemoView">
<rect key="frame" x="0.0" y="0.0" width="400" height="300"/>
<autoresizingMask key="autoresizingMask"/>
</view>
</viewController>
<customObject id="rPt-NT-nkU" userLabel="First Responder" customClass="NSResponder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="83" y="564"/>
</scene>
</scenes>
</document>

View File

@ -0,0 +1,85 @@
# ~~~
# Copyright (c) 2018 Valve Corporation
# Copyright (c) 2018 LunarG, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# ~~~
# VkCube Application Bundle
set(cubepp_SRCS
${CMAKE_CURRENT_SOURCE_DIR}/macOS/cubepp/main.mm
${CMAKE_CURRENT_SOURCE_DIR}/macOS/cubepp/AppDelegate.mm
${CMAKE_CURRENT_SOURCE_DIR}/macOS/cubepp/DemoViewController.mm)
set(
cubepp_HDRS ${CMAKE_CURRENT_SOURCE_DIR}/macOS/cubepp/AppDelegate.h ${CMAKE_CURRENT_SOURCE_DIR}/macOS/cubepp/DemoViewController.h
)
set(cubepp_RESOURCES ${CMAKE_BINARY_DIR}/staging-json/MoltenVK_icd.json
${CMAKE_CURRENT_SOURCE_DIR}/macOS/cubepp/Resources/VulkanIcon.icns)
# Have Xcode handle the Storyboard
if(${CMAKE_GENERATOR} MATCHES "^Xcode.*")
set(cubepp_RESOURCES ${cubepp_RESOURCES} ${CMAKE_CURRENT_SOURCE_DIR}/macOS/cubepp/Resources/Main.storyboard)
endif()
add_executable(vkcubepp MACOSX_BUNDLE ${cubepp_SRCS} ${cubepp_HDRS} ${cubepp_RESOURCES} cube.vert.inc cube.frag.inc)
# Handle the Storyboard ourselves
if(NOT ${CMAKE_GENERATOR} MATCHES "^Xcode.*")
# Compile the storyboard file with the ibtool.
add_custom_command(TARGET vkcubepp POST_BUILD
COMMAND ${IBTOOL}
--errors
--warnings
--notices
--output-format human-readable-text
--compile ${CMAKE_CURRENT_BINARY_DIR}/vkcubepp.app/Contents/Resources/Main.storyboardc
${CMAKE_CURRENT_SOURCE_DIR}/macOS/cubepp/Resources/Main.storyboard
COMMENT "Compiling storyboard")
endif()
add_dependencies(vkcubepp MoltenVK_icd-staging-json)
# Include demo source code dir because the MacOS vkcubepp's Objective-C source includes the "original" vkcubepp application C++ source
# code. Also include the MoltenVK helper files.
target_include_directories(vkcubepp PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} ${MOLTENVK_DIR}/MoltenVK/include)
# We do this so vulkaninfo is linked to an individual library and NOT a framework.
target_link_libraries(vkcubepp ${Vulkan_LIBRARY} "-framework Cocoa -framework QuartzCore")
set_target_properties(vkcubepp PROPERTIES MACOSX_BUNDLE_INFO_PLIST ${CMAKE_CURRENT_SOURCE_DIR}/macOS/cubepp/Info.plist)
# The RESOURCE target property cannot be used in conjunction with the MACOSX_PACKAGE_LOCATION property. We need fine-grained
# control over the Resource directory, so we have to specify the destination of all the resource files on a per-destination-
# directory basis. If all the files went into the top-level Resource directory, then we could simply set the RESOURCE property to a
# list of all the resource files.
set_source_files_properties(${cubepp_RESOURCES} PROPERTIES MACOSX_PACKAGE_LOCATION "Resources")
set_source_files_properties("${CMAKE_BINARY_DIR}/staging-json/MoltenVK_icd.json"
PROPERTIES
MACOSX_PACKAGE_LOCATION
"Resources/vulkan/icd.d")
# Copy the MoltenVK lib into the bundle.
if(${CMAKE_GENERATOR} MATCHES "^Xcode.*")
add_custom_command(TARGET vkcubepp POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy "${MOLTENVK_DIR}/MoltenVK/dylib/macOS/libMoltenVK.dylib"
${CMAKE_CURRENT_BINARY_DIR}/$<CONFIG>/vkcubepp.app/Contents/Frameworks/libMoltenVK.dylib
DEPENDS vulkan)
else()
add_custom_command(TARGET vkcubepp POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy "${MOLTENVK_DIR}/MoltenVK/dylib/macOS/libMoltenVK.dylib"
${CMAKE_CURRENT_BINARY_DIR}/vkcubepp.app/Contents/Frameworks/libMoltenVK.dylib
DEPENDS vulkan)
endif()

View File

@ -0,0 +1,21 @@
/*
* main.m
*
* Copyright (c) 2014-2018 The Brenwill Workshop Ltd. (http://www.brenwill.com)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#import <Cocoa/Cocoa.h>
int main(int argc, const char* argv[]) { return NSApplicationMain(argc, argv); }

View File

@ -0,0 +1,107 @@
/***************************************************************************
*
* Copyright (c) 2018 The Khronos Group Inc.
* Copyright (c) 2018 Valve Corporation
* Copyright (c) 2018 LunarG, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* Author: Mark Lobodzinski <mark@lunarg.com>
*
****************************************************************************/
#pragma once
#ifdef _MSC_VER
#pragma warning(disable : 4065)
#endif
#include <vulkan/vulkan.h>
static inline const char* string_VkObjectType(VkObjectType input_value) {
switch ((VkObjectType)input_value) {
case VK_OBJECT_TYPE_QUERY_POOL:
return "VK_OBJECT_TYPE_QUERY_POOL";
case VK_OBJECT_TYPE_SAMPLER_YCBCR_CONVERSION:
return "VK_OBJECT_TYPE_SAMPLER_YCBCR_CONVERSION";
case VK_OBJECT_TYPE_SEMAPHORE:
return "VK_OBJECT_TYPE_SEMAPHORE";
case VK_OBJECT_TYPE_SHADER_MODULE:
return "VK_OBJECT_TYPE_SHADER_MODULE";
case VK_OBJECT_TYPE_SWAPCHAIN_KHR:
return "VK_OBJECT_TYPE_SWAPCHAIN_KHR";
case VK_OBJECT_TYPE_SAMPLER:
return "VK_OBJECT_TYPE_SAMPLER";
case VK_OBJECT_TYPE_INDIRECT_COMMANDS_LAYOUT_NV:
return "VK_OBJECT_TYPE_INDIRECT_COMMANDS_LAYOUT_NV";
case VK_OBJECT_TYPE_DEBUG_REPORT_CALLBACK_EXT:
return "VK_OBJECT_TYPE_DEBUG_REPORT_CALLBACK_EXT";
case VK_OBJECT_TYPE_IMAGE:
return "VK_OBJECT_TYPE_IMAGE";
case VK_OBJECT_TYPE_UNKNOWN:
return "VK_OBJECT_TYPE_UNKNOWN";
case VK_OBJECT_TYPE_DESCRIPTOR_POOL:
return "VK_OBJECT_TYPE_DESCRIPTOR_POOL";
case VK_OBJECT_TYPE_COMMAND_BUFFER:
return "VK_OBJECT_TYPE_COMMAND_BUFFER";
case VK_OBJECT_TYPE_BUFFER:
return "VK_OBJECT_TYPE_BUFFER";
case VK_OBJECT_TYPE_SURFACE_KHR:
return "VK_OBJECT_TYPE_SURFACE_KHR";
case VK_OBJECT_TYPE_INSTANCE:
return "VK_OBJECT_TYPE_INSTANCE";
case VK_OBJECT_TYPE_VALIDATION_CACHE_EXT:
return "VK_OBJECT_TYPE_VALIDATION_CACHE_EXT";
case VK_OBJECT_TYPE_IMAGE_VIEW:
return "VK_OBJECT_TYPE_IMAGE_VIEW";
case VK_OBJECT_TYPE_DESCRIPTOR_SET:
return "VK_OBJECT_TYPE_DESCRIPTOR_SET";
case VK_OBJECT_TYPE_DESCRIPTOR_SET_LAYOUT:
return "VK_OBJECT_TYPE_DESCRIPTOR_SET_LAYOUT";
case VK_OBJECT_TYPE_COMMAND_POOL:
return "VK_OBJECT_TYPE_COMMAND_POOL";
case VK_OBJECT_TYPE_PHYSICAL_DEVICE:
return "VK_OBJECT_TYPE_PHYSICAL_DEVICE";
case VK_OBJECT_TYPE_DISPLAY_KHR:
return "VK_OBJECT_TYPE_DISPLAY_KHR";
case VK_OBJECT_TYPE_BUFFER_VIEW:
return "VK_OBJECT_TYPE_BUFFER_VIEW";
case VK_OBJECT_TYPE_DEBUG_UTILS_MESSENGER_EXT:
return "VK_OBJECT_TYPE_DEBUG_UTILS_MESSENGER_EXT";
case VK_OBJECT_TYPE_FRAMEBUFFER:
return "VK_OBJECT_TYPE_FRAMEBUFFER";
case VK_OBJECT_TYPE_DESCRIPTOR_UPDATE_TEMPLATE:
return "VK_OBJECT_TYPE_DESCRIPTOR_UPDATE_TEMPLATE";
case VK_OBJECT_TYPE_PIPELINE_CACHE:
return "VK_OBJECT_TYPE_PIPELINE_CACHE";
case VK_OBJECT_TYPE_PIPELINE_LAYOUT:
return "VK_OBJECT_TYPE_PIPELINE_LAYOUT";
case VK_OBJECT_TYPE_DEVICE_MEMORY:
return "VK_OBJECT_TYPE_DEVICE_MEMORY";
case VK_OBJECT_TYPE_FENCE:
return "VK_OBJECT_TYPE_FENCE";
case VK_OBJECT_TYPE_QUEUE:
return "VK_OBJECT_TYPE_QUEUE";
case VK_OBJECT_TYPE_DEVICE:
return "VK_OBJECT_TYPE_DEVICE";
case VK_OBJECT_TYPE_RENDER_PASS:
return "VK_OBJECT_TYPE_RENDER_PASS";
case VK_OBJECT_TYPE_DISPLAY_MODE_KHR:
return "VK_OBJECT_TYPE_DISPLAY_MODE_KHR";
case VK_OBJECT_TYPE_EVENT:
return "VK_OBJECT_TYPE_EVENT";
case VK_OBJECT_TYPE_PIPELINE:
return "VK_OBJECT_TYPE_PIPELINE";
default:
return "Unhandled VkObjectType";
}
}

View File

@ -0,0 +1,177 @@
# ~~~
# Copyright (c) 2014-2018 Valve Corporation
# Copyright (c) 2014-2018 LunarG, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# ~~~
if(WIN32)
add_definitions(-DVK_USE_PLATFORM_WIN32_KHR -DVK_USE_PLATFORM_WIN32_KHX -DWIN32_LEAN_AND_MEAN)
elseif(ANDROID)
add_definitions(-DVK_USE_PLATFORM_ANDROID_KHR -DVK_USE_PLATFORM_ANDROID_KHX)
elseif(APPLE)
add_definitions(-DVK_USE_PLATFORM_MACOS_MVK)
elseif(UNIX AND NOT APPLE) # i.e. Linux
if(BUILD_WSI_XCB_SUPPORT)
add_definitions(-DVK_USE_PLATFORM_XCB_KHR -DVK_USE_PLATFORM_XCB_KHX)
endif()
if(BUILD_WSI_XLIB_SUPPORT)
add_definitions(-DVK_USE_PLATFORM_XLIB_KHR -DVK_USE_PLATFORM_XLIB_KHX -DVK_USE_PLATFORM_XLIB_XRANDR_EXT)
endif()
if(BUILD_WSI_WAYLAND_SUPPORT)
add_definitions(-DVK_USE_PLATFORM_WAYLAND_KHR -DVK_USE_PLATFORM_WAYLAND_KHX)
endif()
else()
message(FATAL_ERROR "Unsupported Platform!")
endif()
# Copy or link the JSON files to the binary directory for ease of use in the build tree.
set(ICD_JSON_FILES VkICD_mock_icd)
if(WIN32)
# extra setup for out-of-tree builds
if(NOT (CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_CURRENT_BINARY_DIR))
if(CMAKE_GENERATOR MATCHES "^Visual Studio.*")
foreach(config_file ${ICD_JSON_FILES})
file(TO_NATIVE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/windows/${config_file}.json src_json)
file(TO_NATIVE_PATH ${CMAKE_CURRENT_BINARY_DIR}/$<CONFIG>/${config_file}.json dst_json)
add_custom_target(${config_file}-json ALL COMMAND copy ${src_json} ${dst_json} VERBATIM)
set_target_properties(${config_file}-json PROPERTIES FOLDER ${TOOLS_HELPER_FOLDER})
endforeach(config_file)
else()
foreach(config_file ${ICD_JSON_FILES})
file(TO_NATIVE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/windows/${config_file}.json src_json)
file(TO_NATIVE_PATH ${CMAKE_CURRENT_BINARY_DIR}/${config_file}.json dst_json)
add_custom_target(${config_file}-json ALL COMMAND copy ${src_json} ${dst_json} VERBATIM)
endforeach(config_file)
endif()
endif()
elseif(APPLE)
# extra setup for out-of-tree builds
if(NOT (CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_CURRENT_BINARY_DIR))
if(CMAKE_GENERATOR MATCHES "^Xcode.*")
add_custom_target(mk_icd_config_dir ALL
COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_CURRENT_BINARY_DIR}/$<CONFIG>)
foreach(config_file ${ICD_JSON_FILES})
add_custom_target(${config_file}-json ALL
DEPENDS mk_icd_config_dir
COMMAND ${CMAKE_COMMAND} -E create_symlink ${CMAKE_CURRENT_SOURCE_DIR}/macos/${config_file}.json
$<CONFIG> ${CMAKE_CURRENT_BINARY_DIR}/$<CONFIG>/${config_file}.json
VERBATIM)
endforeach(config_file)
else()
foreach(config_file ${ICD_JSON_FILES})
add_custom_target(${config_file}-json ALL
COMMAND ${CMAKE_COMMAND} -E create_symlink ${CMAKE_CURRENT_SOURCE_DIR}/macos/${config_file}.json
${config_file}.json
VERBATIM)
endforeach(config_file)
endif()
endif()
else()
# extra setup for out-of-tree builds
if(NOT (CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_CURRENT_BINARY_DIR))
foreach(config_file ${ICD_JSON_FILES})
add_custom_target(${config_file}-json ALL
COMMAND ${CMAKE_COMMAND} -E create_symlink ${CMAKE_CURRENT_SOURCE_DIR}/linux/${config_file}.json
${config_file}.json
VERBATIM)
endforeach(config_file)
endif()
endif()
# For ICD with a direct dependency on a project with the same name, use it.
if(NOT (CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_CURRENT_BINARY_DIR))
foreach(config_file ${ICD_JSON_FILES})
add_dependencies(${config_file}-json ${config_file})
endforeach(config_file)
endif()
add_custom_target(generate_icd_files DEPENDS mock_icd.h mock_icd.cpp)
set_target_properties(generate_icd_files PROPERTIES FOLDER ${TOOLS_HELPER_FOLDER})
if(WIN32)
macro(add_vk_icd target)
file(TO_NATIVE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/VkICD_${target}.def DEF_FILE)
add_custom_target(copy-${target}-def-file ALL
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${DEF_FILE} VkICD_${target}.def
VERBATIM)
set_target_properties(copy-${target}-def-file PROPERTIES FOLDER ${TOOLS_HELPER_FOLDER})
add_library(VkICD_${target} SHARED ${ARGN} VkICD_${target}.def)
if(INSTALL_ICD)
install(TARGETS VkICD_${target} DESTINATION ${CMAKE_INSTALL_LIBDIR})
endif()
endmacro()
elseif(APPLE)
macro(add_vk_icd target)
add_library(VkICD_${target} SHARED ${ARGN})
set_target_properties(VkICD_${target} PROPERTIES LINK_FLAGS "-Wl")
if(INSTALL_ICD)
install(TARGETS VkICD_${target} DESTINATION ${CMAKE_CURRENT_BINARY_DIR})
endif()
endmacro()
else()
macro(add_vk_icd target)
add_library(VkICD_${target} SHARED ${ARGN})
set_target_properties(VkICD_${target} PROPERTIES LINK_FLAGS "-Wl,-export-dynamic,-Bsymbolic,--exclude-libs,ALL")
if((UNIX AND NOT APPLE) AND INSTALL_ICD) # i.e. Linux
install(TARGETS VkICD_${target} DESTINATION ${CMAKE_INSTALL_LIBDIR})
endif()
endmacro()
endif()
include_directories(${CMAKE_CURRENT_SOURCE_DIR}
${VulkanHeaders_INCLUDE_DIR}
${WAYLAND_CLIENT_INCLUDE_DIR}
${CMAKE_CURRENT_BINARY_DIR}
${PROJECT_BINARY_DIR}
${CMAKE_BINARY_DIR})
if(WIN32)
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -D_CRT_SECURE_NO_WARNINGS")
set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -D_CRT_SECURE_NO_WARNINGS")
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} -D_CRT_SECURE_NO_WARNINGS")
set(CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO} -D_CRT_SECURE_NO_WARNINGS")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -D_CRT_SECURE_NO_WARNINGS /bigobj")
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -D_CRT_SECURE_NO_WARNINGS /bigobj")
# Turn off transitional "changed behavior" warning message for Visual Studio versions prior to 2015. The changed behavior is
# that constructor initializers are now fixed to clear the struct members.
add_compile_options("$<$<AND:$<CXX_COMPILER_ID:MSVC>,$<VERSION_LESS:$<CXX_COMPILER_VERSION>,19>>:/wd4351>")
else()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wpointer-arith -Wno-unused-function -Wno-sign-compare")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wpointer-arith -Wno-unused-function -Wno-sign-compare")
endif()
add_vk_icd(mock_icd generated/mock_icd.cpp generated/mock_icd.h)
# JSON file(s) install targets. For Linux, need to remove the "./" from the library path before installing to system directories.
if((UNIX AND NOT APPLE) AND INSTALL_ICD) # i.e. Linux
foreach(config_file ${ICD_JSON_FILES})
add_custom_target(${config_file}-staging-json ALL
COMMAND mkdir -p ${CMAKE_CURRENT_BINARY_DIR}/staging-json
COMMAND cp ${CMAKE_CURRENT_SOURCE_DIR}/linux/${config_file}.json ${CMAKE_CURRENT_BINARY_DIR}/staging-json
COMMAND sed -i -e "/\"library_path\":/s$./libVkICD$libVkICD$"
${CMAKE_CURRENT_BINARY_DIR}/staging-json/${config_file}.json
VERBATIM
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/linux/${config_file}.json)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/staging-json/${config_file}.json
DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/vulkan/icd.d)
endforeach(config_file)
endif()
# Windows uses the JSON file as-is.
if(WIN32 AND INSTALL_ICD)
foreach(config_file ${ICD_JSON_FILES})
install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/windows/${config_file}.json DESTINATION ${CMAKE_INSTALL_LIBDIR})
endforeach(config_file)
endif()

View File

@ -0,0 +1,80 @@
# Vulkan Mock ICD
This directory contains a mock ICD driver designed for validation layer testing.
## Introduction
The mock ICD is focused on enabling validation testing apart from an actual device. Because the validation layers
sit on top of the ICD and don't depend upon the results of Vulkan rendering, they can be tested without having actual
GPU hardware backing the ICD. The final mock driver will be composed of three main features: a null driver, flexible
device configuration, and entrypoint tracking & verification.
### Null Driver
The intial mock driver features just the null driver capability. This allows all of the validation tests to be run
on a fixed device configuration that is hard-coded into the ICD.
### Entrypoint Tracking & Verification
Entrypoint tracking and verification will be added to the mock layer as a later feature. The idea is that all expected
Vulkan function calls and their parameters can be stored in the ICD and then a separate call can be made to verify that
the exepected calls and parameters actually entered the ICD. This allows verification that the validation layers are
correctly passing calls and their parameters through to the ICD unchanged.
## Using the Mock ICD
To enable the mock ICD, set VK\_ICD\_FILENAMES environment variable to point to your {BUILD_DIR}/icd/VkICD\_mock\_icd.json.
## Plans
The initial mock ICD is just the null driver which can be used to test validation layers on
simulated devices. Here's a rough sequence of tasks planned for the mock driver going forward:
- [X] Get all LVL tests passing on the bare null driver
- [X] Get failing tests passing
- [X] Get skipped tests passing as able
- [ ] Get all LVL tests to run without unexpected errors
- [X] Develop automated test flow using mock ICD (alternative to or replacement for run\_all\_tests.sh)
- [ ] Update LVL tests with device dependencies to target specific device profiles
- [ ] Add entrypoint tracking & verification
- [ ] Initially track expected calls
- [ ] Update some tests to verify expected capability
- [ ] Expand tracking to include parameters
## Beyond Validation Layer Testing
The focus of the mock icd is for validation testing, but the code is available to use and enhance for anyone wishing to apply it for alternative
purposes.
With the following enhancements, the mock driver state available to the app should very closely mimic an actual ICD:
- Update various function return codes
- Simulated synchronization objects
- Simulated query with mock data
- Basic command buffer state tracking to note synch object transitions and query state updates
Beyond that it's certainly possible that the mock icd could be hooked up to a SW renderer and serve as a virtual GPU with complete rendering/compute
capabilities.
## Status
This is a temporary section used for tracking as the mock icd is being developed. Once all tests are passing with the mock, this section can be removed.
Currently 333/333 tests are passing with the mock icd, but many passing tests have unexpected validation errors that need to be cleaned up.
### Failing Tests
NONE
### Passing Tests With Unexpected Errors
- VkLayerTest.RenderPassInUseDestroyedSignaled
- VkLayerTest.RenderPassIncompatible
### Skipped Tests
- VkLayerTest.BindImageInvalidMemoryType
- VkLayerTest.CreatePipelineBadVertexAttributeFormat
- VkLayerTest.MiscBlitImageTests
- VkLayerTest.TemporaryExternalSemaphore
- VkLayerTest.TemporaryExternalFence
- VkLayerTest.InvalidBarriers
- VkLayerTest.CommandQueueFlags
- VkPositiveLayerTest.TwoQueuesEnsureCorrectRetirementWithWorkStolen
- VkPositiveLayerTest.ExternalSemaphore
- VkPositiveLayerTest.ExternalFence
- VkPositiveLayerTest.ExternalMemory

View File

@ -0,0 +1,36 @@
;;;; Begin Copyright Notice ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
; Copyright (c) 2015-2017 The Khronos Group Inc.
; Copyright (c) 2015-2017 Valve Corporation
; Copyright (c) 2015-2017 LunarG, Inc.
; Copyright (c) 2015-2017 Google Inc.
;
; Licensed under the Apache License, Version 2.0 (the "License");
; you may not use this file except in compliance with the License.
; You may obtain a copy of the License at
;
; http://www.apache.org/licenses/LICENSE-2.0
;
; Unless required by applicable law or agreed to in writing, software
; distributed under the License is distributed on an "AS IS" BASIS,
; WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
; See the License for the specific language governing permissions and
; limitations under the License.
;
; Author: Tobin Ehlis <tobine@google.com>
;
;;;; End Copyright Notice ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
LIBRARY VkICD_mock_icd
EXPORTS
vk_icdGetInstanceProcAddr
vk_icdGetPhysicalDeviceProcAddr
vk_icdNegotiateLoaderICDInterfaceVersion
vkDestroySurfaceKHR
vkGetPhysicalDeviceSurfaceSupportKHR
vkGetPhysicalDeviceSurfaceCapabilitiesKHR
vkGetPhysicalDeviceSurfaceFormatsKHR
vkGetPhysicalDeviceSurfacePresentModesKHR
vkCreateDisplayPlaneSurfaceKHR
vkCreateWin32SurfaceKHR

View File

@ -0,0 +1,5 @@
---
# Disable clang-format for generated code
DisableFormat: true
SortIncludes: false
...

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,12 @@
{
"file_format_version" : "1.0.1",
"ICD": {
"library_path": "./libVkICD_mock_icd.so",
"api_version": "1.1.97"
}
}

View File

@ -0,0 +1,8 @@
{
"file_format_version" : "1.0.1",
"ICD": {
"library_path": "./libVkICD_mock_icd.dylib",
"api_version": "1.1.97"
}
}

View File

@ -0,0 +1,12 @@
{
"file_format_version" : "1.0.1",
"ICD": {
"library_path": ".\\VkICD_mock_icd.dll",
"api_version": "1.1.97"
}
}

View File

@ -0,0 +1,56 @@
# ~~~
# Copyright (c) 2018 Valve Corporation
# Copyright (c) 2018 LunarG, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# ~~~
# Set up common settings for building all demos on Apple platforms.
# Source for the MoltenVK ICD library and JSON file
set(MOLTENVK_DIR ${MOLTENVK_REPO_ROOT})
# MoltenVK JSON File
execute_process(COMMAND mkdir -p ${CMAKE_BINARY_DIR}/staging-json)
execute_process(COMMAND sed -e "/\"library_path\":/s$:[[:space:]]*\"[[:space:]]*[\\.\\/]*$: \"..\\/..\\/..\\/Frameworks\\/$"
${MOLTENVK_DIR}/MoltenVK/icd/MoltenVK_icd.json
OUTPUT_FILE ${CMAKE_BINARY_DIR}/staging-json/MoltenVK_icd.json)
# ~~~
# Modify the ICD JSON file to adjust the library path.
# The ICD JSON file goes in the Resources/vulkan/icd.d directory, so adjust the
# library_path to the relative path to the Frameworks directory in the bundle.
# The regex does: substitute ':<whitespace>"<whitespace><all occurences of . and />' with:
# ': "../../../Frameworks/'
# ~~~
add_custom_target(MoltenVK_icd-staging-json ALL
COMMAND mkdir -p ${CMAKE_BINARY_DIR}/staging-json
COMMAND sed -e "/\"library_path\":/s$:[[:space:]]*\"[[:space:]]*[\\.\\/]*$: \"..\\/..\\/..\\/Frameworks\\/$"
${MOLTENVK_DIR}/MoltenVK/icd/MoltenVK_icd.json > ${CMAKE_BINARY_DIR}/staging-json/MoltenVK_icd.json
VERBATIM
DEPENDS "${MOLTENVK_DIR}/MoltenVK/icd/MoltenVK_icd.json")
set_source_files_properties(${CMAKE_BINARY_DIR}/staging-json/MoltenVK_icd.json PROPERTIES GENERATED TRUE)
find_library(COCOA NAMES Cocoa)
# Locate Interface Builder Tool, needed to build things like Storyboards outside of Xcode.
if(NOT ${CMAKE_GENERATOR} MATCHES "^Xcode.*")
# Make sure we can find the 'ibtool' program. If we can NOT find it we skip generation of this project.
find_program(IBTOOL ibtool HINTS "/usr/bin" "${OSX_DEVELOPER_ROOT}/usr/bin")
if(${IBTOOL} STREQUAL "IBTOOL-NOTFOUND")
message(SEND_ERROR "ibtool can not be found and is needed to compile the .xib files. "
"It should have been installed with the Apple developer tools. "
"The default system paths were searched in addition to ${OSX_DEVELOPER_ROOT}/usr/bin.")
endif()
endif()

View File

@ -0,0 +1,45 @@
#!/bin/bash
# Copyright (c) 2017 Google Inc.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# Script to determine if source code in Pull Request is properly formatted.
# Exits with non 0 exit code if formatting is needed.
#
# This script assumes to be invoked at the project root directory.
RED='\033[0;31m'
GREEN='\033[0;32m'
NC='\033[0m' # No Color
clang-format --version
FILES_TO_CHECK=$(git diff --name-only master | grep -v -E "^include/vulkan" | grep -E ".*\.(cpp|cc|c\+\+|cxx|c|h|hpp)$")
if [ -z "${FILES_TO_CHECK}" ]; then
echo -e "${GREEN}No source code to check for formatting.${NC}"
exit 0
fi
FORMAT_DIFF=$(git diff -U0 master -- ${FILES_TO_CHECK} | python ./scripts/clang-format-diff.py -p1 -style=file)
if [ -z "${FORMAT_DIFF}" ]; then
echo -e "${GREEN}All source code in PR properly formatted.${NC}"
exit 0
else
echo -e "${RED}Found formatting errors!${NC}"
echo "${FORMAT_DIFF}"
echo "Be sure you are using the following version of clang-format:"
clang-format --version
exit 1
fi

View File

@ -0,0 +1,102 @@
#!/bin/bash
# Copyright (c) 2018 Valve Corporation
# Copyright (c) 2018 LunarG, Inc.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# Checks commit messages against project standards in CONTRIBUTING.md document
# Script to determine if commit messages in Pull Request are properly formatted.
# Exits with non 0 exit code if reformatting is needed.
# Disable subshells
shopt -s lastpipe
RED='\033[0;31m'
GREEN='\033[0;32m'
NC='\033[0m' # No Color
# TRAVIS_COMMIT_RANGE contains range of commits for this PR
# Get user-supplied commit message text for applicable commits and insert
# a unique separator string identifier. The git command returns ONLY the
# subject line and body for each of the commits.
COMMIT_TEXT=$(git log ${TRAVIS_COMMIT_RANGE} --pretty=format:"XXXNEWLINEXXX"%n%B)
# Bail if there are none
if [ -z "${COMMIT_TEXT}" ]; then
echo -e "${GREEN}No commit messgages to check for formatting.${NC}"
exit 0
elif ! echo $TRAVIS_COMMIT_RANGE | grep -q "\.\.\."; then
echo -e "${GREEN}No commit messgages to check for formatting.${NC}"
exit 0
fi
# Process commit messages
success=1
current_line=0
prevline=""
# Process each line of the commit message output, resetting counter on separator
printf %s "$COMMIT_TEXT" | while IFS='' read -r line; do
# echo "Count = $current_line <Line> = $line"
current_line=$((current_line+1))
if [ "$line" = "XXXNEWLINEXXX" ]; then
current_line=0
fi
chars=${#line}
if [ $current_line -eq 1 ]; then
# Subject line should be 50 chars or less (but give some slack here)
if [ $chars -gt 54 ]; then
echo "The following subject line exceeds 50 characters in length."
echo " '$line'"
success=0
fi
i=$(($chars-1))
last_char=${line:$i:1}
# Output error if last char of subject line is not alpha-numeric
if [[ ! $last_char =~ [0-9a-zA-Z] ]]; then
echo "For the following commit, the last character of the subject line must not be non-alphanumeric."
echo " '$line'"
success=0
fi
# Checking if subject line doesn't start with 'module: '
prefix=$(echo $line | cut -f1 -d " ")
if [ "${prefix: -1}" != ":" ]; then
echo "The following subject line must start with a single word specifying the functional area of the change, followed by a colon and space. I.e., 'layers: Subject line here'"
echo " '$line'"
success=0
fi
elif [ $current_line -eq 2 ]; then
# Commit message must have a blank line between subject and body
if [ $chars -ne 0 ]; then
echo "The following subject line must be followed by a blank line."
echo " '$prevline'"
success=0
fi
else
# Lines in a commit message body must be less than 72 characters in length (but give some slack)
if [ $chars -gt 76 ]; then
echo "The following commit message body line exceeds the 72 character limit."
echo "'$line\'"
success=0
fi
fi
prevline=$line
done
if [ $success -eq 1 ]; then
echo -e "${GREEN}All commit messages in pull request are properly formatted.${NC}"
exit 0
else
exit 1
fi

View File

@ -0,0 +1,77 @@
#!/usr/bin/python3 -i
#
# Copyright (c) 2015-2017, 2019-2021 The Khronos Group Inc.
# Copyright (c) 2015-2017, 2019-2021 Valve Corporation
# Copyright (c) 2015-2017, 2019-2021 LunarG, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# Author: Mark Lobodzinski <mark@lunarg.com>
import os
# Copyright text prefixing all headers (list of strings).
prefixStrings = [
'/*',
'** Copyright (c) 2015-2017, 2019-2021 The Khronos Group Inc.',
'** Copyright (c) 2015-2017, 2019-2021 Valve Corporation',
'** Copyright (c) 2015-2017, 2019-2021 LunarG, Inc.',
'** Copyright (c) 2015-2017, 2019-2021 Google Inc.',
'**',
'** Licensed under the Apache License, Version 2.0 (the "License");',
'** you may not use this file except in compliance with the License.',
'** You may obtain a copy of the License at',
'**',
'** http://www.apache.org/licenses/LICENSE-2.0',
'**',
'** Unless required by applicable law or agreed to in writing, software',
'** distributed under the License is distributed on an "AS IS" BASIS,',
'** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.',
'** See the License for the specific language governing permissions and',
'** limitations under the License.',
'*/',
''
]
platform_dict = {
'android' : 'VK_USE_PLATFORM_ANDROID_KHR',
'fuchsia' : 'VK_USE_PLATFORM_FUCHSIA',
'ggp': 'VK_USE_PLATFORM_GGP',
'ios' : 'VK_USE_PLATFORM_IOS_MVK',
'macos' : 'VK_USE_PLATFORM_MACOS_MVK',
'metal' : 'VK_USE_PLATFORM_METAL_EXT',
'vi' : 'VK_USE_PLATFORM_VI_NN',
'wayland' : 'VK_USE_PLATFORM_WAYLAND_KHR',
'win32' : 'VK_USE_PLATFORM_WIN32_KHR',
'xcb' : 'VK_USE_PLATFORM_XCB_KHR',
'xlib' : 'VK_USE_PLATFORM_XLIB_KHR',
'xlib_xrandr' : 'VK_USE_PLATFORM_XLIB_XRANDR_EXT',
'provisional' : 'VK_ENABLE_BETA_EXTENSIONS',
'directfb' : 'VK_USE_PLATFORM_DIRECTFB_EXT',
'screen' : 'VK_USE_PLATFORM_SCREEN_QNX',
}
#
# Return appropriate feature protect string from 'platform' tag on feature
def GetFeatureProtect(interface):
"""Get platform protection string"""
platform = interface.get('platform')
protect = None
if platform is not None:
protect = platform_dict[platform]
return protect
# helper to define paths relative to the repo root
def repo_relative(path):
return os.path.abspath(os.path.join(os.path.dirname(__file__), '..', path))

View File

@ -0,0 +1,119 @@
#!/usr/bin/env python3
#
# Copyright (c) 2016 The Khronos Group Inc.
# Copyright (c) 2016 Valve Corporation
# Copyright (c) 2016 LunarG, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# Author: Mark Young <marky@lunarg.com>
import sys
import os
import subprocess
# Following function code snippet was found on StackOverflow (with a change to lower
# camel-case on the variable names):
# http://stackoverflow.com/questions/377017/test-if-executable-exists-in-python
def find_executable(program):
def is_exe(fPath):
return os.path.isfile(fPath) and os.access(fPath, os.X_OK)
fPath, fName = os.path.split(program)
if fPath:
if is_exe(program):
return program
else:
for path in os.environ["PATH"].split(os.pathsep):
path = path.strip('"')
exe_file = os.path.join(path, program)
if is_exe(exe_file):
return exe_file
return None
def determine_year(version):
if version == 8:
return 2005
elif version == 9:
return 2008
elif version == 10:
return 2010
elif version == 11:
return 2012
elif version == 12:
return 2013
elif version == 14:
return 2015
elif version == 15:
return 2017
else:
return 0000
# Determine if msbuild is in the path, then call it to determine the version and parse
# it into a format we can use, which is "<version_num> <version_year>".
if __name__ == '__main__':
exeName = 'msbuild.exe'
arguments = '/ver'
# Determine if the executable exists in the path, this is critical.
#
foundExeName = find_executable(exeName)
# If not found, return an invalid number but in the appropriate format so it will
# fail if the program above tries to use it.
if foundExeName == None:
print('00 0000')
print('Executable ' + exeName + ' not found in PATH!')
else:
proc = subprocess.Popen([exeName, arguments], stdout=subprocess.PIPE)
sysCallOut = proc.stdout.readline().decode('iso-8859-1').rstrip()
version = None
# Split around any spaces first
spaceList = sysCallOut.split(' ')
for spaceString in spaceList:
# If we've already found it, bail.
if version != None:
break
# Now split around line feeds
lineList = spaceString.split('\n')
for curLine in lineList:
# If we've already found it, bail.
if version != None:
break
# We only want to continue if there's a period in the list
if '.' not in curLine:
continue
# Get the first element and determine if it is a number, if so, we've
# got our number.
splitAroundPeriod = curLine.split('.')
if splitAroundPeriod[0].isdigit():
version = int (splitAroundPeriod[0])
break
# Failsafe to return a number in the proper format, but one that will fail.
if version == None:
version = 00
# Determine the year associated with that version
year = determine_year(version)
# Output the string we need for Cmake to properly build for this version
print(str(version) + ' ' + str(year))

View File

@ -0,0 +1,79 @@
#!/usr/bin/env python3
#
# Copyright (c) 2018 The Khronos Group Inc.
# Copyright (c) 2018 Valve Corporation
# Copyright (c) 2018 LunarG, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# Author: Mark Lobodzinski <mark@lunarg.com>
# This script will download the latest glslang release binary and extract the
# glslangValidator binary needed by the vkcube and vkcubepp applications.
#
# It takes as its lone argument the filname (no path) describing the release
# binary name from the glslang github releases page.
import sys
import os
import shutil
import ssl
import subprocess
import urllib.request
import zipfile
import platform
SCRIPTS_DIR = os.path.dirname(os.path.abspath(__file__))
REPO_DIR = os.path.join(SCRIPTS_DIR, '..')
GLSLANG_URL = "https://github.com/KhronosGroup/glslang/releases/download/7.9.2888"
def platformDir(): return platform.system().lower()
if __name__ == '__main__':
if len(sys.argv) != 2:
print("ERROR -- must include a single glslang release zipfile name argument")
sys.exit();
GLSLANG_FILENAME = sys.argv[1]
GLSLANG_COMPLETE_URL = GLSLANG_URL + "/" + GLSLANG_FILENAME
GLSLANG_OUTFILENAME = os.path.join(REPO_DIR, "glslang", GLSLANG_FILENAME)
GLSLANG_DIR = os.path.join(REPO_DIR, "glslang", platformDir())
GLSLANG_VALIDATOR_PATH = os.path.join(GLSLANG_DIR, "bin")
GLSLANG_VALIDATOR_FULL_PATH = os.path.join(GLSLANG_VALIDATOR_PATH, "glslangValidator")
if platform.system() == 'Windows':
GLSLANG_VALIDATOR_FULL_PATH = GLSLANG_VALIDATOR_FULL_PATH + '.exe'
if os.path.isdir(GLSLANG_DIR):
if os.path.exists(GLSLANG_VALIDATOR_FULL_PATH):
print(" Using glslangValidator at %s" % GLSLANG_VALIDATOR_PATH)
sys.exit()
else:
os.makedirs(GLSLANG_DIR)
print(" Downloading glslangValidator binary from glslang releases dir")
sys.stdout.flush()
# Download release zip file from glslang github releases site
with urllib.request.urlopen(GLSLANG_COMPLETE_URL, context=ssl._create_unverified_context()) as response, open(GLSLANG_OUTFILENAME, 'wb') as out_file:
shutil.copyfileobj(response, out_file)
# Unzip the glslang binary archive
zipped_file = zipfile.ZipFile(GLSLANG_OUTFILENAME, 'r')
namelist = zipped_file.namelist()
for afile in namelist:
if "glslangValidator" in afile:
EXE_FILE_PATH = os.path.join(GLSLANG_DIR, afile)
zipped_file.extract(afile, GLSLANG_DIR)
os.chmod(EXE_FILE_PATH, 0o775)
break
zipped_file.close()
sys.exit();

Some files were not shown because too many files have changed in this diff Show More