CompilingShadersToSPIR V
CompilingShadersToSPIR V
Vulkan uses SPIR-V for shader modules. Standard Portable Intermediate Representation (SPIR) is an
open standard to allow parallel compute and graphics operations to be represented in a cross
platform fashion. SPIR-V is the newest version, a binary intermediate representation, with native
graphics and compute constructs.
The standard vertex, fragment, compute, geometry and tessellation shaders can be compiled into
SPIR-V binary blobs using glslang, provided by the Khronos Group on github in source form. It can be
found at https://github.com/KhronosGroup/glslang . Further information can be found on the
Khronos reference compiler page https://www.khronos.org/opengles/sdk/tools/Reference-
Compiler/ .
Glslang provides a validator binary (glslangValidator) that can compile shaders of various type into
SPIR-V which can be provided when creating vulkan pipeline objects. We recommend rebuilding this
binary from the glslang source code to obtain the latest version which supports new Vulkan
constructs.
simple_vert.spv can be loaded in its entirety and provided as a single buffer to the Vulkan APIs.
There is no file header to parse, the whole binary blob is provided to vkCreateShaderModule.
As an alternative, the VkSampleFramework provides functions to load shader modules from memory
and from files within the Assets folder of android projects.
return module;
}
return module;
}