Building the ML SDK Emulation Layer for Vulkan®

Building for Linux

Building the code requires CMake. Also required are Vulkan® and SPIR-V™ dependencies including the ML extensions for Vulkan®.

To build the Emulation Layer, run:

$ cmake -B build                                               \
   -DGLSLANG_PATH=${REPO}/dependencies/glslang                 \
   -DSPIRV_CROSS_PATH=${REPO}/dependencies/SPIRV-Cross         \
   -DSPIRV_HEADERS_PATH=${REPO}/dependencies/SPIRV-Headers     \
   -DSPIRV_TOOLS_PATH=${REPO}/dependencies/SPIRV-Tools         \
   -DVULKAN_HEADERS_PATH=${REPO}/dependencies/Vulkan-Headers

$ cmake --build build

To build the documentation, add the -DVMEL_BUILD_DOCS=ON build flag.

To install the Emulation Layer into a deploy folder, run:

cmake --install build --prefix deploy

Building for Windows®

To build on Windows®, the machine must have a Vulkan® ICD and Vulkan® Loader installed. Vulkan® API 1.3 must also be supported.

The reference environment that the Emulation Layer has been built and tested with is:

  • OS: Win10

  • Build Tool: Visual Studio 17 2022

  • Compiler: MSVC 19.37.32825.0

  • CMake: 3.27.7

  • Terminal: PowerShell

To build the Emulation Layer, run:

$env:REPO="path\to\repo"
cmake -B build                                                 `
   -DGLSLANG_PATH="$env:REPO\dependencies\glslang"             `
   -DSPIRV_CROSS_PATH="$env:REPO\dependencies\SPIRV-Cross"     `
   -DSPIRV_HEADERS_PATH="$env:REPO\dependencies\SPIRV-Headers" `
   -DSPIRV_TOOLS_PATH="$env:REPO\dependencies\SPIRV-Tools"     `
   -DVULKAN_HEADERS_PATH="$env:REPO\dependencies\Vulkan-Headers"
cmake --build build --config Release

To install the Emulation Layer into a deploy folder, run:

cmake --install build --prefix deploy

Building for Android

(Experimental)

The Android NDK toolset is required to build the Emulation layer for an Android device. The Android device must have Vulkan® API 1.3 support.

To build the Emulation Layer, run:

$ cmake -B build
   -DCMAKE_TOOLCHAIN_FILE=${NDK}/build/cmake/android.toolchain.cmake \
   -DANDROID_ABI=arm64-v8a                                           \
   -DGLSLANG_PATH=${REPO}/dependencies/glslang                       \
   -DSPIRV_CROSS_PATH=${REPO}/dependencies/SPIRV-Cross               \
   -DSPIRV_HEADERS_PATH=${REPO}/dependencies/SPIRV-Headers           \
   -DSPIRV_TOOLS_PATH=${REPO}/dependencies/SPIRV-Tools               \
   -DVULKAN_HEADERS_PATH=${REPO}/dependencies/Vulkan-Headers

$ cmake --build build