• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 //
2 // Copyright (C) 2002-2005  3Dlabs Inc. Ltd.
3 // Copyright (C) 2012-2013 LunarG, Inc.
4 // Copyright (C) 2017 ARM Limited.
5 // Modifications Copyright (C) 2020 Advanced Micro Devices, Inc. All rights reserved.
6 //
7 // All rights reserved.
8 //
9 // Redistribution and use in source and binary forms, with or without
10 // modification, are permitted provided that the following conditions
11 // are met:
12 //
13 //    Redistributions of source code must retain the above copyright
14 //    notice, this list of conditions and the following disclaimer.
15 //
16 //    Redistributions in binary form must reproduce the above
17 //    copyright notice, this list of conditions and the following
18 //    disclaimer in the documentation and/or other materials provided
19 //    with the distribution.
20 //
21 //    Neither the name of 3Dlabs Inc. Ltd. nor the names of its
22 //    contributors may be used to endorse or promote products derived
23 //    from this software without specific prior written permission.
24 //
25 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
26 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
27 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
28 // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
29 // COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
30 // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
31 // BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
32 // LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
33 // CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
34 // LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
35 // ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
36 // POSSIBILITY OF SUCH DAMAGE.
37 //
38 
39 #ifndef _BASICTYPES_INCLUDED_
40 #define _BASICTYPES_INCLUDED_
41 
42 namespace glslang {
43 
44 //
45 // Basic type.  Arrays, vectors, sampler details, etc., are orthogonal to this.
46 //
47 enum TBasicType {
48     EbtVoid,
49     EbtFloat,
50     EbtDouble,
51     EbtFloat16,
52     EbtInt8,
53     EbtUint8,
54     EbtInt16,
55     EbtUint16,
56     EbtInt,
57     EbtUint,
58     EbtInt64,
59     EbtUint64,
60     EbtBool,
61     EbtAtomicUint,
62     EbtSampler,
63     EbtStruct,
64     EbtBlock,
65     EbtAccStruct,
66     EbtReference,
67     EbtRayQuery,
68 #ifndef GLSLANG_WEB
69     // SPIR-V type defined by spirv_type
70     EbtSpirvType,
71 #endif
72 
73     // HLSL types that live only temporarily.
74     EbtString,
75 
76     EbtNumTypes
77 };
78 
79 //
80 // Storage qualifiers.  Should align with different kinds of storage or
81 // resource or GLSL storage qualifier.  Expansion is deprecated.
82 //
83 // N.B.: You probably DON'T want to add anything here, but rather just add it
84 // to the built-in variables.  See the comment above TBuiltInVariable.
85 //
86 // A new built-in variable will normally be an existing qualifier, like 'in', 'out', etc.
87 // DO NOT follow the design pattern of, say EvqInstanceId, etc.
88 //
89 enum TStorageQualifier {
90     EvqTemporary,     // For temporaries (within a function), read/write
91     EvqGlobal,        // For globals read/write
92     EvqConst,         // User-defined constant values, will be semantically constant and constant folded
93     EvqVaryingIn,     // pipeline input, read only, also supercategory for all built-ins not included in this enum (see TBuiltInVariable)
94     EvqVaryingOut,    // pipeline output, read/write, also supercategory for all built-ins not included in this enum (see TBuiltInVariable)
95     EvqUniform,       // read only, shared with app
96     EvqBuffer,        // read/write, shared with app
97     EvqShared,        // compute shader's read/write 'shared' qualifier
98 #ifndef GLSLANG_WEB
99     EvqSpirvStorageClass, // spirv_storage_class
100 #endif
101 
102     EvqPayload,
103     EvqPayloadIn,
104     EvqHitAttr,
105     EvqCallableData,
106     EvqCallableDataIn,
107 
108     EvqtaskPayloadSharedEXT,
109 
110     // parameters
111     EvqIn,            // also, for 'in' in the grammar before we know if it's a pipeline input or an 'in' parameter
112     EvqOut,           // also, for 'out' in the grammar before we know if it's a pipeline output or an 'out' parameter
113     EvqInOut,
114     EvqConstReadOnly, // input; also other read-only types having neither a constant value nor constant-value semantics
115 
116     // built-ins read by vertex shader
117     EvqVertexId,
118     EvqInstanceId,
119 
120     // built-ins written by vertex shader
121     EvqPosition,
122     EvqPointSize,
123     EvqClipVertex,
124 
125     // built-ins read by fragment shader
126     EvqFace,
127     EvqFragCoord,
128     EvqPointCoord,
129 
130     // built-ins written by fragment shader
131     EvqFragColor,
132     EvqFragDepth,
133     EvqFragStencil,
134 
135     // end of list
136     EvqLast
137 };
138 
139 //
140 // Subcategories of the TStorageQualifier, simply to give a direct mapping
141 // between built-in variable names and an numerical value (the enum).
142 //
143 // For backward compatibility, there is some redundancy between the
144 // TStorageQualifier and these.  Existing members should both be maintained accurately.
145 // However, any new built-in variable (and any existing non-redundant one)
146 // must follow the pattern that the specific built-in is here, and only its
147 // general qualifier is in TStorageQualifier.
148 //
149 // Something like gl_Position, which is sometimes 'in' and sometimes 'out'
150 // shows up as two different built-in variables in a single stage, but
151 // only has a single enum in TBuiltInVariable, so both the
152 // TStorageQualifier and the TBuitinVariable are needed to distinguish
153 // between them.
154 //
155 enum TBuiltInVariable {
156     EbvNone,
157     EbvNumWorkGroups,
158     EbvWorkGroupSize,
159     EbvWorkGroupId,
160     EbvLocalInvocationId,
161     EbvGlobalInvocationId,
162     EbvLocalInvocationIndex,
163     EbvNumSubgroups,
164     EbvSubgroupID,
165     EbvSubGroupSize,
166     EbvSubGroupInvocation,
167     EbvSubGroupEqMask,
168     EbvSubGroupGeMask,
169     EbvSubGroupGtMask,
170     EbvSubGroupLeMask,
171     EbvSubGroupLtMask,
172     EbvSubgroupSize2,
173     EbvSubgroupInvocation2,
174     EbvSubgroupEqMask2,
175     EbvSubgroupGeMask2,
176     EbvSubgroupGtMask2,
177     EbvSubgroupLeMask2,
178     EbvSubgroupLtMask2,
179     EbvVertexId,
180     EbvInstanceId,
181     EbvVertexIndex,
182     EbvInstanceIndex,
183     EbvBaseVertex,
184     EbvBaseInstance,
185     EbvDrawId,
186     EbvPosition,
187     EbvPointSize,
188     EbvClipVertex,
189     EbvClipDistance,
190     EbvCullDistance,
191     EbvNormal,
192     EbvVertex,
193     EbvMultiTexCoord0,
194     EbvMultiTexCoord1,
195     EbvMultiTexCoord2,
196     EbvMultiTexCoord3,
197     EbvMultiTexCoord4,
198     EbvMultiTexCoord5,
199     EbvMultiTexCoord6,
200     EbvMultiTexCoord7,
201     EbvFrontColor,
202     EbvBackColor,
203     EbvFrontSecondaryColor,
204     EbvBackSecondaryColor,
205     EbvTexCoord,
206     EbvFogFragCoord,
207     EbvInvocationId,
208     EbvPrimitiveId,
209     EbvLayer,
210     EbvViewportIndex,
211     EbvPatchVertices,
212     EbvTessLevelOuter,
213     EbvTessLevelInner,
214     EbvBoundingBox,
215     EbvTessCoord,
216     EbvColor,
217     EbvSecondaryColor,
218     EbvFace,
219     EbvFragCoord,
220     EbvPointCoord,
221     EbvFragColor,
222     EbvFragData,
223     EbvFragDepth,
224     EbvFragStencilRef,
225     EbvSampleId,
226     EbvSamplePosition,
227     EbvSampleMask,
228     EbvHelperInvocation,
229 
230     EbvBaryCoordNoPersp,
231     EbvBaryCoordNoPerspCentroid,
232     EbvBaryCoordNoPerspSample,
233     EbvBaryCoordSmooth,
234     EbvBaryCoordSmoothCentroid,
235     EbvBaryCoordSmoothSample,
236     EbvBaryCoordPullModel,
237 
238     EbvViewIndex,
239     EbvDeviceIndex,
240 
241     EbvShadingRateKHR,
242     EbvPrimitiveShadingRateKHR,
243 
244     EbvFragSizeEXT,
245     EbvFragInvocationCountEXT,
246 
247     EbvSecondaryFragDataEXT,
248     EbvSecondaryFragColorEXT,
249 
250     EbvViewportMaskNV,
251     EbvSecondaryPositionNV,
252     EbvSecondaryViewportMaskNV,
253     EbvPositionPerViewNV,
254     EbvViewportMaskPerViewNV,
255     EbvFragFullyCoveredNV,
256     EbvFragmentSizeNV,
257     EbvInvocationsPerPixelNV,
258     // ray tracing
259     EbvLaunchId,
260     EbvLaunchSize,
261     EbvInstanceCustomIndex,
262     EbvGeometryIndex,
263     EbvWorldRayOrigin,
264     EbvWorldRayDirection,
265     EbvObjectRayOrigin,
266     EbvObjectRayDirection,
267     EbvRayTmin,
268     EbvRayTmax,
269     EbvCullMask,
270     EbvHitT,
271     EbvHitKind,
272     EbvObjectToWorld,
273     EbvObjectToWorld3x4,
274     EbvWorldToObject,
275     EbvWorldToObject3x4,
276     EbvIncomingRayFlags,
277     EbvCurrentRayTimeNV,
278     // barycentrics
279     EbvBaryCoordNV,
280     EbvBaryCoordNoPerspNV,
281     EbvBaryCoordEXT,
282     EbvBaryCoordNoPerspEXT,
283     // mesh shaders
284     EbvTaskCountNV,
285     EbvPrimitiveCountNV,
286     EbvPrimitiveIndicesNV,
287     EbvClipDistancePerViewNV,
288     EbvCullDistancePerViewNV,
289     EbvLayerPerViewNV,
290     EbvMeshViewCountNV,
291     EbvMeshViewIndicesNV,
292     //GL_EXT_mesh_shader
293     EbvPrimitivePointIndicesEXT,
294     EbvPrimitiveLineIndicesEXT,
295     EbvPrimitiveTriangleIndicesEXT,
296     EbvCullPrimitiveEXT,
297 
298     // sm builtins
299     EbvWarpsPerSM,
300     EbvSMCount,
301     EbvWarpID,
302     EbvSMID,
303 
304     // HLSL built-ins that live only temporarily, until they get remapped
305     // to one of the above.
306     EbvFragDepthGreater,
307     EbvFragDepthLesser,
308     EbvGsOutputStream,
309     EbvOutputPatch,
310     EbvInputPatch,
311 
312     // structbuffer types
313     EbvAppendConsume, // no need to differentiate append and consume
314     EbvRWStructuredBuffer,
315     EbvStructuredBuffer,
316     EbvByteAddressBuffer,
317     EbvRWByteAddressBuffer,
318 
319     // ARM specific core builtins
320     EbvCoreCountARM,
321     EbvCoreIDARM,
322     EbvCoreMaxIDARM,
323     EbvWarpIDARM,
324     EbvWarpMaxIDARM,
325 
326     EbvLast
327 };
328 
329 // In this enum, order matters; users can assume higher precision is a bigger value
330 // and EpqNone is 0.
331 enum TPrecisionQualifier {
332     EpqNone = 0,
333     EpqLow,
334     EpqMedium,
335     EpqHigh
336 };
337 
338 #ifdef GLSLANG_WEB
GetStorageQualifierString(TStorageQualifier q)339 __inline const char* GetStorageQualifierString(TStorageQualifier q) { return ""; }
GetPrecisionQualifierString(TPrecisionQualifier p)340 __inline const char* GetPrecisionQualifierString(TPrecisionQualifier p) { return ""; }
341 #else
342 // These will show up in error messages
GetStorageQualifierString(TStorageQualifier q)343 __inline const char* GetStorageQualifierString(TStorageQualifier q)
344 {
345     switch (q) {
346     case EvqTemporary:      return "temp";           break;
347     case EvqGlobal:         return "global";         break;
348     case EvqConst:          return "const";          break;
349     case EvqConstReadOnly:  return "const (read only)"; break;
350 #ifndef GLSLANG_WEB
351     case EvqSpirvStorageClass: return "spirv_storage_class"; break;
352 #endif
353     case EvqVaryingIn:      return "in";             break;
354     case EvqVaryingOut:     return "out";            break;
355     case EvqUniform:        return "uniform";        break;
356     case EvqBuffer:         return "buffer";         break;
357     case EvqShared:         return "shared";         break;
358     case EvqIn:             return "in";             break;
359     case EvqOut:            return "out";            break;
360     case EvqInOut:          return "inout";          break;
361     case EvqVertexId:       return "gl_VertexId";    break;
362     case EvqInstanceId:     return "gl_InstanceId";  break;
363     case EvqPosition:       return "gl_Position";    break;
364     case EvqPointSize:      return "gl_PointSize";   break;
365     case EvqClipVertex:     return "gl_ClipVertex";  break;
366     case EvqFace:           return "gl_FrontFacing"; break;
367     case EvqFragCoord:      return "gl_FragCoord";   break;
368     case EvqPointCoord:     return "gl_PointCoord";  break;
369     case EvqFragColor:      return "fragColor";      break;
370     case EvqFragDepth:      return "gl_FragDepth";   break;
371     case EvqFragStencil:    return "gl_FragStencilRefARB"; break;
372     case EvqPayload:        return "rayPayloadNV";     break;
373     case EvqPayloadIn:      return "rayPayloadInNV";   break;
374     case EvqHitAttr:        return "hitAttributeNV";   break;
375     case EvqCallableData:   return "callableDataNV";   break;
376     case EvqCallableDataIn: return "callableDataInNV"; break;
377     case EvqtaskPayloadSharedEXT: return "taskPayloadSharedEXT"; break;
378     default:                return "unknown qualifier";
379     }
380 }
381 
GetBuiltInVariableString(TBuiltInVariable v)382 __inline const char* GetBuiltInVariableString(TBuiltInVariable v)
383 {
384     switch (v) {
385     case EbvNone:                 return "";
386     case EbvNumWorkGroups:        return "NumWorkGroups";
387     case EbvWorkGroupSize:        return "WorkGroupSize";
388     case EbvWorkGroupId:          return "WorkGroupID";
389     case EbvLocalInvocationId:    return "LocalInvocationID";
390     case EbvGlobalInvocationId:   return "GlobalInvocationID";
391     case EbvLocalInvocationIndex: return "LocalInvocationIndex";
392     case EbvNumSubgroups:         return "NumSubgroups";
393     case EbvSubgroupID:           return "SubgroupID";
394     case EbvSubGroupSize:         return "SubGroupSize";
395     case EbvSubGroupInvocation:   return "SubGroupInvocation";
396     case EbvSubGroupEqMask:       return "SubGroupEqMask";
397     case EbvSubGroupGeMask:       return "SubGroupGeMask";
398     case EbvSubGroupGtMask:       return "SubGroupGtMask";
399     case EbvSubGroupLeMask:       return "SubGroupLeMask";
400     case EbvSubGroupLtMask:       return "SubGroupLtMask";
401     case EbvSubgroupSize2:        return "SubgroupSize";
402     case EbvSubgroupInvocation2:  return "SubgroupInvocationID";
403     case EbvSubgroupEqMask2:      return "SubgroupEqMask";
404     case EbvSubgroupGeMask2:      return "SubgroupGeMask";
405     case EbvSubgroupGtMask2:      return "SubgroupGtMask";
406     case EbvSubgroupLeMask2:      return "SubgroupLeMask";
407     case EbvSubgroupLtMask2:      return "SubgroupLtMask";
408     case EbvVertexId:             return "VertexId";
409     case EbvInstanceId:           return "InstanceId";
410     case EbvVertexIndex:          return "VertexIndex";
411     case EbvInstanceIndex:        return "InstanceIndex";
412     case EbvBaseVertex:           return "BaseVertex";
413     case EbvBaseInstance:         return "BaseInstance";
414     case EbvDrawId:               return "DrawId";
415     case EbvPosition:             return "Position";
416     case EbvPointSize:            return "PointSize";
417     case EbvClipVertex:           return "ClipVertex";
418     case EbvClipDistance:         return "ClipDistance";
419     case EbvCullDistance:         return "CullDistance";
420     case EbvNormal:               return "Normal";
421     case EbvVertex:               return "Vertex";
422     case EbvMultiTexCoord0:       return "MultiTexCoord0";
423     case EbvMultiTexCoord1:       return "MultiTexCoord1";
424     case EbvMultiTexCoord2:       return "MultiTexCoord2";
425     case EbvMultiTexCoord3:       return "MultiTexCoord3";
426     case EbvMultiTexCoord4:       return "MultiTexCoord4";
427     case EbvMultiTexCoord5:       return "MultiTexCoord5";
428     case EbvMultiTexCoord6:       return "MultiTexCoord6";
429     case EbvMultiTexCoord7:       return "MultiTexCoord7";
430     case EbvFrontColor:           return "FrontColor";
431     case EbvBackColor:            return "BackColor";
432     case EbvFrontSecondaryColor:  return "FrontSecondaryColor";
433     case EbvBackSecondaryColor:   return "BackSecondaryColor";
434     case EbvTexCoord:             return "TexCoord";
435     case EbvFogFragCoord:         return "FogFragCoord";
436     case EbvInvocationId:         return "InvocationID";
437     case EbvPrimitiveId:          return "PrimitiveID";
438     case EbvLayer:                return "Layer";
439     case EbvViewportIndex:        return "ViewportIndex";
440     case EbvPatchVertices:        return "PatchVertices";
441     case EbvTessLevelOuter:       return "TessLevelOuter";
442     case EbvTessLevelInner:       return "TessLevelInner";
443     case EbvBoundingBox:          return "BoundingBox";
444     case EbvTessCoord:            return "TessCoord";
445     case EbvColor:                return "Color";
446     case EbvSecondaryColor:       return "SecondaryColor";
447     case EbvFace:                 return "Face";
448     case EbvFragCoord:            return "FragCoord";
449     case EbvPointCoord:           return "PointCoord";
450     case EbvFragColor:            return "FragColor";
451     case EbvFragData:             return "FragData";
452     case EbvFragDepth:            return "FragDepth";
453     case EbvFragStencilRef:       return "FragStencilRef";
454     case EbvSampleId:             return "SampleId";
455     case EbvSamplePosition:       return "SamplePosition";
456     case EbvSampleMask:           return "SampleMaskIn";
457     case EbvHelperInvocation:     return "HelperInvocation";
458 
459     case EbvBaryCoordNoPersp:           return "BaryCoordNoPersp";
460     case EbvBaryCoordNoPerspCentroid:   return "BaryCoordNoPerspCentroid";
461     case EbvBaryCoordNoPerspSample:     return "BaryCoordNoPerspSample";
462     case EbvBaryCoordSmooth:            return "BaryCoordSmooth";
463     case EbvBaryCoordSmoothCentroid:    return "BaryCoordSmoothCentroid";
464     case EbvBaryCoordSmoothSample:      return "BaryCoordSmoothSample";
465     case EbvBaryCoordPullModel:         return "BaryCoordPullModel";
466 
467     case EbvViewIndex:                  return "ViewIndex";
468     case EbvDeviceIndex:                return "DeviceIndex";
469 
470     case EbvFragSizeEXT:                return "FragSizeEXT";
471     case EbvFragInvocationCountEXT:     return "FragInvocationCountEXT";
472 
473     case EbvSecondaryFragDataEXT:       return "SecondaryFragDataEXT";
474     case EbvSecondaryFragColorEXT:      return "SecondaryFragColorEXT";
475 
476     case EbvViewportMaskNV:             return "ViewportMaskNV";
477     case EbvSecondaryPositionNV:        return "SecondaryPositionNV";
478     case EbvSecondaryViewportMaskNV:    return "SecondaryViewportMaskNV";
479     case EbvPositionPerViewNV:          return "PositionPerViewNV";
480     case EbvViewportMaskPerViewNV:      return "ViewportMaskPerViewNV";
481     case EbvFragFullyCoveredNV:         return "FragFullyCoveredNV";
482     case EbvFragmentSizeNV:             return "FragmentSizeNV";
483     case EbvInvocationsPerPixelNV:      return "InvocationsPerPixelNV";
484     case EbvLaunchId:                   return "LaunchIdNV";
485     case EbvLaunchSize:                 return "LaunchSizeNV";
486     case EbvInstanceCustomIndex:        return "InstanceCustomIndexNV";
487     case EbvGeometryIndex:              return "GeometryIndexEXT";
488     case EbvWorldRayOrigin:             return "WorldRayOriginNV";
489     case EbvWorldRayDirection:          return "WorldRayDirectionNV";
490     case EbvObjectRayOrigin:            return "ObjectRayOriginNV";
491     case EbvObjectRayDirection:         return "ObjectRayDirectionNV";
492     case EbvRayTmin:                    return "ObjectRayTminNV";
493     case EbvRayTmax:                    return "ObjectRayTmaxNV";
494     case EbvHitT:                       return "HitTNV";
495     case EbvHitKind:                    return "HitKindNV";
496     case EbvIncomingRayFlags:           return "IncomingRayFlagsNV";
497     case EbvObjectToWorld:              return "ObjectToWorldNV";
498     case EbvWorldToObject:              return "WorldToObjectNV";
499     case EbvCurrentRayTimeNV:           return "CurrentRayTimeNV";
500 
501     case EbvBaryCoordEXT:
502     case EbvBaryCoordNV:                return "BaryCoordKHR";
503     case EbvBaryCoordNoPerspEXT:
504     case EbvBaryCoordNoPerspNV:         return "BaryCoordNoPerspKHR";
505 
506     case EbvTaskCountNV:                return "TaskCountNV";
507     case EbvPrimitiveCountNV:           return "PrimitiveCountNV";
508     case EbvPrimitiveIndicesNV:         return "PrimitiveIndicesNV";
509     case EbvClipDistancePerViewNV:      return "ClipDistancePerViewNV";
510     case EbvCullDistancePerViewNV:      return "CullDistancePerViewNV";
511     case EbvLayerPerViewNV:             return "LayerPerViewNV";
512     case EbvMeshViewCountNV:            return "MeshViewCountNV";
513     case EbvMeshViewIndicesNV:          return "MeshViewIndicesNV";
514     // GL_EXT_mesh_shader
515     case EbvPrimitivePointIndicesEXT:    return "PrimitivePointIndicesEXT";
516     case EbvPrimitiveLineIndicesEXT:     return "PrimitiveLineIndicesEXT";
517     case EbvPrimitiveTriangleIndicesEXT: return "PrimitiveTriangleIndicesEXT";
518     case EbvCullPrimitiveEXT:            return "CullPrimitiveEXT";
519 
520     case EbvWarpsPerSM:                 return "WarpsPerSMNV";
521     case EbvSMCount:                    return "SMCountNV";
522     case EbvWarpID:                     return "WarpIDNV";
523     case EbvSMID:                       return "SMIDNV";
524 
525     case EbvShadingRateKHR:             return "ShadingRateKHR";
526     case EbvPrimitiveShadingRateKHR:    return "PrimitiveShadingRateKHR";
527 
528     default:                      return "unknown built-in variable";
529     }
530 }
531 
GetPrecisionQualifierString(TPrecisionQualifier p)532 __inline const char* GetPrecisionQualifierString(TPrecisionQualifier p)
533 {
534     switch (p) {
535     case EpqNone:   return "";        break;
536     case EpqLow:    return "lowp";    break;
537     case EpqMedium: return "mediump"; break;
538     case EpqHigh:   return "highp";   break;
539     default:        return "unknown precision qualifier";
540     }
541 }
542 #endif
543 
isTypeSignedInt(TBasicType type)544 __inline bool isTypeSignedInt(TBasicType type)
545 {
546     switch (type) {
547     case EbtInt8:
548     case EbtInt16:
549     case EbtInt:
550     case EbtInt64:
551         return true;
552     default:
553         return false;
554     }
555 }
556 
isTypeUnsignedInt(TBasicType type)557 __inline bool isTypeUnsignedInt(TBasicType type)
558 {
559     switch (type) {
560     case EbtUint8:
561     case EbtUint16:
562     case EbtUint:
563     case EbtUint64:
564         return true;
565     default:
566         return false;
567     }
568 }
569 
isTypeInt(TBasicType type)570 __inline bool isTypeInt(TBasicType type)
571 {
572     return isTypeSignedInt(type) || isTypeUnsignedInt(type);
573 }
574 
isTypeFloat(TBasicType type)575 __inline bool isTypeFloat(TBasicType type)
576 {
577     switch (type) {
578     case EbtFloat:
579     case EbtDouble:
580     case EbtFloat16:
581         return true;
582     default:
583         return false;
584     }
585 }
586 
getTypeRank(TBasicType type)587 __inline int getTypeRank(TBasicType type)
588 {
589     int res = -1;
590     switch(type) {
591     case EbtInt8:
592     case EbtUint8:
593         res = 0;
594         break;
595     case EbtInt16:
596     case EbtUint16:
597         res = 1;
598         break;
599     case EbtInt:
600     case EbtUint:
601         res = 2;
602         break;
603     case EbtInt64:
604     case EbtUint64:
605         res = 3;
606         break;
607     default:
608         assert(false);
609         break;
610     }
611     return res;
612 }
613 
614 } // end namespace glslang
615 
616 #endif // _BASICTYPES_INCLUDED_
617