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 EbtHitObjectNV,
69 EbtCoopmat,
70 // SPIR-V type defined by spirv_type
71 EbtSpirvType,
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 EvqSpirvStorageClass, // spirv_storage_class
99
100 EvqPayload,
101 EvqPayloadIn,
102 EvqHitAttr,
103 EvqCallableData,
104 EvqCallableDataIn,
105 EvqHitObjectAttrNV,
106
107 EvqtaskPayloadSharedEXT,
108
109 // parameters
110 EvqIn, // also, for 'in' in the grammar before we know if it's a pipeline input or an 'in' parameter
111 EvqOut, // also, for 'out' in the grammar before we know if it's a pipeline output or an 'out' parameter
112 EvqInOut,
113 EvqConstReadOnly, // input; also other read-only types having neither a constant value nor constant-value semantics
114
115 // built-ins read by vertex shader
116 EvqVertexId,
117 EvqInstanceId,
118
119 // built-ins written by vertex shader
120 EvqPosition,
121 EvqPointSize,
122 EvqClipVertex,
123
124 // built-ins read by fragment shader
125 EvqFace,
126 EvqFragCoord,
127 EvqPointCoord,
128
129 // built-ins written by fragment shader
130 EvqFragColor,
131 EvqFragDepth,
132 EvqFragStencil,
133
134 EvqTileImageEXT,
135
136 // end of list
137 EvqLast
138 };
139
140 //
141 // Subcategories of the TStorageQualifier, simply to give a direct mapping
142 // between built-in variable names and an numerical value (the enum).
143 //
144 // For backward compatibility, there is some redundancy between the
145 // TStorageQualifier and these. Existing members should both be maintained accurately.
146 // However, any new built-in variable (and any existing non-redundant one)
147 // must follow the pattern that the specific built-in is here, and only its
148 // general qualifier is in TStorageQualifier.
149 //
150 // Something like gl_Position, which is sometimes 'in' and sometimes 'out'
151 // shows up as two different built-in variables in a single stage, but
152 // only has a single enum in TBuiltInVariable, so both the
153 // TStorageQualifier and the TBuitinVariable are needed to distinguish
154 // between them.
155 //
156 enum TBuiltInVariable {
157 EbvNone,
158 EbvNumWorkGroups,
159 EbvWorkGroupSize,
160 EbvWorkGroupId,
161 EbvLocalInvocationId,
162 EbvGlobalInvocationId,
163 EbvLocalInvocationIndex,
164 EbvNumSubgroups,
165 EbvSubgroupID,
166 EbvSubGroupSize,
167 EbvSubGroupInvocation,
168 EbvSubGroupEqMask,
169 EbvSubGroupGeMask,
170 EbvSubGroupGtMask,
171 EbvSubGroupLeMask,
172 EbvSubGroupLtMask,
173 EbvSubgroupSize2,
174 EbvSubgroupInvocation2,
175 EbvSubgroupEqMask2,
176 EbvSubgroupGeMask2,
177 EbvSubgroupGtMask2,
178 EbvSubgroupLeMask2,
179 EbvSubgroupLtMask2,
180 EbvVertexId,
181 EbvInstanceId,
182 EbvVertexIndex,
183 EbvInstanceIndex,
184 EbvBaseVertex,
185 EbvBaseInstance,
186 EbvDrawId,
187 EbvPosition,
188 EbvPointSize,
189 EbvClipVertex,
190 EbvClipDistance,
191 EbvCullDistance,
192 EbvNormal,
193 EbvVertex,
194 EbvMultiTexCoord0,
195 EbvMultiTexCoord1,
196 EbvMultiTexCoord2,
197 EbvMultiTexCoord3,
198 EbvMultiTexCoord4,
199 EbvMultiTexCoord5,
200 EbvMultiTexCoord6,
201 EbvMultiTexCoord7,
202 EbvFrontColor,
203 EbvBackColor,
204 EbvFrontSecondaryColor,
205 EbvBackSecondaryColor,
206 EbvTexCoord,
207 EbvFogFragCoord,
208 EbvInvocationId,
209 EbvPrimitiveId,
210 EbvLayer,
211 EbvViewportIndex,
212 EbvPatchVertices,
213 EbvTessLevelOuter,
214 EbvTessLevelInner,
215 EbvBoundingBox,
216 EbvTessCoord,
217 EbvColor,
218 EbvSecondaryColor,
219 EbvFace,
220 EbvFragCoord,
221 EbvPointCoord,
222 EbvFragColor,
223 EbvFragData,
224 EbvFragDepth,
225 EbvFragStencilRef,
226 EbvSampleId,
227 EbvSamplePosition,
228 EbvSampleMask,
229 EbvHelperInvocation,
230
231 EbvBaryCoordNoPersp,
232 EbvBaryCoordNoPerspCentroid,
233 EbvBaryCoordNoPerspSample,
234 EbvBaryCoordSmooth,
235 EbvBaryCoordSmoothCentroid,
236 EbvBaryCoordSmoothSample,
237 EbvBaryCoordPullModel,
238
239 EbvViewIndex,
240 EbvDeviceIndex,
241
242 EbvShadingRateKHR,
243 EbvPrimitiveShadingRateKHR,
244
245 EbvFragSizeEXT,
246 EbvFragInvocationCountEXT,
247
248 EbvSecondaryFragDataEXT,
249 EbvSecondaryFragColorEXT,
250
251 EbvViewportMaskNV,
252 EbvSecondaryPositionNV,
253 EbvSecondaryViewportMaskNV,
254 EbvPositionPerViewNV,
255 EbvViewportMaskPerViewNV,
256 EbvFragFullyCoveredNV,
257 EbvFragmentSizeNV,
258 EbvInvocationsPerPixelNV,
259 // ray tracing
260 EbvLaunchId,
261 EbvLaunchSize,
262 EbvInstanceCustomIndex,
263 EbvGeometryIndex,
264 EbvWorldRayOrigin,
265 EbvWorldRayDirection,
266 EbvObjectRayOrigin,
267 EbvObjectRayDirection,
268 EbvRayTmin,
269 EbvRayTmax,
270 EbvCullMask,
271 EbvHitT,
272 EbvHitKind,
273 EbvObjectToWorld,
274 EbvObjectToWorld3x4,
275 EbvWorldToObject,
276 EbvWorldToObject3x4,
277 EbvIncomingRayFlags,
278 EbvCurrentRayTimeNV,
279 // barycentrics
280 EbvBaryCoordNV,
281 EbvBaryCoordNoPerspNV,
282 EbvBaryCoordEXT,
283 EbvBaryCoordNoPerspEXT,
284 // mesh shaders
285 EbvTaskCountNV,
286 EbvPrimitiveCountNV,
287 EbvPrimitiveIndicesNV,
288 EbvClipDistancePerViewNV,
289 EbvCullDistancePerViewNV,
290 EbvLayerPerViewNV,
291 EbvMeshViewCountNV,
292 EbvMeshViewIndicesNV,
293
294 EbvMicroTrianglePositionNV,
295 EbvMicroTriangleBaryNV,
296 EbvHitKindFrontFacingMicroTriangleNV,
297 EbvHitKindBackFacingMicroTriangleNV,
298
299 //GL_EXT_mesh_shader
300 EbvPrimitivePointIndicesEXT,
301 EbvPrimitiveLineIndicesEXT,
302 EbvPrimitiveTriangleIndicesEXT,
303 EbvCullPrimitiveEXT,
304
305 // sm builtins
306 EbvWarpsPerSM,
307 EbvSMCount,
308 EbvWarpID,
309 EbvSMID,
310
311 // HLSL built-ins that live only temporarily, until they get remapped
312 // to one of the above.
313 EbvFragDepthGreater,
314 EbvFragDepthLesser,
315 EbvGsOutputStream,
316 EbvOutputPatch,
317 EbvInputPatch,
318
319 // structbuffer types
320 EbvAppendConsume, // no need to differentiate append and consume
321 EbvRWStructuredBuffer,
322 EbvStructuredBuffer,
323 EbvByteAddressBuffer,
324 EbvRWByteAddressBuffer,
325
326 // ARM specific core builtins
327 EbvCoreCountARM,
328 EbvCoreIDARM,
329 EbvCoreMaxIDARM,
330 EbvWarpIDARM,
331 EbvWarpMaxIDARM,
332
333 EbvPositionFetch,
334
335 EbvLast
336 };
337
338 // In this enum, order matters; users can assume higher precision is a bigger value
339 // and EpqNone is 0.
340 enum TPrecisionQualifier {
341 EpqNone = 0,
342 EpqLow,
343 EpqMedium,
344 EpqHigh
345 };
346
347 // These will show up in error messages
GetStorageQualifierString(TStorageQualifier q)348 __inline const char* GetStorageQualifierString(TStorageQualifier q)
349 {
350 switch (q) {
351 case EvqTemporary: return "temp"; break;
352 case EvqGlobal: return "global"; break;
353 case EvqConst: return "const"; break;
354 case EvqConstReadOnly: return "const (read only)"; break;
355 case EvqSpirvStorageClass: return "spirv_storage_class"; break;
356 case EvqVaryingIn: return "in"; break;
357 case EvqVaryingOut: return "out"; break;
358 case EvqUniform: return "uniform"; break;
359 case EvqBuffer: return "buffer"; break;
360 case EvqShared: return "shared"; break;
361 case EvqIn: return "in"; break;
362 case EvqOut: return "out"; break;
363 case EvqInOut: return "inout"; break;
364 case EvqVertexId: return "gl_VertexId"; break;
365 case EvqInstanceId: return "gl_InstanceId"; break;
366 case EvqPosition: return "gl_Position"; break;
367 case EvqPointSize: return "gl_PointSize"; break;
368 case EvqClipVertex: return "gl_ClipVertex"; break;
369 case EvqFace: return "gl_FrontFacing"; break;
370 case EvqFragCoord: return "gl_FragCoord"; break;
371 case EvqPointCoord: return "gl_PointCoord"; break;
372 case EvqFragColor: return "fragColor"; break;
373 case EvqFragDepth: return "gl_FragDepth"; break;
374 case EvqFragStencil: return "gl_FragStencilRefARB"; break;
375 case EvqPayload: return "rayPayloadNV"; break;
376 case EvqPayloadIn: return "rayPayloadInNV"; break;
377 case EvqHitAttr: return "hitAttributeNV"; break;
378 case EvqCallableData: return "callableDataNV"; break;
379 case EvqCallableDataIn: return "callableDataInNV"; break;
380 case EvqtaskPayloadSharedEXT: return "taskPayloadSharedEXT"; break;
381 case EvqHitObjectAttrNV:return "hitObjectAttributeNV"; break;
382 default: return "unknown qualifier";
383 }
384 }
385
GetBuiltInVariableString(TBuiltInVariable v)386 __inline const char* GetBuiltInVariableString(TBuiltInVariable v)
387 {
388 switch (v) {
389 case EbvNone: return "";
390 case EbvNumWorkGroups: return "NumWorkGroups";
391 case EbvWorkGroupSize: return "WorkGroupSize";
392 case EbvWorkGroupId: return "WorkGroupID";
393 case EbvLocalInvocationId: return "LocalInvocationID";
394 case EbvGlobalInvocationId: return "GlobalInvocationID";
395 case EbvLocalInvocationIndex: return "LocalInvocationIndex";
396 case EbvNumSubgroups: return "NumSubgroups";
397 case EbvSubgroupID: return "SubgroupID";
398 case EbvSubGroupSize: return "SubGroupSize";
399 case EbvSubGroupInvocation: return "SubGroupInvocation";
400 case EbvSubGroupEqMask: return "SubGroupEqMask";
401 case EbvSubGroupGeMask: return "SubGroupGeMask";
402 case EbvSubGroupGtMask: return "SubGroupGtMask";
403 case EbvSubGroupLeMask: return "SubGroupLeMask";
404 case EbvSubGroupLtMask: return "SubGroupLtMask";
405 case EbvSubgroupSize2: return "SubgroupSize";
406 case EbvSubgroupInvocation2: return "SubgroupInvocationID";
407 case EbvSubgroupEqMask2: return "SubgroupEqMask";
408 case EbvSubgroupGeMask2: return "SubgroupGeMask";
409 case EbvSubgroupGtMask2: return "SubgroupGtMask";
410 case EbvSubgroupLeMask2: return "SubgroupLeMask";
411 case EbvSubgroupLtMask2: return "SubgroupLtMask";
412 case EbvVertexId: return "VertexId";
413 case EbvInstanceId: return "InstanceId";
414 case EbvVertexIndex: return "VertexIndex";
415 case EbvInstanceIndex: return "InstanceIndex";
416 case EbvBaseVertex: return "BaseVertex";
417 case EbvBaseInstance: return "BaseInstance";
418 case EbvDrawId: return "DrawId";
419 case EbvPosition: return "Position";
420 case EbvPointSize: return "PointSize";
421 case EbvClipVertex: return "ClipVertex";
422 case EbvClipDistance: return "ClipDistance";
423 case EbvCullDistance: return "CullDistance";
424 case EbvNormal: return "Normal";
425 case EbvVertex: return "Vertex";
426 case EbvMultiTexCoord0: return "MultiTexCoord0";
427 case EbvMultiTexCoord1: return "MultiTexCoord1";
428 case EbvMultiTexCoord2: return "MultiTexCoord2";
429 case EbvMultiTexCoord3: return "MultiTexCoord3";
430 case EbvMultiTexCoord4: return "MultiTexCoord4";
431 case EbvMultiTexCoord5: return "MultiTexCoord5";
432 case EbvMultiTexCoord6: return "MultiTexCoord6";
433 case EbvMultiTexCoord7: return "MultiTexCoord7";
434 case EbvFrontColor: return "FrontColor";
435 case EbvBackColor: return "BackColor";
436 case EbvFrontSecondaryColor: return "FrontSecondaryColor";
437 case EbvBackSecondaryColor: return "BackSecondaryColor";
438 case EbvTexCoord: return "TexCoord";
439 case EbvFogFragCoord: return "FogFragCoord";
440 case EbvInvocationId: return "InvocationID";
441 case EbvPrimitiveId: return "PrimitiveID";
442 case EbvLayer: return "Layer";
443 case EbvViewportIndex: return "ViewportIndex";
444 case EbvPatchVertices: return "PatchVertices";
445 case EbvTessLevelOuter: return "TessLevelOuter";
446 case EbvTessLevelInner: return "TessLevelInner";
447 case EbvBoundingBox: return "BoundingBox";
448 case EbvTessCoord: return "TessCoord";
449 case EbvColor: return "Color";
450 case EbvSecondaryColor: return "SecondaryColor";
451 case EbvFace: return "Face";
452 case EbvFragCoord: return "FragCoord";
453 case EbvPointCoord: return "PointCoord";
454 case EbvFragColor: return "FragColor";
455 case EbvFragData: return "FragData";
456 case EbvFragDepth: return "FragDepth";
457 case EbvFragStencilRef: return "FragStencilRef";
458 case EbvSampleId: return "SampleId";
459 case EbvSamplePosition: return "SamplePosition";
460 case EbvSampleMask: return "SampleMaskIn";
461 case EbvHelperInvocation: return "HelperInvocation";
462
463 case EbvBaryCoordNoPersp: return "BaryCoordNoPersp";
464 case EbvBaryCoordNoPerspCentroid: return "BaryCoordNoPerspCentroid";
465 case EbvBaryCoordNoPerspSample: return "BaryCoordNoPerspSample";
466 case EbvBaryCoordSmooth: return "BaryCoordSmooth";
467 case EbvBaryCoordSmoothCentroid: return "BaryCoordSmoothCentroid";
468 case EbvBaryCoordSmoothSample: return "BaryCoordSmoothSample";
469 case EbvBaryCoordPullModel: return "BaryCoordPullModel";
470
471 case EbvViewIndex: return "ViewIndex";
472 case EbvDeviceIndex: return "DeviceIndex";
473
474 case EbvFragSizeEXT: return "FragSizeEXT";
475 case EbvFragInvocationCountEXT: return "FragInvocationCountEXT";
476
477 case EbvSecondaryFragDataEXT: return "SecondaryFragDataEXT";
478 case EbvSecondaryFragColorEXT: return "SecondaryFragColorEXT";
479
480 case EbvViewportMaskNV: return "ViewportMaskNV";
481 case EbvSecondaryPositionNV: return "SecondaryPositionNV";
482 case EbvSecondaryViewportMaskNV: return "SecondaryViewportMaskNV";
483 case EbvPositionPerViewNV: return "PositionPerViewNV";
484 case EbvViewportMaskPerViewNV: return "ViewportMaskPerViewNV";
485 case EbvFragFullyCoveredNV: return "FragFullyCoveredNV";
486 case EbvFragmentSizeNV: return "FragmentSizeNV";
487 case EbvInvocationsPerPixelNV: return "InvocationsPerPixelNV";
488 case EbvLaunchId: return "LaunchIdNV";
489 case EbvLaunchSize: return "LaunchSizeNV";
490 case EbvInstanceCustomIndex: return "InstanceCustomIndexNV";
491 case EbvGeometryIndex: return "GeometryIndexEXT";
492 case EbvWorldRayOrigin: return "WorldRayOriginNV";
493 case EbvWorldRayDirection: return "WorldRayDirectionNV";
494 case EbvObjectRayOrigin: return "ObjectRayOriginNV";
495 case EbvObjectRayDirection: return "ObjectRayDirectionNV";
496 case EbvRayTmin: return "ObjectRayTminNV";
497 case EbvRayTmax: return "ObjectRayTmaxNV";
498 case EbvHitT: return "HitTNV";
499 case EbvHitKind: return "HitKindNV";
500 case EbvIncomingRayFlags: return "IncomingRayFlagsNV";
501 case EbvObjectToWorld: return "ObjectToWorldNV";
502 case EbvWorldToObject: return "WorldToObjectNV";
503 case EbvCurrentRayTimeNV: return "CurrentRayTimeNV";
504
505 case EbvBaryCoordEXT:
506 case EbvBaryCoordNV: return "BaryCoordKHR";
507 case EbvBaryCoordNoPerspEXT:
508 case EbvBaryCoordNoPerspNV: return "BaryCoordNoPerspKHR";
509
510 case EbvTaskCountNV: return "TaskCountNV";
511 case EbvPrimitiveCountNV: return "PrimitiveCountNV";
512 case EbvPrimitiveIndicesNV: return "PrimitiveIndicesNV";
513 case EbvClipDistancePerViewNV: return "ClipDistancePerViewNV";
514 case EbvCullDistancePerViewNV: return "CullDistancePerViewNV";
515 case EbvLayerPerViewNV: return "LayerPerViewNV";
516 case EbvMeshViewCountNV: return "MeshViewCountNV";
517 case EbvMeshViewIndicesNV: return "MeshViewIndicesNV";
518 // GL_EXT_mesh_shader
519 case EbvPrimitivePointIndicesEXT: return "PrimitivePointIndicesEXT";
520 case EbvPrimitiveLineIndicesEXT: return "PrimitiveLineIndicesEXT";
521 case EbvPrimitiveTriangleIndicesEXT: return "PrimitiveTriangleIndicesEXT";
522 case EbvCullPrimitiveEXT: return "CullPrimitiveEXT";
523
524 case EbvWarpsPerSM: return "WarpsPerSMNV";
525 case EbvSMCount: return "SMCountNV";
526 case EbvWarpID: return "WarpIDNV";
527 case EbvSMID: return "SMIDNV";
528
529 case EbvShadingRateKHR: return "ShadingRateKHR";
530 case EbvPrimitiveShadingRateKHR: return "PrimitiveShadingRateKHR";
531
532 case EbvHitKindFrontFacingMicroTriangleNV: return "HitKindFrontFacingMicroTriangleNV";
533 case EbvHitKindBackFacingMicroTriangleNV: return "HitKindBackFacingMicroTriangleNV";
534
535 default: return "unknown built-in variable";
536 }
537 }
538
GetPrecisionQualifierString(TPrecisionQualifier p)539 __inline const char* GetPrecisionQualifierString(TPrecisionQualifier p)
540 {
541 switch (p) {
542 case EpqNone: return ""; break;
543 case EpqLow: return "lowp"; break;
544 case EpqMedium: return "mediump"; break;
545 case EpqHigh: return "highp"; break;
546 default: return "unknown precision qualifier";
547 }
548 }
549
isTypeSignedInt(TBasicType type)550 __inline bool isTypeSignedInt(TBasicType type)
551 {
552 switch (type) {
553 case EbtInt8:
554 case EbtInt16:
555 case EbtInt:
556 case EbtInt64:
557 return true;
558 default:
559 return false;
560 }
561 }
562
isTypeUnsignedInt(TBasicType type)563 __inline bool isTypeUnsignedInt(TBasicType type)
564 {
565 switch (type) {
566 case EbtUint8:
567 case EbtUint16:
568 case EbtUint:
569 case EbtUint64:
570 return true;
571 default:
572 return false;
573 }
574 }
575
isTypeInt(TBasicType type)576 __inline bool isTypeInt(TBasicType type)
577 {
578 return isTypeSignedInt(type) || isTypeUnsignedInt(type);
579 }
580
isTypeFloat(TBasicType type)581 __inline bool isTypeFloat(TBasicType type)
582 {
583 switch (type) {
584 case EbtFloat:
585 case EbtDouble:
586 case EbtFloat16:
587 return true;
588 default:
589 return false;
590 }
591 }
592
getTypeRank(TBasicType type)593 __inline int getTypeRank(TBasicType type)
594 {
595 int res = -1;
596 switch(type) {
597 case EbtInt8:
598 case EbtUint8:
599 res = 0;
600 break;
601 case EbtInt16:
602 case EbtUint16:
603 res = 1;
604 break;
605 case EbtInt:
606 case EbtUint:
607 res = 2;
608 break;
609 case EbtInt64:
610 case EbtUint64:
611 res = 3;
612 break;
613 default:
614 assert(false);
615 break;
616 }
617 return res;
618 }
619
620 } // end namespace glslang
621
622 #endif // _BASICTYPES_INCLUDED_
623