Introduction
A .spvasm file holds a SPIR-V module as
readable text, one instruction per line. The SPIRV-Tools project from the Khronos Group
provides spirv-dis, which turns a binary module into this text, and
spirv-as, which assembles the text back into binary. Its documentation
calls it a convention to name SPIR-V assembly files with the suffix
.spvasm and binary files with .spv.
The text form is a tool convention. The SPIR-V specification itself defines only the binary form, so other tools may write assembly in a different style.
Structure
Each line is one instruction: an opcode name, such as OpTypeVoid, and its
operands. Names of ids start with %. An instruction that produces a result
starts with the result id and an equals sign, as in %void = OpTypeVoid;
the other operands follow the opcode. The module opens with capabilities, the memory
model and the entry points, then the types and the functions.
OpCapability Shader
OpMemoryModel Logical Simple
OpEntryPoint GLCompute %main "main"
OpExecutionMode %main LocalSize 64 64 1
%void = OpTypeVoid
%fnMain = OpTypeFunction %void
%main = OpFunction %void None %fnMain
%lbMain = OpLabel
OpReturn
OpFunctionEnd
Not described
Known, not yet covered
- Reference: this overview is the only page. The assembly grammar has no reference pages: the forms an operand can take (ids, literals, enumerants, masks, strings), numeric id naming and the names
spirv-disinvents, comments, and the options ofspirv-asandspirv-dis. The SPIRV-Tools syntax guide describes them. - Reference: the instruction set itself, defined in the SPIR-V specification, is not described.
- Viewer: there is no viewer for this format yet, and nothing is assembled or checked.
Links
Software
- SPIRV-Tools –
spirv-asandspirv-dis, open source (Windows, macOS, Linux)
Reference
- SPIRV-Tools: assembly syntax – how a line is written
- SPIR-V specification – the binary form and the instruction set