Home | History | Annotate | Download | only in spirv
      1 /*
      2  * Copyright  2016 Intel Corporation
      3  *
      4  * Permission is hereby granted, free of charge, to any person obtaining a
      5  * copy of this software and associated documentation files (the "Software"),
      6  * to deal in the Software without restriction, including without limitation
      7  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
      8  * and/or sell copies of the Software, and to permit persons to whom the
      9  * Software is furnished to do so, subject to the following conditions:
     10  *
     11  * The above copyright notice and this permission notice (including the next
     12  * paragraph) shall be included in all copies or substantial portions of the
     13  * Software.
     14  *
     15  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
     16  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
     17  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
     18  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
     19  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
     20  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
     21  * IN THE SOFTWARE.
     22  */
     23 
     24 #include "spirv_info.h"
     25 #include "util/macros.h"
     26 
     27 #define CAPABILITY(cap) [SpvCapability##cap] = #cap
     28 static const char * const capability_to_string[] = {
     29    CAPABILITY(Matrix),
     30    CAPABILITY(Shader),
     31    CAPABILITY(Geometry),
     32    CAPABILITY(Tessellation),
     33    CAPABILITY(Addresses),
     34    CAPABILITY(Linkage),
     35    CAPABILITY(Kernel),
     36    CAPABILITY(Vector16),
     37    CAPABILITY(Float16Buffer),
     38    CAPABILITY(Float16),
     39    CAPABILITY(Float64),
     40    CAPABILITY(Int64),
     41    CAPABILITY(Int64Atomics),
     42    CAPABILITY(ImageBasic),
     43    CAPABILITY(ImageReadWrite),
     44    CAPABILITY(ImageMipmap),
     45    CAPABILITY(Pipes),
     46    CAPABILITY(Groups),
     47    CAPABILITY(DeviceEnqueue),
     48    CAPABILITY(LiteralSampler),
     49    CAPABILITY(AtomicStorage),
     50    CAPABILITY(Int16),
     51    CAPABILITY(TessellationPointSize),
     52    CAPABILITY(GeometryPointSize),
     53    CAPABILITY(ImageGatherExtended),
     54    CAPABILITY(StorageImageMultisample),
     55    CAPABILITY(UniformBufferArrayDynamicIndexing),
     56    CAPABILITY(SampledImageArrayDynamicIndexing),
     57    CAPABILITY(StorageBufferArrayDynamicIndexing),
     58    CAPABILITY(StorageImageArrayDynamicIndexing),
     59    CAPABILITY(ClipDistance),
     60    CAPABILITY(CullDistance),
     61    CAPABILITY(ImageCubeArray),
     62    CAPABILITY(SampleRateShading),
     63    CAPABILITY(ImageRect),
     64    CAPABILITY(SampledRect),
     65    CAPABILITY(GenericPointer),
     66    CAPABILITY(Int8),
     67    CAPABILITY(InputAttachment),
     68    CAPABILITY(SparseResidency),
     69    CAPABILITY(MinLod),
     70    CAPABILITY(Sampled1D),
     71    CAPABILITY(Image1D),
     72    CAPABILITY(SampledCubeArray),
     73    CAPABILITY(SampledBuffer),
     74    CAPABILITY(ImageBuffer),
     75    CAPABILITY(ImageMSArray),
     76    CAPABILITY(StorageImageExtendedFormats),
     77    CAPABILITY(ImageQuery),
     78    CAPABILITY(DerivativeControl),
     79    CAPABILITY(InterpolationFunction),
     80    CAPABILITY(TransformFeedback),
     81    CAPABILITY(GeometryStreams),
     82    CAPABILITY(StorageImageReadWithoutFormat),
     83    CAPABILITY(StorageImageWriteWithoutFormat),
     84    CAPABILITY(MultiViewport),
     85 };
     86 
     87 const char *
     88 spirv_capability_to_string(SpvCapability cap)
     89 {
     90    if (cap < ARRAY_SIZE(capability_to_string))
     91       return capability_to_string[cap];
     92    else
     93       return "unknown";
     94 }
     95 
     96 #define DECORATION(dec) [SpvDecoration##dec] = #dec
     97 static const char * const decoration_to_string[] = {
     98    DECORATION(RelaxedPrecision),
     99    DECORATION(SpecId),
    100    DECORATION(Block),
    101    DECORATION(BufferBlock),
    102    DECORATION(RowMajor),
    103    DECORATION(ColMajor),
    104    DECORATION(ArrayStride),
    105    DECORATION(MatrixStride),
    106    DECORATION(GLSLShared),
    107    DECORATION(GLSLPacked),
    108    DECORATION(CPacked),
    109    DECORATION(BuiltIn),
    110    DECORATION(NoPerspective),
    111    DECORATION(Flat),
    112    DECORATION(Patch),
    113    DECORATION(Centroid),
    114    DECORATION(Sample),
    115    DECORATION(Invariant),
    116    DECORATION(Restrict),
    117    DECORATION(Aliased),
    118    DECORATION(Volatile),
    119    DECORATION(Constant),
    120    DECORATION(Coherent),
    121    DECORATION(NonWritable),
    122    DECORATION(NonReadable),
    123    DECORATION(Uniform),
    124    DECORATION(SaturatedConversion),
    125    DECORATION(Stream),
    126    DECORATION(Location),
    127    DECORATION(Component),
    128    DECORATION(Index),
    129    DECORATION(Binding),
    130    DECORATION(DescriptorSet),
    131    DECORATION(Offset),
    132    DECORATION(XfbBuffer),
    133    DECORATION(XfbStride),
    134    DECORATION(FuncParamAttr),
    135    DECORATION(FPRoundingMode),
    136    DECORATION(FPFastMathMode),
    137    DECORATION(LinkageAttributes),
    138    DECORATION(NoContraction),
    139    DECORATION(InputAttachmentIndex),
    140    DECORATION(Alignment),
    141 };
    142 
    143 const char *
    144 spirv_decoration_to_string(SpvDecoration dec)
    145 {
    146    if (dec < ARRAY_SIZE(decoration_to_string))
    147       return decoration_to_string[dec];
    148    else
    149       return "unknown";
    150 }
    151