1*b7893ccfSSadaf Ebrahimi# Build Instructions 2*b7893ccfSSadaf Ebrahimi 3*b7893ccfSSadaf EbrahimiInstructions for building this repository on Linux, Windows, Android, and 4*b7893ccfSSadaf EbrahimiMacOS. 5*b7893ccfSSadaf Ebrahimi 6*b7893ccfSSadaf Ebrahimi## Index 7*b7893ccfSSadaf Ebrahimi 8*b7893ccfSSadaf Ebrahimi1. [Contributing](#contributing-to-the-repository) 9*b7893ccfSSadaf Ebrahimi1. [Repository Content](#repository-content) 10*b7893ccfSSadaf Ebrahimi1. [Repository Set-Up](#repository-set-up) 11*b7893ccfSSadaf Ebrahimi1. [Windows Build](#building-on-windows) 12*b7893ccfSSadaf Ebrahimi1. [Linux Build](#building-on-linux) 13*b7893ccfSSadaf Ebrahimi1. [Android Build](#building-on-android) 14*b7893ccfSSadaf Ebrahimi1. [MacOS build](#building-on-macos) 15*b7893ccfSSadaf Ebrahimi 16*b7893ccfSSadaf Ebrahimi## Contributing to the Repository 17*b7893ccfSSadaf Ebrahimi 18*b7893ccfSSadaf EbrahimiIf you intend to contribute, the preferred work flow is for you to develop 19*b7893ccfSSadaf Ebrahimiyour contribution in a fork of this repository in your GitHub account and then 20*b7893ccfSSadaf Ebrahimisubmit a pull request. Please see the [CONTRIBUTING.md](CONTRIBUTING.md) file 21*b7893ccfSSadaf Ebrahimiin this repository for more details. 22*b7893ccfSSadaf Ebrahimi 23*b7893ccfSSadaf Ebrahimi## Repository Content 24*b7893ccfSSadaf Ebrahimi 25*b7893ccfSSadaf EbrahimiThis repository contains the source code necessary to build the Vulkan 26*b7893ccfSSadaf Ebrahimivalidation layers and their tests. 27*b7893ccfSSadaf Ebrahimi 28*b7893ccfSSadaf Ebrahimi### Installed Files 29*b7893ccfSSadaf Ebrahimi 30*b7893ccfSSadaf EbrahimiThe `install` target installs the following files under the directory 31*b7893ccfSSadaf Ebrahimiindicated by *install_dir*: 32*b7893ccfSSadaf Ebrahimi 33*b7893ccfSSadaf Ebrahimi- *install_dir*`/lib` : The Vulkan validation layer libraries 34*b7893ccfSSadaf Ebrahimi- *install_dir*`/share/vulkan/explicit_layer.d` : The Vulkan validation layer 35*b7893ccfSSadaf Ebrahimi JSON files (Linux and MacOS) 36*b7893ccfSSadaf Ebrahimi 37*b7893ccfSSadaf EbrahimiThe `uninstall` target can be used to remove the above files from the install 38*b7893ccfSSadaf Ebrahimidirectory. 39*b7893ccfSSadaf Ebrahimi 40*b7893ccfSSadaf Ebrahimi## Repository Set-Up 41*b7893ccfSSadaf Ebrahimi 42*b7893ccfSSadaf Ebrahimi### Display Drivers 43*b7893ccfSSadaf Ebrahimi 44*b7893ccfSSadaf EbrahimiThis repository does not contain a Vulkan-capable driver. You will need to 45*b7893ccfSSadaf Ebrahimiobtain and install a Vulkan driver from your graphics hardware vendor or from 46*b7893ccfSSadaf Ebrahimisome other suitable source if you intend to run Vulkan applications. 47*b7893ccfSSadaf Ebrahimi 48*b7893ccfSSadaf Ebrahimi### Download the Repository 49*b7893ccfSSadaf Ebrahimi 50*b7893ccfSSadaf EbrahimiTo create your local git repository: 51*b7893ccfSSadaf Ebrahimi 52*b7893ccfSSadaf Ebrahimi git clone https://github.com/KhronosGroup/Vulkan-ValidationLayers.git 53*b7893ccfSSadaf Ebrahimi 54*b7893ccfSSadaf Ebrahimi### Repository Dependencies 55*b7893ccfSSadaf Ebrahimi 56*b7893ccfSSadaf EbrahimiThis repository attempts to resolve some of its dependencies by using 57*b7893ccfSSadaf Ebrahimicomponents found from the following places, in this order: 58*b7893ccfSSadaf Ebrahimi 59*b7893ccfSSadaf Ebrahimi1. CMake or Environment variable overrides (e.g., -DVULKAN_HEADERS_INSTALL_DIR) 60*b7893ccfSSadaf Ebrahimi1. LunarG Vulkan SDK, located by the `VULKAN_SDK` environment variable 61*b7893ccfSSadaf Ebrahimi1. System-installed packages, mostly applicable on Linux 62*b7893ccfSSadaf Ebrahimi 63*b7893ccfSSadaf EbrahimiDependencies that cannot be resolved by the SDK or installed packages must be 64*b7893ccfSSadaf Ebrahimiresolved with the "install directory" override and are listed below. The 65*b7893ccfSSadaf Ebrahimi"install directory" override can also be used to force the use of a specific 66*b7893ccfSSadaf Ebrahimiversion of that dependency. 67*b7893ccfSSadaf Ebrahimi 68*b7893ccfSSadaf Ebrahimi#### Vulkan-Headers 69*b7893ccfSSadaf Ebrahimi 70*b7893ccfSSadaf EbrahimiThis repository has a required dependency on the 71*b7893ccfSSadaf Ebrahimi[Vulkan Headers repository](https://github.com/KhronosGroup/Vulkan-Headers). 72*b7893ccfSSadaf EbrahimiYou must clone the headers repository and build its `install` target before 73*b7893ccfSSadaf Ebrahimibuilding this repository. The Vulkan-Headers repository is required because it 74*b7893ccfSSadaf Ebrahimicontains the Vulkan API definition files (registry) that are required to build 75*b7893ccfSSadaf Ebrahimithe validation layers. You must also take note of the headers' install 76*b7893ccfSSadaf Ebrahimidirectory and pass it on the CMake command line for building this repository, 77*b7893ccfSSadaf Ebrahimias described below. 78*b7893ccfSSadaf Ebrahimi 79*b7893ccfSSadaf Ebrahimi#### glslang 80*b7893ccfSSadaf Ebrahimi 81*b7893ccfSSadaf EbrahimiThis repository has a required dependency on the 82*b7893ccfSSadaf Ebrahimi[glslang repository](https://github.com/KhronosGroup/glslang). 83*b7893ccfSSadaf EbrahimiThe glslang repository is required because it contains components that are 84*b7893ccfSSadaf Ebrahimirequired to build the validation layers. You must clone the glslang repository 85*b7893ccfSSadaf Ebrahimiand build its `install` target. Follow the build instructions in the glslang 86*b7893ccfSSadaf Ebrahimi[README.md](https://github.com/KhronosGroup/glslang/blob/master/README.md) 87*b7893ccfSSadaf Ebrahimifile. Ensure that the `update_glslang_sources.py` script has been run as part 88*b7893ccfSSadaf Ebrahimiof building glslang. You must also take note of the glslang install directory 89*b7893ccfSSadaf Ebrahimiand pass it on the CMake command line for building this repository, as 90*b7893ccfSSadaf Ebrahimidescribed below. 91*b7893ccfSSadaf Ebrahimi 92*b7893ccfSSadaf Ebrahimi#### Google Test 93*b7893ccfSSadaf Ebrahimi 94*b7893ccfSSadaf EbrahimiThe validation layer tests depend on the 95*b7893ccfSSadaf Ebrahimi[Google Test](https://github.com/google/googletest) 96*b7893ccfSSadaf Ebrahimiframework and do not build unless this framework is downloaded into the 97*b7893ccfSSadaf Ebrahimirepository's `external` directory. 98*b7893ccfSSadaf Ebrahimi 99*b7893ccfSSadaf EbrahimiTo obtain the framework, change your current directory to the top of your 100*b7893ccfSSadaf EbrahimiVulkan-ValidationLayers repository and run: 101*b7893ccfSSadaf Ebrahimi 102*b7893ccfSSadaf Ebrahimi git clone https://github.com/google/googletest.git external/googletest 103*b7893ccfSSadaf Ebrahimi cd external/googletest 104*b7893ccfSSadaf Ebrahimi git checkout tags/release-1.8.1 105*b7893ccfSSadaf Ebrahimi 106*b7893ccfSSadaf Ebrahimibefore configuring your build with CMake. 107*b7893ccfSSadaf Ebrahimi 108*b7893ccfSSadaf EbrahimiIf you do not need the tests, there is no need to download this 109*b7893ccfSSadaf Ebrahimiframework. 110*b7893ccfSSadaf Ebrahimi 111*b7893ccfSSadaf Ebrahimi#### Vulkan-Loader 112*b7893ccfSSadaf Ebrahimi 113*b7893ccfSSadaf EbrahimiThe validation layer tests depend on the Vulkan loader when they execute and 114*b7893ccfSSadaf Ebrahimiso a loader is needed only if the tests are built and run. 115*b7893ccfSSadaf Ebrahimi 116*b7893ccfSSadaf EbrahimiA loader can be used from an installed LunarG SDK, an installed Linux package, 117*b7893ccfSSadaf Ebrahimior from a driver installation on Windows. 118*b7893ccfSSadaf Ebrahimi 119*b7893ccfSSadaf EbrahimiIf a loader is not available from any of these methods and/or it is important 120*b7893ccfSSadaf Ebrahimito use a loader built from a repository, then you must build the 121*b7893ccfSSadaf Ebrahimi[Vulkan-Loader repository](https://github.com/KhronosGroup/Vulkan-Loader.git) 122*b7893ccfSSadaf Ebrahimiwith its install target. Take note of its install directory location and pass 123*b7893ccfSSadaf Ebrahimiit on the CMake command line for building this repository, as described below. 124*b7893ccfSSadaf Ebrahimi 125*b7893ccfSSadaf EbrahimiIf you do not intend to run the tests, you do not need a Vulkan loader. 126*b7893ccfSSadaf Ebrahimi 127*b7893ccfSSadaf Ebrahimi### Build and Install Directories 128*b7893ccfSSadaf Ebrahimi 129*b7893ccfSSadaf EbrahimiA common convention is to place the build directory in the top directory of 130*b7893ccfSSadaf Ebrahimithe repository with a name of `build` and place the install directory as a 131*b7893ccfSSadaf Ebrahimichild of the build directory with the name `install`. The remainder of these 132*b7893ccfSSadaf Ebrahimiinstructions follow this convention, although you can use any name for these 133*b7893ccfSSadaf Ebrahimidirectories and place them in any location. 134*b7893ccfSSadaf Ebrahimi 135*b7893ccfSSadaf Ebrahimi### Building Dependent Repositories with Known-Good Revisions 136*b7893ccfSSadaf Ebrahimi 137*b7893ccfSSadaf EbrahimiThere is a Python utility script, `scripts/update_deps.py`, that you can use to 138*b7893ccfSSadaf Ebrahimigather and build the dependent repositories mentioned above. This script uses 139*b7893ccfSSadaf Ebrahimiinformation stored in the `scripts/known_good.json` file to check out dependent 140*b7893ccfSSadaf Ebrahimirepository revisions that are known to be compatible with the revision of this 141*b7893ccfSSadaf Ebrahimirepository that you currently have checked out. As such, this script is useful 142*b7893ccfSSadaf Ebrahimias a quick-start tool for common use cases and default configurations. 143*b7893ccfSSadaf Ebrahimi 144*b7893ccfSSadaf EbrahimiFor all platforms, start with: 145*b7893ccfSSadaf Ebrahimi 146*b7893ccfSSadaf Ebrahimi git clone [email protected]:KhronosGroup/Vulkan-ValidationLayers.git 147*b7893ccfSSadaf Ebrahimi cd Vulkan-ValidationLayers 148*b7893ccfSSadaf Ebrahimi mkdir build 149*b7893ccfSSadaf Ebrahimi cd build 150*b7893ccfSSadaf Ebrahimi 151*b7893ccfSSadaf EbrahimiFor 64-bit Linux and MacOS, continue with: 152*b7893ccfSSadaf Ebrahimi 153*b7893ccfSSadaf Ebrahimi ../scripts/update_deps.py 154*b7893ccfSSadaf Ebrahimi cmake -C helper.cmake .. 155*b7893ccfSSadaf Ebrahimi cmake --build . 156*b7893ccfSSadaf Ebrahimi 157*b7893ccfSSadaf EbrahimiFor 64-bit Windows, continue with: 158*b7893ccfSSadaf Ebrahimi 159*b7893ccfSSadaf Ebrahimi ..\scripts\update_deps.py --arch x64 160*b7893ccfSSadaf Ebrahimi cmake -A x64 -C helper.cmake .. 161*b7893ccfSSadaf Ebrahimi cmake --build . 162*b7893ccfSSadaf Ebrahimi 163*b7893ccfSSadaf EbrahimiFor 32-bit Windows, continue with: 164*b7893ccfSSadaf Ebrahimi 165*b7893ccfSSadaf Ebrahimi ..\scripts\update_deps.py --arch Win32 166*b7893ccfSSadaf Ebrahimi cmake -A Win32 -C helper.cmake .. 167*b7893ccfSSadaf Ebrahimi cmake --build . 168*b7893ccfSSadaf Ebrahimi 169*b7893ccfSSadaf EbrahimiPlease see the more detailed build information later in this file if you have 170*b7893ccfSSadaf Ebrahimispecific requirements for configuring and building these components. 171*b7893ccfSSadaf Ebrahimi 172*b7893ccfSSadaf Ebrahimi#### Notes 173*b7893ccfSSadaf Ebrahimi 174*b7893ccfSSadaf Ebrahimi- You may need to adjust some of the CMake options based on your platform. See 175*b7893ccfSSadaf Ebrahimi the platform-specific sections later in this document. 176*b7893ccfSSadaf Ebrahimi- The `update_deps.py` script fetches and builds the dependent repositories in 177*b7893ccfSSadaf Ebrahimi the current directory when it is invoked. In this case, they are built in 178*b7893ccfSSadaf Ebrahimi the `build` directory. 179*b7893ccfSSadaf Ebrahimi- The `build` directory is also being used to build this 180*b7893ccfSSadaf Ebrahimi (Vulkan-ValidationLayers) repository. But there shouldn't be any conflicts 181*b7893ccfSSadaf Ebrahimi inside the `build` directory between the dependent repositories and the 182*b7893ccfSSadaf Ebrahimi build files for this repository. 183*b7893ccfSSadaf Ebrahimi- The `--dir` option for `update_deps.py` can be used to relocate the 184*b7893ccfSSadaf Ebrahimi dependent repositories to another arbitrary directory using an absolute or 185*b7893ccfSSadaf Ebrahimi relative path. 186*b7893ccfSSadaf Ebrahimi- The `update_deps.py` script generates a file named `helper.cmake` and places 187*b7893ccfSSadaf Ebrahimi it in the same directory as the dependent repositories (`build` in this 188*b7893ccfSSadaf Ebrahimi case). This file contains CMake commands to set the CMake `*_INSTALL_DIR` 189*b7893ccfSSadaf Ebrahimi variables that are used to point to the install artifacts of the dependent 190*b7893ccfSSadaf Ebrahimi repositories. You can use this file with the `cmake -C` option to set these 191*b7893ccfSSadaf Ebrahimi variables when you generate your build files with CMake. This lets you avoid 192*b7893ccfSSadaf Ebrahimi entering several `*_INSTALL_DIR` variable settings on the CMake command line. 193*b7893ccfSSadaf Ebrahimi- If using "MINGW" (Git For Windows), you may wish to run 194*b7893ccfSSadaf Ebrahimi `winpty update_deps.py` in order to avoid buffering all of the script's 195*b7893ccfSSadaf Ebrahimi "print" output until the end and to retain the ability to interrupt script 196*b7893ccfSSadaf Ebrahimi execution. 197*b7893ccfSSadaf Ebrahimi- Please use `update_deps.py --help` to list additional options and read the 198*b7893ccfSSadaf Ebrahimi internal documentation in `update_deps.py` for further information. 199*b7893ccfSSadaf Ebrahimi 200*b7893ccfSSadaf Ebrahimi### Generated source code 201*b7893ccfSSadaf Ebrahimi 202*b7893ccfSSadaf EbrahimiThis repository contains generated source code in the `layers/generated` 203*b7893ccfSSadaf Ebrahimidirectory which is not intended to be modified directly. Instead, changes should be 204*b7893ccfSSadaf Ebrahimimade to the corresponding generator in the `scripts` directory. The source files can 205*b7893ccfSSadaf Ebrahimithen be regenerated using `scripts/generate_source.py`: 206*b7893ccfSSadaf Ebrahimi 207*b7893ccfSSadaf Ebrahimi python3 scripts/generate_source.py PATH_TO_VULKAN_HEADERS_REGISTRY_DIR 208*b7893ccfSSadaf Ebrahimi 209*b7893ccfSSadaf EbrahimiA helper CMake target `VulkanVL_generated_source` is also provided to simplify 210*b7893ccfSSadaf Ebrahimithe invocation of `scripts/generate_source.py` from the build directory: 211*b7893ccfSSadaf Ebrahimi 212*b7893ccfSSadaf Ebrahimi cmake --build . --target VulkanVL_generated_source 213*b7893ccfSSadaf Ebrahimi 214*b7893ccfSSadaf Ebrahimi### Build Options 215*b7893ccfSSadaf Ebrahimi 216*b7893ccfSSadaf EbrahimiWhen generating native platform build files through CMake, several options can 217*b7893ccfSSadaf Ebrahimibe specified to customize the build. Some of the options are binary on/off 218*b7893ccfSSadaf Ebrahimioptions, while others take a string as input. The following is a table of all 219*b7893ccfSSadaf Ebrahimion/off options currently supported by this repository: 220*b7893ccfSSadaf Ebrahimi 221*b7893ccfSSadaf Ebrahimi| Option | Platform | Default | Description | 222*b7893ccfSSadaf Ebrahimi| ------ | -------- | ------- | ----------- | 223*b7893ccfSSadaf Ebrahimi| BUILD_LAYERS | All | `ON` | Controls whether or not the validation layers are built. | 224*b7893ccfSSadaf Ebrahimi| BUILD_LAYER_SUPPORT_FILES | All | `OFF` | Controls whether or not layer support files are built if the layers are not built. | 225*b7893ccfSSadaf Ebrahimi| BUILD_TESTS | All | `???` | Controls whether or not the validation layer tests are built. The default is `ON` when the Google Test repository is cloned into the `external` directory. Otherwise, the default is `OFF`. | 226*b7893ccfSSadaf Ebrahimi| INSTALL_TESTS | All | `OFF` | Controls whether or not the validation layer tests are installed. This option is only available when a copy of Google Test is available 227*b7893ccfSSadaf Ebrahimi| BUILD_WSI_XCB_SUPPORT | Linux | `ON` | Build the components with XCB support. | 228*b7893ccfSSadaf Ebrahimi| BUILD_WSI_XLIB_SUPPORT | Linux | `ON` | Build the components with Xlib support. | 229*b7893ccfSSadaf Ebrahimi| BUILD_WSI_WAYLAND_SUPPORT | Linux | `ON` | Build the components with Wayland support. | 230*b7893ccfSSadaf Ebrahimi| USE_CCACHE | Linux | `OFF` | Enable caching with the CCache program. | 231*b7893ccfSSadaf Ebrahimi 232*b7893ccfSSadaf EbrahimiThe following is a table of all string options currently supported by this repository: 233*b7893ccfSSadaf Ebrahimi 234*b7893ccfSSadaf Ebrahimi| Option | Platform | Default | Description | 235*b7893ccfSSadaf Ebrahimi| ------ | -------- | ------- | ----------- | 236*b7893ccfSSadaf Ebrahimi| CMAKE_OSX_DEPLOYMENT_TARGET | MacOS | `10.12` | The minimum version of MacOS for loader deployment. | 237*b7893ccfSSadaf Ebrahimi 238*b7893ccfSSadaf EbrahimiThese variables should be set using the `-D` option when invoking CMake to 239*b7893ccfSSadaf Ebrahimigenerate the native platform files. 240*b7893ccfSSadaf Ebrahimi 241*b7893ccfSSadaf Ebrahimi## Building On Windows 242*b7893ccfSSadaf Ebrahimi 243*b7893ccfSSadaf Ebrahimi### Windows Development Environment Requirements 244*b7893ccfSSadaf Ebrahimi 245*b7893ccfSSadaf Ebrahimi- Windows 246*b7893ccfSSadaf Ebrahimi - Any Personal Computer version supported by Microsoft 247*b7893ccfSSadaf Ebrahimi- Microsoft [Visual Studio](https://www.visualstudio.com/) 248*b7893ccfSSadaf Ebrahimi - Versions 249*b7893ccfSSadaf Ebrahimi - [2015](https://www.visualstudio.com/vs/older-downloads/) 250*b7893ccfSSadaf Ebrahimi - [2017](https://www.visualstudio.com/vs/downloads/) 251*b7893ccfSSadaf Ebrahimi - The Community Edition of each of the above versions is sufficient, as 252*b7893ccfSSadaf Ebrahimi well as any more capable edition. 253*b7893ccfSSadaf Ebrahimi- [CMake 3.10.2](https://cmake.org/files/v3.10/cmake-3.10.2-win64-x64.zip) is recommended. 254*b7893ccfSSadaf Ebrahimi - Use the installer option to add CMake to the system PATH 255*b7893ccfSSadaf Ebrahimi- Git Client Support 256*b7893ccfSSadaf Ebrahimi - [Git for Windows](http://git-scm.com/download/win) is a popular solution 257*b7893ccfSSadaf Ebrahimi for Windows 258*b7893ccfSSadaf Ebrahimi - Some IDEs (e.g., [Visual Studio](https://www.visualstudio.com/), 259*b7893ccfSSadaf Ebrahimi [GitHub Desktop](https://desktop.github.com/)) have integrated 260*b7893ccfSSadaf Ebrahimi Git client support 261*b7893ccfSSadaf Ebrahimi 262*b7893ccfSSadaf Ebrahimi### Windows Build - Microsoft Visual Studio 263*b7893ccfSSadaf Ebrahimi 264*b7893ccfSSadaf EbrahimiThe general approach is to run CMake to generate the Visual Studio project 265*b7893ccfSSadaf Ebrahimifiles. Then either run CMake with the `--build` option to build from the 266*b7893ccfSSadaf Ebrahimicommand line or use the Visual Studio IDE to open the generated solution and 267*b7893ccfSSadaf Ebrahimiwork with the solution interactively. 268*b7893ccfSSadaf Ebrahimi 269*b7893ccfSSadaf Ebrahimi#### Windows Quick Start 270*b7893ccfSSadaf Ebrahimi 271*b7893ccfSSadaf Ebrahimi cd Vulkan-ValidationLayers 272*b7893ccfSSadaf Ebrahimi mkdir build 273*b7893ccfSSadaf Ebrahimi cd build 274*b7893ccfSSadaf Ebrahimi cmake -A x64 -DVULKAN_HEADERS_INSTALL_DIR=absolute_path_to_install_dir \ 275*b7893ccfSSadaf Ebrahimi -DGLSLANG_INSTALL_DIR=absolute_path_to_install_dir .. 276*b7893ccfSSadaf Ebrahimi cmake --build . 277*b7893ccfSSadaf Ebrahimi 278*b7893ccfSSadaf EbrahimiThe above commands instruct CMake to find and use the default Visual Studio 279*b7893ccfSSadaf Ebrahimiinstallation to generate a Visual Studio solution and projects for the x64 280*b7893ccfSSadaf Ebrahimiarchitecture. The second CMake command builds the Debug (default) 281*b7893ccfSSadaf Ebrahimiconfiguration of the solution. 282*b7893ccfSSadaf Ebrahimi 283*b7893ccfSSadaf EbrahimiSee below for the details. 284*b7893ccfSSadaf Ebrahimi 285*b7893ccfSSadaf Ebrahimi#### Use `CMake` to Create the Visual Studio Project Files 286*b7893ccfSSadaf Ebrahimi 287*b7893ccfSSadaf EbrahimiChange your current directory to the top of the cloned repository directory, 288*b7893ccfSSadaf Ebrahimicreate a build directory and generate the Visual Studio project files: 289*b7893ccfSSadaf Ebrahimi 290*b7893ccfSSadaf Ebrahimi cd Vulkan-ValidationLayers 291*b7893ccfSSadaf Ebrahimi mkdir build 292*b7893ccfSSadaf Ebrahimi cd build 293*b7893ccfSSadaf Ebrahimi cmake -A x64 -DVULKAN_HEADERS_INSTALL_DIR=absolute_path_to_install_dir \ 294*b7893ccfSSadaf Ebrahimi -DGLSLANG_INSTALL_DIR=absolute_path_to_install_dir .. 295*b7893ccfSSadaf Ebrahimi 296*b7893ccfSSadaf Ebrahimi> Note: The `..` parameter tells `cmake` the location of the top of the 297*b7893ccfSSadaf Ebrahimi> repository. If you place your build directory someplace else, you'll need to 298*b7893ccfSSadaf Ebrahimi> specify the location of the repository top differently. 299*b7893ccfSSadaf Ebrahimi 300*b7893ccfSSadaf EbrahimiThe `-A` option is used to select either the "Win32" or "x64" architecture. 301*b7893ccfSSadaf Ebrahimi 302*b7893ccfSSadaf EbrahimiIf a generator for a specific version of Visual Studio is required, you can 303*b7893ccfSSadaf Ebrahimispecify it for Visual Studio 2015, for example, with: 304*b7893ccfSSadaf Ebrahimi 305*b7893ccfSSadaf Ebrahimi 64-bit: -G "Visual Studio 14 2015 Win64" 306*b7893ccfSSadaf Ebrahimi 32-bit: -G "Visual Studio 14 2015" 307*b7893ccfSSadaf Ebrahimi 308*b7893ccfSSadaf EbrahimiSee this [list](#cmake-visual-studio-generators) of other possible generators 309*b7893ccfSSadaf Ebrahimifor Visual Studio. 310*b7893ccfSSadaf Ebrahimi 311*b7893ccfSSadaf EbrahimiWhen generating the project files, the absolute path to a Vulkan-Headers 312*b7893ccfSSadaf Ebrahimiinstall directory must be provided. This can be done by setting the 313*b7893ccfSSadaf Ebrahimi`VULKAN_HEADERS_INSTALL_DIR` environment variable or by setting the 314*b7893ccfSSadaf Ebrahimi`VULKAN_HEADERS_INSTALL_DIR` CMake variable with the `-D` CMake option. In 315*b7893ccfSSadaf Ebrahimieither case, the variable should point to the installation directory of a 316*b7893ccfSSadaf EbrahimiVulkan-Headers repository built with the install target. 317*b7893ccfSSadaf Ebrahimi 318*b7893ccfSSadaf EbrahimiWhen generating the project files, the absolute path to a glslang install 319*b7893ccfSSadaf Ebrahimidirectory must be provided. This can be done by setting the 320*b7893ccfSSadaf Ebrahimi`GLSLANG_INSTALL_DIR` environment variable or by setting the 321*b7893ccfSSadaf Ebrahimi`GLSLANG_INSTALL_DIR` CMake variable with the `-D` CMake option. In either 322*b7893ccfSSadaf Ebrahimicase, the variable should point to the installation directory of a glslang 323*b7893ccfSSadaf Ebrahimirepository built with the install target. 324*b7893ccfSSadaf Ebrahimi 325*b7893ccfSSadaf EbrahimiThe above steps create a Windows solution file named 326*b7893ccfSSadaf Ebrahimi`Vulkan-ValidationLayers.sln` in the build directory. 327*b7893ccfSSadaf Ebrahimi 328*b7893ccfSSadaf EbrahimiAt this point, you can build the solution from the command line or open the 329*b7893ccfSSadaf Ebrahimigenerated solution with Visual Studio. 330*b7893ccfSSadaf Ebrahimi 331*b7893ccfSSadaf Ebrahimi#### Build the Solution From the Command Line 332*b7893ccfSSadaf Ebrahimi 333*b7893ccfSSadaf EbrahimiWhile still in the build directory: 334*b7893ccfSSadaf Ebrahimi 335*b7893ccfSSadaf Ebrahimi cmake --build . 336*b7893ccfSSadaf Ebrahimi 337*b7893ccfSSadaf Ebrahimito build the Debug configuration (the default), or: 338*b7893ccfSSadaf Ebrahimi 339*b7893ccfSSadaf Ebrahimi cmake --build . --config Release 340*b7893ccfSSadaf Ebrahimi 341*b7893ccfSSadaf Ebrahimito make a Release build. 342*b7893ccfSSadaf Ebrahimi 343*b7893ccfSSadaf Ebrahimi#### Build the Solution With Visual Studio 344*b7893ccfSSadaf Ebrahimi 345*b7893ccfSSadaf EbrahimiLaunch Visual Studio and open the "Vulkan-ValidationLayers.sln" solution file 346*b7893ccfSSadaf Ebrahimiin the build folder. You may select "Debug" or "Release" from the Solution 347*b7893ccfSSadaf EbrahimiConfigurations drop-down list. Start a build by selecting the Build->Build 348*b7893ccfSSadaf EbrahimiSolution menu item. 349*b7893ccfSSadaf Ebrahimi 350*b7893ccfSSadaf Ebrahimi#### Windows Install Target 351*b7893ccfSSadaf Ebrahimi 352*b7893ccfSSadaf EbrahimiThe CMake project also generates an "install" target that you can use to copy 353*b7893ccfSSadaf Ebrahimithe primary build artifacts to a specific location using a "bin, include, lib" 354*b7893ccfSSadaf Ebrahimistyle directory structure. This may be useful for collecting the artifacts and 355*b7893ccfSSadaf Ebrahimiproviding them to another project that is dependent on them. 356*b7893ccfSSadaf Ebrahimi 357*b7893ccfSSadaf EbrahimiThe default location is `$CMAKE_BINARY_DIR\install`, but can be changed with 358*b7893ccfSSadaf Ebrahimithe `CMAKE_INSTALL_PREFIX` variable when first generating the project build 359*b7893ccfSSadaf Ebrahimifiles with CMake. 360*b7893ccfSSadaf Ebrahimi 361*b7893ccfSSadaf EbrahimiYou can build the install target from the command line with: 362*b7893ccfSSadaf Ebrahimi 363*b7893ccfSSadaf Ebrahimi cmake --build . --config Release --target install 364*b7893ccfSSadaf Ebrahimi 365*b7893ccfSSadaf Ebrahimior build the `INSTALL` target from the Visual Studio solution explorer. 366*b7893ccfSSadaf Ebrahimi 367*b7893ccfSSadaf Ebrahimi#### Using a Loader Built from a Repository 368*b7893ccfSSadaf Ebrahimi 369*b7893ccfSSadaf EbrahimiIf you do need to build and use your own loader, build the Vulkan-Loader 370*b7893ccfSSadaf Ebrahimirepository with the install target and modify your CMake invocation to add the 371*b7893ccfSSadaf Ebrahimilocation of the loader's install directory: 372*b7893ccfSSadaf Ebrahimi 373*b7893ccfSSadaf Ebrahimi cmake -A x64 -DVULKAN_HEADERS_INSTALL_DIR=absolute_path_to_install_dir \ 374*b7893ccfSSadaf Ebrahimi -DVULKAN_LOADER_INSTALL_DIR=absolute_path_to_install_dir \ 375*b7893ccfSSadaf Ebrahimi -DGLSLANG_INSTALL_DIR=absolute_path_to_install_dir .. 376*b7893ccfSSadaf Ebrahimi 377*b7893ccfSSadaf Ebrahimi### Windows Tests and Demos 378*b7893ccfSSadaf Ebrahimi 379*b7893ccfSSadaf EbrahimiAfter making any changes to the repository, you should perform some quick 380*b7893ccfSSadaf Ebrahimisanity tests, including the run_all_tests Powershell script. In addition, 381*b7893ccfSSadaf Ebrahimirunning sample applications such as the 382*b7893ccfSSadaf Ebrahimi[vkcube demo](https://www.github.com/KhronosGroup/Vulkan-Tools.git) 383*b7893ccfSSadaf Ebrahimiwith validation enabled is advised. 384*b7893ccfSSadaf Ebrahimi 385*b7893ccfSSadaf EbrahimiTo run the validation test script, open a Powershell Console, change to the 386*b7893ccfSSadaf Ebrahimibuild/tests directory, and run: 387*b7893ccfSSadaf Ebrahimi 388*b7893ccfSSadaf EbrahimiFor Release builds: 389*b7893ccfSSadaf Ebrahimi 390*b7893ccfSSadaf Ebrahimi .\run_all_tests.ps1 391*b7893ccfSSadaf Ebrahimi 392*b7893ccfSSadaf EbrahimiFor Debug builds: 393*b7893ccfSSadaf Ebrahimi 394*b7893ccfSSadaf Ebrahimi .\run_all_tests.ps1 -Debug 395*b7893ccfSSadaf Ebrahimi 396*b7893ccfSSadaf EbrahimiThis script will run the following tests: 397*b7893ccfSSadaf Ebrahimi 398*b7893ccfSSadaf Ebrahimi- `vk_layer_validation_tests`: 399*b7893ccfSSadaf Ebrahimi Test Vulkan validation layers 400*b7893ccfSSadaf Ebrahimi 401*b7893ccfSSadaf Ebrahimi### Windows Notes 402*b7893ccfSSadaf Ebrahimi 403*b7893ccfSSadaf Ebrahimi#### CMake Visual Studio Generators 404*b7893ccfSSadaf Ebrahimi 405*b7893ccfSSadaf EbrahimiThe chosen generator should match one of the Visual Studio versions that you 406*b7893ccfSSadaf Ebrahimihave installed. Generator strings that correspond to versions of Visual Studio 407*b7893ccfSSadaf Ebrahimiinclude: 408*b7893ccfSSadaf Ebrahimi 409*b7893ccfSSadaf Ebrahimi| Build Platform | 64-bit Generator | 32-bit Generator | 410*b7893ccfSSadaf Ebrahimi|------------------------------|-------------------------------|-------------------------| 411*b7893ccfSSadaf Ebrahimi| Microsoft Visual Studio 2015 | "Visual Studio 14 2015 Win64" | "Visual Studio 14 2015" | 412*b7893ccfSSadaf Ebrahimi| Microsoft Visual Studio 2017 | "Visual Studio 15 2017 Win64" | "Visual Studio 15 2017" | 413*b7893ccfSSadaf Ebrahimi 414*b7893ccfSSadaf Ebrahimi#### Using The Vulkan Loader Library in this Repository on Windows 415*b7893ccfSSadaf Ebrahimi 416*b7893ccfSSadaf EbrahimiVulkan programs must be able to find and use the Vulkan loader 417*b7893ccfSSadaf Ebrahimi(`vulkan-1.dll`) library as well as any other libraries the program requires. 418*b7893ccfSSadaf EbrahimiOne convenient way to do this is to copy the required libraries into the same 419*b7893ccfSSadaf Ebrahimidirectory as the program. If you provided a loader repository location via the 420*b7893ccfSSadaf Ebrahimi`VULKAN_LOADER_INSTALL_DIR` variable, the projects in this solution copy the 421*b7893ccfSSadaf EbrahimiVulkan loader library and the "googletest" libraries to the 422*b7893ccfSSadaf Ebrahimi`build\tests\Debug` or the `build\tests\Release` directory, which is where the 423*b7893ccfSSadaf Ebrahimitest executables are found, depending on what configuration you built. (The 424*b7893ccfSSadaf Ebrahimilayer validation tests use the "googletest" testing framework.) 425*b7893ccfSSadaf Ebrahimi 426*b7893ccfSSadaf Ebrahimi## Building On Linux 427*b7893ccfSSadaf Ebrahimi 428*b7893ccfSSadaf Ebrahimi### Linux Build Requirements 429*b7893ccfSSadaf Ebrahimi 430*b7893ccfSSadaf EbrahimiThis repository has been built and tested on the two most recent Ubuntu LTS 431*b7893ccfSSadaf Ebrahimiversions. Currently, the oldest supported version is Ubuntu 16.04, meaning 432*b7893ccfSSadaf Ebrahimithat the minimum officially supported C++11 compiler version is GCC 5.4.0, 433*b7893ccfSSadaf Ebrahimialthough earlier versions may work. It should be straightforward to adapt this 434*b7893ccfSSadaf Ebrahimirepository to other Linux distributions. 435*b7893ccfSSadaf Ebrahimi 436*b7893ccfSSadaf Ebrahimi[CMake 3.10.2](https://cmake.org/files/v3.10/cmake-3.10.2-Linux-x86_64.tar.gz) is recommended. 437*b7893ccfSSadaf Ebrahimi 438*b7893ccfSSadaf Ebrahimi#### Required Package List 439*b7893ccfSSadaf Ebrahimi 440*b7893ccfSSadaf Ebrahimi sudo apt-get install git build-essential libx11-xcb-dev \ 441*b7893ccfSSadaf Ebrahimi libxkbcommon-dev libwayland-dev libxrandr-dev \ 442*b7893ccfSSadaf Ebrahimi libegl1-mesa-dev 443*b7893ccfSSadaf Ebrahimi 444*b7893ccfSSadaf Ebrahimi### Linux Build 445*b7893ccfSSadaf Ebrahimi 446*b7893ccfSSadaf EbrahimiThe general approach is to run CMake to generate make files. Then either run 447*b7893ccfSSadaf EbrahimiCMake with the `--build` option or `make` to build from the command line. 448*b7893ccfSSadaf Ebrahimi 449*b7893ccfSSadaf Ebrahimi#### Linux Quick Start 450*b7893ccfSSadaf Ebrahimi 451*b7893ccfSSadaf Ebrahimi cd Vulkan-ValidationLayers 452*b7893ccfSSadaf Ebrahimi mkdir build 453*b7893ccfSSadaf Ebrahimi cd build 454*b7893ccfSSadaf Ebrahimi cmake -DVULKAN_HEADERS_INSTALL_DIR=absolute_path_to_install_dir \ 455*b7893ccfSSadaf Ebrahimi -DGLSLANG_INSTALL_DIR=absolute_path_to_install_dir .. 456*b7893ccfSSadaf Ebrahimi make 457*b7893ccfSSadaf Ebrahimi 458*b7893ccfSSadaf EbrahimiSee below for the details. 459*b7893ccfSSadaf Ebrahimi 460*b7893ccfSSadaf Ebrahimi#### Use CMake to Create the Make Files 461*b7893ccfSSadaf Ebrahimi 462*b7893ccfSSadaf EbrahimiChange your current directory to the top of the cloned repository directory, 463*b7893ccfSSadaf Ebrahimicreate a build directory and generate the make files. 464*b7893ccfSSadaf Ebrahimi 465*b7893ccfSSadaf Ebrahimi cd Vulkan-ValidationLayers 466*b7893ccfSSadaf Ebrahimi mkdir build 467*b7893ccfSSadaf Ebrahimi cd build 468*b7893ccfSSadaf Ebrahimi cmake -DCMAKE_BUILD_TYPE=Debug \ 469*b7893ccfSSadaf Ebrahimi -DVULKAN_HEADERS_INSTALL_DIR=absolute_path_to_install_dir \ 470*b7893ccfSSadaf Ebrahimi -DGLSLANG_INSTALL_DIR=absolute_path_to_install_dir \ 471*b7893ccfSSadaf Ebrahimi -DCMAKE_INSTALL_PREFIX=install .. 472*b7893ccfSSadaf Ebrahimi 473*b7893ccfSSadaf Ebrahimi> Note: The `..` parameter tells `cmake` the location of the top of the 474*b7893ccfSSadaf Ebrahimi> repository. If you place your `build` directory someplace else, you'll need 475*b7893ccfSSadaf Ebrahimi> to specify the location of the repository top differently. 476*b7893ccfSSadaf Ebrahimi 477*b7893ccfSSadaf EbrahimiUse `-DCMAKE_BUILD_TYPE` to specify a Debug or Release build. 478*b7893ccfSSadaf Ebrahimi 479*b7893ccfSSadaf EbrahimiWhen generating the project files, the absolute path to a Vulkan-Headers 480*b7893ccfSSadaf Ebrahimiinstall directory must be provided. This can be done by setting the 481*b7893ccfSSadaf Ebrahimi`VULKAN_HEADERS_INSTALL_DIR` environment variable or by setting the 482*b7893ccfSSadaf Ebrahimi`VULKAN_HEADERS_INSTALL_DIR` CMake variable with the `-D` CMake option. In 483*b7893ccfSSadaf Ebrahimieither case, the variable should point to the installation directory of a 484*b7893ccfSSadaf EbrahimiVulkan-Headers repository built with the install target. 485*b7893ccfSSadaf Ebrahimi 486*b7893ccfSSadaf EbrahimiWhen generating the project files, the absolute path to a glslang install 487*b7893ccfSSadaf Ebrahimidirectory must be provided. This can be done by setting the 488*b7893ccfSSadaf Ebrahimi`GLSLANG_INSTALL_DIR` environment variable or by setting the 489*b7893ccfSSadaf Ebrahimi`GLSLANG_INSTALL_DIR` CMake variable with the `-D` CMake option. In either 490*b7893ccfSSadaf Ebrahimicase, the variable should point to the installation directory of a glslang 491*b7893ccfSSadaf Ebrahimirepository built with the install target. 492*b7893ccfSSadaf Ebrahimi 493*b7893ccfSSadaf Ebrahimi> Note: For Linux, the default value for `CMAKE_INSTALL_PREFIX` is 494*b7893ccfSSadaf Ebrahimi> `/usr/local`, which would be used if you do not specify 495*b7893ccfSSadaf Ebrahimi> `CMAKE_INSTALL_PREFIX`. In this case, you may need to use `sudo` to install 496*b7893ccfSSadaf Ebrahimi> to system directories later when you run `make install`. 497*b7893ccfSSadaf Ebrahimi 498*b7893ccfSSadaf Ebrahimi#### Build the Project 499*b7893ccfSSadaf Ebrahimi 500*b7893ccfSSadaf EbrahimiYou can just run `make` to begin the build. 501*b7893ccfSSadaf Ebrahimi 502*b7893ccfSSadaf EbrahimiTo speed up the build on a multi-core machine, use the `-j` option for `make` 503*b7893ccfSSadaf Ebrahimito specify the number of cores to use for the build. For example: 504*b7893ccfSSadaf Ebrahimi 505*b7893ccfSSadaf Ebrahimi make -j4 506*b7893ccfSSadaf Ebrahimi 507*b7893ccfSSadaf EbrahimiYou can also use 508*b7893ccfSSadaf Ebrahimi 509*b7893ccfSSadaf Ebrahimi cmake --build . 510*b7893ccfSSadaf Ebrahimi 511*b7893ccfSSadaf EbrahimiIf your build system supports ccache, you can enable that via CMake option `-DUSE_CCACHE=On` 512*b7893ccfSSadaf Ebrahimi 513*b7893ccfSSadaf Ebrahimi### Linux Notes 514*b7893ccfSSadaf Ebrahimi 515*b7893ccfSSadaf Ebrahimi#### WSI Support Build Options 516*b7893ccfSSadaf Ebrahimi 517*b7893ccfSSadaf EbrahimiBy default, the repository components are built with support for the 518*b7893ccfSSadaf EbrahimiVulkan-defined WSI display servers: Xcb, Xlib, and Wayland. It is recommended 519*b7893ccfSSadaf Ebrahimito build the repository components with support for these display servers to 520*b7893ccfSSadaf Ebrahimimaximize their usability across Linux platforms. If it is necessary to build 521*b7893ccfSSadaf Ebrahimithese modules without support for one of the display servers, the appropriate 522*b7893ccfSSadaf EbrahimiCMake option of the form `BUILD_WSI_xxx_SUPPORT` can be set to `OFF`. 523*b7893ccfSSadaf Ebrahimi 524*b7893ccfSSadaf Ebrahimi#### Linux Install to System Directories 525*b7893ccfSSadaf Ebrahimi 526*b7893ccfSSadaf EbrahimiInstalling the files resulting from your build to the systems directories is 527*b7893ccfSSadaf Ebrahimioptional since environment variables can usually be used instead to locate the 528*b7893ccfSSadaf Ebrahimibinaries. There are also risks with interfering with binaries installed by 529*b7893ccfSSadaf Ebrahimipackages. If you are certain that you would like to install your binaries to 530*b7893ccfSSadaf Ebrahimisystem directories, you can proceed with these instructions. 531*b7893ccfSSadaf Ebrahimi 532*b7893ccfSSadaf EbrahimiAssuming that you've built the code as described above and the current 533*b7893ccfSSadaf Ebrahimidirectory is still `build`, you can execute: 534*b7893ccfSSadaf Ebrahimi 535*b7893ccfSSadaf Ebrahimi sudo make install 536*b7893ccfSSadaf Ebrahimi 537*b7893ccfSSadaf EbrahimiThis command installs files to `/usr/local` if no `CMAKE_INSTALL_PREFIX` is 538*b7893ccfSSadaf Ebrahimispecified when creating the build files with CMake: 539*b7893ccfSSadaf Ebrahimi 540*b7893ccfSSadaf Ebrahimi- `/usr/local/lib`: Vulkan layers shared objects 541*b7893ccfSSadaf Ebrahimi- `/usr/local/share/vulkan/explicit_layer.d`: Layer JSON files 542*b7893ccfSSadaf Ebrahimi 543*b7893ccfSSadaf EbrahimiYou may need to run `ldconfig` in order to refresh the system loader search 544*b7893ccfSSadaf Ebrahimicache on some Linux systems. 545*b7893ccfSSadaf Ebrahimi 546*b7893ccfSSadaf EbrahimiYou can further customize the installation location by setting additional 547*b7893ccfSSadaf EbrahimiCMake variables to override their defaults. For example, if you would like to 548*b7893ccfSSadaf Ebrahimiinstall to `/tmp/build` instead of `/usr/local`, on your CMake command line 549*b7893ccfSSadaf Ebrahimispecify: 550*b7893ccfSSadaf Ebrahimi 551*b7893ccfSSadaf Ebrahimi -DCMAKE_INSTALL_PREFIX=/tmp/build 552*b7893ccfSSadaf Ebrahimi 553*b7893ccfSSadaf EbrahimiThen run `make install` as before. The install step places the files in 554*b7893ccfSSadaf Ebrahimi`/tmp/build`. This may be useful for collecting the artifacts and providing 555*b7893ccfSSadaf Ebrahimithem to another project that is dependent on them. 556*b7893ccfSSadaf Ebrahimi 557*b7893ccfSSadaf EbrahimiSee the CMake documentation for more details on using these variables to 558*b7893ccfSSadaf Ebrahimifurther customize your installation. 559*b7893ccfSSadaf Ebrahimi 560*b7893ccfSSadaf EbrahimiAlso see the `LoaderAndLayerInterface` document in the `loader` folder of the 561*b7893ccfSSadaf EbrahimiVulkan-Loader repository for more information about loader and layer 562*b7893ccfSSadaf Ebrahimioperation. 563*b7893ccfSSadaf Ebrahimi 564*b7893ccfSSadaf Ebrahimi#### Linux Uninstall 565*b7893ccfSSadaf Ebrahimi 566*b7893ccfSSadaf EbrahimiTo uninstall the files from the system directories, you can execute: 567*b7893ccfSSadaf Ebrahimi 568*b7893ccfSSadaf Ebrahimi sudo make uninstall 569*b7893ccfSSadaf Ebrahimi 570*b7893ccfSSadaf Ebrahimi#### Linux Tests 571*b7893ccfSSadaf Ebrahimi 572*b7893ccfSSadaf EbrahimiTo run the **validation test script**, in a terminal change to the build/tests directory and run: 573*b7893ccfSSadaf Ebrahimi 574*b7893ccfSSadaf Ebrahimi VK_LAYER_PATH=../layers ./run_all_tests.sh 575*b7893ccfSSadaf Ebrahimi 576*b7893ccfSSadaf EbrahimiThis script will run the following tests: 577*b7893ccfSSadaf Ebrahimi 578*b7893ccfSSadaf Ebrahimi- `vk_layer_validation_tests`: Test Vulkan validation layers 579*b7893ccfSSadaf Ebrahimi 580*b7893ccfSSadaf Ebrahimi#### Linux 32-bit support 581*b7893ccfSSadaf Ebrahimi 582*b7893ccfSSadaf EbrahimiUsage of this repository's contents in 32-bit Linux environments is not 583*b7893ccfSSadaf Ebrahimiofficially supported. However, since this repository is supported on 32-bit 584*b7893ccfSSadaf EbrahimiWindows, these modules should generally work on 32-bit Linux. 585*b7893ccfSSadaf Ebrahimi 586*b7893ccfSSadaf EbrahimiHere are some notes for building 32-bit targets on a 64-bit Ubuntu "reference" 587*b7893ccfSSadaf Ebrahimiplatform: 588*b7893ccfSSadaf Ebrahimi 589*b7893ccfSSadaf EbrahimiIf not already installed, install the following 32-bit development libraries: 590*b7893ccfSSadaf Ebrahimi 591*b7893ccfSSadaf Ebrahimi`gcc-multilib g++-multilib libx11-dev:i386` 592*b7893ccfSSadaf Ebrahimi 593*b7893ccfSSadaf EbrahimiThis list may vary depending on your distribution and which windowing systems 594*b7893ccfSSadaf Ebrahimiyou are building for. 595*b7893ccfSSadaf Ebrahimi 596*b7893ccfSSadaf EbrahimiSet up your environment for building 32-bit targets: 597*b7893ccfSSadaf Ebrahimi 598*b7893ccfSSadaf Ebrahimi export ASFLAGS=--32 599*b7893ccfSSadaf Ebrahimi export CFLAGS=-m32 600*b7893ccfSSadaf Ebrahimi export CXXFLAGS=-m32 601*b7893ccfSSadaf Ebrahimi export PKG_CONFIG_LIBDIR=/usr/lib/i386-linux-gnu 602*b7893ccfSSadaf Ebrahimi 603*b7893ccfSSadaf EbrahimiAgain, your PKG_CONFIG configuration may be different, depending on your distribution. 604*b7893ccfSSadaf Ebrahimi 605*b7893ccfSSadaf EbrahimiFinally, rebuild the repository using `cmake` and `make`, as explained above. 606*b7893ccfSSadaf Ebrahimi 607*b7893ccfSSadaf Ebrahimi#### Using the new layers 608*b7893ccfSSadaf Ebrahimi 609*b7893ccfSSadaf Ebrahimi export VK_LAYER_PATH=<path to your repository root>/build/layers 610*b7893ccfSSadaf Ebrahimi 611*b7893ccfSSadaf EbrahimiYou can run the `vkcube` or `vulkaninfo` applications from the Vulkan-Tools 612*b7893ccfSSadaf Ebrahimirepository to see which driver, loader and layers are being used. 613*b7893ccfSSadaf Ebrahimi 614*b7893ccfSSadaf Ebrahimi## Building On Android 615*b7893ccfSSadaf Ebrahimi 616*b7893ccfSSadaf EbrahimiInstall the required tools for Linux and Windows covered above, then add the 617*b7893ccfSSadaf Ebrahimifollowing. 618*b7893ccfSSadaf Ebrahimi 619*b7893ccfSSadaf Ebrahimi### Android Build Requirements 620*b7893ccfSSadaf Ebrahimi 621*b7893ccfSSadaf EbrahimiNote that the minimum supported Android SDK API Level is 26, revision 622*b7893ccfSSadaf Ebrahimilevel 3. 623*b7893ccfSSadaf Ebrahimi 624*b7893ccfSSadaf Ebrahimi- Install [Android Studio 2.3](https://developer.android.com/studio/index.html) 625*b7893ccfSSadaf Ebrahimi or later. 626*b7893ccfSSadaf Ebrahimi- From the "Welcome to Android Studio" splash screen, add the following 627*b7893ccfSSadaf Ebrahimi components using Configure > SDK Manager: 628*b7893ccfSSadaf Ebrahimi - SDK Platforms > Android 8.0.0 and newer 629*b7893ccfSSadaf Ebrahimi - SDK Tools > Android SDK Build-Tools 630*b7893ccfSSadaf Ebrahimi - SDK Tools > Android SDK Platform-Tools 631*b7893ccfSSadaf Ebrahimi - SDK Tools > Android SDK Tools 632*b7893ccfSSadaf Ebrahimi - SDK Tools > NDK 633*b7893ccfSSadaf Ebrahimi 634*b7893ccfSSadaf Ebrahimi#### Add Android specifics to environment 635*b7893ccfSSadaf Ebrahimi 636*b7893ccfSSadaf EbrahimiFor each of the below, you may need to specify a different build-tools 637*b7893ccfSSadaf Ebrahimiversion, as Android Studio will roll it forward fairly regularly. 638*b7893ccfSSadaf Ebrahimi 639*b7893ccfSSadaf EbrahimiOn Linux: 640*b7893ccfSSadaf Ebrahimi 641*b7893ccfSSadaf Ebrahimi export ANDROID_SDK_HOME=$HOME/Android/sdk 642*b7893ccfSSadaf Ebrahimi export ANDROID_NDK_HOME=$HOME/Android/sdk/ndk-bundle 643*b7893ccfSSadaf Ebrahimi export PATH=$ANDROID_SDK_HOME:$PATH 644*b7893ccfSSadaf Ebrahimi export PATH=$ANDROID_NDK_HOME:$PATH 645*b7893ccfSSadaf Ebrahimi export PATH=$ANDROID_SDK_HOME/build-tools/26.0.3:$PATH 646*b7893ccfSSadaf Ebrahimi 647*b7893ccfSSadaf EbrahimiOn Windows: 648*b7893ccfSSadaf Ebrahimi 649*b7893ccfSSadaf Ebrahimi set ANDROID_SDK_HOME=%LOCALAPPDATA%\Android\sdk 650*b7893ccfSSadaf Ebrahimi set ANDROID_NDK_HOME=%LOCALAPPDATA%\Android\sdk\ndk-bundle 651*b7893ccfSSadaf Ebrahimi set PATH=%LOCALAPPDATA%\Android\sdk\ndk-bundle;%PATH% 652*b7893ccfSSadaf Ebrahimi 653*b7893ccfSSadaf EbrahimiOn OSX: 654*b7893ccfSSadaf Ebrahimi 655*b7893ccfSSadaf Ebrahimi export ANDROID_SDK_HOME=$HOME/Library/Android/sdk 656*b7893ccfSSadaf Ebrahimi export ANDROID_NDK_HOME=$HOME/Library/Android/sdk/ndk-bundle 657*b7893ccfSSadaf Ebrahimi export PATH=$ANDROID_NDK_PATH:$PATH 658*b7893ccfSSadaf Ebrahimi export PATH=$ANDROID_SDK_HOME/build-tools/26.0.3:$PATH 659*b7893ccfSSadaf Ebrahimi 660*b7893ccfSSadaf EbrahimiNote: If `jarsigner` is missing from your platform, you can find it in the 661*b7893ccfSSadaf EbrahimiAndroid Studio install or in your Java installation. If you do not have Java, 662*b7893ccfSSadaf Ebrahimiyou can get it with something like the following: 663*b7893ccfSSadaf Ebrahimi 664*b7893ccfSSadaf Ebrahimi sudo apt-get install openjdk-8-jdk 665*b7893ccfSSadaf Ebrahimi 666*b7893ccfSSadaf Ebrahimi#### Additional OSX System Requirements 667*b7893ccfSSadaf Ebrahimi 668*b7893ccfSSadaf EbrahimiTested on OSX version 10.13.3 669*b7893ccfSSadaf Ebrahimi 670*b7893ccfSSadaf EbrahimiSetup Homebrew and components 671*b7893ccfSSadaf Ebrahimi 672*b7893ccfSSadaf Ebrahimi- Follow instructions on [brew.sh](http://brew.sh) to get Homebrew installed. 673*b7893ccfSSadaf Ebrahimi 674*b7893ccfSSadaf Ebrahimi /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" 675*b7893ccfSSadaf Ebrahimi 676*b7893ccfSSadaf Ebrahimi- Ensure Homebrew is at the beginning of your PATH: 677*b7893ccfSSadaf Ebrahimi 678*b7893ccfSSadaf Ebrahimi export PATH=/usr/local/bin:$PATH 679*b7893ccfSSadaf Ebrahimi 680*b7893ccfSSadaf Ebrahimi- Add packages with the following: 681*b7893ccfSSadaf Ebrahimi 682*b7893ccfSSadaf Ebrahimi brew install python 683*b7893ccfSSadaf Ebrahimi 684*b7893ccfSSadaf Ebrahimi### Android Build 685*b7893ccfSSadaf Ebrahimi 686*b7893ccfSSadaf EbrahimiThere are two options for building the Android layers. Either using the SPIRV 687*b7893ccfSSadaf Ebrahimitools provided as part of the Android NDK, or using upstream sources. To build 688*b7893ccfSSadaf Ebrahimiwith SPIRV tools from the NDK, remove the build-android/third_party directory 689*b7893ccfSSadaf Ebrahimicreated by running update_external_sources_android.sh, (or avoid running 690*b7893ccfSSadaf Ebrahimiupdate_external_sources_android.sh). Use the following script to build 691*b7893ccfSSadaf Ebrahimieverything in the repository for Android, including validation layers, tests, 692*b7893ccfSSadaf Ebrahimidemos, and APK packaging: This script does retrieve and use the upstream SPRIV 693*b7893ccfSSadaf Ebrahimitools. 694*b7893ccfSSadaf Ebrahimi 695*b7893ccfSSadaf Ebrahimi cd build-android 696*b7893ccfSSadaf Ebrahimi ./build_all.sh 697*b7893ccfSSadaf Ebrahimi 698*b7893ccfSSadaf EbrahimiResulting validation layer binaries will be in build-android/libs. Test and 699*b7893ccfSSadaf Ebrahimidemo APKs can be installed on production devices with: 700*b7893ccfSSadaf Ebrahimi 701*b7893ccfSSadaf Ebrahimi ./install_all.sh [-s <serial number>] 702*b7893ccfSSadaf Ebrahimi 703*b7893ccfSSadaf EbrahimiNote that there are no equivalent scripts on Windows yet, that work needs to 704*b7893ccfSSadaf Ebrahimibe completed. The following per platform commands can be used for layer only 705*b7893ccfSSadaf Ebrahimibuilds: 706*b7893ccfSSadaf Ebrahimi 707*b7893ccfSSadaf Ebrahimi#### Linux and OSX 708*b7893ccfSSadaf Ebrahimi 709*b7893ccfSSadaf EbrahimiFollow the setup steps for Linux or OSX above, then from your terminal: 710*b7893ccfSSadaf Ebrahimi 711*b7893ccfSSadaf Ebrahimi cd build-android 712*b7893ccfSSadaf Ebrahimi ./update_external_sources_android.sh --no-build 713*b7893ccfSSadaf Ebrahimi ndk-build -j4 714*b7893ccfSSadaf Ebrahimi 715*b7893ccfSSadaf Ebrahimi#### Windows 716*b7893ccfSSadaf Ebrahimi 717*b7893ccfSSadaf EbrahimiFollow the setup steps for Windows above, then from Developer Command Prompt 718*b7893ccfSSadaf Ebrahimifor VS2015: 719*b7893ccfSSadaf Ebrahimi 720*b7893ccfSSadaf Ebrahimi cd build-android 721*b7893ccfSSadaf Ebrahimi update_external_sources_android.bat 722*b7893ccfSSadaf Ebrahimi ndk-build 723*b7893ccfSSadaf Ebrahimi 724*b7893ccfSSadaf Ebrahimi### Android Tests and Demos 725*b7893ccfSSadaf Ebrahimi 726*b7893ccfSSadaf EbrahimiAfter making any changes to the repository you should perform some quick 727*b7893ccfSSadaf Ebrahimisanity tests, including the layer validation tests and the vkcube 728*b7893ccfSSadaf Ebrahimidemo with validation enabled. 729*b7893ccfSSadaf Ebrahimi 730*b7893ccfSSadaf Ebrahimi#### Run Layer Validation Tests 731*b7893ccfSSadaf Ebrahimi 732*b7893ccfSSadaf EbrahimiUse the following steps to build, install, and run the layer validation tests 733*b7893ccfSSadaf Ebrahimifor Android: 734*b7893ccfSSadaf Ebrahimi 735*b7893ccfSSadaf Ebrahimi cd build-android 736*b7893ccfSSadaf Ebrahimi ./build_all.sh 737*b7893ccfSSadaf Ebrahimi adb install -r bin/VulkanLayerValidationTests.apk 738*b7893ccfSSadaf Ebrahimi adb shell am start com.example.VulkanLayerValidationTests/android.app.NativeActivity 739*b7893ccfSSadaf Ebrahimi 740*b7893ccfSSadaf EbrahimiAlternatively, you can use the test_APK script to install and run the layer 741*b7893ccfSSadaf Ebrahimivalidation tests: 742*b7893ccfSSadaf Ebrahimi 743*b7893ccfSSadaf Ebrahimi test_APK.sh -s <serial number> -p <plaform name> -f <gtest_filter> 744*b7893ccfSSadaf Ebrahimi 745*b7893ccfSSadaf Ebrahimi## Building on MacOS 746*b7893ccfSSadaf Ebrahimi 747*b7893ccfSSadaf Ebrahimi### MacOS Build Requirements 748*b7893ccfSSadaf Ebrahimi 749*b7893ccfSSadaf EbrahimiTested on OSX version 10.12.6 750*b7893ccfSSadaf Ebrahimi 751*b7893ccfSSadaf Ebrahimi[CMake 3.10.2](https://cmake.org/files/v3.10/cmake-3.10.2-Darwin-x86_64.tar.gz) is recommended. 752*b7893ccfSSadaf Ebrahimi 753*b7893ccfSSadaf EbrahimiSetup Homebrew and components 754*b7893ccfSSadaf Ebrahimi 755*b7893ccfSSadaf Ebrahimi- Follow instructions on [brew.sh](http://brew.sh) to get Homebrew installed. 756*b7893ccfSSadaf Ebrahimi 757*b7893ccfSSadaf Ebrahimi /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" 758*b7893ccfSSadaf Ebrahimi 759*b7893ccfSSadaf Ebrahimi- Ensure Homebrew is at the beginning of your PATH: 760*b7893ccfSSadaf Ebrahimi 761*b7893ccfSSadaf Ebrahimi export PATH=/usr/local/bin:$PATH 762*b7893ccfSSadaf Ebrahimi 763*b7893ccfSSadaf Ebrahimi- Add packages with the following (may need refinement) 764*b7893ccfSSadaf Ebrahimi 765*b7893ccfSSadaf Ebrahimi brew install python python3 git 766*b7893ccfSSadaf Ebrahimi 767*b7893ccfSSadaf Ebrahimi### Clone the Repository 768*b7893ccfSSadaf Ebrahimi 769*b7893ccfSSadaf EbrahimiClone the Vulkan-ValidationLayers repository: 770*b7893ccfSSadaf Ebrahimi 771*b7893ccfSSadaf Ebrahimi git clone https://github.com/KhronosGroup/Vulkan-ValidationLayers.git 772*b7893ccfSSadaf Ebrahimi 773*b7893ccfSSadaf Ebrahimi### MacOS build 774*b7893ccfSSadaf Ebrahimi 775*b7893ccfSSadaf Ebrahimi#### CMake Generators 776*b7893ccfSSadaf Ebrahimi 777*b7893ccfSSadaf EbrahimiThis repository uses CMake to generate build or project files that are then 778*b7893ccfSSadaf Ebrahimiused to build the repository. The CMake generators explicitly supported in 779*b7893ccfSSadaf Ebrahimithis repository are: 780*b7893ccfSSadaf Ebrahimi 781*b7893ccfSSadaf Ebrahimi- Unix Makefiles 782*b7893ccfSSadaf Ebrahimi- Xcode 783*b7893ccfSSadaf Ebrahimi 784*b7893ccfSSadaf Ebrahimi#### Building with the Unix Makefiles Generator 785*b7893ccfSSadaf Ebrahimi 786*b7893ccfSSadaf EbrahimiThis generator is the default generator, so all that is needed for a debug 787*b7893ccfSSadaf Ebrahimibuild is: 788*b7893ccfSSadaf Ebrahimi 789*b7893ccfSSadaf Ebrahimi mkdir build 790*b7893ccfSSadaf Ebrahimi cd build 791*b7893ccfSSadaf Ebrahimi cmake -DVULKAN_HEADERS_INSTALL_DIR=absolute_path_to_install_dir \ 792*b7893ccfSSadaf Ebrahimi -DGLSLANG_INSTALL_DIR=absolute_path_to_install_dir \ 793*b7893ccfSSadaf Ebrahimi -DCMAKE_BUILD_TYPE=Debug .. 794*b7893ccfSSadaf Ebrahimi make 795*b7893ccfSSadaf Ebrahimi 796*b7893ccfSSadaf EbrahimiTo speed up the build on a multi-core machine, use the `-j` option for `make` 797*b7893ccfSSadaf Ebrahimito specify the number of cores to use for the build. For example: 798*b7893ccfSSadaf Ebrahimi 799*b7893ccfSSadaf Ebrahimi make -j4 800*b7893ccfSSadaf Ebrahimi 801*b7893ccfSSadaf Ebrahimi#### Building with the Xcode Generator 802*b7893ccfSSadaf Ebrahimi 803*b7893ccfSSadaf EbrahimiTo create and open an Xcode project: 804*b7893ccfSSadaf Ebrahimi 805*b7893ccfSSadaf Ebrahimi mkdir build-xcode 806*b7893ccfSSadaf Ebrahimi cd build-xcode 807*b7893ccfSSadaf Ebrahimi cmake -DVULKAN_HEADERS_INSTALL_DIR=absolute_path_to_install_dir \ 808*b7893ccfSSadaf Ebrahimi -DGLSLANG_INSTALL_DIR=absolute_path_to_install_dir \ 809*b7893ccfSSadaf Ebrahimi -GXcode .. 810*b7893ccfSSadaf Ebrahimi open VULKAN.xcodeproj 811*b7893ccfSSadaf Ebrahimi 812*b7893ccfSSadaf EbrahimiWithin Xcode, you can select Debug or Release builds in the Build Settings of the project. 813*b7893ccfSSadaf Ebrahimi 814*b7893ccfSSadaf Ebrahimi#### Using the new layers on MacOS 815*b7893ccfSSadaf Ebrahimi 816*b7893ccfSSadaf Ebrahimi export VK_LAYER_PATH=<path to your repository root>/build/layers 817*b7893ccfSSadaf Ebrahimi 818*b7893ccfSSadaf EbrahimiYou can run the `vulkaninfo` applications from the Vulkan-Tools repository to 819*b7893ccfSSadaf Ebrahimisee which driver, loader and layers are being used. 820*b7893ccfSSadaf Ebrahimi 821*b7893ccfSSadaf Ebrahimi### MacOS Tests 822*b7893ccfSSadaf Ebrahimi 823*b7893ccfSSadaf EbrahimiAfter making any changes to the repository, you should perform the included sanity tests by running 824*b7893ccfSSadaf Ebrahimithe run_all_tests shell script. 825*b7893ccfSSadaf Ebrahimi 826*b7893ccfSSadaf EbrahimiThese test require a manual path to an ICD to run properly on MacOS. 827*b7893ccfSSadaf Ebrahimi 828*b7893ccfSSadaf EbrahimiYou can use: 829*b7893ccfSSadaf Ebrahimi 830*b7893ccfSSadaf Ebrahimi- MoltenVK ICD 831*b7893ccfSSadaf Ebrahimi- Mock ICD 832*b7893ccfSSadaf Ebrahimi 833*b7893ccfSSadaf Ebrahimi#### Using MoltenVK ICD 834*b7893ccfSSadaf Ebrahimi 835*b7893ccfSSadaf EbrahimiClone and build the [MoltenVK](https://github.com/KhronosGroup/MoltenVK) repository. 836*b7893ccfSSadaf Ebrahimi 837*b7893ccfSSadaf EbrahimiYou will have to direct the loader from Vulkan-Loader to the MoltenVK ICD: 838*b7893ccfSSadaf Ebrahimi 839*b7893ccfSSadaf Ebrahimi export VK_ICD_FILENAMES=<path to MoltenVK repository>/Package/Latest/MoltenVK/macOS/MoltenVK_icd.json 840*b7893ccfSSadaf Ebrahimi 841*b7893ccfSSadaf Ebrahimi#### Using Mock ICD 842*b7893ccfSSadaf Ebrahimi 843*b7893ccfSSadaf EbrahimiClone and build the [Vulkan-Tools](https://github.com/KhronosGroup/Vulkan-Tools) repository. 844*b7893ccfSSadaf Ebrahimi 845*b7893ccfSSadaf EbrahimiYou will have to direct the loader from Vulkan-Loader to the Mock ICD: 846*b7893ccfSSadaf Ebrahimi 847*b7893ccfSSadaf Ebrahimi export VK_ICD_FILENAMES=<path to Vulkan-Tools repository>/build/icd/VkICD_mock_icd.json 848*b7893ccfSSadaf Ebrahimi 849*b7893ccfSSadaf Ebrahimi#### Running the Tests 850*b7893ccfSSadaf Ebrahimi 851*b7893ccfSSadaf EbrahimiTo run the **validation test script**, in a terminal change to the build/tests directory and run: 852*b7893ccfSSadaf Ebrahimi 853*b7893ccfSSadaf Ebrahimi VK_LAYER_PATH=../layers ./run_all_tests.sh 854*b7893ccfSSadaf Ebrahimi 855*b7893ccfSSadaf EbrahimiThis script will run the following tests: 856*b7893ccfSSadaf Ebrahimi 857*b7893ccfSSadaf Ebrahimi- `vk_layer_validation_tests`: Test Vulkan validation layers 858*b7893ccfSSadaf Ebrahimi 859*b7893ccfSSadaf EbrahimiFurther testing and sanity checking can be achieved by running the vkcube and 860*b7893ccfSSadaf Ebrahimivulkaninfo applications in the 861*b7893ccfSSadaf Ebrahimi[Vulkan-Tools](https://github.com/KhronosGroup/Vulkan-Tools) 862*b7893ccfSSadaf Ebrahimirepository. 863*b7893ccfSSadaf Ebrahimi 864*b7893ccfSSadaf EbrahimiNote that MoltenVK is still adding Vulkan features and some tests may fail. 865