Home | History | Annotate | Download | only in Include
      1 //
      2 //Copyright (C) 2002-2005  3Dlabs Inc. Ltd.
      3 //Copyright (C) 2012-2013 LunarG, Inc.
      4 //
      5 //All rights reserved.
      6 //
      7 //Redistribution and use in source and binary forms, with or without
      8 //modification, are permitted provided that the following conditions
      9 //are met:
     10 //
     11 //    Redistributions of source code must retain the above copyright
     12 //    notice, this list of conditions and the following disclaimer.
     13 //
     14 //    Redistributions in binary form must reproduce the above
     15 //    copyright notice, this list of conditions and the following
     16 //    disclaimer in the documentation and/or other materials provided
     17 //    with the distribution.
     18 //
     19 //    Neither the name of 3Dlabs Inc. Ltd. nor the names of its
     20 //    contributors may be used to endorse or promote products derived
     21 //    from this software without specific prior written permission.
     22 //
     23 //THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
     24 //"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
     25 //LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
     26 //FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
     27 //COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
     28 //INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
     29 //BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
     30 //LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
     31 //CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     32 //LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
     33 //ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     34 //POSSIBILITY OF SUCH DAMAGE.
     35 //
     36 
     37 #ifndef _BASICTYPES_INCLUDED_
     38 #define _BASICTYPES_INCLUDED_
     39 
     40 namespace glslang {
     41 
     42 //
     43 // Basic type.  Arrays, vectors, sampler details, etc., are orthogonal to this.
     44 //
     45 enum TBasicType {
     46     EbtVoid,
     47     EbtFloat,
     48     EbtDouble,
     49     EbtInt,
     50     EbtUint,
     51     EbtInt64,
     52     EbtUint64,
     53     EbtBool,
     54     EbtAtomicUint,
     55     EbtSampler,
     56     EbtStruct,
     57     EbtBlock,
     58     EbtNumTypes
     59 };
     60 
     61 //
     62 // Storage qualifiers.  Should align with different kinds of storage or
     63 // resource or GLSL storage qualifier.  Expansion is deprecated.
     64 //
     65 // N.B.: You probably DON'T want to add anything here, but rather just add it
     66 // to the built-in variables.  See the comment above TBuiltInVariable.
     67 //
     68 // A new built-in variable will normally be an existing qualifier, like 'in', 'out', etc.
     69 // DO NOT follow the design pattern of, say EvqInstanceId, etc.
     70 //
     71 enum TStorageQualifier {
     72     EvqTemporary,     // For temporaries (within a function), read/write
     73     EvqGlobal,        // For globals read/write
     74     EvqConst,         // User-defined constant values, will be semantically constant and constant folded
     75     EvqVaryingIn,     // pipeline input, read only, also supercategory for all built-ins not included in this enum (see TBuiltInVariable)
     76     EvqVaryingOut,    // pipeline output, read/write, also supercategory for all built-ins not included in this enum (see TBuiltInVariable)
     77     EvqUniform,       // read only, shared with app
     78     EvqBuffer,        // read/write, shared with app
     79     EvqShared,        // compute shader's read/write 'shared' qualifier
     80 
     81     // parameters
     82     EvqIn,            // also, for 'in' in the grammar before we know if it's a pipeline input or an 'in' parameter
     83     EvqOut,           // also, for 'out' in the grammar before we know if it's a pipeline output or an 'out' parameter
     84     EvqInOut,
     85     EvqConstReadOnly, // input; also other read-only types having neither a constant value nor constant-value semantics
     86 
     87     // built-ins read by vertex shader
     88     EvqVertexId,
     89     EvqInstanceId,
     90 
     91     // built-ins written by vertex shader
     92     EvqPosition,
     93     EvqPointSize,
     94     EvqClipVertex,
     95 
     96     // built-ins read by fragment shader
     97     EvqFace,
     98     EvqFragCoord,
     99     EvqPointCoord,
    100 
    101     // built-ins written by fragment shader
    102     EvqFragColor,
    103     EvqFragDepth,
    104 
    105     // end of list
    106     EvqLast
    107 };
    108 
    109 //
    110 // Subcategories of the TStorageQualifier, simply to give a direct mapping
    111 // between built-in variable names and an numerical value (the enum).
    112 //
    113 // For backward compatibility, there is some redundancy between the
    114 // TStorageQualifier and these.  Existing members should both be maintained accurately.
    115 // However, any new built-in variable (and any existing non-redundant one)
    116 // must follow the pattern that the specific built-in is here, and only its
    117 // general qualifier is in TStorageQualifier.
    118 //
    119 // Something like gl_Position, which is sometimes 'in' and sometimes 'out'
    120 // shows up as two different built-in variables in a single stage, but
    121 // only has a single enum in TBuiltInVariable, so both the
    122 // TStorageQualifier and the TBuitinVariable are needed to distinguish
    123 // between them.
    124 //
    125 enum TBuiltInVariable {
    126     EbvNone,
    127     EbvNumWorkGroups,
    128     EbvWorkGroupSize,
    129     EbvWorkGroupId,
    130     EbvLocalInvocationId,
    131     EbvGlobalInvocationId,
    132     EbvLocalInvocationIndex,
    133     EbvSubGroupSize,
    134     EbvSubGroupInvocation,
    135     EbvSubGroupEqMask,
    136     EbvSubGroupGeMask,
    137     EbvSubGroupGtMask,
    138     EbvSubGroupLeMask,
    139     EbvSubGroupLtMask,
    140     EbvVertexId,
    141     EbvInstanceId,
    142     EbvVertexIndex,
    143     EbvInstanceIndex,
    144     EbvBaseVertex,
    145     EbvBaseInstance,
    146     EbvDrawId,
    147     EbvPosition,
    148     EbvPointSize,
    149     EbvClipVertex,
    150     EbvClipDistance,
    151     EbvCullDistance,
    152     EbvNormal,
    153     EbvVertex,
    154     EbvMultiTexCoord0,
    155     EbvMultiTexCoord1,
    156     EbvMultiTexCoord2,
    157     EbvMultiTexCoord3,
    158     EbvMultiTexCoord4,
    159     EbvMultiTexCoord5,
    160     EbvMultiTexCoord6,
    161     EbvMultiTexCoord7,
    162     EbvFrontColor,
    163     EbvBackColor,
    164     EbvFrontSecondaryColor,
    165     EbvBackSecondaryColor,
    166     EbvTexCoord,
    167     EbvFogFragCoord,
    168     EbvInvocationId,
    169     EbvPrimitiveId,
    170     EbvLayer,
    171     EbvViewportIndex,
    172     EbvPatchVertices,
    173     EbvTessLevelOuter,
    174     EbvTessLevelInner,
    175     EbvBoundingBox,
    176     EbvTessCoord,
    177     EbvColor,
    178     EbvSecondaryColor,
    179     EbvFace,
    180     EbvFragCoord,
    181     EbvPointCoord,
    182     EbvFragColor,
    183     EbvFragData,
    184     EbvFragDepth,
    185     EbvSampleId,
    186     EbvSamplePosition,
    187     EbvSampleMask,
    188     EbvHelperInvocation,
    189 
    190     EbvLast
    191 };
    192 
    193 // These will show up in error messages
    194 __inline const char* GetStorageQualifierString(TStorageQualifier q)
    195 {
    196     switch (q) {
    197     case EvqTemporary:      return "temp";           break;
    198     case EvqGlobal:         return "global";         break;
    199     case EvqConst:          return "const";          break;
    200     case EvqConstReadOnly:  return "const (read only)"; break;
    201     case EvqVaryingIn:      return "in";             break;
    202     case EvqVaryingOut:     return "out";            break;
    203     case EvqUniform:        return "uniform";        break;
    204     case EvqBuffer:         return "buffer";         break;
    205     case EvqShared:         return "shared";         break;
    206     case EvqIn:             return "in";             break;
    207     case EvqOut:            return "out";            break;
    208     case EvqInOut:          return "inout";          break;
    209     case EvqVertexId:       return "gl_VertexId";    break;
    210     case EvqInstanceId:     return "gl_InstanceId";  break;
    211     case EvqPosition:       return "gl_Position";    break;
    212     case EvqPointSize:      return "gl_PointSize";   break;
    213     case EvqClipVertex:     return "gl_ClipVertex";  break;
    214     case EvqFace:           return "gl_FrontFacing"; break;
    215     case EvqFragCoord:      return "gl_FragCoord";   break;
    216     case EvqPointCoord:     return "gl_PointCoord";  break;
    217     case EvqFragColor:      return "fragColor";      break;
    218     case EvqFragDepth:      return "gl_FragDepth";   break;
    219     default:                return "unknown qualifier";
    220     }
    221 }
    222 
    223 __inline const char* GetBuiltInVariableString(TBuiltInVariable v)
    224 {
    225     switch (v) {
    226     case EbvNone:                 return "";
    227     case EbvNumWorkGroups:        return "NumWorkGroups";
    228     case EbvWorkGroupSize:        return "WorkGroupSize";
    229     case EbvWorkGroupId:          return "WorkGroupID";
    230     case EbvLocalInvocationId:    return "LocalInvocationID";
    231     case EbvGlobalInvocationId:   return "GlobalInvocationID";
    232     case EbvLocalInvocationIndex: return "LocalInvocationIndex";
    233     case EbvSubGroupSize:         return "SubGroupSize";
    234     case EbvSubGroupInvocation:   return "SubGroupInvocation";
    235     case EbvSubGroupEqMask:       return "SubGroupEqMask";
    236     case EbvSubGroupGeMask:       return "SubGroupGeMask";
    237     case EbvSubGroupGtMask:       return "SubGroupGtMask";
    238     case EbvSubGroupLeMask:       return "SubGroupLeMask";
    239     case EbvSubGroupLtMask:       return "SubGroupLtMask";
    240     case EbvVertexId:             return "VertexId";
    241     case EbvInstanceId:           return "InstanceId";
    242     case EbvVertexIndex:          return "VertexIndex";
    243     case EbvInstanceIndex:        return "InstanceIndex";
    244     case EbvBaseVertex:           return "BaseVertex";
    245     case EbvBaseInstance:         return "BaseInstance";
    246     case EbvDrawId:               return "DrawId";
    247     case EbvPosition:             return "Position";
    248     case EbvPointSize:            return "PointSize";
    249     case EbvClipVertex:           return "ClipVertex";
    250     case EbvClipDistance:         return "ClipDistance";
    251     case EbvCullDistance:         return "CullDistance";
    252     case EbvNormal:               return "Normal";
    253     case EbvVertex:               return "Vertex";
    254     case EbvMultiTexCoord0:       return "MultiTexCoord0";
    255     case EbvMultiTexCoord1:       return "MultiTexCoord1";
    256     case EbvMultiTexCoord2:       return "MultiTexCoord2";
    257     case EbvMultiTexCoord3:       return "MultiTexCoord3";
    258     case EbvMultiTexCoord4:       return "MultiTexCoord4";
    259     case EbvMultiTexCoord5:       return "MultiTexCoord5";
    260     case EbvMultiTexCoord6:       return "MultiTexCoord6";
    261     case EbvMultiTexCoord7:       return "MultiTexCoord7";
    262     case EbvFrontColor:           return "FrontColor";
    263     case EbvBackColor:            return "BackColor";
    264     case EbvFrontSecondaryColor:  return "FrontSecondaryColor";
    265     case EbvBackSecondaryColor:   return "BackSecondaryColor";
    266     case EbvTexCoord:             return "TexCoord";
    267     case EbvFogFragCoord:         return "FogFragCoord";
    268     case EbvInvocationId:         return "InvocationID";
    269     case EbvPrimitiveId:          return "PrimitiveID";
    270     case EbvLayer:                return "Layer";
    271     case EbvViewportIndex:        return "ViewportIndex";
    272     case EbvPatchVertices:        return "PatchVertices";
    273     case EbvTessLevelOuter:       return "TessLevelOuter";
    274     case EbvTessLevelInner:       return "TessLevelInner";
    275     case EbvBoundingBox:          return "BoundingBox";
    276     case EbvTessCoord:            return "TessCoord";
    277     case EbvColor:                return "Color";
    278     case EbvSecondaryColor:       return "SecondaryColor";
    279     case EbvFace:                 return "Face";
    280     case EbvFragCoord:            return "FragCoord";
    281     case EbvPointCoord:           return "PointCoord";
    282     case EbvFragColor:            return "FragColor";
    283     case EbvFragData:             return "FragData";
    284     case EbvFragDepth:            return "FragDepth";
    285     case EbvSampleId:             return "SampleId";
    286     case EbvSamplePosition:       return "SamplePosition";
    287     case EbvSampleMask:           return "SampleMaskIn";
    288     case EbvHelperInvocation:     return "HelperInvocation";
    289     default:                      return "unknown built-in variable";
    290     }
    291 }
    292 
    293 // In this enum, order matters; users can assume higher precision is a bigger value
    294 // and EpqNone is 0.
    295 enum TPrecisionQualifier {
    296     EpqNone = 0,
    297     EpqLow,
    298     EpqMedium,
    299     EpqHigh
    300 };
    301 
    302 __inline const char* GetPrecisionQualifierString(TPrecisionQualifier p)
    303 {
    304     switch(p) {
    305     case EpqNone:   return "";        break;
    306     case EpqLow:    return "lowp";    break;
    307     case EpqMedium: return "mediump"; break;
    308     case EpqHigh:   return "highp";   break;
    309     default:        return "unknown precision qualifier";
    310     }
    311 }
    312 
    313 } // end namespace glslang
    314 
    315 #endif // _BASICTYPES_INCLUDED_
    316