Home | History | Annotate | Download | only in libSPIRV
      1 //===- SPIRVEnum.h - SPIR-V enums -------------------------------*- C++ -*-===//
      2 //
      3 //                     The LLVM/SPIRV Translator
      4 //
      5 // This file is distributed under the University of Illinois Open Source
      6 // License. See LICENSE.TXT for details.
      7 //
      8 // Copyright (c) 2014 Advanced Micro Devices, Inc. All rights reserved.
      9 //
     10 // Permission is hereby granted, free of charge, to any person obtaining a
     11 // copy of this software and associated documentation files (the "Software"),
     12 // to deal with the Software without restriction, including without limitation
     13 // the rights to use, copy, modify, merge, publish, distribute, sublicense,
     14 // and/or sell copies of the Software, and to permit persons to whom the
     15 // Software is furnished to do so, subject to the following conditions:
     16 //
     17 // Redistributions of source code must retain the above copyright notice,
     18 // this list of conditions and the following disclaimers.
     19 // Redistributions in binary form must reproduce the above copyright notice,
     20 // this list of conditions and the following disclaimers in the documentation
     21 // and/or other materials provided with the distribution.
     22 // Neither the names of Advanced Micro Devices, Inc., nor the names of its
     23 // contributors may be used to endorse or promote products derived from this
     24 // Software without specific prior written permission.
     25 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
     26 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
     27 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
     28 // CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
     29 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
     30 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS WITH
     31 // THE SOFTWARE.
     32 //
     33 //===----------------------------------------------------------------------===//
     34 /// \file
     35 ///
     36 /// This file defines SPIR-V enums.
     37 ///
     38 //===----------------------------------------------------------------------===//
     39 
     40 #ifndef SPIRVENUM_HPP_
     41 #define SPIRVENUM_HPP_
     42 
     43 #include "spirv.hpp"
     44 #include "SPIRVOpCode.h"
     45 #include <cstdint>
     46 using namespace spv;
     47 
     48 namespace SPIRV{
     49 
     50 typedef uint32_t SPIRVWord;
     51 typedef uint32_t SPIRVId;
     52 #define SPIRVID_MAX       ~0U
     53 #define SPIRVID_INVALID   ~0U
     54 #define SPIRVWORD_MAX     ~0U
     55 
     56 inline bool
     57 isValidId(SPIRVId Id) { return Id != SPIRVID_INVALID && Id != 0;}
     58 
     59 inline SPIRVWord
     60 mkWord(unsigned WordCount, Op OpCode) {
     61   return (WordCount << 16) | OpCode;
     62 }
     63 
     64 const static unsigned kSPIRVMemOrderSemanticMask = 0x1F;
     65 
     66 enum SPIRVVersion : SPIRVWord {
     67   SPIRV_1_0 = 0x00010000,
     68   SPIRV_1_1 = 0x00010100
     69 };
     70 
     71 enum SPIRVGeneratorKind {
     72   SPIRVGEN_KhronosLLVMSPIRVTranslator   = 6,
     73   SPIRVGEN_KhronosSPIRVAssembler        = 7,
     74 };
     75 
     76 enum SPIRVInstructionSchemaKind {
     77   SPIRVISCH_Default,
     78 };
     79 
     80 enum SPIRVExtInstSetKind {
     81   SPIRVEIS_OpenCL,
     82   SPIRVEIS_Count,
     83 };
     84 
     85 enum SPIRVSamplerAddressingModeKind {
     86   SPIRVSAM_None = 0,
     87   SPIRVSAM_ClampEdge = 2,
     88   SPIRVSAM_Clamp = 4,
     89   SPIRVSAM_Repeat = 6,
     90   SPIRVSAM_RepeatMirrored = 8,
     91   SPIRVSAM_Invalid = 255,
     92 };
     93 
     94 enum SPIRVSamplerFilterModeKind {
     95   SPIRVSFM_Nearest = 16,
     96   SPIRVSFM_Linear = 32,
     97   SPIRVSFM_Invalid = 255,
     98 };
     99 
    100 typedef spv::Capability SPIRVCapabilityKind;
    101 typedef spv::ExecutionModel SPIRVExecutionModelKind;
    102 typedef spv::ExecutionMode SPIRVExecutionModeKind;
    103 typedef spv::AccessQualifier SPIRVAccessQualifierKind;
    104 typedef spv::AddressingModel SPIRVAddressingModelKind;
    105 typedef spv::LinkageType SPIRVLinkageTypeKind;
    106 typedef spv::MemoryModel SPIRVMemoryModelKind;
    107 typedef spv::StorageClass SPIRVStorageClassKind;
    108 typedef spv::FunctionControlMask SPIRVFunctionControlMaskKind;
    109 typedef spv::FPRoundingMode SPIRVFPRoundingModeKind;
    110 typedef spv::FunctionParameterAttribute SPIRVFuncParamAttrKind;
    111 typedef spv::BuiltIn SPIRVBuiltinVariableKind;
    112 typedef spv::MemoryAccessMask SPIRVMemoryAccessKind;
    113 typedef spv::GroupOperation SPIRVGroupOperationKind;
    114 typedef spv::Dim SPIRVImageDimKind;
    115 typedef std::vector<SPIRVCapabilityKind> SPIRVCapVec;
    116 
    117 template<> inline void
    118 SPIRVMap<SPIRVExtInstSetKind, std::string>::init() {
    119   add(SPIRVEIS_OpenCL, "OpenCL.std");
    120 }
    121 typedef SPIRVMap<SPIRVExtInstSetKind, std::string> SPIRVBuiltinSetNameMap;
    122 
    123 template<typename K>
    124 SPIRVCapVec
    125 getCapability(K Key) {
    126   SPIRVCapVec V;
    127   SPIRVMap<K, SPIRVCapVec>::find(Key, &V);
    128   return V;
    129 }
    130 
    131 #define ADD_VEC_INIT(Cap, ...)                                                 \
    132 {                                                                              \
    133   SPIRVCapabilityKind C[] = __VA_ARGS__;                                       \
    134   SPIRVCapVec V(C, C + sizeof(C) / sizeof(C[0]));                              \
    135   add(Cap, V);                                                                 \
    136 }
    137 
    138 template<> inline void
    139 SPIRVMap<SPIRVCapabilityKind, SPIRVCapVec>::init() {
    140   ADD_VEC_INIT(CapabilityShader, { CapabilityMatrix });
    141   ADD_VEC_INIT(CapabilityGeometry, { CapabilityShader });
    142   ADD_VEC_INIT(CapabilityTessellation, { CapabilityShader });
    143   ADD_VEC_INIT(CapabilityVector16, { CapabilityKernel });
    144   ADD_VEC_INIT(CapabilityFloat16Buffer, { CapabilityKernel });
    145   ADD_VEC_INIT(CapabilityInt64Atomics, { CapabilityInt64 });
    146   ADD_VEC_INIT(CapabilityImageBasic, { CapabilityKernel });
    147   ADD_VEC_INIT(CapabilityImageReadWrite, { CapabilityImageBasic });
    148   ADD_VEC_INIT(CapabilityImageMipmap, { CapabilityImageBasic });
    149   ADD_VEC_INIT(CapabilityPipes, { CapabilityKernel });
    150   ADD_VEC_INIT(CapabilityDeviceEnqueue, { CapabilityKernel });
    151   ADD_VEC_INIT(CapabilityLiteralSampler, { CapabilityKernel });
    152   ADD_VEC_INIT(CapabilityAtomicStorage, { CapabilityShader });
    153   ADD_VEC_INIT(CapabilityTessellationPointSize, { CapabilityTessellation });
    154   ADD_VEC_INIT(CapabilityGeometryPointSize, { CapabilityGeometry });
    155   ADD_VEC_INIT(CapabilityImageGatherExtended, { CapabilityShader });
    156   ADD_VEC_INIT(CapabilityStorageImageMultisample, { CapabilityShader });
    157   ADD_VEC_INIT(CapabilityUniformBufferArrayDynamicIndexing, { CapabilityShader });
    158   ADD_VEC_INIT(CapabilitySampledImageArrayDynamicIndexing, { CapabilityShader });
    159   ADD_VEC_INIT(CapabilityStorageBufferArrayDynamicIndexing, { CapabilityShader });
    160   ADD_VEC_INIT(CapabilityStorageImageArrayDynamicIndexing, { CapabilityShader });
    161   ADD_VEC_INIT(CapabilityClipDistance, { CapabilityShader });
    162   ADD_VEC_INIT(CapabilityCullDistance, { CapabilityShader });
    163   ADD_VEC_INIT(CapabilityImageCubeArray, { CapabilitySampledCubeArray });
    164   ADD_VEC_INIT(CapabilitySampleRateShading, { CapabilityShader });
    165   ADD_VEC_INIT(CapabilityImageRect, { CapabilitySampledRect });
    166   ADD_VEC_INIT(CapabilitySampledRect, { CapabilityShader });
    167   ADD_VEC_INIT(CapabilityGenericPointer, { CapabilityAddresses });
    168   ADD_VEC_INIT(CapabilityInt8, { CapabilityKernel });
    169   ADD_VEC_INIT(CapabilityInputAttachment, { CapabilityShader });
    170   ADD_VEC_INIT(CapabilitySparseResidency, { CapabilityShader });
    171   ADD_VEC_INIT(CapabilityMinLod, { CapabilityShader });
    172   ADD_VEC_INIT(CapabilitySampled1D, { CapabilityShader });
    173   ADD_VEC_INIT(CapabilityImage1D, { CapabilitySampled1D });
    174   ADD_VEC_INIT(CapabilitySampledCubeArray, { CapabilityShader });
    175   ADD_VEC_INIT(CapabilitySampledBuffer, { CapabilityShader });
    176   ADD_VEC_INIT(CapabilityImageBuffer, { CapabilitySampledBuffer });
    177   ADD_VEC_INIT(CapabilityImageMSArray, { CapabilityShader });
    178   ADD_VEC_INIT(CapabilityStorageImageExtendedFormats, { CapabilityShader });
    179   ADD_VEC_INIT(CapabilityImageQuery, { CapabilityShader });
    180   ADD_VEC_INIT(CapabilityDerivativeControl, { CapabilityShader });
    181   ADD_VEC_INIT(CapabilityInterpolationFunction, { CapabilityShader });
    182   ADD_VEC_INIT(CapabilityTransformFeedback, { CapabilityShader });
    183   ADD_VEC_INIT(CapabilityGeometryStreams, { CapabilityGeometry });
    184   ADD_VEC_INIT(CapabilityStorageImageReadWithoutFormat, { CapabilityShader });
    185   ADD_VEC_INIT(CapabilityStorageImageWriteWithoutFormat, { CapabilityShader });
    186   ADD_VEC_INIT(CapabilityMultiViewport, { CapabilityGeometry });
    187 }
    188 
    189 template<> inline void
    190 SPIRVMap<SPIRVExecutionModelKind, SPIRVCapVec>::init() {
    191   ADD_VEC_INIT(ExecutionModelVertex, { CapabilityShader });
    192   ADD_VEC_INIT(ExecutionModelTessellationControl, { CapabilityTessellation });
    193   ADD_VEC_INIT(ExecutionModelTessellationEvaluation, { CapabilityTessellation });
    194   ADD_VEC_INIT(ExecutionModelGeometry, { CapabilityGeometry });
    195   ADD_VEC_INIT(ExecutionModelFragment, { CapabilityShader });
    196   ADD_VEC_INIT(ExecutionModelGLCompute, { CapabilityShader });
    197   ADD_VEC_INIT(ExecutionModelKernel, { CapabilityKernel });
    198 }
    199 
    200 template<> inline void
    201 SPIRVMap<SPIRVExecutionModeKind, SPIRVCapVec>::init() {
    202   ADD_VEC_INIT(ExecutionModeInvocations, { CapabilityGeometry });
    203   ADD_VEC_INIT(ExecutionModeSpacingEqual, { CapabilityTessellation });
    204   ADD_VEC_INIT(ExecutionModeSpacingFractionalEven, { CapabilityTessellation });
    205   ADD_VEC_INIT(ExecutionModeSpacingFractionalOdd, { CapabilityTessellation });
    206   ADD_VEC_INIT(ExecutionModeVertexOrderCw, { CapabilityTessellation });
    207   ADD_VEC_INIT(ExecutionModeVertexOrderCcw, { CapabilityTessellation });
    208   ADD_VEC_INIT(ExecutionModePixelCenterInteger, { CapabilityShader });
    209   ADD_VEC_INIT(ExecutionModeOriginUpperLeft, { CapabilityShader });
    210   ADD_VEC_INIT(ExecutionModeOriginLowerLeft, { CapabilityShader });
    211   ADD_VEC_INIT(ExecutionModeEarlyFragmentTests, { CapabilityShader });
    212   ADD_VEC_INIT(ExecutionModePointMode, { CapabilityTessellation });
    213   ADD_VEC_INIT(ExecutionModeXfb, { CapabilityTransformFeedback });
    214   ADD_VEC_INIT(ExecutionModeDepthReplacing, { CapabilityShader });
    215   ADD_VEC_INIT(ExecutionModeDepthGreater, { CapabilityShader });
    216   ADD_VEC_INIT(ExecutionModeDepthLess, { CapabilityShader });
    217   ADD_VEC_INIT(ExecutionModeDepthUnchanged, { CapabilityShader });
    218   ADD_VEC_INIT(ExecutionModeLocalSizeHint, { CapabilityKernel });
    219   ADD_VEC_INIT(ExecutionModeInputPoints, { CapabilityGeometry });
    220   ADD_VEC_INIT(ExecutionModeInputLines, { CapabilityGeometry });
    221   ADD_VEC_INIT(ExecutionModeInputLinesAdjacency, { CapabilityGeometry });
    222   ADD_VEC_INIT(ExecutionModeTriangles, { CapabilityGeometry, CapabilityTessellation });
    223   ADD_VEC_INIT(ExecutionModeInputTrianglesAdjacency, { CapabilityGeometry });
    224   ADD_VEC_INIT(ExecutionModeQuads, { CapabilityTessellation });
    225   ADD_VEC_INIT(ExecutionModeIsolines, { CapabilityTessellation });
    226   ADD_VEC_INIT(ExecutionModeOutputVertices, { CapabilityGeometry, CapabilityTessellation });
    227   ADD_VEC_INIT(ExecutionModeOutputPoints, { CapabilityGeometry });
    228   ADD_VEC_INIT(ExecutionModeOutputLineStrip, { CapabilityGeometry });
    229   ADD_VEC_INIT(ExecutionModeOutputTriangleStrip, { CapabilityGeometry });
    230   ADD_VEC_INIT(ExecutionModeVecTypeHint, { CapabilityKernel });
    231   ADD_VEC_INIT(ExecutionModeContractionOff, { CapabilityKernel });
    232 }
    233 
    234 template<> inline void
    235 SPIRVMap<SPIRVMemoryModelKind, SPIRVCapVec>::init() {
    236   ADD_VEC_INIT(MemoryModelSimple, { CapabilityShader });
    237   ADD_VEC_INIT(MemoryModelGLSL450, { CapabilityShader });
    238   ADD_VEC_INIT(MemoryModelOpenCL, { CapabilityKernel });
    239 }
    240 
    241 template<> inline void
    242 SPIRVMap<SPIRVStorageClassKind, SPIRVCapVec>::init() {
    243   ADD_VEC_INIT(StorageClassInput, { CapabilityShader });
    244   ADD_VEC_INIT(StorageClassUniform, { CapabilityShader });
    245   ADD_VEC_INIT(StorageClassOutput, { CapabilityShader });
    246   ADD_VEC_INIT(StorageClassPrivate, { CapabilityShader });
    247   ADD_VEC_INIT(StorageClassGeneric, { CapabilityGenericPointer });
    248   ADD_VEC_INIT(StorageClassPushConstant, { CapabilityShader });
    249   ADD_VEC_INIT(StorageClassAtomicCounter, { CapabilityAtomicStorage });
    250 }
    251 
    252 template<> inline void
    253 SPIRVMap<SPIRVImageDimKind, SPIRVCapVec>::init() {
    254   ADD_VEC_INIT(Dim1D, { CapabilitySampled1D });
    255   ADD_VEC_INIT(DimCube, { CapabilityShader });
    256   ADD_VEC_INIT(DimRect, { CapabilitySampledRect });
    257   ADD_VEC_INIT(DimBuffer, { CapabilitySampledBuffer });
    258   ADD_VEC_INIT(DimSubpassData, {CapabilityInputAttachment });
    259 }
    260 
    261 template<> inline void
    262 SPIRVMap<ImageFormat, SPIRVCapVec>::init() {
    263   ADD_VEC_INIT(ImageFormatRgba32f, { CapabilityShader });
    264   ADD_VEC_INIT(ImageFormatRgba16f, { CapabilityShader });
    265   ADD_VEC_INIT(ImageFormatR32f, { CapabilityShader });
    266   ADD_VEC_INIT(ImageFormatRgba8, { CapabilityShader });
    267   ADD_VEC_INIT(ImageFormatRgba8Snorm, { CapabilityShader });
    268   ADD_VEC_INIT(ImageFormatRg32f, { CapabilityStorageImageExtendedFormats });
    269   ADD_VEC_INIT(ImageFormatRg16f, { CapabilityStorageImageExtendedFormats });
    270   ADD_VEC_INIT(ImageFormatR11fG11fB10f, { CapabilityStorageImageExtendedFormats });
    271   ADD_VEC_INIT(ImageFormatR16f, { CapabilityStorageImageExtendedFormats });
    272   ADD_VEC_INIT(ImageFormatRgba16, { CapabilityStorageImageExtendedFormats });
    273   ADD_VEC_INIT(ImageFormatRgb10A2, { CapabilityStorageImageExtendedFormats });
    274   ADD_VEC_INIT(ImageFormatRg16, { CapabilityStorageImageExtendedFormats });
    275   ADD_VEC_INIT(ImageFormatRg8, { CapabilityStorageImageExtendedFormats });
    276   ADD_VEC_INIT(ImageFormatR16, { CapabilityStorageImageExtendedFormats });
    277   ADD_VEC_INIT(ImageFormatR8, { CapabilityStorageImageExtendedFormats });
    278   ADD_VEC_INIT(ImageFormatRgba16Snorm, { CapabilityStorageImageExtendedFormats });
    279   ADD_VEC_INIT(ImageFormatRg16Snorm, { CapabilityStorageImageExtendedFormats });
    280   ADD_VEC_INIT(ImageFormatRg8Snorm, { CapabilityStorageImageExtendedFormats });
    281   ADD_VEC_INIT(ImageFormatR16Snorm, { CapabilityStorageImageExtendedFormats });
    282   ADD_VEC_INIT(ImageFormatR8Snorm, { CapabilityStorageImageExtendedFormats });
    283   ADD_VEC_INIT(ImageFormatRgba32i, { CapabilityShader });
    284   ADD_VEC_INIT(ImageFormatRgba16i, { CapabilityShader });
    285   ADD_VEC_INIT(ImageFormatRgba8i, { CapabilityShader });
    286   ADD_VEC_INIT(ImageFormatR32i, { CapabilityShader });
    287   ADD_VEC_INIT(ImageFormatRg32i, { CapabilityStorageImageExtendedFormats });
    288   ADD_VEC_INIT(ImageFormatRg16i, { CapabilityStorageImageExtendedFormats });
    289   ADD_VEC_INIT(ImageFormatRg8i, { CapabilityStorageImageExtendedFormats });
    290   ADD_VEC_INIT(ImageFormatR16i, { CapabilityStorageImageExtendedFormats });
    291   ADD_VEC_INIT(ImageFormatR8i, { CapabilityStorageImageExtendedFormats });
    292   ADD_VEC_INIT(ImageFormatRgba32ui, { CapabilityShader });
    293   ADD_VEC_INIT(ImageFormatRgba16ui, { CapabilityShader });
    294   ADD_VEC_INIT(ImageFormatRgba8ui, { CapabilityShader });
    295   ADD_VEC_INIT(ImageFormatR32ui, { CapabilityShader });
    296   ADD_VEC_INIT(ImageFormatRgb10a2ui, { CapabilityStorageImageExtendedFormats });
    297   ADD_VEC_INIT(ImageFormatRg32ui, { CapabilityStorageImageExtendedFormats });
    298   ADD_VEC_INIT(ImageFormatRg16ui, { CapabilityStorageImageExtendedFormats });
    299   ADD_VEC_INIT(ImageFormatR16ui, { CapabilityStorageImageExtendedFormats });
    300   ADD_VEC_INIT(ImageFormatR8ui, { CapabilityStorageImageExtendedFormats });
    301 }
    302 
    303 template<> inline void
    304 SPIRVMap<ImageOperandsMask, SPIRVCapVec>::init() {
    305   ADD_VEC_INIT(ImageOperandsBiasMask, { CapabilityShader });
    306   ADD_VEC_INIT(ImageOperandsOffsetMask, { CapabilityImageGatherExtended });
    307   ADD_VEC_INIT(ImageOperandsMinLodMask, { CapabilityMinLod });
    308 }
    309 
    310 template<> inline void
    311 SPIRVMap<Decoration, SPIRVCapVec>::init() {
    312   ADD_VEC_INIT(DecorationRelaxedPrecision, { CapabilityShader });
    313   ADD_VEC_INIT(DecorationSpecId, { CapabilityShader });
    314   ADD_VEC_INIT(DecorationBlock, { CapabilityShader });
    315   ADD_VEC_INIT(DecorationBufferBlock, { CapabilityShader });
    316   ADD_VEC_INIT(DecorationRowMajor, { CapabilityMatrix });
    317   ADD_VEC_INIT(DecorationColMajor, { CapabilityMatrix });
    318   ADD_VEC_INIT(DecorationArrayStride, { CapabilityShader });
    319   ADD_VEC_INIT(DecorationMatrixStride, { CapabilityMatrix });
    320   ADD_VEC_INIT(DecorationGLSLShared, { CapabilityShader });
    321   ADD_VEC_INIT(DecorationGLSLPacked, { CapabilityShader });
    322   ADD_VEC_INIT(DecorationCPacked, { CapabilityKernel });
    323   ADD_VEC_INIT(DecorationNoPerspective, { CapabilityShader });
    324   ADD_VEC_INIT(DecorationFlat, { CapabilityShader });
    325   ADD_VEC_INIT(DecorationPatch, { CapabilityTessellation });
    326   ADD_VEC_INIT(DecorationCentroid, { CapabilityShader });
    327   ADD_VEC_INIT(DecorationSample, { CapabilitySampleRateShading });
    328   ADD_VEC_INIT(DecorationInvariant, { CapabilityShader });
    329   ADD_VEC_INIT(DecorationConstant, { CapabilityKernel });
    330   ADD_VEC_INIT(DecorationUniform, { CapabilityShader });
    331   ADD_VEC_INIT(DecorationSaturatedConversion, { CapabilityKernel });
    332   ADD_VEC_INIT(DecorationStream, { CapabilityGeometryStreams });
    333   ADD_VEC_INIT(DecorationLocation, { CapabilityShader });
    334   ADD_VEC_INIT(DecorationComponent, { CapabilityShader });
    335   ADD_VEC_INIT(DecorationIndex, { CapabilityShader });
    336   ADD_VEC_INIT(DecorationBinding, { CapabilityShader });
    337   ADD_VEC_INIT(DecorationDescriptorSet, { CapabilityShader });
    338   ADD_VEC_INIT(DecorationOffset, { CapabilityShader });
    339   ADD_VEC_INIT(DecorationXfbBuffer, { CapabilityTransformFeedback });
    340   ADD_VEC_INIT(DecorationXfbStride, { CapabilityTransformFeedback });
    341   ADD_VEC_INIT(DecorationFuncParamAttr, { CapabilityKernel });
    342   ADD_VEC_INIT(DecorationFPRoundingMode, { CapabilityKernel });
    343   ADD_VEC_INIT(DecorationFPFastMathMode, { CapabilityKernel });
    344   ADD_VEC_INIT(DecorationLinkageAttributes, { CapabilityLinkage });
    345   ADD_VEC_INIT(DecorationNoContraction, { CapabilityShader });
    346   ADD_VEC_INIT(DecorationInputAttachmentIndex, { CapabilityInputAttachment });
    347   ADD_VEC_INIT(DecorationAlignment, { CapabilityKernel });
    348 }
    349 
    350 template<> inline void
    351 SPIRVMap<BuiltIn, SPIRVCapVec>::init() {
    352   ADD_VEC_INIT(BuiltInPosition, { CapabilityShader });
    353   ADD_VEC_INIT(BuiltInPointSize, { CapabilityShader });
    354   ADD_VEC_INIT(BuiltInClipDistance, { CapabilityClipDistance });
    355   ADD_VEC_INIT(BuiltInCullDistance, { CapabilityCullDistance });
    356   ADD_VEC_INIT(BuiltInVertexId, { CapabilityShader });
    357   ADD_VEC_INIT(BuiltInInstanceId, { CapabilityShader });
    358   ADD_VEC_INIT(BuiltInPrimitiveId, { CapabilityGeometry, CapabilityTessellation });
    359   ADD_VEC_INIT(BuiltInInvocationId, { CapabilityGeometry, CapabilityTessellation });
    360   ADD_VEC_INIT(BuiltInLayer, { CapabilityGeometry });
    361   ADD_VEC_INIT(BuiltInViewportIndex, { CapabilityMultiViewport });
    362   ADD_VEC_INIT(BuiltInTessLevelOuter, { CapabilityTessellation });
    363   ADD_VEC_INIT(BuiltInTessLevelInner, { CapabilityTessellation });
    364   ADD_VEC_INIT(BuiltInTessCoord, { CapabilityTessellation });
    365   ADD_VEC_INIT(BuiltInPatchVertices, { CapabilityTessellation });
    366   ADD_VEC_INIT(BuiltInFragCoord, { CapabilityShader });
    367   ADD_VEC_INIT(BuiltInPointCoord, { CapabilityShader });
    368   ADD_VEC_INIT(BuiltInFrontFacing, { CapabilityShader });
    369   ADD_VEC_INIT(BuiltInSampleId, { CapabilitySampleRateShading });
    370   ADD_VEC_INIT(BuiltInSamplePosition, { CapabilitySampleRateShading });
    371   ADD_VEC_INIT(BuiltInSampleMask, { CapabilitySampleRateShading });
    372   ADD_VEC_INIT(BuiltInFragDepth, { CapabilityShader });
    373   ADD_VEC_INIT(BuiltInHelperInvocation, { CapabilityShader });
    374   ADD_VEC_INIT(BuiltInWorkDim, { CapabilityKernel });
    375   ADD_VEC_INIT(BuiltInGlobalSize, { CapabilityKernel });
    376   ADD_VEC_INIT(BuiltInEnqueuedWorkgroupSize, { CapabilityKernel });
    377   ADD_VEC_INIT(BuiltInGlobalOffset, { CapabilityKernel });
    378   ADD_VEC_INIT(BuiltInGlobalLinearId, { CapabilityKernel });
    379   ADD_VEC_INIT(BuiltInSubgroupSize, { CapabilityKernel });
    380   ADD_VEC_INIT(BuiltInSubgroupMaxSize, { CapabilityKernel });
    381   ADD_VEC_INIT(BuiltInNumSubgroups, { CapabilityKernel });
    382   ADD_VEC_INIT(BuiltInNumEnqueuedSubgroups, { CapabilityKernel });
    383   ADD_VEC_INIT(BuiltInSubgroupId, { CapabilityKernel });
    384   ADD_VEC_INIT(BuiltInSubgroupLocalInvocationId, { CapabilityKernel });
    385   ADD_VEC_INIT(BuiltInVertexIndex, { CapabilityShader });
    386   ADD_VEC_INIT(BuiltInInstanceIndex, { CapabilityShader });
    387 }
    388 
    389 template<> inline void
    390 SPIRVMap<MemorySemanticsMask, SPIRVCapVec>::init() {
    391   ADD_VEC_INIT(MemorySemanticsUniformMemoryMask, { CapabilityShader });
    392   ADD_VEC_INIT(MemorySemanticsAtomicCounterMemoryMask, { CapabilityAtomicStorage });
    393 }
    394 
    395 #undef ADD_VEC_INIT
    396 
    397 inline unsigned
    398 getImageDimension(SPIRVImageDimKind K) {
    399   switch(K){
    400   case Dim1D:      return 1;
    401   case Dim2D:      return 2;
    402   case Dim3D:      return 3;
    403   case DimCube:    return 2;
    404   case DimRect:    return 2;
    405   case DimBuffer:  return 1;
    406   default:              return 0;
    407   }
    408 }
    409 
    410 /// Extract memory order part of SPIR-V memory semantics.
    411 inline unsigned
    412 extractSPIRVMemOrderSemantic(unsigned Sema) {
    413   return Sema & kSPIRVMemOrderSemanticMask;
    414 }
    415 
    416 
    417 }
    418 
    419 
    420 #endif /* SPIRVENUM_HPP_ */
    421