SPIR-V file naming convention


Just as GLSL has .vert and .frag files, and they aren’t part of the specification, nor are they official rules, is there any common informal naming convention for compiled SPIR-V bytecode files? I have seen files with the .spv file extension, but is there any convention for determining which is a vertex and which is a fragment shader, and which files go together?


I don’t think so. But I do use *.vert.spv.


SPIR-V allows you to store multiple/all shader stages in the same binary. So having a per-stage filename extension should definitely be an app-specific convention.


Perfect. So we can store one complete shader in a single .spv file.

Here are the parameters to compile multiple files into one:

glslangValidator.exe "shader.frag" "shader.vert" -V -l -o "shader.spv"


Now how do you supply that binary data to Vulkan? Do you just give it a pointer to the loaded file data, and it will find the right part of the data for the stage you are loading?


A SPIR-V binary that contains multiple stages is still just a single shader module as far as Vulkan is concerned.

The VkPipelineShaderStageCreateInfo contains a pName field, which is the name of the entry point for that particular shader stage. Multiple stage create info objects can reference the same shader module, just with different entry points.


Okay, I am trying to compile these into a single file with GLSlangValidator:

glslangValidator.exe "shader.frag" "shader.vert" -V -l -o "shader.spv"
ERROR: Linking vertex stage: Missing entry point: Each stage requires one entry point
ERROR: Linking fragment stage: Missing entry point: Each stage requires one entry point

The -e option here doesn’t seem to work. If I add “-e main” or anything like that it thinks I am trying to indicate another file to compile:

Can anyone provide an example of command-line for GLSlangValidator that packs multiple shaders stages into one file and specifies entry points for each stage?


Are you sure there is such a command line option in glslangvalidator? Or that the tool can properly generate SPIR-V binaries that have multiple shader stages in them?

Indeed, the presence of these two open issues suggests that it doesn’t do that.


Yes, it is strange this functionality does not seem to be supported. Does anyone know any equivalent tool that does this?