RetroArch
BaseTypes.h
Go to the documentation of this file.
1 //
2 // Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
3 // Copyright (C) 2012-2013 LunarG, Inc.
4 // Copyright (C) 2017 ARM Limited.
5 //
6 // All rights reserved.
7 //
8 // Redistribution and use in source and binary forms, with or without
9 // modification, are permitted provided that the following conditions
10 // are met:
11 //
12 // Redistributions of source code must retain the above copyright
13 // notice, this list of conditions and the following disclaimer.
14 //
15 // Redistributions in binary form must reproduce the above
16 // copyright notice, this list of conditions and the following
17 // disclaimer in the documentation and/or other materials provided
18 // with the distribution.
19 //
20 // Neither the name of 3Dlabs Inc. Ltd. nor the names of its
21 // contributors may be used to endorse or promote products derived
22 // from this software without specific prior written permission.
23 //
24 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
25 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
26 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
27 // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
28 // COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
29 // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
30 // BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
31 // LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
32 // CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
33 // LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
34 // ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
35 // POSSIBILITY OF SUCH DAMAGE.
36 //
37 
38 #ifndef _BASICTYPES_INCLUDED_
39 #define _BASICTYPES_INCLUDED_
40 
41 namespace glslang {
42 
43 //
44 // Basic type. Arrays, vectors, sampler details, etc., are orthogonal to this.
45 //
46 enum TBasicType {
64 
65  // HLSL types that live only temporarily.
67 
69 };
70 
71 //
72 // Storage qualifiers. Should align with different kinds of storage or
73 // resource or GLSL storage qualifier. Expansion is deprecated.
74 //
75 // N.B.: You probably DON'T want to add anything here, but rather just add it
76 // to the built-in variables. See the comment above TBuiltInVariable.
77 //
78 // A new built-in variable will normally be an existing qualifier, like 'in', 'out', etc.
79 // DO NOT follow the design pattern of, say EvqInstanceId, etc.
80 //
82  EvqTemporary, // For temporaries (within a function), read/write
83  EvqGlobal, // For globals read/write
84  EvqConst, // User-defined constant values, will be semantically constant and constant folded
85  EvqVaryingIn, // pipeline input, read only, also supercategory for all built-ins not included in this enum (see TBuiltInVariable)
86  EvqVaryingOut, // pipeline output, read/write, also supercategory for all built-ins not included in this enum (see TBuiltInVariable)
87  EvqUniform, // read only, shared with app
88  EvqBuffer, // read/write, shared with app
89  EvqShared, // compute shader's read/write 'shared' qualifier
90 
91  // parameters
92  EvqIn, // also, for 'in' in the grammar before we know if it's a pipeline input or an 'in' parameter
93  EvqOut, // also, for 'out' in the grammar before we know if it's a pipeline output or an 'out' parameter
95  EvqConstReadOnly, // input; also other read-only types having neither a constant value nor constant-value semantics
96 
97  // built-ins read by vertex shader
100 
101  // built-ins written by vertex shader
105 
106  // built-ins read by fragment shader
110 
111  // built-ins written by fragment shader
114 
115  // end of list
117 };
118 
119 //
120 // Subcategories of the TStorageQualifier, simply to give a direct mapping
121 // between built-in variable names and an numerical value (the enum).
122 //
123 // For backward compatibility, there is some redundancy between the
124 // TStorageQualifier and these. Existing members should both be maintained accurately.
125 // However, any new built-in variable (and any existing non-redundant one)
126 // must follow the pattern that the specific built-in is here, and only its
127 // general qualifier is in TStorageQualifier.
128 //
129 // Something like gl_Position, which is sometimes 'in' and sometimes 'out'
130 // shows up as two different built-in variables in a single stage, but
131 // only has a single enum in TBuiltInVariable, so both the
132 // TStorageQualifier and the TBuitinVariable are needed to distinguish
133 // between them.
134 //
209 
210 #ifdef AMD_EXTENSIONS
211  EbvBaryCoordNoPersp,
212  EbvBaryCoordNoPerspCentroid,
213  EbvBaryCoordNoPerspSample,
214  EbvBaryCoordSmooth,
215  EbvBaryCoordSmoothCentroid,
216  EbvBaryCoordSmoothSample,
217  EbvBaryCoordPullModel,
218 #endif
219 
222 
223 #ifdef NV_EXTENSIONS
224  EbvViewportMaskNV,
225  EbvSecondaryPositionNV,
226  EbvSecondaryViewportMaskNV,
227  EbvPositionPerViewNV,
228  EbvViewportMaskPerViewNV,
229  EbvFragFullyCoveredNV,
230 #endif
231 
232  // HLSL built-ins that live only temporarily, until they get remapped
233  // to one of the above.
239 
240  // structbuffer types
241  EbvAppendConsume, // no need to differentiate append and consume
246 
248 };
249 
250 // These will show up in error messages
252 {
253  switch (q) {
254  case EvqTemporary: return "temp"; break;
255  case EvqGlobal: return "global"; break;
256  case EvqConst: return "const"; break;
257  case EvqConstReadOnly: return "const (read only)"; break;
258  case EvqVaryingIn: return "in"; break;
259  case EvqVaryingOut: return "out"; break;
260  case EvqUniform: return "uniform"; break;
261  case EvqBuffer: return "buffer"; break;
262  case EvqShared: return "shared"; break;
263  case EvqIn: return "in"; break;
264  case EvqOut: return "out"; break;
265  case EvqInOut: return "inout"; break;
266  case EvqVertexId: return "gl_VertexId"; break;
267  case EvqInstanceId: return "gl_InstanceId"; break;
268  case EvqPosition: return "gl_Position"; break;
269  case EvqPointSize: return "gl_PointSize"; break;
270  case EvqClipVertex: return "gl_ClipVertex"; break;
271  case EvqFace: return "gl_FrontFacing"; break;
272  case EvqFragCoord: return "gl_FragCoord"; break;
273  case EvqPointCoord: return "gl_PointCoord"; break;
274  case EvqFragColor: return "fragColor"; break;
275  case EvqFragDepth: return "gl_FragDepth"; break;
276  default: return "unknown qualifier";
277  }
278 }
279 
281 {
282  switch (v) {
283  case EbvNone: return "";
284  case EbvNumWorkGroups: return "NumWorkGroups";
285  case EbvWorkGroupSize: return "WorkGroupSize";
286  case EbvWorkGroupId: return "WorkGroupID";
287  case EbvLocalInvocationId: return "LocalInvocationID";
288  case EbvGlobalInvocationId: return "GlobalInvocationID";
289  case EbvLocalInvocationIndex: return "LocalInvocationIndex";
290  case EbvSubGroupSize: return "SubGroupSize";
291  case EbvSubGroupInvocation: return "SubGroupInvocation";
292  case EbvSubGroupEqMask: return "SubGroupEqMask";
293  case EbvSubGroupGeMask: return "SubGroupGeMask";
294  case EbvSubGroupGtMask: return "SubGroupGtMask";
295  case EbvSubGroupLeMask: return "SubGroupLeMask";
296  case EbvSubGroupLtMask: return "SubGroupLtMask";
297  case EbvVertexId: return "VertexId";
298  case EbvInstanceId: return "InstanceId";
299  case EbvVertexIndex: return "VertexIndex";
300  case EbvInstanceIndex: return "InstanceIndex";
301  case EbvBaseVertex: return "BaseVertex";
302  case EbvBaseInstance: return "BaseInstance";
303  case EbvDrawId: return "DrawId";
304  case EbvPosition: return "Position";
305  case EbvPointSize: return "PointSize";
306  case EbvClipVertex: return "ClipVertex";
307  case EbvClipDistance: return "ClipDistance";
308  case EbvCullDistance: return "CullDistance";
309  case EbvNormal: return "Normal";
310  case EbvVertex: return "Vertex";
311  case EbvMultiTexCoord0: return "MultiTexCoord0";
312  case EbvMultiTexCoord1: return "MultiTexCoord1";
313  case EbvMultiTexCoord2: return "MultiTexCoord2";
314  case EbvMultiTexCoord3: return "MultiTexCoord3";
315  case EbvMultiTexCoord4: return "MultiTexCoord4";
316  case EbvMultiTexCoord5: return "MultiTexCoord5";
317  case EbvMultiTexCoord6: return "MultiTexCoord6";
318  case EbvMultiTexCoord7: return "MultiTexCoord7";
319  case EbvFrontColor: return "FrontColor";
320  case EbvBackColor: return "BackColor";
321  case EbvFrontSecondaryColor: return "FrontSecondaryColor";
322  case EbvBackSecondaryColor: return "BackSecondaryColor";
323  case EbvTexCoord: return "TexCoord";
324  case EbvFogFragCoord: return "FogFragCoord";
325  case EbvInvocationId: return "InvocationID";
326  case EbvPrimitiveId: return "PrimitiveID";
327  case EbvLayer: return "Layer";
328  case EbvViewportIndex: return "ViewportIndex";
329  case EbvPatchVertices: return "PatchVertices";
330  case EbvTessLevelOuter: return "TessLevelOuter";
331  case EbvTessLevelInner: return "TessLevelInner";
332  case EbvBoundingBox: return "BoundingBox";
333  case EbvTessCoord: return "TessCoord";
334  case EbvColor: return "Color";
335  case EbvSecondaryColor: return "SecondaryColor";
336  case EbvFace: return "Face";
337  case EbvFragCoord: return "FragCoord";
338  case EbvPointCoord: return "PointCoord";
339  case EbvFragColor: return "FragColor";
340  case EbvFragData: return "FragData";
341  case EbvFragDepth: return "FragDepth";
342  case EbvFragStencilRef: return "FragStencilRef";
343  case EbvSampleId: return "SampleId";
344  case EbvSamplePosition: return "SamplePosition";
345  case EbvSampleMask: return "SampleMaskIn";
346  case EbvHelperInvocation: return "HelperInvocation";
347 
348 #ifdef AMD_EXTENSIONS
349  case EbvBaryCoordNoPersp: return "BaryCoordNoPersp";
350  case EbvBaryCoordNoPerspCentroid: return "BaryCoordNoPerspCentroid";
351  case EbvBaryCoordNoPerspSample: return "BaryCoordNoPerspSample";
352  case EbvBaryCoordSmooth: return "BaryCoordSmooth";
353  case EbvBaryCoordSmoothCentroid: return "BaryCoordSmoothCentroid";
354  case EbvBaryCoordSmoothSample: return "BaryCoordSmoothSample";
355  case EbvBaryCoordPullModel: return "BaryCoordPullModel";
356 #endif
357 
358  case EbvViewIndex: return "ViewIndex";
359  case EbvDeviceIndex: return "DeviceIndex";
360 
361 #ifdef NV_EXTENSIONS
362  case EbvViewportMaskNV: return "ViewportMaskNV";
363  case EbvSecondaryPositionNV: return "SecondaryPositionNV";
364  case EbvSecondaryViewportMaskNV: return "SecondaryViewportMaskNV";
365  case EbvPositionPerViewNV: return "PositionPerViewNV";
366  case EbvViewportMaskPerViewNV: return "ViewportMaskPerViewNV";
367  case EbvFragFullyCoveredNV: return "FragFullyCoveredNV";
368 #endif
369  default: return "unknown built-in variable";
370  }
371 }
372 
373 // In this enum, order matters; users can assume higher precision is a bigger value
374 // and EpqNone is 0.
376  EpqNone = 0,
380 };
381 
383 {
384  switch (p) {
385  case EpqNone: return ""; break;
386  case EpqLow: return "lowp"; break;
387  case EpqMedium: return "mediump"; break;
388  case EpqHigh: return "highp"; break;
389  default: return "unknown precision qualifier";
390  }
391 }
392 
394 {
395  switch (type) {
396  case EbtInt8:
397  case EbtInt16:
398  case EbtInt:
399  case EbtInt64:
400  return true;
401  default:
402  return false;
403  }
404 }
405 
407 {
408  switch (type) {
409  case EbtUint8:
410  case EbtUint16:
411  case EbtUint:
412  case EbtUint64:
413  return true;
414  default:
415  return false;
416  }
417 }
418 
419 __inline bool isTypeInt(TBasicType type)
420 {
422 }
423 
425 {
426  switch (type) {
427  case EbtFloat:
428  case EbtDouble:
429  case EbtFloat16:
430  return true;
431  default:
432  return false;
433  }
434 }
435 
436 __inline int getTypeRank(TBasicType type) {
437  int res = -1;
438  switch(type) {
439  case EbtInt8:
440  case EbtUint8:
441  res = 0;
442  break;
443  case EbtInt16:
444  case EbtUint16:
445  res = 1;
446  break;
447  case EbtInt:
448  case EbtUint:
449  res = 2;
450  break;
451  case EbtInt64:
452  case EbtUint64:
453  res = 3;
454  break;
455  default:
456  assert(false);
457  break;
458  }
459  return res;
460 }
461 
462 } // end namespace glslang
463 
464 #endif // _BASICTYPES_INCLUDED_
Definition: BaseTypes.h:165
Definition: BaseTypes.h:182
Definition: BaseTypes.h:58
Definition: BaseTypes.h:53
Definition: BaseTypes.h:86
Definition: BaseTypes.h:234
Definition: BaseTypes.h:61
Definition: BaseTypes.h:162
Definition: BaseTypes.h:379
Definition: BaseTypes.h:55
__inline int getTypeRank(TBasicType type)
Definition: BaseTypes.h:436
Definition: BaseTypes.h:177
Definition: BaseTypes.h:88
Definition: BaseTypes.h:235
Definition: BaseTypes.h:160
Definition: BaseTypes.h:87
Definition: BaseTypes.h:60
Definition: BaseTypes.h:107
Definition: BaseTypes.h:49
Definition: BaseTypes.h:63
__inline bool isTypeInt(TBasicType type)
Definition: BaseTypes.h:419
Definition: BaseTypes.h:156
Definition: BaseTypes.h:112
Definition: BaseTypes.h:52
Definition: BaseTypes.h:148
Definition: BaseTypes.h:145
Definition: BaseTypes.h:189
Definition: BaseTypes.h:247
GLuint res
Definition: glext.h:10520
Definition: BaseTypes.h:242
Definition: BaseTypes.h:109
Definition: BaseTypes.h:200
Definition: BaseTypes.h:47
Definition: BaseTypes.h:140
Definition: BaseTypes.h:102
__inline const char * GetStorageQualifierString(TStorageQualifier q)
Definition: BaseTypes.h:251
Definition: BaseTypes.h:161
Definition: BaseTypes.h:137
Definition: BaseTypes.h:159
Definition: BaseTypes.h:171
Definition: BaseTypes.h:203
TBuiltInVariable
Definition: BaseTypes.h:135
Definition: BaseTypes.h:113
Definition: BaseTypes.h:154
Definition: BaseTypes.h:93
Definition: BaseTypes.h:187
Definition: BaseTypes.h:99
__inline bool isTypeUnsignedInt(TBasicType type)
Definition: BaseTypes.h:406
Definition: BaseTypes.h:221
Definition: BaseTypes.h:188
Definition: BaseTypes.h:184
Definition: BaseTypes.h:139
Definition: BaseTypes.h:175
Definition: BaseTypes.h:82
Definition: BaseTypes.h:104
Definition: BaseTypes.h:179
__inline const char * GetBuiltInVariableString(TBuiltInVariable v)
Definition: BaseTypes.h:280
Definition: BaseTypes.h:195
Definition: BaseTypes.h:191
Definition: BaseTypes.h:158
Definition: BaseTypes.h:244
Definition: BaseTypes.h:51
Definition: BaseTypes.h:56
Definition: BaseTypes.h:116
Definition: BaseTypes.h:147
GLenum type
Definition: glext.h:6233
Definition: BaseTypes.h:172
Definition: BaseTypes.h:169
Definition: BaseTypes.h:207
Definition: BaseTypes.h:83
Definition: BaseTypes.h:173
Definition: BaseTypes.h:206
__inline const char * GetPrecisionQualifierString(TPrecisionQualifier p)
Definition: BaseTypes.h:382
Definition: BaseTypes.h:220
Definition: BaseTypes.h:94
Definition: BaseTypes.h:377
Definition: BaseTypes.h:376
Definition: BaseTypes.h:174
Definition: BaseTypes.h:196
Definition: BaseTypes.h:178
Definition: BaseTypes.h:181
Definition: BaseTypes.h:198
Definition: BaseTypes.h:166
Definition: BaseTypes.h:150
Definition: BaseTypes.h:183
GLdouble GLdouble GLdouble GLdouble q
Definition: glext.h:6414
Definition: BaseTypes.h:92
GLfloat GLfloat p
Definition: glext.h:9809
Definition: BaseTypes.h:164
__inline bool isTypeFloat(TBasicType type)
Definition: BaseTypes.h:424
Definition: BaseTypes.h:243
Definition: BaseTypes.h:168
Definition: BaseTypes.h:142
Definition: BaseTypes.h:108
Definition: arrays.h:46
Definition: BaseTypes.h:167
TStorageQualifier
Definition: BaseTypes.h:81
Definition: BaseTypes.h:66
Definition: BaseTypes.h:186
Definition: BaseTypes.h:138
Definition: BaseTypes.h:157
Definition: BaseTypes.h:190
const GLdouble * v
Definition: glext.h:6391
Definition: BaseTypes.h:103
Definition: BaseTypes.h:378
Definition: BaseTypes.h:199
Definition: BaseTypes.h:89
Definition: BaseTypes.h:149
Definition: BaseTypes.h:193
Definition: BaseTypes.h:236
Definition: BaseTypes.h:95
Definition: BaseTypes.h:192
Definition: BaseTypes.h:163
TPrecisionQualifier
Definition: BaseTypes.h:375
Definition: BaseTypes.h:176
Definition: BaseTypes.h:205
Definition: BaseTypes.h:185
TBasicType
Definition: BaseTypes.h:46
Definition: BaseTypes.h:141
Definition: BaseTypes.h:152
Definition: BaseTypes.h:50
Definition: BaseTypes.h:151
Definition: BaseTypes.h:59
Definition: BaseTypes.h:98
Definition: BaseTypes.h:238
Definition: BaseTypes.h:208
Definition: BaseTypes.h:143
Definition: BaseTypes.h:194
Definition: BaseTypes.h:144
Definition: BaseTypes.h:136
Definition: BaseTypes.h:155
Definition: BaseTypes.h:237
Definition: BaseTypes.h:170
Definition: BaseTypes.h:54
__inline bool isTypeSignedInt(TBasicType type)
Definition: BaseTypes.h:393
Definition: BaseTypes.h:245
Definition: BaseTypes.h:62
Definition: BaseTypes.h:202
Definition: BaseTypes.h:180
Definition: BaseTypes.h:197
Definition: BaseTypes.h:204
Definition: BaseTypes.h:146
Definition: BaseTypes.h:84
Definition: BaseTypes.h:85
Definition: BaseTypes.h:153
Definition: BaseTypes.h:241
Definition: BaseTypes.h:57
Definition: BaseTypes.h:201
Definition: BaseTypes.h:68
Definition: BaseTypes.h:48