Converting GLSL shaders to SPIR-V assemblies
The Vulkan API requires us to provide shaders in the form of SPIR-V assemblies. It is a binary, intermediate representation, so writing it manually is a very hard and cumbersome task. It is much easier and quicker to write shader programs in a high-level shading language such as GLSL. After that we just need to convert them into a SPIR-V form using the glslangValidator tool.
How to do it...
- Download and install the Vulkan SDK (refer to the Downloading Vulkan SDK recipe from Chapter 1, Instance and Devices).
- Open the command prompt/terminal and go to the folder which contains shader files that should be converted.
- To convert a GLSL shader stored in the
<input>
file into a SPIR-V assembly stored in the<output>
file, run the following command:
glslangValidator -H -o <output> <input> > <output_txt>
How it works...
The glslangValidator tool is distributed along with the Vulkan SDK. It is located in the VulkanSDK/<...