AI-generated Key Takeaways
-
This guide provides instructions on generating Vulkan C++ header files from shader files for use in your application.
-
You will need to download and install the Khronos Group Glslang tool to convert shader files into header files.
-
The process involves locating your shader files and using the glslangValidator tool with specific commands to generate the corresponding header files.
-
The generated header files,
distortion_frag.spv.h
anddistortion_vert.spv.h
, will contain the Vulkan-compatible code derived from your shaders.
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
Download the Khronos Group Glslang Tool: Candidate of July 26, 2020 on your local machine.
Unzip it.
Check its version:
Windows
bin\glslangValidator --version
macOS
./bin/glslangValidator --version
Linux
./bin/glslangValidator --version
In the Cardboard repository, locate the
sdk/rendering/android/shaders
folder and save its path.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.