Generate Vulkan header files for each shader

This guide shows you how to generate the Vulkan C++ headers for each host OS from the shader files.

Generate C++ headers from the shader files

  1. Download the Khronos Group Glslang Tool: Candidate of July 26, 2020 on your local machine.

  2. Unzip it.

  3. Check its version:

    • Windows

      bin\glslangValidator --version

    • macOS

      ./bin/glslangValidator --version

    • Linux

      ./bin/glslangValidator --version

  4. In the Cardboard repository, locate the sdk/rendering/android/shaders folder and save its path.

  5. Generate the Vulkan header files in C++:

    • Windows

      bin\glslangValidator -V --vn distortion_frag %SHADERS_FOLDER_PATH%\distortion.frag -o distortion_frag.spv.h
      bin\glslangValidator -V --vn distortion_vert %SHADERS_FOLDER_PATH%\distortion.vert -o distortion_vert.spv.h
      

    • macOS

      ./bin/glslangValidator -V --vn distortion_frag $SHADERS_FOLDER_PATH/distortion.frag -o distortion_frag.spv.h
      
      ./bin/glslangValidator -V --vn distortion_vert $SHADERS_FOLDER_PATH/distortion.vert -o distortion_vert.spv.h
      
      

    • Linux

      ./bin/glslangValidator -V --vn distortion_frag $SHADERS_FOLDER_PATH/distortion.frag -o distortion_frag.spv.h
      
      ./bin/glslangValidator -V --vn distortion_vert $SHADERS_FOLDER_PATH/distortion.vert -o distortion_vert.spv.h
      
      

You should now have distortion_frag.spv.h and distortion_vert.spv.h.