2018-03-12 10:02:13 -04:00
< a class = "site-logo" href = "https://github.com/KhronosGroup/MoltenVK" title = "MoltenVK" >
< img src = "../Docs/images/MoltenVK-Logo-Banner.png" alt = "MoltenVK" style = "width:256px;height:auto" >
< / a >
#MoltenVK External Dependencies
2019-01-01 21:13:25 -05:00
Copyright (c) 2014-2019 [The Brenwill Workshop Ltd. ](http://www.brenwill.com )
2018-03-12 10:02:13 -04:00
*This document is written in [Markdown ](http://en.wikipedia.org/wiki/Markdown ) format.
For best results, use a Markdown reader.*
Table of Contents
-----------------
2018-12-24 19:11:15 -05:00
- [Fetching and Building External Libraries ](#fetching )
2018-03-12 10:02:13 -04:00
- [Updating External Library Versions ](#updating )
2018-05-28 08:33:46 -04:00
- [Adding the *cereal* Library to the *MoltenVK Xcode* Project ](#add_cereal )
2018-12-24 19:11:15 -05:00
- [Adding the *SPIRV-Cross* Library to the *ExternalDependencies Xcode* Project ](#add_spirv-cross )
- [Adding the *SPIRV-Tools* Library to the *ExternalDependencies Xcode* Project ](#add_spirv-tools )
- [Adding the *glslang* Library to the *ExternalDependencies Xcode* Project ](#add_glslang )
2018-03-12 10:02:13 -04:00
< a name = "fetching" > < / a >
2018-12-24 19:11:15 -05:00
Fetching and Building External Libraries
----------------------------------------
2018-03-12 10:02:13 -04:00
**MoltenVK** uses technology from the following external open-source libraries:
2018-04-16 16:26:34 -04:00
- [*cereal* ](https://github.com/USCiLab/cereal )
2018-05-28 08:33:46 -04:00
- [*Vulkan-Headers* ](https://github.com/KhronosGroup/Vulkan-Headers )
2018-03-12 10:02:13 -04:00
- [*SPIRV-Cross* ](https://github.com/KhronosGroup/SPIRV-Cross )
- [*glslang* ](https://github.com/KhronosGroup/glslang )
- [*SPIRV-Tools* ](https://github.com/KhronosGroup/SPIRV-Tools )
- [*SPIRV-Headers* ](https://github.com/KhronosGroup/SPIRV-Headers )
2018-05-28 08:33:46 -04:00
- [*Vulkan-Tools* ](https://github.com/KhronosGroup/Vulkan-Tools )
2018-04-16 16:26:34 -04:00
- [*VulkanSamples* ](https://github.com/LunarG/VulkanSamples )
2018-03-12 10:02:13 -04:00
These external open-source libraries are maintained in the `External` directory.
2018-12-24 19:11:15 -05:00
To retrieve and build these libraries from their sources, run the `fetchDependencies`
script in the main repository directory:
2018-03-12 10:02:13 -04:00
2019-04-18 15:08:39 -04:00
./fetchDependencies [--debug]
2018-03-12 10:02:13 -04:00
2019-04-18 15:08:39 -04:00
The `--debug` option will build the external libraries in Debug mode, which may
be useful when debugging and tracing calls into those libraries.
2018-03-12 10:02:13 -04:00
< a name = "updating" > < / a >
Updating External Library Versions
----------------------------------
To maintain consistency between the libraries, **MoltenVK** retrieves specific
versions of each external library. The version of each external library is
determined as follows:
2018-04-16 16:26:34 -04:00
- **_cereal_**: a GitHub repository commit identifier found in the
`ExternalRevisions/cereal_repo_revision` file.
2018-05-28 08:33:46 -04:00
- **_Vulkan-Headers_**: a GitHub repository commit identifier found in the
`ExternalRevisions/Vulkan-Headers_repo_revision` file.
2018-04-16 16:26:34 -04:00
2018-03-12 10:02:13 -04:00
- **_SPIRV-Cross_**: a GitHub repository commit identifier found in the
2018-03-30 22:16:27 -04:00
`ExternalRevisions/SPIRV-Cross_repo_revision` file.
2018-03-12 10:02:13 -04:00
2018-05-28 08:33:46 -04:00
- **_glslang_**: a GitHub repository commit identifier found
in the `ExternalRevisions/glslang_repo_revision` file.
2018-03-12 10:02:13 -04:00
- **_SPIRV-Tools_**: automatically retrieved by the *glslang* repository.
- **_SPIRV-Headers_**: automatically retrieved by the *glslang* repository.
2018-03-30 12:13:50 -04:00
2018-05-28 08:33:46 -04:00
- **_Vulkan-Tools_**: a GitHub repository commit identifier found in the
`ExternalRevisions/Vulkan-Tools_repo_revision` file.
- **_VulkanSamples_**: a GitHub repository commit identifier found in the
`ExternalRevisions/VulkanSamples_repo_revision` file.
You can update which versions of the *cereal* , *Vulkan-Headers* , *SPIRV-Cross* ,
*glslang*, *Vulkan-Tools* , or *VulkanSamples* libraries are retrieved by changing
the value held in the corresponding `*_repo_revision` file listed above.
2018-03-12 10:02:13 -04:00
2018-05-28 08:33:46 -04:00
The version of the *SPIRV-Tools* and *SPIRV-Headers* libraries is automatically
determined by the version of the *glslang* library you have retrieved.
2018-03-12 10:02:13 -04:00
2018-12-24 19:11:15 -05:00
Once you have made changes to the `*_repo_revision` files, you can retrieve the updated
library versions by running the `fetchDependencies` script, as described above, again.
2018-03-12 10:02:13 -04:00
2018-05-24 13:21:07 +08:00
>***Note:*** If, after updating to new versions of the external libraries, you encounter
2018-03-12 10:02:13 -04:00
>build errors when building **MoltenVK** , review the instructions in the sections below
>to ensure all necessary external library files are included in the **MoltenVK** builds.
2018-04-16 16:26:34 -04:00
< a name = "add_cereal" > < / a >
Adding the *cereal* Library to the *MoltenVK Xcode* Project
-----------------------------------------------------------
The `MoltenVK` *Xcode* project is already configured to use the *cereal* library. However, after
updating the version of *cereal* , as described [above ](#updating ), if you encounter any building
errors, you may need to re-add the *cereal* library to the `MoltenVK` *Xcode* project as follows:
1. In the *Project Navigator* panel, select the `MoltenVK` *Xcode* project, then the `MoltenVK`
project target, and open the *Build Settings* tab. Locate the build setting entry
**Header Search Paths** (`HEADER_SEARCH_PATHS` ) and add the following paths:
"$(SRCROOT)/../External/cereal/include"
2018-03-12 10:02:13 -04:00
< a name = "add_spirv-cross" > < / a >
2018-12-24 19:11:15 -05:00
Adding the *SPIRV-Cross* Library to the *ExternalDependencies Xcode* Project
----------------------------------------------------------------------------
2018-03-12 10:02:13 -04:00
2018-12-24 19:11:15 -05:00
The `ExternalDependencies` *Xcode* project is already configured to use the *SPIRV-Cross*
2018-03-12 10:02:13 -04:00
library. However, after updating the version of *SPIRV-Cross* , as described [above ](#updating ),
2018-03-30 12:13:50 -04:00
if you encounter any building errors, you may need to re-add the *SPIRV-Cross* library to the
2018-12-24 19:11:15 -05:00
`ExternalDependencies` *Xcode* project as follows:
2018-03-12 10:02:13 -04:00
1. In the *Project Navigator* , remove all of the files under the *Group* named
2018-12-24 19:11:15 -05:00
`External/SPIRV-Cross` .
2018-03-12 10:02:13 -04:00
2018-12-24 19:11:15 -05:00
2. Drag the following files from the `External/SPIRV-Cross` directory to the `External/SPIRV-Cross`
2018-03-12 10:02:13 -04:00
group in the *Project Navigator* panel:
spirv_cfg.cpp
spirv_cfg.hpp
spirv_common.hpp
2018-11-06 16:01:36 -05:00
spirv_cross_parsed_ir.cpp
spirv_cross_parsed_ir.hpp
2018-03-12 10:02:13 -04:00
spirv_cross.cpp
spirv_cross.hpp
spirv_glsl.cpp
spirv_glsl.hpp
spirv_msl.cpp
spirv_msl.hpp
2018-11-06 16:01:36 -05:00
spirv_parser.cpp
spirv_parser.hpp
2018-03-12 10:02:13 -04:00
2018-12-24 19:11:15 -05:00
In the ** *Choose options for adding these files*** dialog that opens, select the ** *Create groups*** option,
add the files to *both* the `SPIRV-Cross-macOS` and `SPIRV-Cross-iOS` targets, and click the ** *Finish*** button.
2018-03-12 10:02:13 -04:00
### Regression Testing Your Changes to *SPIRV-Cross*
2018-12-25 21:43:29 -05:00
The *SPIRV-Cross* library plays an important part in providing features for **_MoltenVK_** , and if
you are developing features for **_MoltenVK_** , you may end up making changes to *SPIRV-Cross* .
If you make changes to the `SPIRV-Cross` repository, you can build a new version of the `libSPIRVCross.a`
static library by opening the `ExternalDependencies.xcodeproj` *Xcode* project, and running the **_ExternalDependencies_** *Xcode* scheme. You can then rebuild **MoltenVK** to include the new library.
While makng changes to the `SPIRV-Cross` repository, you can regression test your changes using the
following steps:
2018-03-12 10:02:13 -04:00
1. Load and build the versions of `SPRIV-Tools` and `glslang` that are used by the `SPIRV-Cross` tests:
cd External/SPIRV-Cross
./checkout_glslang_spirv_tools.sh
2018-05-04 12:11:19 -04:00
./build_glslang_spirv_tools.sh
2018-03-12 10:02:13 -04:00
2018-05-04 12:11:19 -04:00
2. Build `SPIRV-Cross` :
make
3. Run the regression tests:
2018-03-12 10:02:13 -04:00
./test_shaders.sh
2018-12-24 19:11:15 -05:00
< a name = "add_spirv-tools" > < / a >
Adding the *SPIRV-Tools* Library to the *ExternalDependencies Xcode* Project
----------------------------------------------------------------------------
2018-03-12 10:02:13 -04:00
2018-12-24 19:11:15 -05:00
The `ExternalDependencies` *Xcode* project is already configured to use the *SPIRV-Tools*
library. However, after updating the version of *glslang* (which adds *SPIRV-Tools* ),
as described [above ](#updating ), if you encounter any building errors, you may need to re-add
the *SPIRV-Tools* library to the `ExternalDependencies` *Xcode* project as follows:
2018-03-12 10:02:13 -04:00
2018-12-24 19:11:15 -05:00
1. In the *Project Navigator* , remove the *Group* named `source` from under the *Group* named
`External/SPIRV-Tools` .
2018-03-12 10:02:13 -04:00
2019-07-23 14:29:32 -04:00
2. Drag the `External/glslang/External/spirv-tools/source` file folder to the `External/SPIRV-Tools`
2018-12-24 19:11:15 -05:00
group in the *Project Navigator* panel. In the _**Choose options for adding these files**_ dialog
that opens, select the _**Create groups**_ option, add the files to *both* the `SPIRV-Tools-macOS`
and `SPIRV-Tools-iOS` targets, and click the ** *Finish*** button.
2018-03-12 10:02:13 -04:00
2019-06-13 17:11:44 -04:00
3. Remove the *Group* named `fuzz` from under the *Group* named `External/SPIRV-Tools/source` .
4. In the *Project Navigator* panel, select the `ExternalDependencies` *Xcode* project, then
2018-12-24 19:11:15 -05:00
select the `SPIRV-Tools-macOS` target, and open the *Build Settings* tab. Locate the build
setting entry **Header Search Paths** (`HEADER_SEARCH_PATHS` ) and add the following paths:
2018-03-12 10:02:13 -04:00
2018-12-24 19:11:15 -05:00
$(inherited)
"$(SRCROOT)/External/glslang/External/spirv-tools/"
"$(SRCROOT)/External/glslang/External/spirv-tools/include"
"$(SRCROOT)/External/glslang/External/spirv-tools/external/spirv-headers/include"
"$(SRCROOT)/External/glslang/External/spirv-tools/build"
2018-03-12 10:02:13 -04:00
2018-12-24 19:11:15 -05:00
4. Repeat *Step 3* for the `SPIRV-Tools-iOS` target within the `ExternalDependencies` *Xcode* project
2018-03-12 10:02:13 -04:00
2019-10-29 15:10:50 -04:00
5. Update `Templates/spirv-tools/build.zip` from the contents of `External/glslang/External/spirv-tools/build` ,
and test by running `./fetchDependencies --skip-spirv-tools-build` , and a **MoltenVK** build.
2018-05-28 08:33:46 -04:00
2018-12-24 19:11:15 -05:00
< a name = "add_glslang" > < / a >
Adding the *glslang* Library to the *ExternalDependencies Xcode* Project
------------------------------------------------------------------------
2018-05-28 08:33:46 -04:00
2018-12-24 19:11:15 -05:00
The `ExternalDependencies` *Xcode* project is already configured to use the *glslang*
library. However, after updating the version of *glslang* , as described [above ](#updating ),
if you encounter any building errors, you may need to re-add the *glslang* library to the
`ExternalDependencies` *Xcode* project as follows:
2018-05-28 08:33:46 -04:00
2018-12-24 19:11:15 -05:00
1. In the *Project Navigator* , remove all *Groups* from under the *Group* named
`External/glslang` .
2018-05-28 08:33:46 -04:00
2018-12-24 19:11:15 -05:00
2. Drag the following folders from the `External/glslang` file folder to the `External/glslang`
*Group* in the *Project Navigator* panel:
2018-05-28 08:33:46 -04:00
2018-12-24 19:11:15 -05:00
glslang
OGLCompilersDLL
SPIRV
2018-05-28 08:33:46 -04:00
2018-12-24 19:11:15 -05:00
In the ** *Choose options for adding these files*** dialog that opens, select the ** *Create groups*** option,
add the files to *both* the `glslang-macOS` and `glslang-iOS` targets, and click the ** *Finish*** button.
2018-05-28 08:33:46 -04:00
2018-12-24 19:11:15 -05:00
3. In the *Project Navigator* panel, remove the references to the following files and folders:
2018-05-28 08:33:46 -04:00
2018-12-24 19:11:15 -05:00
External/glslang/glslang/MachineIndependant/glslang.y
External/glslang/glslang/OSDependent/Windows