This Specification is protected by copyright laws and contains material proprietary to Khronos.Except as described by these terms, it or any components may not be reproduced, republished,distributed, transmitted, displayed, broadcast or otherwise exploited in any manner without theexpress prior written permission of Khronos.
This Specification has been created under the Khronos Intellectual Property RightsPolicy, which is Attachment A of the Khronos Group Membership Agreement available atwww.khronos.org/files/member_agreement.pdf.
Khronos grants a conditional copyright license to use and reproduce theunmodified Specification for any purpose, without fee or royalty, EXCEPT no licensesto any patent, trademark or other intellectual property rights are granted under theseterms. Parties desiring to implement the Specification and make use of Khronos trademarksin relation to that implementation, and receive reciprocal patent license protection underthe Khronos Intellectual Property Rights Policy must become Adopters and confirm theimplementation as conformant under the process defined by Khronos for this Specification;see
Khronos makes no, and expressly disclaims any, representations or warranties,express or implied, regarding this Specification, including, without limitation:merchantability, fitness for a particular purpose, non-infringement of anyintellectual property, correctness, accuracy, completeness, timeliness, andreliability. Under no circumstances will Khronos, or any of its Promoters,Contributors or Members, or their respective partners, officers, directors,employees, agents or representatives be liable for any damages, whether direct,indirect, special or consequential damages for lost revenues, lost profits, orotherwise, arising from or in connection with these materials.
This Specification contains substantially unmodified functionality from, and is a successorto, Khronos specifications including all versions of "The SPIR Specification","The OpenGL Shading Language", "The OpenGL ES Shading Language", as well as all KhronosOpenCL API and OpenCL programming language specifications.
Some parts of this Specification are purely informative and so are EXCLUDED from the Scopeof this Specification. Section 1.3 "About This Document" defines howthese parts of the Specification are identified.
Where this Specification uses technical terminology, defined in the Glossary or otherwise,that refer to enabling technologies that are not expressly set forth in this Specification,those enabling technologies are EXCLUDED from the Scope of this Specification. For clarity,enabling technologies not disclosed with particularity in this Specification(e.g. semiconductor manufacturing technology, hardware architecture, processor architectureor microarchitecture, memory architecture, compiler technology, object oriented technology,basic operating system technology, compression technology, algorithms, and so on) are NOTto be considered expressly set forth; only those application program interfaces and datastructures disclosed with particularity are included in the Scope of this Specification.
For purposes of the Khronos Intellectual Property Rights Policy as it relates to thedefinition of Necessary Patent Claims, all recommended or optional features, behaviorsand functionality set forth in this Specification, if implemented, are considered tobe included as Compliant Portions.
Reduce compile time during application run time. (Eliminating most of the compile time during application run time is not a goal of this intermediate language.Target-specific register allocation and scheduling are still expected to take significant time.)
Major is reserved for future use and has been fixed at 1.Minor changes have signified additions, deprecation, and removal of features.Revision changes have included clarifications, bug fixes,and deprecation (but not removal) of existing features.
Registration. Ranges of token values in the Binary Form section can be pre-allocated to numerous vendors/parties.This allows combining multiple independent extensions without conflict.To register ranges, use the -Headers repository,and submit pull requests against the include/spirv/spir-v.xml file.
Extended Instructions. Sets of extended instructions can be provided and specified in separate specifications.Multiple sets of extended instructions can be imported without conflict, as the extended instructions are selected by set id, instruction number pairs.
Instruction Skipping. Tools are encouraged to skip opcodes for features they are not required to process.This is trivially enabled by the word count in an instruction, which makes it easier to add new instructions without breaking existing tools.
SPIR-V can decorate, with a text string, virtually anything created in the shader: types, variables, functions, etc.This is required for externally visible symbols, and also allowed for naming the result of any instruction.This can be used to aid in understandability when disassembling or debugging lowered versions of SPIR-V.
Non Combinatorial. There is no combinatorial type explosion or need for large encode/decode tables for types.Rather, types are parameterized. Image types declare their dimensionality, arrayness, etc. all orthogonally, which greatly simplify code.This is done similarly for other types. It also applies to opcodes. Operations are orthogonal to scalar/vector size, but notto integer vs. floating-point differences.
Modeless. After a given execution model (e.g., pipeline stage) is specified, internal operation is essentially modeless:Generally, it follows the rule: "same spelling, same semantics", and does not have mode bits that modify semantics.If a change to SPIR-V modifies semantics, it should use a different spelling. This makes consumers of SPIR-V much more robust.There are execution modes declared, but these generally affect the way the module interacts with its execution environment, not its internal semantics.Capabilities are also declared, but this is to declare the subset of functionality that is used, not to change any semantics of what is used.
Declarative. SPIR-V declares externally-visible modes like "writes depth", rather than having rules that require deduction from full shader inspection.It also explicitly declares what addressing modes, execution model, extended instruction sets, etc. will be used.See Language Capabilities for more information.
SSA. All results of intermediate operations are strictly SSA.However, declared variables reside in memory and use load/store for access, and such variables can be stored to multiple times.
SPIR-V includes a phi instruction to allow the merging together of intermediate results from split control flow.This allows split control flow without load/store to memory.SPIR-V is flexible in the degree to which load/store is used; it is possible to use control flow with no phi-instructions,while still staying in SSA form, by using memory load/store.
SPIR-V identifies built-in variables from a high-level language with an enumerant decoration.This assigns any unusual semantics to the variable.Built-in variables are otherwise declared with their correct SPIR-V type and treated the same as any other variable.
A SPIR-V module is consumed by a client API that needs to support the features used by that SPIR-V module.Features are classified through capabilities.Capabilities used by a particular SPIR-V module are declared early in that module with the OpCapability instruction. Then:
All available capabilities and their dependencies form a capability hierarchy, fully listed in the capability section.Only top-level capabilities need to be explicitly declared; their dependencies are implicitly declared.
If an instruction, enumerant, or other feature specifies multiple enabling capabilities, only one such capabilityneeds to be declared to use the feature. This declaration does not itself imply anything about the presence of theother enabling capabilities: The execution environment needs to support only the declared capability.
Decoration: Auxiliary information such as built-in variable, stream numbers, invariance, interpolation type, relaxed precision, etc.,added to s or structure-type members through Decorations.Decorations are enumerated in Decoration in the Binary Form section.
Memory Object: An object created through OpVariable.Such an object exists only for the duration of a function if it is a function variable,and otherwise exists for the duration of an invocation.
Memory Object Declaration: An OpVariable,or an OpFunctionParameter of pointer type, or the contents of an OpVariablethat holds either a pointer to the PhysicalStorageBuffer storage class or an array of such pointers.
Image: A traditional texture or image; SPIR-V has this single name for these.An image type is declared with OpTypeImage.An image does not include any information about how to access, filter, or sample it.
Sampler: Settings that describe how to access, filter, or sample an image.Comes either from literal declarations of settings or from an opaque reference to externally bound settings.A sampler does not include an image.
Additionally, any OpAccessChain, OpInBoundsAccessChain,or OpCopyObject that takes a variable pointer as an operand also produces a variable pointer.An OpFunctionParameter of pointer type is a variable pointer if anyOpFunctionCall to the function statically passes a variable pointer as the value of the parameter.
Execution Mode: Modes of operation relating to the interface or execution environment of the module.These are enumerated in Execution Mode. Generally, modes do not change the semanticsof instructions within a SPIR-V module.
Structurally Post Dominate: A block B structurally post dominates a block A, where A and B are in the same function,if every structured control-flow path from A to a function termination instruction includes block B.
b1e95dc632