Skip to content

Commit 9babbc5

Browse files
authored
Merge pull request #83 from EthicalML/update_dependencies
Fix compatibility for Vulkan HPP 1.2.155 and above
2 parents 7c8c0ee + 109d035 commit 9babbc5

20 files changed

+199
-119
lines changed

.ccls

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,9 @@
1313
-DDEBUG=1
1414
-DKOMPUTE_INCLUDE_FOR_SYNTAX
1515

16-
-I/c/Users/axsau/Programming/lib/vcpkg/installed/x64-linux/include/
16+
-I./external/Vulkan-Headers/include/
17+
-I./external/googletest/googletest/include/
18+
-I./external/spdlog/include/
1719
-I./src/include/
1820
-I./single_include/
1921
-I./vk_ndk_wrapper_include/

.gitmodules

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
[submodule "external/googletest"]
2+
path = external/googletest
3+
url = https://github.com/google/googletest
4+
branch = release-1.10.0
5+
[submodule "external/Vulkan-Headers"]
6+
path = external/Vulkan-Headers
7+
url = https://github.com/KhronosGroup/Vulkan-Headers
8+
branch = v1.2.158
9+
[submodule "external/spdlog"]
10+
path = external/spdlog
11+
url = https://github.com/gabime/spdlog
12+
branch = v1.8.1

CMakeLists.txt

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,13 @@ option(KOMPUTE_OPT_BUILD_TESTS "Enable if you want to build tests" 0)
1111
option(KOMPUTE_OPT_BUILD_DOCS "Enable if you want to build documentation" 0)
1212
option(KOMPUTE_OPT_BUILD_SHADERS "Enable if you want to re-build all shader files" 0)
1313
option(KOMPUTE_OPT_BUILD_SINGLE_HEADER "Enable if you want to build the single header file" 0)
14-
option(KOMPUTE_OPT_INSTALL "Enable if you want to enable installation" 1)
14+
option(KOMPUTE_OPT_INSTALL "Enable if you want to enable installation" 0)
15+
# Build options
1516
option(KOMPUTE_OPT_ENABLE_SPDLOG "Extra compile flags for Kompute, see docs for full list" 0)
17+
option(KOMPUTE_OPT_REPO_SUBMODULE_BUILD, "Use the submodule repos instead of external package manager" 0)
1618
option(KOMPUTE_OPT_ANDOID_BUILD "Enable android compilation flags required" 0)
17-
# TODO: Add on docs
1819
option(KOMPUTE_OPT_DISABLE_VK_DEBUG_LAYERS "Explicitly disable debug layers even on debug" 0)
19-
20+
# Build flags
2021
set(KOMPUTE_EXTRA_CXX_FLAGS "" CACHE STRING "Extra compile flags for Kompute, see docs for full list")
2122

2223
if(KOMPUTE_OPT_ENABLE_SPDLOG)

Makefile

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -48,16 +48,18 @@ MK_KOMPUTE_EXTRA_CXX_FLAGS ?= ""
4848
mk_cmake:
4949
cmake \
5050
-Bbuild \
51+
$(MK_CMAKE_EXTRA_FLAGS) \
52+
-DCMAKE_TOOLCHAIN_FILE=$(VCPKG_UNIX_PATH) \
5153
-DCMAKE_BUILD_TYPE=$(MK_BUILD_TYPE) \
5254
-DCMAKE_INSTALL_PREFIX=$(MK_INSTALL_PATH) \
53-
-DCMAKE_TOOLCHAIN_FILE=$(VCPKG_UNIX_PATH) \
5455
-DKOMPUTE_EXTRA_CXX_FLAGS=$(MK_KOMPUTE_EXTRA_CXX_FLAGS) \
56+
-DKOMPUTE_OPT_INSTALL=1 \
57+
-DKOMPUTE_OPT_REPO_SUBMODULE_BUILD=0 \
5558
-DKOMPUTE_OPT_BUILD_TESTS=1 \
5659
-DKOMPUTE_OPT_BUILD_DOCS=1 \
5760
-DKOMPUTE_OPT_BUILD_SHADERS=1 \
5861
-DKOMPUTE_OPT_BUILD_SINGLE_HEADER=1 \
5962
-DKOMPUTE_OPT_ENABLE_SPDLOG=1 \
60-
$(MK_CMAKE_EXTRA_FLAGS) \
6163
-G "Unix Makefiles"
6264

6365
mk_build_all:
@@ -84,16 +86,18 @@ mk_run_tests: mk_build_tests
8486
VS_BUILD_TYPE ?= "Debug"
8587
# Run with multiprocessin / parallel build by default
8688
VS_CMAKE_EXTRA_FLAGS ?= ""
87-
VS_KOMPUTE_EXTRA_CXX_FLAGS ?= "/MP" # Adding multiprocessing by default
89+
VS_KOMPUTE_EXTRA_CXX_FLAGS ?= "/MP" # Adding multiprocessing by default. You should add "/MT" for submodule builds for compatibility with gtest
8890
VS_INSTALL_PATH ?= "build/src/CMakeFiles/Export/" # Set to "" if prefer default
8991

9092
vs_cmake:
9193
$(CMAKE_BIN) \
9294
-Bbuild \
93-
-DCMAKE_TOOLCHAIN_FILE=$(VCPKG_WIN_PATH) \
9495
$(VS_CMAKE_EXTRA_FLAGS) \
96+
-DCMAKE_TOOLCHAIN_FILE=$(VCPKG_WIN_PATH) \
9597
-DKOMPUTE_EXTRA_CXX_FLAGS=$(VS_KOMPUTE_EXTRA_CXX_FLAGS) \
9698
-DCMAKE_INSTALL_PREFIX=$(VS_INSTALL_PATH) \
99+
-DKOMPUTE_OPT_INSTALL=1 \
100+
-DKOMPUTE_OPT_REPO_SUBMODULE_BUILD=0 \
97101
-DKOMPUTE_OPT_BUILD_TESTS=1 \
98102
-DKOMPUTE_OPT_BUILD_DOCS=1 \
99103
-DKOMPUTE_OPT_BUILD_SHADERS=1 \
@@ -125,7 +129,7 @@ vs_run_tests: vs_build_tests
125129
####### Create release ######
126130

127131
update_builder_image:
128-
docker build -f Dockerfile.linux . \
132+
docker build -f builders/Dockerfile.linux . \
129133
-t axsauze/kompute-builder:0.1
130134
docker push axsauze/kompute-builder:0.1
131135

@@ -152,12 +156,6 @@ build_shaders:
152156
--header-path test/compiled_shaders_include/kompute_test/shaders/ \
153157
-v
154158

155-
docker_vulkan_build:
156-
docker build . -t axsauze/vulkan-sum:0.1
157-
158-
push_vulkan_docker:
159-
docker push axsauze/vulkan-sum:0.1
160-
161159
build_single_header:
162160
quom \
163161
--include_directory \

README.md

Lines changed: 4 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -285,70 +285,15 @@ We are currently developing Vulkan Kompute not to hide the Vulkan SDK interface
285285

286286
The build system provided uses `cmake`, which allows for cross platform builds.
287287

288-
### Build parameters (cmake)
288+
The top level `Makefile` provides a set of optimized configurations for development as well as the docker image build, but you can start a build with the following command:
289289

290-
The recommended approach to build the project is as out-of-source build in the `build` folder. This project comes with a `Makefile` that provides a set of commands that help with developer workflows. You can see some of the commands if you want to add some of the more advanced commands.
291-
292-
For a base build you just have to run:
293-
```
294-
cmake -Bbuild
295290
```
296-
297-
This by default configures without any of the extra build tasks (such as building shaders) and compiles without the optional dependencies. The table below provides more detail.
298-
299-
| Flag | Description |
300-
|-------------------------------------------------------|--------------------------------------------------------------------------|
301-
| -DCMAKE_INSTALL_PREFIX="build/src/CMakefiles/Export/" | Enables local installation (which won't require admin privileges) |
302-
| -DCMAKE_TOOLCHAIN_FILE="..." | This is the path for your package manager if you use it such as vcpkg |
303-
| -DKOMPUTE_OPT_BUILD_TESTS=1 | Enable if you wish to build and run the tests (must have deps installed. |
304-
| -DKOMPUTE_OPT_BUILD_DOCS=1 | Enable if you wish to build the docs (must have docs deps installed) |
305-
| -DKOMPUTE_OPT_BUILD_SINGLE_HEADER=1 | Option to build the single header file using "quom" utility |
306-
| -DKOMPUTE_EXTRA_CXX_FLAGS="..." | Allows you to pass extra config flags to compiler |
307-
| -DKOMPUTE_OPT_INSTALL=0 | Disables the install step in the cmake file (useful for android build) |
308-
| -DKOMPUTE_OPT_ANDROID_BUILD=1 | Enables android build which includes and excludes relevant libraries |
309-
310-
#### Compile Flags
311-
312-
313-
| Flag | Description |
314-
|--------------------------------------|-----------------------------------------------------------------------------------------|
315-
| KOMPUTE_CREATE_PIPELINE_RESULT_VALUE | Ensure the return value of createPipeline is processed as ResultValue instead of Result |
316-
| -DKOMPUTE_VK_API_VERSION="..." | Sets the default api version to use for vulkan kompute api |
317-
| -DKOMPUTE_VK_API_MAJOR_VERSION=1 | Major version to use for the Vulkan API |
318-
| -DKOMPUTE_VK_API_MINOR_VERSION=1 | Minor version to use for the Vulkan API |
319-
| -DKOMPUTE_ENABLE_SPDLOG=1 | Enables the build with SPDLOG and FMT dependencies (must be installed) |
320-
| -DKOMPUTE_LOG_VERRIDE=1 | Does not define the SPDLOG_<LEVEL> macros if these are to be overridden |
321-
| -DSPDLOG_ACTIVE_LEVEL | The level for the log level on compile level (whether spdlog is enabled) |
322-
| -DVVK_USE_PLATFORM_ANDROID_KHR | Flag to enable android imports in kompute (enabled with -DKOMPUTE_OPT_ANDROID_BUILD) |
323-
| -DRELEASE=1 | Enable release build (enabled by cmake release build) |
324-
| -DDEBUG=1 | Enable debug build including debug flags (enabled by cmake debug build) |
325-
| -DKOMPUTE_DISABLE_VK_DEBUG_LAYERS | Disable the debug Vulkan layers, mainly used for android builds |
326-
327-
### Dependencies
328-
329-
Given Kompute is expected to be used across a broad range of architectures and hardware, it will be important to make sure we are able to minimise dependencies.
330-
331-
#### Required dependencies
332-
333-
The only required dependency in the build is Vulkan. More specifically, the header files vulkan.h and vulkan.hpp, which are both part of the Vulkan SDK. If you haven't installed the Vulkan SDK yet, you can [download it here](https://vulkan.lunarg.com/).
334-
335-
#### Optional dependencies
336-
337-
SPDLOG is the preferred logging library, however by default Vulkan Kompute runs without SPDLOG by overriding the macros. It also provides an easy way to override the macros if you prefer to bring your own logging framework. The macro override is the following:
338-
339-
```c++
340-
#ifndef KOMPUTE_LOG_OVERRIDE // Use this if you want to define custom macro overrides
341-
#if KOMPUTE_SPDLOG_ENABLED // Use this if you want to enable SPDLOG
342-
#include <spdlog/spdlog.h>
343-
#endif //KOMPUTE_SPDLOG_ENABLED
344-
// ... Otherwise it adds macros that use std::cout (and only print first element)
345-
#endif // KOMPUTE_LOG_OVERRIDE
291+
cmake -Bbuild
346292
```
347293

348-
You can choose to build with or without SPDLOG by using the cmake flag `KOMPUTE_OPT_ENABLE_SPDLOG`.
349-
350-
Finally, remember that you will still need to set both the compile time log level with `SPDLOG_ACTIVE_LEVEL`, and the runtime log level with `spdlog::set_level(spdlog::level::debug);`.
294+
You also are able to add Kompute in your repo with `add_subdirectory` - the [Android example CMakeLists.txt file](https://github.com/EthicalML/vulkan-kompute/blob/7c8c0eeba2cdc098349fcd999102bb2cca1bf711/examples/android/android-simple/app/src/main/cpp/CMakeLists.txt#L3) shows how this would be done.
351295

296+
For a more advanced overview of the build configuration check out the [Build System Deep Dive](https://kompute.cc/overview/build-system.html) documentation.
352297

353298
## Kompute Development
354299

builders/Dockerfile.linux

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,17 @@
11
FROM amd64/ubuntu:20.04
22

3+
ARG VULKAN_SDK_VERSION=1.2.154.0
4+
35
# First install vulkan
46
RUN apt-get update
57
RUN apt-get install -y curl unzip tar wget
6-
RUN wget -O VulkanSDK.tar.gz https://sdk.lunarg.com/sdk/download/1.2.141.2/linux/vulkansdk-linux-x86_64-1.2.141.2.tar.gz?u=true && \
8+
RUN wget -O VulkanSDK.tar.gz https://sdk.lunarg.com/sdk/download/${VULKAN_SDK_VERSION}/linux/vulkansdk-linux-x86_64-${VULKAN_SDK_VERSION}.tar.gz?u=true && \
79
mkdir VulkanSDK && \
810
cd VulkanSDK && \
911
tar xvf /VulkanSDK.tar.gz
1012

11-
RUN cd VulkanSDK/1.2.141.2
12-
ENV VULKAN_SDK="/VulkanSDK/1.2.141.2/x86_64"
13+
RUN cd VulkanSDK/${VULKAN_SDK_VERSION}
14+
ENV VULKAN_SDK="/VulkanSDK/${VULKAN_SDK_VERSION}/x86_64"
1315
ENV PATH="${VULKAN_SDK}/bin:${PATH}"
1416
ENV LD_LIBRARY_PATH="${VULKAN_SDK}/lib"
1517
ENV VK_LAYER_PATH="${VULKAN_SDK}/etc/explicit_layer.d"
@@ -53,7 +55,7 @@ ENV VCPKG_PATH=/core/vcpkg
5355
ENV VCPKG_ROOT=/core/vcpkg
5456

5557
# INstall dependencies for kompute
56-
RUN vcpkg install catch2 fmt spdlog vulkan
58+
RUN /core/vcpkg/vcpkg install fmt spdlog vulkan-headers gtest
5759

5860
RUN mkdir /workspace
5961
WORKDIR /workspace

docs/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ Index
1515
Advanced Examples <overview/advanced-examples>
1616
Asynchronous & Parallel Operations <overview/async-parallel>
1717
Memory Management Principles <overview/memory-management>
18+
Build System Deep Dive <overview/build-system>
1819
Converting GLSL/HLSL Shaders to C++ Headers <overview/shaders-to-headers>
1920
Mobile App Integration (Android) <overview/mobile-android>
2021
Game Engine Integration (Godot Engine) <overview/game-engine-godot>

docs/overview/build-system.rst

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
2+
Build System Deep Dive
3+
======================
4+
5+
The recommended approach to build the project is as out-of-source build in the ``build`` folder. This project comes with a ``Makefile`` that provides a set of commands that help with developer workflows. You can see some of the commands if you want to add some of the more advanced commands.
6+
7+
For a base build you just have to run:
8+
9+
.. code-block::
10+
11+
cmake -Bbuild
12+
13+
This by default configures without any of the extra build tasks (such as building shaders) and compiles without the optional dependencies. The table below provides more detail.
14+
15+
.. list-table::
16+
:header-rows: 1
17+
18+
* - Flag
19+
- Description
20+
* - -DCMAKE_INSTALL_PREFIX="build/src/CMakefiles/Export/"
21+
- Enables local installation (which won't require admin privileges)
22+
* - -DCMAKE_TOOLCHAIN_FILE="..."
23+
- This is the path for your package manager if you use it such as vcpkg
24+
* - -DKOMPUTE_OPT_BUILD_TESTS=1
25+
- Enable if you wish to build and run the tests (must have deps installed.
26+
* - -DKOMPUTE_OPT_BUILD_DOCS=1
27+
- Enable if you wish to build the docs (must have docs deps installed)
28+
* - -DKOMPUTE_OPT_BUILD_SINGLE_HEADER=1
29+
- Option to build the single header file using "quom" utility
30+
* - -DKOMPUTE_EXTRA_CXX_FLAGS="..."
31+
- Allows you to pass extra config flags to compiler
32+
* - -DKOMPUTE_OPT_INSTALL=0
33+
- Disables the install step in the cmake file (useful for android build)
34+
* - -DKOMPUTE_OPT_ANDROID_BUILD=1
35+
- Enables android build which includes and excludes relevant libraries
36+
37+
38+
Compile Flags
39+
~~~~~~~~~~~~~
40+
41+
.. list-table::
42+
:header-rows: 1
43+
44+
* - Flag
45+
- Description
46+
* - KOMPUTE_CREATE_PIPELINE_RESULT_VALUE
47+
- Ensure the return value of createPipeline is processed as ResultValue instead of Result
48+
* - -DKOMPUTE_VK_API_VERSION="..."
49+
- Sets the default api version to use for vulkan kompute api
50+
* - -DKOMPUTE_VK_API_MAJOR_VERSION=1
51+
- Major version to use for the Vulkan API
52+
* - -DKOMPUTE_VK_API_MINOR_VERSION=1
53+
- Minor version to use for the Vulkan API
54+
* - -DKOMPUTE_ENABLE_SPDLOG=1
55+
- Enables the build with SPDLOG and FMT dependencies (must be installed)
56+
* - -DKOMPUTE_LOG_VERRIDE=1
57+
- Does not define the SPDLOG_\ :raw-html-m2r:`<LEVEL>` macros if these are to be overridden
58+
* - -DSPDLOG_ACTIVE_LEVEL
59+
- The level for the log level on compile level (whether spdlog is enabled)
60+
* - -DVVK_USE_PLATFORM_ANDROID_KHR
61+
- Flag to enable android imports in kompute (enabled with -DKOMPUTE_OPT_ANDROID_BUILD)
62+
* - -DRELEASE=1
63+
- Enable release build (enabled by cmake release build)
64+
* - -DDEBUG=1
65+
- Enable debug build including debug flags (enabled by cmake debug build)
66+
* - -DKOMPUTE_DISABLE_VK_DEBUG_LAYERS
67+
- Disable the debug Vulkan layers, mainly used for android builds
68+
69+
70+
Dependencies
71+
^^^^^^^^^^^^
72+
73+
Given Kompute is expected to be used across a broad range of architectures and hardware, it will be important to make sure we are able to minimise dependencies.
74+
75+
Required dependencies
76+
~~~~~~~~~~~~~~~~~~~~~
77+
78+
The only required dependency in the build is Vulkan. More specifically, the header files vulkan.h and vulkan.hpp, which are both part of the Vulkan SDK. If you haven't installed the Vulkan SDK yet, you can `download it here <https://vulkan.lunarg.com/>`_.
79+
80+
Optional dependencies
81+
~~~~~~~~~~~~~~~~~~~~~
82+
83+
SPDLOG is the preferred logging library, however by default Vulkan Kompute runs without SPDLOG by overriding the macros. It also provides an easy way to override the macros if you prefer to bring your own logging framework. The macro override is the following:
84+
85+
.. code-block:: c++
86+
87+
#ifndef KOMPUTE_LOG_OVERRIDE // Use this if you want to define custom macro overrides
88+
#if KOMPUTE_SPDLOG_ENABLED // Use this if you want to enable SPDLOG
89+
#include <spdlog/spdlog.h>
90+
#endif //KOMPUTE_SPDLOG_ENABLED
91+
// ... Otherwise it adds macros that use std::cout (and only print first element)
92+
#endif // KOMPUTE_LOG_OVERRIDE
93+
94+
You can choose to build with or without SPDLOG by using the cmake flag ``KOMPUTE_OPT_ENABLE_SPDLOG``.
95+
96+
Finally, remember that you will still need to set both the compile time log level with ``SPDLOG_ACTIVE_LEVEL``\ , and the runtime log level with ``spdlog::set_level(spdlog::level::debug);``.

external/Vulkan-Headers

Submodule Vulkan-Headers added at 320af06

external/googletest

Submodule googletest added at 703bd9c

0 commit comments

Comments
 (0)