Generate Vulkan header files for each shader
Stay organized with collections
Save and categorize content based on your preferences.
This guide shows you how to generate the Vulkan C++ headers for each host OS 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.
All rights reserved. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2024-08-06 UTC.
[null,null,["Last updated 2024-08-06 UTC."],[[["\u003cp\u003eThis guide provides instructions on generating Vulkan C++ header files from shader files for use in your application.\u003c/p\u003e\n"],["\u003cp\u003eYou will need to download and install the Khronos Group Glslang tool to convert shader files into header files.\u003c/p\u003e\n"],["\u003cp\u003eThe process involves locating your shader files and using the glslangValidator tool with specific commands to generate the corresponding header files.\u003c/p\u003e\n"],["\u003cp\u003eThe generated header files, \u003ccode\u003edistortion_frag.spv.h\u003c/code\u003e and \u003ccode\u003edistortion_vert.spv.h\u003c/code\u003e, will contain the Vulkan-compatible code derived from your shaders.\u003c/p\u003e\n"]]],[],null,["# Generate Vulkan header files for each shader\n\nThis guide shows you how to generate the Vulkan C++ headers for each host OS from the shader files.\n\nGenerate C++ headers from the shader files\n------------------------------------------\n\n1. Download the [Khronos Group Glslang Tool: Candidate of July 26, 2020](https://github.com/KhronosGroup/glslang/releases/tag/SDK-candidate-26-Jul-2020) on your local machine.\n\n2. Unzip it.\n\n3. Check its version:\n\n - Windows\n\n ```\n bin\\glslangValidator --version\n ```\n\n \u003cbr /\u003e\n\n - macOS\n\n ```\n ./bin/glslangValidator --version\n ```\n\n \u003cbr /\u003e\n\n - Linux\n\n ```\n ./bin/glslangValidator --version\n ```\n\n \u003cbr /\u003e\n\n4. In the Cardboard repository, locate the `sdk/rendering/android/shaders` folder and save its path.\n\n5. Generate the Vulkan header files in C++:\n\n - Windows\n\n bin\\glslangValidator -V --vn distortion_frag \u003cvar translate=\"no\"\u003e%SHADERS_FOLDER_PATH%\u003c/var\u003e\\distortion.frag -o distortion_frag.spv.h\n bin\\glslangValidator -V --vn distortion_vert \u003cvar translate=\"no\"\u003e%SHADERS_FOLDER_PATH%\u003c/var\u003e\\distortion.vert -o distortion_vert.spv.h\n\n \u003cbr /\u003e\n\n - macOS\n\n ./bin/glslangValidator -V --vn distortion_frag \u003cvar translate=\"no\"\u003e$SHADERS_FOLDER_PATH\u003c/var\u003e/distortion.frag -o distortion_frag.spv.h\n\n ./bin/glslangValidator -V --vn distortion_vert \u003cvar translate=\"no\"\u003e$SHADERS_FOLDER_PATH\u003c/var\u003e/distortion.vert -o distortion_vert.spv.h\n\n \u003cbr /\u003e\n\n - Linux\n\n ./bin/glslangValidator -V --vn distortion_frag \u003cvar translate=\"no\"\u003e$SHADERS_FOLDER_PATH\u003c/var\u003e/distortion.frag -o distortion_frag.spv.h\n\n ./bin/glslangValidator -V --vn distortion_vert \u003cvar translate=\"no\"\u003e$SHADERS_FOLDER_PATH\u003c/var\u003e/distortion.vert -o distortion_vert.spv.h\n\n \u003cbr /\u003e\n\nYou should now have **distortion_frag.spv.h** and **distortion_vert.spv.h**."]]