From 109d0350d090595271ad7989f178d47cf5085e15 Mon Sep 17 00:00:00 2001 From: Alejandro Saucedo Date: Sun, 1 Nov 2020 12:39:25 +0000 Subject: [PATCH] Added documentation for build system --- README.md | 63 ++-------------------- docs/index.rst | 1 + docs/overview/build-system.rst | 96 ++++++++++++++++++++++++++++++++++ 3 files changed, 101 insertions(+), 59 deletions(-) create mode 100644 docs/overview/build-system.rst diff --git a/README.md b/README.md index 9639a99fc..2ff7e0f9a 100644 --- a/README.md +++ b/README.md @@ -285,70 +285,15 @@ We are currently developing Vulkan Kompute not to hide the Vulkan SDK interface The build system provided uses `cmake`, which allows for cross platform builds. -### Build parameters (cmake) +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: -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. - -For a base build you just have to run: ``` -cmake -Bbuild + cmake -Bbuild ``` -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. - -| Flag | Description | -|-------------------------------------------------------|--------------------------------------------------------------------------| -| -DCMAKE_INSTALL_PREFIX="build/src/CMakefiles/Export/" | Enables local installation (which won't require admin privileges) | -| -DCMAKE_TOOLCHAIN_FILE="..." | This is the path for your package manager if you use it such as vcpkg | -| -DKOMPUTE_OPT_BUILD_TESTS=1 | Enable if you wish to build and run the tests (must have deps installed. | -| -DKOMPUTE_OPT_BUILD_DOCS=1 | Enable if you wish to build the docs (must have docs deps installed) | -| -DKOMPUTE_OPT_BUILD_SINGLE_HEADER=1 | Option to build the single header file using "quom" utility | -| -DKOMPUTE_EXTRA_CXX_FLAGS="..." | Allows you to pass extra config flags to compiler | -| -DKOMPUTE_OPT_INSTALL=0 | Disables the install step in the cmake file (useful for android build) | -| -DKOMPUTE_OPT_ANDROID_BUILD=1 | Enables android build which includes and excludes relevant libraries | - -#### Compile Flags - - -| Flag | Description | -|--------------------------------------|-----------------------------------------------------------------------------------------| -| KOMPUTE_CREATE_PIPELINE_RESULT_VALUE | Ensure the return value of createPipeline is processed as ResultValue instead of Result | -| -DKOMPUTE_VK_API_VERSION="..." | Sets the default api version to use for vulkan kompute api | -| -DKOMPUTE_VK_API_MAJOR_VERSION=1 | Major version to use for the Vulkan API | -| -DKOMPUTE_VK_API_MINOR_VERSION=1 | Minor version to use for the Vulkan API | -| -DKOMPUTE_ENABLE_SPDLOG=1 | Enables the build with SPDLOG and FMT dependencies (must be installed) | -| -DKOMPUTE_LOG_VERRIDE=1 | Does not define the SPDLOG_ macros if these are to be overridden | -| -DSPDLOG_ACTIVE_LEVEL | The level for the log level on compile level (whether spdlog is enabled) | -| -DVVK_USE_PLATFORM_ANDROID_KHR | Flag to enable android imports in kompute (enabled with -DKOMPUTE_OPT_ANDROID_BUILD) | -| -DRELEASE=1 | Enable release build (enabled by cmake release build) | -| -DDEBUG=1 | Enable debug build including debug flags (enabled by cmake debug build) | -| -DKOMPUTE_DISABLE_VK_DEBUG_LAYERS | Disable the debug Vulkan layers, mainly used for android builds | - -### Dependencies - -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. - -#### Required dependencies - -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/). - -#### Optional dependencies - -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: - -```c++ -#ifndef KOMPUTE_LOG_OVERRIDE // Use this if you want to define custom macro overrides -#if KOMPUTE_SPDLOG_ENABLED // Use this if you want to enable SPDLOG -#include -#endif //KOMPUTE_SPDLOG_ENABLED -// ... Otherwise it adds macros that use std::cout (and only print first element) -#endif // KOMPUTE_LOG_OVERRIDE -``` - -You can choose to build with or without SPDLOG by using the cmake flag `KOMPUTE_OPT_ENABLE_SPDLOG`. - -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);`. +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. +For a more advanced overview of the build configuration check out the [Build System Deep Dive](https://kompute.cc/overview/build-system.html) documentation. ## Kompute Development diff --git a/docs/index.rst b/docs/index.rst index 8f15a61e8..60d01f21b 100755 --- a/docs/index.rst +++ b/docs/index.rst @@ -15,6 +15,7 @@ Index Advanced Examples Asynchronous & Parallel Operations Memory Management Principles + Build System Deep Dive Converting GLSL/HLSL Shaders to C++ Headers Mobile App Integration (Android) Game Engine Integration (Godot Engine) diff --git a/docs/overview/build-system.rst b/docs/overview/build-system.rst new file mode 100644 index 000000000..dd4f8e8b9 --- /dev/null +++ b/docs/overview/build-system.rst @@ -0,0 +1,96 @@ + +Build System Deep Dive +====================== + +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. + +For a base build you just have to run: + +.. code-block:: + + cmake -Bbuild + +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. + +.. list-table:: + :header-rows: 1 + + * - Flag + - Description + * - -DCMAKE_INSTALL_PREFIX="build/src/CMakefiles/Export/" + - Enables local installation (which won't require admin privileges) + * - -DCMAKE_TOOLCHAIN_FILE="..." + - This is the path for your package manager if you use it such as vcpkg + * - -DKOMPUTE_OPT_BUILD_TESTS=1 + - Enable if you wish to build and run the tests (must have deps installed. + * - -DKOMPUTE_OPT_BUILD_DOCS=1 + - Enable if you wish to build the docs (must have docs deps installed) + * - -DKOMPUTE_OPT_BUILD_SINGLE_HEADER=1 + - Option to build the single header file using "quom" utility + * - -DKOMPUTE_EXTRA_CXX_FLAGS="..." + - Allows you to pass extra config flags to compiler + * - -DKOMPUTE_OPT_INSTALL=0 + - Disables the install step in the cmake file (useful for android build) + * - -DKOMPUTE_OPT_ANDROID_BUILD=1 + - Enables android build which includes and excludes relevant libraries + + +Compile Flags +~~~~~~~~~~~~~ + +.. list-table:: + :header-rows: 1 + + * - Flag + - Description + * - KOMPUTE_CREATE_PIPELINE_RESULT_VALUE + - Ensure the return value of createPipeline is processed as ResultValue instead of Result + * - -DKOMPUTE_VK_API_VERSION="..." + - Sets the default api version to use for vulkan kompute api + * - -DKOMPUTE_VK_API_MAJOR_VERSION=1 + - Major version to use for the Vulkan API + * - -DKOMPUTE_VK_API_MINOR_VERSION=1 + - Minor version to use for the Vulkan API + * - -DKOMPUTE_ENABLE_SPDLOG=1 + - Enables the build with SPDLOG and FMT dependencies (must be installed) + * - -DKOMPUTE_LOG_VERRIDE=1 + - Does not define the SPDLOG_\ :raw-html-m2r:`` macros if these are to be overridden + * - -DSPDLOG_ACTIVE_LEVEL + - The level for the log level on compile level (whether spdlog is enabled) + * - -DVVK_USE_PLATFORM_ANDROID_KHR + - Flag to enable android imports in kompute (enabled with -DKOMPUTE_OPT_ANDROID_BUILD) + * - -DRELEASE=1 + - Enable release build (enabled by cmake release build) + * - -DDEBUG=1 + - Enable debug build including debug flags (enabled by cmake debug build) + * - -DKOMPUTE_DISABLE_VK_DEBUG_LAYERS + - Disable the debug Vulkan layers, mainly used for android builds + + +Dependencies +^^^^^^^^^^^^ + +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. + +Required dependencies +~~~~~~~~~~~~~~~~~~~~~ + +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 `_. + +Optional dependencies +~~~~~~~~~~~~~~~~~~~~~ + +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: + +.. code-block:: c++ + + #ifndef KOMPUTE_LOG_OVERRIDE // Use this if you want to define custom macro overrides + #if KOMPUTE_SPDLOG_ENABLED // Use this if you want to enable SPDLOG + #include + #endif //KOMPUTE_SPDLOG_ENABLED + // ... Otherwise it adds macros that use std::cout (and only print first element) + #endif // KOMPUTE_LOG_OVERRIDE + +You can choose to build with or without SPDLOG by using the cmake flag ``KOMPUTE_OPT_ENABLE_SPDLOG``. + +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);``.