Creating a shader module
The first step in creating a pipeline object is to prepare shader modules. They represent shaders and contain their code written in a SPIR-V assembly. A single module may contain code for multiple shader stages. When we write shader programs and convert them into SPIR-V form, we need to create a shader module (or multiple modules) before we can use shaders in our application.
How to do it...
- Take the handle of a logical device stored in a variable of type
VkDevicenamedlogical_device. - Load a binary SPIR-V assembly of a selected shader and store it in a variable of type
std::vector<unsigned char>namedsource_code. - Create a variable of type
VkShaderModuleCreateInfonamedshader_module_create_info. Use the following values to initialize its members:VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFOvalue forsType.nullptrvalue forpNext0value forflags- The number of elements in the
source_codevector (size in bytes) forcodeSize - A pointer to the first element of the
source_code...