RetroArch
Types.h
Go to the documentation of this file.
1 //
2 // Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
3 // Copyright (C) 2012-2016 LunarG, Inc.
4 // Copyright (C) 2015-2016 Google, Inc.
5 // Copyright (C) 2017 ARM Limited.
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 _TYPES_INCLUDED
40 #define _TYPES_INCLUDED
41 
42 #include "../Include/Common.h"
43 #include "../Include/BaseTypes.h"
44 #include "../Public/ShaderLang.h"
45 #include "arrays.h"
46 
47 #include <algorithm>
48 
49 namespace glslang {
50 
51 const int GlslangMaxTypeLength = 200; // TODO: need to print block/struct one member per line, so this can stay bounded
52 
53 const char* const AnonymousPrefix = "anon@"; // for something like a block whose members can be directly accessed
54 inline bool IsAnonymous(const TString& name)
55 {
56  return name.compare(0, 5, AnonymousPrefix) == 0;
57 }
58 
59 //
60 // Details within a sampler type
61 //
70  EsdSubpass, // goes only with non-sampled image (image is true)
72 };
73 
74 struct TSampler { // misnomer now; includes images, textures without sampler, and textures with sampler
75  TBasicType type : 8; // type returned by sampler
77  bool arrayed : 1;
78  bool shadow : 1;
79  bool ms : 1;
80  bool image : 1; // image, combined should be false
81  bool combined : 1; // true means texture is combined with a sampler, false means texture with no sampler
82  bool sampler : 1; // true means a pure sampler, other fields should be clear()
83  bool external : 1; // GL_OES_EGL_image_external
84  unsigned int vectorSize : 3; // vector return type size.
85 
86  // Some languages support structures as sample results. Storing the whole structure in the
87  // TSampler is too large, so there is an index to a separate table.
88  static const unsigned structReturnIndexBits = 4; // number of index bits to use.
89  static const unsigned structReturnSlots = (1<<structReturnIndexBits)-1; // number of valid values
90  static const unsigned noReturnStruct = structReturnSlots; // value if no return struct type.
91 
92  // Index into a language specific table of texture return structures.
94 
95  // Encapsulate getting members' vector sizes packed into the vectorSize bitfield.
96  unsigned int getVectorSize() const { return vectorSize; }
97 
98  bool isImage() const { return image && dim != EsdSubpass; }
99  bool isSubpass() const { return dim == EsdSubpass; }
100  bool isCombined() const { return combined; }
101  bool isPureSampler() const { return sampler; }
102  bool isTexture() const { return !sampler && !image; }
103  bool isShadow() const { return shadow; }
104  bool isArrayed() const { return arrayed; }
105  bool isMultiSample() const { return ms; }
107 
108  void clear()
109  {
110  type = EbtVoid;
111  dim = EsdNone;
112  arrayed = false;
113  shadow = false;
114  ms = false;
115  image = false;
116  combined = false;
117  sampler = false;
118  external = false;
120 
121  // by default, returns a single vec4;
122  vectorSize = 4;
123  }
124 
125  // make a combined sampler and texture
126  void set(TBasicType t, TSamplerDim d, bool a = false, bool s = false, bool m = false)
127  {
128  clear();
129  type = t;
130  dim = d;
131  arrayed = a;
132  shadow = s;
133  ms = m;
134  combined = true;
135  }
136 
137  // make an image
138  void setImage(TBasicType t, TSamplerDim d, bool a = false, bool s = false, bool m = false)
139  {
140  clear();
141  type = t;
142  dim = d;
143  arrayed = a;
144  shadow = s;
145  ms = m;
146  image = true;
147  }
148 
149  // make a texture with no sampler
150  void setTexture(TBasicType t, TSamplerDim d, bool a = false, bool s = false, bool m = false)
151  {
152  clear();
153  type = t;
154  dim = d;
155  arrayed = a;
156  shadow = s;
157  ms = m;
158  }
159 
160  // make a subpass input attachment
161  void setSubpass(TBasicType t, bool m = false)
162  {
163  clear();
164  type = t;
165  image = true;
166  dim = EsdSubpass;
167  ms = m;
168  }
169 
170  // make a pure sampler, no texture, no image, nothing combined, the 'sampler' keyword
171  void setPureSampler(bool s)
172  {
173  clear();
174  sampler = true;
175  shadow = s;
176  }
177 
178  bool operator==(const TSampler& right) const
179  {
180  return type == right.type &&
181  dim == right.dim &&
182  arrayed == right.arrayed &&
183  shadow == right.shadow &&
184  ms == right.ms &&
185  image == right.image &&
186  combined == right.combined &&
187  sampler == right.sampler &&
188  external == right.external &&
189  vectorSize == right.vectorSize &&
190  structReturnIndex == right.structReturnIndex;
191  }
192 
193  bool operator!=(const TSampler& right) const
194  {
195  return ! operator==(right);
196  }
197 
199  {
200  TString s;
201 
202  if (sampler) {
203  s.append("sampler");
204  return s;
205  }
206 
207  switch (type) {
208  case EbtFloat: break;
209 #ifdef AMD_EXTENSIONS
210  case EbtFloat16: s.append("f16"); break;
211 #endif
212  case EbtInt8: s.append("i8"); break;
213  case EbtUint16: s.append("u8"); break;
214  case EbtInt16: s.append("i16"); break;
215  case EbtUint8: s.append("u16"); break;
216  case EbtInt: s.append("i"); break;
217  case EbtUint: s.append("u"); break;
218  case EbtInt64: s.append("i64"); break;
219  case EbtUint64: s.append("u64"); break;
220  default: break; // some compilers want this
221  }
222  if (image) {
223  if (dim == EsdSubpass)
224  s.append("subpass");
225  else
226  s.append("image");
227  } else if (combined) {
228  s.append("sampler");
229  } else {
230  s.append("texture");
231  }
232  if (external) {
233  s.append("ExternalOES");
234  return s;
235  }
236  switch (dim) {
237  case Esd1D: s.append("1D"); break;
238  case Esd2D: s.append("2D"); break;
239  case Esd3D: s.append("3D"); break;
240  case EsdCube: s.append("Cube"); break;
241  case EsdRect: s.append("2DRect"); break;
242  case EsdBuffer: s.append("Buffer"); break;
243  case EsdSubpass: s.append("Input"); break;
244  default: break; // some compilers want this
245  }
246  if (ms)
247  s.append("MS");
248  if (arrayed)
249  s.append("Array");
250  if (shadow)
251  s.append("Shadow");
252 
253  return s;
254  }
255 };
256 
257 //
258 // Need to have association of line numbers to types in a list for building structs.
259 //
260 class TType;
261 struct TTypeLoc {
264 };
266 
268 
269 //
270 // Following are a series of helper enums for managing layouts and qualifiers,
271 // used for TPublicType, TType, others.
272 //
273 
276  ElpShared, // default, but different than saying nothing
280  ElpCount // If expanding, see bitfield width below
281 };
282 
286  ElmColumnMajor, // default, but different than saying nothing
287  ElmCount // If expanding, see bitfield width below
288 };
289 
290 // Union of geometry shader and tessellation shader geometry types.
291 // They don't go into TType, but rather have current state per shader or
292 // active parser type (TPublicType).
304 };
305 
311 };
312 
317 };
318 
319 // Note: order matters, as type of format is done by comparison.
322 
323  // Float image
329 
330  ElfEsFloatGuard, // to help with comparisons
331 
347 
348  ElfFloatGuard, // to help with comparisons
349 
350  // Int image
355 
356  ElfEsIntGuard, // to help with comparisons
357 
363 
364  ElfIntGuard, // to help with comparisons
365 
366  // Uint image
371 
372  ElfEsUintGuard, // to help with comparisons
373 
380 
382 };
383 
390 
392 };
393 
395  // No 'EBlendNone':
396  // These are used as bit-shift amounts. A mask of such shifts will have type 'int',
397  // and in that space, 0 means no bits set, or none. In this enum, 0 means (1 << 0), a bit is set.
414 
416 };
417 
418 class TQualifier {
419 public:
420  static const int layoutNotSet = -1;
421 
422  void clear()
423  {
424  precision = EpqNone;
425  invariant = false;
426  noContraction = false;
427  makeTemporary();
429  }
430 
431  // drop qualifiers that don't belong in a temporary variable
433  {
434  semanticName = nullptr;
436  builtIn = EbvNone;
437  clearInterstage();
438  clearMemory();
439  specConstant = false;
440  nonUniform = false;
441  clearLayout();
442  }
443 
445  {
447  patch = false;
448  sample = false;
449  }
450 
452  {
453  centroid = false;
454  smooth = false;
455  flat = false;
456  nopersp = false;
457 #ifdef AMD_EXTENSIONS
458  explicitInterp = false;
459 #endif
460  }
461 
462  void clearMemory()
463  {
464  coherent = false;
465  volatil = false;
466  restrict = false;
467  readonly = false;
468  writeonly = false;
469  }
470 
471  // Drop just the storage qualification, which perhaps should
472  // never be done, as it is fundamentally inconsistent, but need to
473  // explore what downstream consumers need.
474  // E.g., in a dereference, it is an inconsistency between:
475  // A) partially dereferenced resource is still in the storage class it started in
476  // B) partially dereferenced resource is a new temporary object
477  // If A, then nothing should change, if B, then everything should change, but this is half way.
479  {
481  specConstant = false;
482  nonUniform = false;
483  }
484 
485  const char* semanticName;
490  bool invariant : 1; // require canonical treatment for cross-shader invariance
491  bool noContraction: 1; // prevent contraction and reassociation, e.g., for 'precise' keyword, and expressions it affects
492  bool centroid : 1;
493  bool smooth : 1;
494  bool flat : 1;
495  bool nopersp : 1;
496 #ifdef AMD_EXTENSIONS
497  bool explicitInterp : 1;
498 #endif
499  bool patch : 1;
500  bool sample : 1;
501  bool coherent : 1;
502  bool volatil : 1;
503  bool restrict : 1;
504  bool readonly : 1;
505  bool writeonly : 1;
506  bool specConstant : 1; // having a constant_id is not sufficient: expressions have no id, but are still specConstant
507  bool nonUniform : 1;
508 
509  bool isMemory() const
510  {
511  return coherent || volatil || restrict || readonly || writeonly;
512  }
513  bool isInterpolation() const
514  {
515 #ifdef AMD_EXTENSIONS
516  return flat || smooth || nopersp || explicitInterp;
517 #else
518  return flat || smooth || nopersp;
519 #endif
520  }
521 #ifdef AMD_EXTENSIONS
522  bool isExplicitInterpolation() const
523  {
524  return explicitInterp;
525  }
526 #endif
527  bool isAuxiliary() const
528  {
529  return centroid || patch || sample;
530  }
531 
532  bool isPipeInput() const
533  {
534  switch (storage) {
535  case EvqVaryingIn:
536  case EvqFragCoord:
537  case EvqPointCoord:
538  case EvqFace:
539  case EvqVertexId:
540  case EvqInstanceId:
541  return true;
542  default:
543  return false;
544  }
545  }
546 
547  bool isPipeOutput() const
548  {
549  switch (storage) {
550  case EvqPosition:
551  case EvqPointSize:
552  case EvqClipVertex:
553  case EvqVaryingOut:
554  case EvqFragColor:
555  case EvqFragDepth:
556  return true;
557  default:
558  return false;
559  }
560  }
561 
562  bool isParamInput() const
563  {
564  switch (storage) {
565  case EvqIn:
566  case EvqInOut:
567  case EvqConstReadOnly:
568  return true;
569  default:
570  return false;
571  }
572  }
573 
574  bool isParamOutput() const
575  {
576  switch (storage) {
577  case EvqOut:
578  case EvqInOut:
579  return true;
580  default:
581  return false;
582  }
583  }
584 
585  bool isUniformOrBuffer() const
586  {
587  switch (storage) {
588  case EvqUniform:
589  case EvqBuffer:
590  return true;
591  default:
592  return false;
593  }
594  }
595 
596  bool isIo() const
597  {
598  switch (storage) {
599  case EvqUniform:
600  case EvqBuffer:
601  case EvqVaryingIn:
602  case EvqFragCoord:
603  case EvqPointCoord:
604  case EvqFace:
605  case EvqVertexId:
606  case EvqInstanceId:
607  case EvqPosition:
608  case EvqPointSize:
609  case EvqClipVertex:
610  case EvqVaryingOut:
611  case EvqFragColor:
612  case EvqFragDepth:
613  return true;
614  default:
615  return false;
616  }
617  }
618 
619  // True if this type of IO is supposed to be arrayed with extra level for per-vertex data
620  bool isArrayedIo(EShLanguage language) const
621  {
622  switch (language) {
623  case EShLangGeometry:
624  return isPipeInput();
625  case EShLangTessControl:
626  return ! patch && (isPipeInput() || isPipeOutput());
628  return ! patch && isPipeInput();
629  default:
630  return false;
631  }
632  }
633 
634  // Implementing an embedded layout-qualifier class here, since C++ can't have a real class bitfield
635  void clearLayout() // all layout
636  {
638 
639  layoutPushConstant = false;
640 #ifdef NV_EXTENSIONS
641  layoutPassthrough = false;
642  layoutViewportRelative = false;
643  // -2048 as the default value indicating layoutSecondaryViewportRelative is not set
644  layoutSecondaryViewportRelativeOffset = -2048;
645 #endif
646 
648 
650 
652  }
654  {
659  clearXfbLayout();
660  }
662  {
664  }
666  {
670  }
671 
672  bool hasNonXfbLayout() const
673  {
674  return hasUniformLayout() ||
675  hasAnyLocation() ||
676  hasStream() ||
677  hasFormat() ||
679  }
680  bool hasLayout() const
681  {
682  return hasNonXfbLayout() ||
683  hasXfb();
684  }
689 
690  unsigned int layoutLocation :12;
691  static const unsigned int layoutLocationEnd = 0xFFF;
692 
693  unsigned int layoutComponent : 3;
694  static const unsigned int layoutComponentEnd = 4;
695 
696  unsigned int layoutSet : 7;
697  static const unsigned int layoutSetEnd = 0x3F;
698 
699  unsigned int layoutBinding : 16;
700  static const unsigned int layoutBindingEnd = 0xFFFF;
701 
702  unsigned int layoutIndex : 8;
703  static const unsigned int layoutIndexEnd = 0xFF;
704 
705  unsigned int layoutStream : 8;
706  static const unsigned int layoutStreamEnd = 0xFF;
707 
708  unsigned int layoutXfbBuffer : 4;
709  static const unsigned int layoutXfbBufferEnd = 0xF;
710 
711  unsigned int layoutXfbStride : 10;
712  static const unsigned int layoutXfbStrideEnd = 0x3FF;
713 
714  unsigned int layoutXfbOffset : 10;
715  static const unsigned int layoutXfbOffsetEnd = 0x3FF;
716 
717  unsigned int layoutAttachment : 8; // for input_attachment_index
718  static const unsigned int layoutAttachmentEnd = 0XFF;
719 
720  unsigned int layoutSpecConstantId : 11;
721  static const unsigned int layoutSpecConstantIdEnd = 0x7FF;
722 
724 
726 
727 #ifdef NV_EXTENSIONS
728  bool layoutPassthrough;
729  bool layoutViewportRelative;
730  int layoutSecondaryViewportRelativeOffset;
731 #endif
732 
733  bool hasUniformLayout() const
734  {
735  return hasMatrix() ||
736  hasPacking() ||
737  hasOffset() ||
738  hasBinding() ||
739  hasSet() ||
740  hasAlign();
741  }
742  void clearUniformLayout() // only uniform specific
743  {
748 
752  }
753 
754  bool hasMatrix() const
755  {
756  return layoutMatrix != ElmNone;
757  }
758  bool hasPacking() const
759  {
760  return layoutPacking != ElpNone;
761  }
762  bool hasOffset() const
763  {
764  return layoutOffset != layoutNotSet;
765  }
766  bool hasAlign() const
767  {
768  return layoutAlign != layoutNotSet;
769  }
770  bool hasAnyLocation() const
771  {
772  return hasLocation() ||
773  hasComponent() ||
774  hasIndex();
775  }
776  bool hasLocation() const
777  {
779  }
780  bool hasComponent() const
781  {
783  }
784  bool hasIndex() const
785  {
786  return layoutIndex != layoutIndexEnd;
787  }
788  bool hasSet() const
789  {
790  return layoutSet != layoutSetEnd;
791  }
792  bool hasBinding() const
793  {
795  }
796  bool hasStream() const
797  {
798  return layoutStream != layoutStreamEnd;
799  }
800  bool hasFormat() const
801  {
802  return layoutFormat != ElfNone;
803  }
804  bool hasXfb() const
805  {
806  return hasXfbBuffer() ||
807  hasXfbStride() ||
808  hasXfbOffset();
809  }
810  bool hasXfbBuffer() const
811  {
813  }
814  bool hasXfbStride() const
815  {
817  }
818  bool hasXfbOffset() const
819  {
821  }
822  bool hasAttachment() const
823  {
825  }
826  bool hasSpecConstantId() const
827  {
828  // Not the same thing as being a specialization constant, this
829  // is just whether or not it was declared with an ID.
831  }
832  bool isSpecConstant() const
833  {
834  // True if type is a specialization constant, whether or not it
835  // had a specialization-constant ID, and false if it is not a
836  // true front-end constant.
837  return specConstant;
838  }
839  bool isNonUniform() const
840  {
841  return nonUniform;
842  }
843  bool isFrontEndConstant() const
844  {
845  // True if the front-end knows the final constant value.
846  // This allows front-end constant folding.
847  return storage == EvqConst && ! specConstant;
848  }
849  bool isConstant() const
850  {
851  // True if is either kind of constant; specialization or regular.
852  return isFrontEndConstant() || isSpecConstant();
853  }
855  {
856  storage = EvqConst;
857  specConstant = true;
858  }
859  static const char* getLayoutPackingString(TLayoutPacking packing)
860  {
861  switch (packing) {
862  case ElpPacked: return "packed";
863  case ElpShared: return "shared";
864  case ElpStd140: return "std140";
865  case ElpStd430: return "std430";
866  default: return "none";
867  }
868  }
870  {
871  switch (m) {
872  case ElmColumnMajor: return "column_major";
873  case ElmRowMajor: return "row_major";
874  default: return "none";
875  }
876  }
878  {
879  switch (f) {
880  case ElfRgba32f: return "rgba32f";
881  case ElfRgba16f: return "rgba16f";
882  case ElfRg32f: return "rg32f";
883  case ElfRg16f: return "rg16f";
884  case ElfR11fG11fB10f: return "r11f_g11f_b10f";
885  case ElfR32f: return "r32f";
886  case ElfR16f: return "r16f";
887  case ElfRgba16: return "rgba16";
888  case ElfRgb10A2: return "rgb10_a2";
889  case ElfRgba8: return "rgba8";
890  case ElfRg16: return "rg16";
891  case ElfRg8: return "rg8";
892  case ElfR16: return "r16";
893  case ElfR8: return "r8";
894  case ElfRgba16Snorm: return "rgba16_snorm";
895  case ElfRgba8Snorm: return "rgba8_snorm";
896  case ElfRg16Snorm: return "rg16_snorm";
897  case ElfRg8Snorm: return "rg8_snorm";
898  case ElfR16Snorm: return "r16_snorm";
899  case ElfR8Snorm: return "r8_snorm";
900 
901  case ElfRgba32i: return "rgba32i";
902  case ElfRgba16i: return "rgba16i";
903  case ElfRgba8i: return "rgba8i";
904  case ElfRg32i: return "rg32i";
905  case ElfRg16i: return "rg16i";
906  case ElfRg8i: return "rg8i";
907  case ElfR32i: return "r32i";
908  case ElfR16i: return "r16i";
909  case ElfR8i: return "r8i";
910 
911  case ElfRgba32ui: return "rgba32ui";
912  case ElfRgba16ui: return "rgba16ui";
913  case ElfRgba8ui: return "rgba8ui";
914  case ElfRg32ui: return "rg32ui";
915  case ElfRg16ui: return "rg16ui";
916  case ElfRgb10a2ui: return "rgb10_a2ui";
917  case ElfRg8ui: return "rg8ui";
918  case ElfR32ui: return "r32ui";
919  case ElfR16ui: return "r16ui";
920  case ElfR8ui: return "r8ui";
921  default: return "none";
922  }
923  }
924  static const char* getLayoutDepthString(TLayoutDepth d)
925  {
926  switch (d) {
927  case EldAny: return "depth_any";
928  case EldGreater: return "depth_greater";
929  case EldLess: return "depth_less";
930  case EldUnchanged: return "depth_unchanged";
931  default: return "none";
932  }
933  }
935  {
936  switch (e) {
937  case EBlendMultiply: return "blend_support_multiply";
938  case EBlendScreen: return "blend_support_screen";
939  case EBlendOverlay: return "blend_support_overlay";
940  case EBlendDarken: return "blend_support_darken";
941  case EBlendLighten: return "blend_support_lighten";
942  case EBlendColordodge: return "blend_support_colordodge";
943  case EBlendColorburn: return "blend_support_colorburn";
944  case EBlendHardlight: return "blend_support_hardlight";
945  case EBlendSoftlight: return "blend_support_softlight";
946  case EBlendDifference: return "blend_support_difference";
947  case EBlendExclusion: return "blend_support_exclusion";
948  case EBlendHslHue: return "blend_support_hsl_hue";
949  case EBlendHslSaturation: return "blend_support_hsl_saturation";
950  case EBlendHslColor: return "blend_support_hsl_color";
951  case EBlendHslLuminosity: return "blend_support_hsl_luminosity";
952  case EBlendAllEquations: return "blend_support_all_equations";
953  default: return "unknown";
954  }
955  }
956  static const char* getGeometryString(TLayoutGeometry geometry)
957  {
958  switch (geometry) {
959  case ElgPoints: return "points";
960  case ElgLines: return "lines";
961  case ElgLinesAdjacency: return "lines_adjacency";
962  case ElgLineStrip: return "line_strip";
963  case ElgTriangles: return "triangles";
964  case ElgTrianglesAdjacency: return "triangles_adjacency";
965  case ElgTriangleStrip: return "triangle_strip";
966  case ElgQuads: return "quads";
967  case ElgIsolines: return "isolines";
968  default: return "none";
969  }
970  }
971  static const char* getVertexSpacingString(TVertexSpacing spacing)
972  {
973  switch (spacing) {
974  case EvsEqual: return "equal_spacing";
975  case EvsFractionalEven: return "fractional_even_spacing";
976  case EvsFractionalOdd: return "fractional_odd_spacing";
977  default: return "none";
978  }
979  }
981  {
982  switch (order) {
983  case EvoCw: return "cw";
984  case EvoCcw: return "ccw";
985  default: return "none";
986  }
987  }
988  static int mapGeometryToSize(TLayoutGeometry geometry)
989  {
990  switch (geometry) {
991  case ElgPoints: return 1;
992  case ElgLines: return 2;
993  case ElgLinesAdjacency: return 4;
994  case ElgTriangles: return 3;
995  case ElgTrianglesAdjacency: return 6;
996  default: return 0;
997  }
998  }
999 };
1000 
1001 // Qualifiers that don't need to be keep per object. They have shader scope, not object scope.
1002 // So, they will not be part of TType, TQualifier, etc.
1004  TLayoutGeometry geometry; // geometry/tessellation shader in/out primitives
1005  bool pixelCenterInteger; // fragment shader
1006  bool originUpperLeft; // fragment shader
1008  int vertices; // both for tessellation "vertices" and geometry "max_vertices"
1012  int localSize[3]; // compute shader
1013  int localSizeSpecId[3]; // compute shader specialization id for gl_WorkGroupSize
1014  bool earlyFragmentTests; // fragment input
1015  bool postDepthCoverage; // fragment input
1017  bool blendEquation; // true if any blend equation was specified
1018  int numViews; // multiview extenstions
1019 
1020 #ifdef NV_EXTENSIONS
1021  bool layoutOverrideCoverage; // true if layout override_coverage set
1022 #endif
1023 
1024  void init()
1025  {
1026  geometry = ElgNone;
1027  originUpperLeft = false;
1028  pixelCenterInteger = false;
1031  spacing = EvsNone;
1032  order = EvoNone;
1033  pointMode = false;
1034  localSize[0] = 1;
1035  localSize[1] = 1;
1036  localSize[2] = 1;
1040  earlyFragmentTests = false;
1041  postDepthCoverage = false;
1042  layoutDepth = EldNone;
1043  blendEquation = false;
1045 #ifdef NV_EXTENSIONS
1046  layoutOverrideCoverage = false;
1047 #endif
1048  }
1049 
1050  // Merge in characteristics from the 'src' qualifier. They can override when
1051  // set, but never erase when not set.
1053  {
1054  if (src.geometry != ElgNone)
1055  geometry = src.geometry;
1056  if (src.pixelCenterInteger)
1057  pixelCenterInteger = src.pixelCenterInteger;
1058  if (src.originUpperLeft)
1059  originUpperLeft = src.originUpperLeft;
1060  if (src.invocations != TQualifier::layoutNotSet)
1061  invocations = src.invocations;
1062  if (src.vertices != TQualifier::layoutNotSet)
1063  vertices = src.vertices;
1064  if (src.spacing != EvsNone)
1065  spacing = src.spacing;
1066  if (src.order != EvoNone)
1067  order = src.order;
1068  if (src.pointMode)
1069  pointMode = true;
1070  for (int i = 0; i < 3; ++i) {
1071  if (src.localSize[i] > 1)
1072  localSize[i] = src.localSize[i];
1073  }
1074  for (int i = 0; i < 3; ++i) {
1075  if (src.localSizeSpecId[i] != TQualifier::layoutNotSet)
1076  localSizeSpecId[i] = src.localSizeSpecId[i];
1077  }
1078  if (src.earlyFragmentTests)
1079  earlyFragmentTests = true;
1080  if (src.postDepthCoverage)
1081  postDepthCoverage = true;
1082  if (src.layoutDepth)
1083  layoutDepth = src.layoutDepth;
1084  if (src.blendEquation)
1085  blendEquation = src.blendEquation;
1086  if (src.numViews != TQualifier::layoutNotSet)
1087  numViews = src.numViews;
1088 #ifdef NV_EXTENSIONS
1089  if (src.layoutOverrideCoverage)
1090  layoutOverrideCoverage = src.layoutOverrideCoverage;
1091 #endif
1092  }
1093 };
1094 
1095 //
1096 // TPublicType is just temporarily used while parsing and not quite the same
1097 // information kept per node in TType. Due to the bison stack, it can't have
1098 // types that it thinks have non-trivial constructors. It should
1099 // just be used while recognizing the grammar, not anything else.
1100 // Once enough is known about the situation, the proper information
1101 // moved into a TType, or the parse context, etc.
1102 //
1104 public:
1109  int vectorSize : 4;
1110  int matrixCols : 4;
1111  int matrixRows : 4;
1113  const TType* userDef;
1115 
1116  void initType(const TSourceLoc& l)
1117  {
1118  basicType = EbtVoid;
1119  vectorSize = 1;
1120  matrixRows = 0;
1121  matrixCols = 0;
1122  arraySizes = nullptr;
1123  userDef = nullptr;
1124  loc = l;
1125  }
1126 
1127  void initQualifiers(bool global = false)
1128  {
1129  qualifier.clear();
1130  if (global)
1132  }
1133 
1134  void init(const TSourceLoc& l, bool global = false)
1135  {
1136  initType(l);
1137  sampler.clear();
1140  }
1141 
1142  void setVector(int s)
1143  {
1144  matrixRows = 0;
1145  matrixCols = 0;
1146  vectorSize = s;
1147  }
1148 
1149  void setMatrix(int c, int r)
1150  {
1151  matrixRows = r;
1152  matrixCols = c;
1153  vectorSize = 0;
1154  }
1155 
1156  bool isScalar() const
1157  {
1158  return matrixCols == 0 && vectorSize == 1 && arraySizes == nullptr && userDef == nullptr;
1159  }
1160 
1161  // "Image" is a superset of "Subpass"
1162  bool isImage() const { return basicType == EbtSampler && sampler.isImage(); }
1163  bool isSubpass() const { return basicType == EbtSampler && sampler.isSubpass(); }
1164 };
1165 
1166 //
1167 // Base class for things that have a type.
1168 //
1169 class TType {
1170 public:
1172 
1173  // for "empty" type (no args) or simple scalar/vector/matrix
1174  explicit TType(TBasicType t = EbtVoid, TStorageQualifier q = EvqTemporary, int vs = 1, int mc = 0, int mr = 0,
1175  bool isVector = false) :
1176  basicType(t), vectorSize(vs), matrixCols(mc), matrixRows(mr), vector1(isVector && vs == 1),
1177  arraySizes(nullptr), structure(nullptr), fieldName(nullptr), typeName(nullptr)
1178  {
1179  sampler.clear();
1180  qualifier.clear();
1181  qualifier.storage = q;
1182  assert(!(isMatrix() && vectorSize != 0)); // prevent vectorSize != 0 on matrices
1183  }
1184  // for explicit precision qualifier
1185  TType(TBasicType t, TStorageQualifier q, TPrecisionQualifier p, int vs = 1, int mc = 0, int mr = 0,
1186  bool isVector = false) :
1187  basicType(t), vectorSize(vs), matrixCols(mc), matrixRows(mr), vector1(isVector && vs == 1),
1188  arraySizes(nullptr), structure(nullptr), fieldName(nullptr), typeName(nullptr)
1189  {
1190  sampler.clear();
1191  qualifier.clear();
1192  qualifier.storage = q;
1193  qualifier.precision = p;
1194  assert(p >= EpqNone && p <= EpqHigh);
1195  assert(!(isMatrix() && vectorSize != 0)); // prevent vectorSize != 0 on matrices
1196  }
1197  // for turning a TPublicType into a TType, using a shallow copy
1198  explicit TType(const TPublicType& p) :
1201  arraySizes(p.arraySizes), structure(nullptr), fieldName(nullptr), typeName(nullptr)
1202  {
1203  if (basicType == EbtSampler)
1204  sampler = p.sampler;
1205  else
1206  sampler.clear();
1207  qualifier = p.qualifier;
1208  if (p.userDef) {
1209  structure = p.userDef->getWritableStruct(); // public type is short-lived; there are no sharing issues
1210  typeName = NewPoolTString(p.userDef->getTypeName().c_str());
1211  }
1212  }
1213  // for construction of sampler types
1216  arraySizes(as), structure(nullptr), fieldName(nullptr), typeName(nullptr),
1217  sampler(sampler)
1218  {
1219  qualifier.clear();
1220  qualifier.storage = q;
1221  }
1222  // to efficiently make a dereferenced type
1223  // without ever duplicating the outer structure that will be thrown away
1224  // and using only shallow copy
1225  TType(const TType& type, int derefIndex, bool rowMajor = false)
1226  {
1227  if (type.isArray()) {
1228  shallowCopy(type);
1229  if (type.getArraySizes()->getNumDims() == 1) {
1230  arraySizes = nullptr;
1231  } else {
1232  // want our own copy of the array, so we can edit it
1233  arraySizes = new TArraySizes;
1234  arraySizes->copyDereferenced(*type.arraySizes);
1235  }
1236  } else if (type.basicType == EbtStruct || type.basicType == EbtBlock) {
1237  // do a structure dereference
1238  const TTypeList& memberList = *type.getStruct();
1239  shallowCopy(*memberList[derefIndex].type);
1240  return;
1241  } else {
1242  // do a vector/matrix dereference
1243  shallowCopy(type);
1244  if (matrixCols > 0) {
1245  // dereference from matrix to vector
1246  if (rowMajor)
1248  else
1250  matrixCols = 0;
1251  matrixRows = 0;
1252  if (vectorSize == 1)
1253  vector1 = true;
1254  } else if (isVector()) {
1255  // dereference from vector to scalar
1256  vectorSize = 1;
1257  vector1 = false;
1258  }
1259  }
1260  }
1261  // for making structures, ...
1262  TType(TTypeList* userDef, const TString& n) :
1264  arraySizes(nullptr), structure(userDef), fieldName(nullptr)
1265  {
1266  sampler.clear();
1267  qualifier.clear();
1268  typeName = NewPoolTString(n.c_str());
1269  }
1270  // For interface blocks
1271  TType(TTypeList* userDef, const TString& n, const TQualifier& q) :
1273  qualifier(q), arraySizes(nullptr), structure(userDef), fieldName(nullptr)
1274  {
1275  sampler.clear();
1276  typeName = NewPoolTString(n.c_str());
1277  }
1278  virtual ~TType() {}
1279 
1280  // Not for use across pool pops; it will cause multiple instances of TType to point to the same information.
1281  // This only works if that information (like a structure's list of types) does not change and
1282  // the instances are sharing the same pool.
1283  void shallowCopy(const TType& copyOf)
1284  {
1285  basicType = copyOf.basicType;
1286  sampler = copyOf.sampler;
1287  qualifier = copyOf.qualifier;
1288  vectorSize = copyOf.vectorSize;
1289  matrixCols = copyOf.matrixCols;
1290  matrixRows = copyOf.matrixRows;
1291  vector1 = copyOf.vector1;
1292  arraySizes = copyOf.arraySizes; // copying the pointer only, not the contents
1293  structure = copyOf.structure;
1294  fieldName = copyOf.fieldName;
1295  typeName = copyOf.typeName;
1296  }
1297 
1298  // Make complete copy of the whole type graph rooted at 'copyOf'.
1299  void deepCopy(const TType& copyOf)
1300  {
1301  TMap<TTypeList*,TTypeList*> copied; // to enable copying a type graph as a graph, not a tree
1302  deepCopy(copyOf, copied);
1303  }
1304 
1305  // Recursively make temporary
1307  {
1309 
1310  if (isStruct())
1311  for (unsigned int i = 0; i < structure->size(); ++i)
1312  (*structure)[i].type->makeTemporary();
1313  }
1314 
1315  TType* clone() const
1316  {
1317  TType *newType = new TType();
1318  newType->deepCopy(*this);
1319 
1320  return newType;
1321  }
1322 
1323  void makeVector() { vector1 = true; }
1324 
1325  virtual void hideMember() { basicType = EbtVoid; vectorSize = 1; }
1326  virtual bool hiddenMember() const { return basicType == EbtVoid; }
1327 
1328  virtual void setFieldName(const TString& n) { fieldName = NewPoolTString(n.c_str()); }
1329  virtual const TString& getTypeName() const
1330  {
1331  assert(typeName);
1332  return *typeName;
1333  }
1334 
1335  virtual const TString& getFieldName() const
1336  {
1337  assert(fieldName);
1338  return *fieldName;
1339  }
1340 
1341  virtual TBasicType getBasicType() const { return basicType; }
1342  virtual const TSampler& getSampler() const { return sampler; }
1343  virtual TSampler& getSampler() { return sampler; }
1344 
1345  virtual TQualifier& getQualifier() { return qualifier; }
1346  virtual const TQualifier& getQualifier() const { return qualifier; }
1347 
1348  virtual int getVectorSize() const { return vectorSize; } // returns 1 for either scalar or vector of size 1, valid for both
1349  virtual int getMatrixCols() const { return matrixCols; }
1350  virtual int getMatrixRows() const { return matrixRows; }
1351  virtual int getOuterArraySize() const { return arraySizes->getOuterSize(); }
1352  virtual TIntermTyped* getOuterArrayNode() const { return arraySizes->getOuterNode(); }
1353  virtual int getCumulativeArraySize() const { return arraySizes->getCumulativeSize(); }
1354  virtual bool isArrayOfArrays() const { return arraySizes != nullptr && arraySizes->getNumDims() > 1; }
1355  virtual int getImplicitArraySize() const { return arraySizes->getImplicitSize(); }
1356  virtual const TArraySizes* getArraySizes() const { return arraySizes; }
1357  virtual TArraySizes* getArraySizes() { return arraySizes; }
1358 
1359  virtual bool isScalar() const { return ! isVector() && ! isMatrix() && ! isStruct() && ! isArray(); }
1360  virtual bool isScalarOrVec1() const { return isScalar() || vector1; }
1361  virtual bool isVector() const { return vectorSize > 1 || vector1; }
1362  virtual bool isMatrix() const { return matrixCols ? true : false; }
1363  virtual bool isArray() const { return arraySizes != nullptr; }
1364  virtual bool isSizedArray() const { return isArray() && arraySizes->isSized(); }
1365  virtual bool isUnsizedArray() const { return isArray() && !arraySizes->isSized(); }
1366  virtual bool isArrayVariablyIndexed() const { assert(isArray()); return arraySizes->isVariablyIndexed(); }
1369  virtual bool isStruct() const { return structure != nullptr; }
1370  virtual bool isFloatingDomain() const { return basicType == EbtFloat || basicType == EbtDouble || basicType == EbtFloat16; }
1371  virtual bool isIntegerDomain() const
1372  {
1373  switch (basicType) {
1374  case EbtInt8:
1375  case EbtUint8:
1376  case EbtInt16:
1377  case EbtUint16:
1378  case EbtInt:
1379  case EbtUint:
1380  case EbtInt64:
1381  case EbtUint64:
1382  case EbtAtomicUint:
1383  return true;
1384  default:
1385  break;
1386  }
1387  return false;
1388  }
1389  virtual bool isOpaque() const { return basicType == EbtSampler || basicType == EbtAtomicUint; }
1390  virtual bool isBuiltIn() const { return getQualifier().builtIn != EbvNone; }
1391 
1392  // "Image" is a superset of "Subpass"
1393  virtual bool isImage() const { return basicType == EbtSampler && getSampler().isImage(); }
1394  virtual bool isSubpass() const { return basicType == EbtSampler && getSampler().isSubpass(); }
1395  virtual bool isTexture() const { return basicType == EbtSampler && getSampler().isTexture(); }
1396 
1397  // return true if this type contains any subtype which satisfies the given predicate.
1398  template <typename P>
1399  bool contains(P predicate) const
1400  {
1401  if (predicate(this))
1402  return true;
1403 
1404  const auto hasa = [predicate](const TTypeLoc& tl) { return tl.type->contains(predicate); };
1405 
1406  return structure && std::any_of(structure->begin(), structure->end(), hasa);
1407  }
1408 
1409  // Recursively checks if the type contains the given basic type
1410  virtual bool containsBasicType(TBasicType checkType) const
1411  {
1412  return contains([checkType](const TType* t) { return t->basicType == checkType; } );
1413  }
1414 
1415  // Recursively check the structure for any arrays, needed for some error checks
1416  virtual bool containsArray() const
1417  {
1418  return contains([](const TType* t) { return t->isArray(); } );
1419  }
1420 
1421  // Check the structure for any structures, needed for some error checks
1422  virtual bool containsStructure() const
1423  {
1424  return contains([this](const TType* t) { return t != this && t->isStruct(); } );
1425  }
1426 
1427  // Recursively check the structure for any unsized arrays, needed for triggering a copyUp().
1428  virtual bool containsUnsizedArray() const
1429  {
1430  return contains([](const TType* t) { return t->isUnsizedArray(); } );
1431  }
1432 
1433  virtual bool containsOpaque() const
1434  {
1435  return contains([](const TType* t) { return t->isOpaque(); } );
1436  }
1437 
1438  // Recursively checks if the type contains a built-in variable
1439  virtual bool containsBuiltIn() const
1440  {
1441  return contains([](const TType* t) { return t->isBuiltIn(); } );
1442  }
1443 
1444  virtual bool containsNonOpaque() const
1445  {
1446  const auto nonOpaque = [](const TType* t) {
1447  switch (t->basicType) {
1448  case EbtVoid:
1449  case EbtFloat:
1450  case EbtDouble:
1451  case EbtFloat16:
1452  case EbtInt8:
1453  case EbtUint8:
1454  case EbtInt16:
1455  case EbtUint16:
1456  case EbtInt:
1457  case EbtUint:
1458  case EbtInt64:
1459  case EbtUint64:
1460  case EbtBool:
1461  return true;
1462  default:
1463  return false;
1464  }
1465  };
1466 
1467  return contains(nonOpaque);
1468  }
1469 
1470  virtual bool containsSpecializationSize() const
1471  {
1472  return contains([](const TType* t) { return t->isArray() && t->arraySizes->isOuterSpecialization(); } );
1473  }
1474 
1475  // Array editing methods. Array descriptors can be shared across
1476  // type instances. This allows all uses of the same array
1477  // to be updated at once. E.g., all nodes can be explicitly sized
1478  // by tracking and correcting one implicit size. Or, all nodes
1479  // can get the explicit size on a redeclaration that gives size.
1480  //
1481  // N.B.: Don't share with the shared symbol tables (symbols are
1482  // marked as isReadOnly(). Such symbols with arrays that will be
1483  // edited need to copyUp() on first use, so that
1484  // A) the edits don't effect the shared symbol table, and
1485  // B) the edits are shared across all users.
1487  {
1488  // For when we may already be sharing existing array descriptors,
1489  // keeping the pointers the same, just updating the contents.
1490  assert(arraySizes != nullptr);
1491  assert(type.arraySizes != nullptr);
1492  *arraySizes = *type.arraySizes;
1493  }
1495  {
1496  // For setting a fresh new set of array sizes, not yet worrying about sharing.
1497  arraySizes = new TArraySizes;
1498  *arraySizes = s;
1499  }
1501  {
1502  // For setting an already allocated set of sizes that this type can use
1503  // (no copy made).
1504  arraySizes = s;
1505  }
1507  {
1508  arraySizes = nullptr;
1509  }
1510 
1511  // Add inner array sizes, to any existing sizes, via copy; the
1512  // sizes passed in can still be reused for other purposes.
1514  {
1515  if (s != nullptr) {
1516  if (arraySizes == nullptr)
1517  copyArraySizes(*s);
1518  else
1520  }
1521  }
1523 
1524  // Recursively make the implicit array size the explicit array size.
1525  // Expicit arrays are compile-time or link-time sized, never run-time sized.
1526  // Sometimes, policy calls for an array to be run-time sized even if it was
1527  // never variably indexed: Don't turn a 'skipNonvariablyIndexed' array into
1528  // an explicit array.
1529  void adoptImplicitArraySizes(bool skipNonvariablyIndexed)
1530  {
1531  if (isUnsizedArray() && !(skipNonvariablyIndexed || isArrayVariablyIndexed()))
1533  if (isStruct() && structure->size() > 0) {
1534  int lastMember = (int)structure->size() - 1;
1535  for (int i = 0; i < lastMember; ++i)
1536  (*structure)[i].type->adoptImplicitArraySizes(false);
1537  // implement the "last member of an SSBO" policy
1538  (*structure)[lastMember].type->adoptImplicitArraySizes(getQualifier().storage == EvqBuffer);
1539  }
1540  }
1541 
1542  const char* getBasicString() const
1543  {
1545  }
1546 
1547  static const char* getBasicString(TBasicType t)
1548  {
1549  switch (t) {
1550  case EbtVoid: return "void";
1551  case EbtFloat: return "float";
1552  case EbtDouble: return "double";
1553  case EbtFloat16: return "float16_t";
1554  case EbtInt8: return "int8_t";
1555  case EbtUint8: return "uint8_t";
1556  case EbtInt16: return "int16_t";
1557  case EbtUint16: return "uint16_t";
1558  case EbtInt: return "int";
1559  case EbtUint: return "uint";
1560  case EbtInt64: return "int64_t";
1561  case EbtUint64: return "uint64_t";
1562  case EbtBool: return "bool";
1563  case EbtAtomicUint: return "atomic_uint";
1564  case EbtSampler: return "sampler/image";
1565  case EbtStruct: return "structure";
1566  case EbtBlock: return "block";
1567  default: return "unknown type";
1568  }
1569  }
1570 
1572  {
1573  TString typeString;
1574 
1575  const auto appendStr = [&](const char* s) { typeString.append(s); };
1576  const auto appendUint = [&](unsigned int u) { typeString.append(std::to_string(u).c_str()); };
1577  const auto appendInt = [&](int i) { typeString.append(std::to_string(i).c_str()); };
1578 
1579  if (qualifier.hasLayout()) {
1580  // To reduce noise, skip this if the only layout is an xfb_buffer
1581  // with no triggering xfb_offset.
1582  TQualifier noXfbBuffer = qualifier;
1584  if (noXfbBuffer.hasLayout()) {
1585  appendStr("layout(");
1586  if (qualifier.hasAnyLocation()) {
1587  appendStr(" location=");
1588  appendUint(qualifier.layoutLocation);
1589  if (qualifier.hasComponent()) {
1590  appendStr(" component=");
1591  appendUint(qualifier.layoutComponent);
1592  }
1593  if (qualifier.hasIndex()) {
1594  appendStr(" index=");
1595  appendUint(qualifier.layoutIndex);
1596  }
1597  }
1598  if (qualifier.hasSet()) {
1599  appendStr(" set=");
1600  appendUint(qualifier.layoutSet);
1601  }
1602  if (qualifier.hasBinding()) {
1603  appendStr(" binding=");
1604  appendUint(qualifier.layoutBinding);
1605  }
1606  if (qualifier.hasStream()) {
1607  appendStr(" stream=");
1608  appendUint(qualifier.layoutStream);
1609  }
1610  if (qualifier.hasMatrix()) {
1611  appendStr(" ");
1613  }
1614  if (qualifier.hasPacking()) {
1615  appendStr(" ");
1617  }
1618  if (qualifier.hasOffset()) {
1619  appendStr(" offset=");
1620  appendInt(qualifier.layoutOffset);
1621  }
1622  if (qualifier.hasAlign()) {
1623  appendStr(" align=");
1624  appendInt(qualifier.layoutAlign);
1625  }
1626  if (qualifier.hasFormat()) {
1627  appendStr(" ");
1629  }
1631  appendStr(" xfb_buffer=");
1632  appendUint(qualifier.layoutXfbBuffer);
1633  }
1634  if (qualifier.hasXfbOffset()) {
1635  appendStr(" xfb_offset=");
1636  appendUint(qualifier.layoutXfbOffset);
1637  }
1638  if (qualifier.hasXfbStride()) {
1639  appendStr(" xfb_stride=");
1640  appendUint(qualifier.layoutXfbStride);
1641  }
1642  if (qualifier.hasAttachment()) {
1643  appendStr(" input_attachment_index=");
1644  appendUint(qualifier.layoutAttachment);
1645  }
1646  if (qualifier.hasSpecConstantId()) {
1647  appendStr(" constant_id=");
1648  appendUint(qualifier.layoutSpecConstantId);
1649  }
1651  appendStr(" push_constant");
1652 
1653 #ifdef NV_EXTENSIONS
1654  if (qualifier.layoutPassthrough)
1655  appendStr(" passthrough");
1656  if (qualifier.layoutViewportRelative)
1657  appendStr(" layoutViewportRelative");
1658  if (qualifier.layoutSecondaryViewportRelativeOffset != -2048) {
1659  appendStr(" layoutSecondaryViewportRelativeOffset=");
1660  appendInt(qualifier.layoutSecondaryViewportRelativeOffset);
1661  }
1662 #endif
1663 
1664  appendStr(")");
1665  }
1666  }
1667 
1668  if (qualifier.invariant)
1669  appendStr(" invariant");
1671  appendStr(" noContraction");
1672  if (qualifier.centroid)
1673  appendStr(" centroid");
1674  if (qualifier.smooth)
1675  appendStr(" smooth");
1676  if (qualifier.flat)
1677  appendStr(" flat");
1678  if (qualifier.nopersp)
1679  appendStr(" noperspective");
1680 #ifdef AMD_EXTENSIONS
1681  if (qualifier.explicitInterp)
1682  appendStr(" __explicitInterpAMD");
1683 #endif
1684  if (qualifier.patch)
1685  appendStr(" patch");
1686  if (qualifier.sample)
1687  appendStr(" sample");
1688  if (qualifier.coherent)
1689  appendStr(" coherent");
1690  if (qualifier.volatil)
1691  appendStr(" volatile");
1692  if (qualifier.restrict)
1693  appendStr(" restrict");
1694  if (qualifier.readonly)
1695  appendStr(" readonly");
1696  if (qualifier.writeonly)
1697  appendStr(" writeonly");
1698  if (qualifier.specConstant)
1699  appendStr(" specialization-constant");
1700  if (qualifier.nonUniform)
1701  appendStr(" nonuniform");
1702  appendStr(" ");
1703  appendStr(getStorageQualifierString());
1704  if (isArray()) {
1705  for(int i = 0; i < (int)arraySizes->getNumDims(); ++i) {
1706  int size = arraySizes->getDimSize(i);
1707  if (size == UnsizedArraySize && i == 0 && arraySizes->isVariablyIndexed())
1708  appendStr(" runtime-sized array of");
1709  else {
1710  if (size == UnsizedArraySize) {
1711  appendStr(" unsized");
1712  if (i == 0) {
1713  appendStr(" ");
1714  appendInt(arraySizes->getImplicitSize());
1715  }
1716  } else {
1717  appendStr(" ");
1718  appendInt(arraySizes->getDimSize(i));
1719  }
1720  appendStr("-element array of");
1721  }
1722  }
1723  }
1724  if (qualifier.precision != EpqNone) {
1725  appendStr(" ");
1726  appendStr(getPrecisionQualifierString());
1727  }
1728  if (isMatrix()) {
1729  appendStr(" ");
1730  appendInt(matrixCols);
1731  appendStr("X");
1732  appendInt(matrixRows);
1733  appendStr(" matrix of");
1734  } else if (isVector()) {
1735  appendStr(" ");
1736  appendInt(vectorSize);
1737  appendStr("-component vector of");
1738  }
1739 
1740  appendStr(" ");
1741  typeString.append(getBasicTypeString());
1742 
1743  if (qualifier.builtIn != EbvNone) {
1744  appendStr(" ");
1745  appendStr(getBuiltInVariableString());
1746  }
1747 
1748  // Add struct/block members
1749  if (structure) {
1750  appendStr("{");
1751  for (size_t i = 0; i < structure->size(); ++i) {
1752  if (! (*structure)[i].type->hiddenMember()) {
1753  typeString.append((*structure)[i].type->getCompleteString());
1754  typeString.append(" ");
1755  typeString.append((*structure)[i].type->getFieldName());
1756  if (i < structure->size() - 1)
1757  appendStr(", ");
1758  }
1759  }
1760  appendStr("}");
1761  }
1762 
1763  return typeString;
1764  }
1765 
1767  {
1768  if (basicType == EbtSampler)
1769  return sampler.getString();
1770  else
1771  return getBasicString();
1772  }
1773 
1777  const TTypeList* getStruct() const { return structure; }
1779  TTypeList* getWritableStruct() const { return structure; } // This should only be used when known to not be sharing with other threads
1780 
1782  {
1783  int components = 0;
1784 
1785  if (getBasicType() == EbtStruct || getBasicType() == EbtBlock) {
1786  for (TTypeList::const_iterator tl = getStruct()->begin(); tl != getStruct()->end(); tl++)
1787  components += ((*tl).type)->computeNumComponents();
1788  } else if (matrixCols)
1790  else
1792 
1793  if (arraySizes != nullptr) {
1795  }
1796 
1797  return components;
1798  }
1799 
1800  // append this type's mangled name to the passed in 'name'
1802  {
1804  name += ';' ;
1805  }
1806 
1807  // Do two structure types match? They could be declared independently,
1808  // in different places, but still might satisfy the definition of matching.
1809  // From the spec:
1810  //
1811  // "Structures must have the same name, sequence of type names, and
1812  // type definitions, and member names to be considered the same type.
1813  // This rule applies recursively for nested or embedded types."
1814  //
1815  bool sameStructType(const TType& right) const
1816  {
1817  // Most commonly, they are both nullptr, or the same pointer to the same actual structure
1818  if (structure == right.structure)
1819  return true;
1820 
1821  // Both being nullptr was caught above, now they both have to be structures of the same number of elements
1822  if (structure == nullptr || right.structure == nullptr ||
1823  structure->size() != right.structure->size())
1824  return false;
1825 
1826  // Structure names have to match
1827  if (*typeName != *right.typeName)
1828  return false;
1829 
1830  // Compare the names and types of all the members, which have to match
1831  for (unsigned int i = 0; i < structure->size(); ++i) {
1832  if ((*structure)[i].type->getFieldName() != (*right.structure)[i].type->getFieldName())
1833  return false;
1834 
1835  if (*(*structure)[i].type != *(*right.structure)[i].type)
1836  return false;
1837  }
1838 
1839  return true;
1840  }
1841 
1842  // See if two types match, in all aspects except arrayness
1843  bool sameElementType(const TType& right) const
1844  {
1845  return basicType == right.basicType && sameElementShape(right);
1846  }
1847 
1848  // See if two type's arrayness match
1849  bool sameArrayness(const TType& right) const
1850  {
1851  return ((arraySizes == nullptr && right.arraySizes == nullptr) ||
1852  (arraySizes != nullptr && right.arraySizes != nullptr && *arraySizes == *right.arraySizes));
1853  }
1854 
1855  // See if two type's arrayness match in everything except their outer dimension
1856  bool sameInnerArrayness(const TType& right) const
1857  {
1858  assert(arraySizes != nullptr && right.arraySizes != nullptr);
1859  return arraySizes->sameInnerArrayness(*right.arraySizes);
1860  }
1861 
1862  // See if two type's elements match in all ways except basic type
1863  bool sameElementShape(const TType& right) const
1864  {
1865  return sampler == right.sampler &&
1866  vectorSize == right.vectorSize &&
1867  matrixCols == right.matrixCols &&
1868  matrixRows == right.matrixRows &&
1869  vector1 == right.vector1 &&
1871  }
1872 
1873  // See if two types match in all ways (just the actual type, not qualification)
1874  bool operator==(const TType& right) const
1875  {
1877  }
1878 
1879  bool operator!=(const TType& right) const
1880  {
1881  return ! operator==(right);
1882  }
1883 
1884 protected:
1885  // Require consumer to pick between deep copy and shallow copy.
1886  TType(const TType& type);
1887  TType& operator=(const TType& type);
1888 
1889  // Recursively copy a type graph, while preserving the graph-like
1890  // quality. That is, don't make more than one copy of a structure that
1891  // gets reused multiple times in the type graph.
1892  void deepCopy(const TType& copyOf, TMap<TTypeList*,TTypeList*>& copiedMap)
1893  {
1894  shallowCopy(copyOf);
1895 
1896  if (copyOf.arraySizes) {
1897  arraySizes = new TArraySizes;
1898  *arraySizes = *copyOf.arraySizes;
1899  }
1900 
1901  if (copyOf.structure) {
1902  auto prevCopy = copiedMap.find(copyOf.structure);
1903  if (prevCopy != copiedMap.end())
1904  structure = prevCopy->second;
1905  else {
1906  structure = new TTypeList;
1907  copiedMap[copyOf.structure] = structure;
1908  for (unsigned int i = 0; i < copyOf.structure->size(); ++i) {
1909  TTypeLoc typeLoc;
1910  typeLoc.loc = (*copyOf.structure)[i].loc;
1911  typeLoc.type = new TType();
1912  typeLoc.type->deepCopy(*(*copyOf.structure)[i].type, copiedMap);
1913  structure->push_back(typeLoc);
1914  }
1915  }
1916  }
1917 
1918  if (copyOf.fieldName)
1919  fieldName = NewPoolTString(copyOf.fieldName->c_str());
1920  if (copyOf.typeName)
1921  typeName = NewPoolTString(copyOf.typeName->c_str());
1922  }
1923 
1924 
1925  void buildMangledName(TString&) const;
1926 
1928  int vectorSize : 4; // 1 means either scalar or 1-component vector; see vector1 to disambiguate.
1929  int matrixCols : 4;
1930  int matrixRows : 4;
1931  bool vector1 : 1; // Backward-compatible tracking of a 1-component vector distinguished from a scalar.
1932  // GLSL 4.5 never has a 1-component vector; so this will always be false until such
1933  // functionality is added.
1934  // HLSL does have a 1-component vectors, so this will be true to disambiguate
1935  // from a scalar.
1937 
1938  TArraySizes* arraySizes; // nullptr unless an array; can be shared across types
1939  TTypeList* structure; // nullptr unless this is a struct; can be shared across types
1940  TString *fieldName; // for structure field names
1941  TString *typeName; // for structure type name
1943 };
1944 
1945 } // end namespace glslang
1946 
1947 #endif // _TYPES_INCLUDED_
bool hasAnyLocation() const
Definition: Types.h:770
virtual bool containsNonOpaque() const
Definition: Types.h:1444
TSamplerDim
Definition: Types.h:62
Definition: Types.h:1103
Definition: Types.h:346
bool isArrayed() const
Definition: Types.h:104
bool layoutPushConstant
Definition: Types.h:725
TBuiltInVariable declaredBuiltIn
Definition: Types.h:488
static const char * getBasicString(TBasicType t)
Definition: Types.h:1547
const char * getPrecisionQualifierString() const
Definition: Types.h:1776
Definition: Common.h:190
Definition: Types.h:404
TType(TTypeList *userDef, const TString &n)
Definition: Types.h:1262
const TTypeList * getStruct() const
Definition: Types.h:1777
TType(TTypeList *userDef, const TString &n, const TQualifier &q)
Definition: Types.h:1271
GLuint const GLchar * name
Definition: glext.h:6671
Definition: BaseTypes.h:58
virtual int getCumulativeArraySize() const
Definition: Types.h:1353
int matrixCols
Definition: Types.h:1929
Definition: Types.h:328
Definition: Types.h:370
void appendMangledName(TString &name) const
Definition: Types.h:1801
void changeOuterSize(int s)
Definition: arrays.h:259
Definition: BaseTypes.h:53
Definition: Types.h:278
Definition: BaseTypes.h:86
void merge(const TShaderQualifiers &src)
Definition: Types.h:1052
Definition: Types.h:326
Definition: ShaderLang.h:92
static const unsigned int layoutLocationEnd
Definition: Types.h:691
void makeTemporary()
Definition: Types.h:432
Definition: BaseTypes.h:61
bool centroid
Definition: Types.h:492
GLenum GLenum GLuint components
Definition: glext.h:10527
int matrixRows
Definition: Types.h:1930
int localSizeSpecId[3]
Definition: Types.h:1013
Definition: ShaderLang.h:94
Definition: Types.h:309
Definition: BaseTypes.h:379
bool hasNonXfbLayout() const
Definition: Types.h:672
TType * type
Definition: Types.h:262
Definition: Types.h:294
Definition: BaseTypes.h:55
bool isShadow() const
Definition: Types.h:103
void deepCopy(const TType &copyOf, TMap< TTypeList *, TTypeList *> &copiedMap)
Definition: Types.h:1892
bool hasUniformLayout() const
Definition: Types.h:733
bool isSpecConstant() const
Definition: Types.h:832
int getDimSize(int dim) const
Definition: arrays.h:239
Definition: BaseTypes.h:88
bool noContraction
Definition: Types.h:491
EShLanguage
Definition: ShaderLang.h:90
static const unsigned int layoutComponentEnd
Definition: Types.h:694
Definition: BaseTypes.h:87
TBlendEquationShift
Definition: Types.h:394
bool hasOffset() const
Definition: Types.h:762
Definition: BaseTypes.h:60
const char * semanticName
Definition: Types.h:485
bool restrict
Definition: Types.h:503
unsigned int layoutXfbBuffer
Definition: Types.h:708
std::string to_string(const T &val)
Definition: Common.h:45
Definition: BaseTypes.h:107
virtual bool hiddenMember() const
Definition: Types.h:1326
Definition: BaseTypes.h:49
TString * fieldName
Definition: Types.h:1940
Definition: Common.h:231
Definition: BaseTypes.h:63
Definition: Types.h:411
unsigned int layoutSpecConstantId
Definition: Types.h:720
bool sameStructType(const TType &right) const
Definition: Types.h:1815
const int GlslangMaxTypeLength
Definition: Types.h:51
Definition: Types.h:287
Definition: BaseTypes.h:112
virtual int getImplicitArraySize() const
Definition: Types.h:1355
bool hasComponent() const
Definition: Types.h:780
Definition: BaseTypes.h:52
int layoutOffset
Definition: Types.h:687
TLayoutDepth layoutDepth
Definition: Types.h:1016
Definition: Types.h:298
virtual bool containsOpaque() const
Definition: Types.h:1433
Definition: Types.h:369
TStorageQualifier storage
Definition: Types.h:486
virtual bool isTexture() const
Definition: Types.h:1395
GLdouble GLdouble GLdouble r
Definition: glext.h:6406
Definition: Types.h:63
Definition: Types.h:295
Definition: Types.h:343
Definition: Types.h:316
GLenum GLuint GLint GLint GLsizei numViews
Definition: glsym_es2.h:226
void clearInterstage()
Definition: Types.h:444
void clearInterstageLayout()
Definition: Types.h:653
GLdouble GLdouble t
Definition: glext.h:6398
bool sample
Definition: Types.h:500
Definition: Types.h:352
Definition: Types.h:280
virtual bool containsUnsizedArray() const
Definition: Types.h:1428
unsigned int layoutStream
Definition: Types.h:705
Definition: BaseTypes.h:109
Definition: Types.h:400
void clearXfbLayout()
Definition: Types.h:665
static const char * getVertexOrderString(TVertexOrder order)
Definition: Types.h:980
Definition: BaseTypes.h:47
Definition: Types.h:261
bool hasLocation() const
Definition: Types.h:776
Definition: Types.h:372
#define P(a, b, c, d, k, s, t)
bool hasIndex() const
Definition: Types.h:784
const char * getBuiltInVariableString() const
Definition: Types.h:1775
unsigned int layoutComponent
Definition: Types.h:693
void clear()
Definition: Types.h:422
bool operator!=(const TType &right) const
Definition: Types.h:1879
Definition: Types.h:376
GLsizeiptr size
Definition: glext.h:6559
Definition: BaseTypes.h:102
GLfloat f
Definition: glext.h:8207
bool hasReturnStruct() const
Definition: Types.h:106
__inline const char * GetStorageQualifierString(TStorageQualifier q)
Definition: BaseTypes.h:251
bool readonly
Definition: Types.h:504
virtual TArraySizes * getArraySizes()
Definition: Types.h:1357
static const char * getLayoutDepthString(TLayoutDepth d)
Definition: Types.h:924
TString * NewPoolTString(const char *s)
Definition: Common.h:156
Definition: Types.h:358
Definition: Types.h:410
bool postDepthCoverage
Definition: Types.h:1015
int vectorSize
Definition: Types.h:1109
bool isVariablyIndexed() const
Definition: arrays.h:319
virtual const TString & getFieldName() const
Definition: Types.h:1335
bool isPureSampler() const
Definition: Types.h:101
static const unsigned int layoutBindingEnd
Definition: Types.h:700
void makeTemporary()
Definition: Types.h:1306
void setImage(TBasicType t, TSamplerDim d, bool a=false, bool s=false, bool m=false)
Definition: Types.h:138
void shallowCopy(const TType &copyOf)
Definition: Types.h:1283
bool isUniformOrBuffer() const
Definition: Types.h:585
GLdouble s
Definition: glext.h:6390
static const int layoutNotSet
Definition: Types.h:420
TTypeList * getWritableStruct() const
Definition: Types.h:1779
TVertexSpacing spacing
Definition: Types.h:1009
TSourceLoc loc
Definition: Types.h:1114
TLayoutMatrix
Definition: Types.h:283
bool hasXfb() const
Definition: Types.h:804
TBuiltInVariable
Definition: BaseTypes.h:135
Definition: Types.h:302
virtual bool isArray() const
Definition: Types.h:1363
bool invariant
Definition: Types.h:490
TType(TBasicType t=EbtVoid, TStorageQualifier q=EvqTemporary, int vs=1, int mc=0, int mr=0, bool isVector=false)
Definition: Types.h:1174
unsigned int layoutAttachment
Definition: Types.h:717
bool sameElementType(const TType &right) const
Definition: Types.h:1843
Definition: Types.h:279
void clearLayout()
Definition: Types.h:635
const char * getBasicString() const
Definition: Types.h:1542
Definition: BaseTypes.h:113
Definition: Types.h:65
const char * getStorageQualifierString() const
Definition: Types.h:1774
Definition: Types.h:342
Definition: Types.h:381
virtual TIntermTyped * getOuterArrayNode() const
Definition: Types.h:1352
bool hasXfbBuffer() const
Definition: Types.h:810
TSourceLoc loc
Definition: Types.h:263
static const unsigned int layoutStreamEnd
Definition: Types.h:706
Definition: BaseTypes.h:93
unsigned int layoutXfbStride
Definition: Types.h:711
bool isMemory() const
Definition: Types.h:509
void init()
Definition: Types.h:1024
void makeSpecConstant()
Definition: Types.h:854
Definition: Types.h:276
Definition: Types.h:301
Definition: BaseTypes.h:99
GLenum GLint GLint * precision
Definition: glext.h:8206
bool nopersp
Definition: Types.h:495
unsigned int getVectorSize() const
Definition: Types.h:96
TString * typeName
Definition: Types.h:1941
Definition: Types.h:399
bool shadow
Definition: Types.h:78
Definition: Types.h:315
GLdouble GLdouble right
Definition: glext.h:11766
Definition: Types.h:1003
Definition: Types.h:375
static const char * getVertexSpacingString(TVertexSpacing spacing)
Definition: Types.h:971
static int mapGeometryToSize(TLayoutGeometry geometry)
Definition: Types.h:988
const GLubyte * c
Definition: glext.h:9812
void clearUniformLayout()
Definition: Types.h:742
Definition: Types.h:300
bool isCombined() const
Definition: Types.h:100
Definition: Types.h:74
TSampler sampler
Definition: Types.h:1106
void updateImplicitSize(int s)
Definition: arrays.h:261
bool isIo() const
Definition: Types.h:596
Definition: Types.h:408
void copyArrayInnerSizes(const TArraySizes *s)
Definition: Types.h:1513
Definition: BaseTypes.h:82
Definition: Types.h:413
void set(TBasicType t, TSamplerDim d, bool a=false, bool s=false, bool m=false)
Definition: Types.h:126
virtual TSampler & getSampler()
Definition: Types.h:1343
Definition: BaseTypes.h:104
Definition: Types.h:405
Definition: Types.h:303
__inline const char * GetBuiltInVariableString(TBuiltInVariable v)
Definition: BaseTypes.h:280
bool hasSpecConstantId() const
Definition: Types.h:826
TLayoutPacking
Definition: Types.h:274
bool isPipeInput() const
Definition: Types.h:532
bool ms
Definition: Types.h:79
bool flat
Definition: Types.h:494
TQualifier qualifier
Definition: Types.h:1936
Definition: Types.h:308
TVector< TString * > TIdentifierList
Definition: Types.h:267
bool isConstant() const
Definition: Types.h:849
TPoolAllocator & GetThreadPoolAllocator()
Definition: PoolAlloc.cpp:47
Definition: BaseTypes.h:51
Definition: BaseTypes.h:56
bool hasXfbOffset() const
Definition: Types.h:818
static const unsigned noReturnStruct
Definition: Types.h:90
bool nonUniform
Definition: Types.h:507
Definition: Types.h:356
TString getString() const
Definition: Types.h:198
virtual bool isIntegerDomain() const
Definition: Types.h:1371
unsigned int layoutLocation
Definition: Types.h:690
bool volatil
Definition: Types.h:502
Definition: Types.h:359
bool pixelCenterInteger
Definition: Types.h:1005
int getOuterSize() const
Definition: arrays.h:242
GLenum type
Definition: glext.h:6233
static const char * getBlendEquationString(TBlendEquationShift e)
Definition: Types.h:934
Definition: Types.h:275
bool hasBinding() const
Definition: Types.h:792
Definition: Types.h:344
bool l
Definition: connect_wiiupro.c:37
TType & operator=(const TType &type)
Definition: Types.h:1169
TBasicType basicType
Definition: Types.h:1927
static const unsigned int layoutSpecConstantIdEnd
Definition: Types.h:721
void copyDereferenced(const TArraySizes &rhs)
Definition: arrays.h:297
bool hasMatrix() const
Definition: Types.h:754
void setVariablyIndexed()
Definition: arrays.h:318
static const unsigned int layoutXfbOffsetEnd
Definition: Types.h:715
Definition: Types.h:286
int matrixRows
Definition: Types.h:1111
bool isParamInput() const
Definition: Types.h:562
virtual bool isStruct() const
Definition: Types.h:1369
Definition: BaseTypes.h:83
TLayoutPacking layoutPacking
Definition: Types.h:686
Definition: Types.h:418
void deepCopy(const TType &copyOf)
Definition: Types.h:1299
bool hasAlign() const
Definition: Types.h:766
bool IsAnonymous(const TString &name)
Definition: Types.h:54
TType(const TSampler &sampler, TStorageQualifier q=EvqUniform, TArraySizes *as=nullptr)
Definition: Types.h:1214
bool isArrayedIo(EShLanguage language) const
Definition: Types.h:620
bool external
Definition: Types.h:83
static const unsigned structReturnSlots
Definition: Types.h:89
Definition: Types.h:336
Definition: Types.h:332
void setVector(int s)
Definition: Types.h:1142
static const unsigned int layoutXfbBufferEnd
Definition: Types.h:709
virtual void setFieldName(const TString &n)
Definition: Types.h:1328
virtual bool isImage() const
Definition: Types.h:1393
bool sampler
Definition: Types.h:82
__inline const char * GetPrecisionQualifierString(TPrecisionQualifier p)
Definition: BaseTypes.h:382
Definition: BaseTypes.h:94
int computeNumComponents() const
Definition: Types.h:1781
bool isImage() const
Definition: Types.h:98
Definition: BaseTypes.h:376
virtual bool containsStructure() const
Definition: Types.h:1422
TVertexSpacing
Definition: Types.h:306
TString getCompleteString() const
Definition: Types.h:1571
Definition: Types.h:71
Definition: Types.h:415
TTypeList * structure
Definition: Types.h:1939
#define POOL_ALLOCATOR_NEW_DELETE(A)
Definition: Common.h:112
TSamplerDim dim
Definition: Types.h:76
virtual bool containsBasicType(TBasicType checkType) const
Definition: Types.h:1410
const char *const AnonymousPrefix
Definition: Types.h:53
bool writeonly
Definition: Types.h:505
Definition: Types.h:388
Definition: Types.h:403
virtual bool isScalar() const
Definition: Types.h:1359
bool operator==(const TSampler &right) const
Definition: Types.h:178
virtual const TString & getTypeName() const
Definition: Types.h:1329
static const char * getLayoutPackingString(TLayoutPacking packing)
Definition: Types.h:859
virtual void setArrayVariablyIndexed()
Definition: Types.h:1367
Definition: Types.h:360
Definition: Types.h:333
bool vector1
Definition: Types.h:1931
Definition: Types.h:285
Definition: Types.h:296
void updateArraySizes(const TType &type)
Definition: Types.h:1486
bool sameElementShape(const TType &right) const
Definition: Types.h:1863
void clearInterpolation()
Definition: Types.h:451
TQualifier qualifier
Definition: Types.h:1107
GLenum GLsizei GLenum GLenum const GLvoid * image
Definition: glext.h:6305
TIntermTyped * getOuterNode() const
Definition: arrays.h:243
bool earlyFragmentTests
Definition: Types.h:1014
void changeOuterArraySize(int s)
Definition: Types.h:1522
Definition: Types.h:348
bool arrayed
Definition: Types.h:77
static const unsigned int layoutIndexEnd
Definition: Types.h:703
Definition: Types.h:324
TSampler sampler
Definition: Types.h:1942
Definition: Types.h:66
TLayoutFormat layoutFormat
Definition: Types.h:723
Definition: Types.h:314
bool contains(P predicate) const
Definition: Types.h:1399
Definition: Types.h:412
GLenum src
Definition: glext.h:6980
bool hasFormat() const
Definition: Types.h:800
bool isPipeOutput() const
Definition: Types.h:547
TType(TBasicType t, TStorageQualifier q, TPrecisionQualifier p, int vs=1, int mc=0, int mr=0, bool isVector=false)
Definition: Types.h:1185
const int UnsizedArraySize
Definition: arrays.h:49
bool isTexture() const
Definition: Types.h:102
TLayoutGeometry
Definition: Types.h:293
Definition: Types.h:409
void setTexture(TBasicType t, TSamplerDim d, bool a=false, bool s=false, bool m=false)
Definition: Types.h:150
bool hasXfbStride() const
Definition: Types.h:814
int vectorSize
Definition: Types.h:1928
GLdouble GLdouble GLdouble GLdouble q
Definition: glext.h:6414
GLuint GLdouble GLdouble GLint GLint order
Definition: glext.h:12101
void setStruct(TTypeList *s)
Definition: Types.h:1778
TType * clone() const
Definition: Types.h:1315
Definition: BaseTypes.h:92
const TType * userDef
Definition: Types.h:1113
bool isInterpolation() const
Definition: Types.h:513
Definition: Types.h:386
Definition: Types.h:378
bool isAuxiliary() const
Definition: Types.h:527
virtual TBasicType getBasicType() const
Definition: Types.h:1341
bool operator==(const TType &right) const
Definition: Types.h:1874
Definition: Types.h:310
GLfloat GLfloat p
Definition: glext.h:9809
Definition: Types.h:345
virtual bool isFloatingDomain() const
Definition: Types.h:1370
virtual bool isSubpass() const
Definition: Types.h:1394
TShaderQualifiers shaderQualifiers
Definition: Types.h:1108
bool isFrontEndConstant() const
Definition: Types.h:843
Definition: Types.h:338
virtual bool isArrayVariablyIndexed() const
Definition: Types.h:1366
TArraySizes * arraySizes
Definition: Types.h:1938
bool coherent
Definition: Types.h:501
Definition: arrays.h:222
bool isImage() const
Definition: Types.h:1162
Definition: Types.h:402
Definition: Types.h:69
static const unsigned int layoutSetEnd
Definition: Types.h:697
Definition: Types.h:377
virtual bool isBuiltIn() const
Definition: Types.h:1390
Definition: BaseTypes.h:108
void buildMangledName(TString &) const
Definition: SymbolTable.cpp:54
TVector< TTypeLoc > TTypeList
Definition: Types.h:265
TLayoutMatrix layoutMatrix
Definition: Types.h:685
bool hasPacking() const
Definition: Types.h:758
Definition: Types.h:67
TArraySizes * arraySizes
Definition: Types.h:1112
Definition: arrays.h:46
bool sameArrayness(const TType &right) const
Definition: Types.h:1849
void clear()
Definition: Types.h:108
virtual bool isArrayOfArrays() const
Definition: Types.h:1354
TStorageQualifier
Definition: BaseTypes.h:81
void initQualifiers(bool global=false)
Definition: Types.h:1127
Definition: Types.h:277
virtual bool isVector() const
Definition: Types.h:1361
void copyArraySizes(const TArraySizes &s)
Definition: Types.h:1494
bool hasAttachment() const
Definition: Types.h:822
Definition: Types.h:401
virtual int getMatrixCols() const
Definition: Types.h:1349
bool hasLayout() const
Definition: Types.h:680
Definition: Types.h:361
virtual bool containsBuiltIn() const
Definition: Types.h:1439
virtual TQualifier & getQualifier()
Definition: Types.h:1345
int vertices
Definition: Types.h:1008
Definition: Types.h:385
Definition: BaseTypes.h:103
static const char * getLayoutMatrixString(TLayoutMatrix m)
Definition: Types.h:869
void setSubpass(TBasicType t, bool m=false)
Definition: Types.h:161
virtual void updateImplicitArraySize(int size)
Definition: Types.h:1368
Definition: ibxm.h:14
unsigned int layoutIndex
Definition: Types.h:702
int layoutAlign
Definition: Types.h:688
TType(const TPublicType &p)
Definition: Types.h:1198
int getCumulativeSize() const
Definition: arrays.h:244
int getNumDims() const
Definition: arrays.h:238
virtual bool isUnsizedArray() const
Definition: Types.h:1365
Definition: Types.h:354
TVertexOrder order
Definition: Types.h:1010
Definition: Types.h:335
virtual bool isScalarOrVec1() const
Definition: Types.h:1360
Definition: Types.h:339
Definition: BaseTypes.h:95
void addInnerSizes(const TArraySizes &s)
Definition: arrays.h:258
Definition: Types.h:398
int localSize[3]
Definition: Types.h:1012
static const char * getGeometryString(TLayoutGeometry geometry)
Definition: Types.h:956
bool isScalar() const
Definition: Types.h:1156
Definition: Types.h:353
Definition: Types.h:284
Definition: Types.h:327
static const unsigned int layoutAttachmentEnd
Definition: Types.h:718
bool smooth
Definition: Types.h:493
TPrecisionQualifier
Definition: BaseTypes.h:375
bool pointMode
Definition: Types.h:1011
Definition: Types.h:299
void makeVector()
Definition: Types.h:1323
Definition: Types.h:297
virtual const TArraySizes * getArraySizes() const
Definition: Types.h:1356
TVertexOrder
Definition: Types.h:313
TBasicType
Definition: BaseTypes.h:46
bool hasSet() const
Definition: Types.h:788
Definition: Types.h:68
virtual bool isMatrix() const
Definition: Types.h:1362
bool isParamOutput() const
Definition: Types.h:574
unsigned int layoutBinding
Definition: Types.h:699
Definition: Types.h:389
Definition: BaseTypes.h:50
TLayoutGeometry geometry
Definition: Types.h:1004
Definition: Types.h:364
TBasicType basicType
Definition: Types.h:1105
void transferArraySizes(TArraySizes *s)
Definition: Types.h:1500
virtual bool containsSpecializationSize() const
Definition: Types.h:1470
Definition: BaseTypes.h:59
int getImplicitSize() const
Definition: arrays.h:260
Definition: BaseTypes.h:98
Definition: retroarch.h:240
bool sameInnerArrayness(const TArraySizes &rhs) const
Definition: arrays.h:304
unsigned int layoutSet
Definition: Types.h:696
bool isSized() const
Definition: arrays.h:295
Definition: Types.h:407
Definition: Types.h:330
static const unsigned structReturnIndexBits
Definition: Types.h:88
virtual int getOuterArraySize() const
Definition: Types.h:1351
virtual bool isSizedArray() const
Definition: Types.h:1364
static const unsigned int layoutXfbStrideEnd
Definition: Types.h:712
static const char * getLayoutFormatString(TLayoutFormat f)
Definition: Types.h:877
virtual bool containsArray() const
Definition: Types.h:1416
void init(const TSourceLoc &l, bool global=false)
Definition: Types.h:1134
TLayoutFormat
Definition: Types.h:320
virtual const TQualifier & getQualifier() const
Definition: Types.h:1346
bool isNonUniform() const
Definition: Types.h:839
int numViews
Definition: Types.h:1018
Definition: Types.h:307
void adoptImplicitArraySizes(bool skipNonvariablyIndexed)
Definition: Types.h:1529
TBuiltInVariable builtIn
Definition: Types.h:487
Definition: BaseTypes.h:136
Definition: BaseTypes.h:54
Definition: Types.h:367
bool isSubpass() const
Definition: Types.h:99
void makePartialTemporary()
Definition: Types.h:478
int invocations
Definition: Types.h:1007
virtual const TSampler & getSampler() const
Definition: Types.h:1342
bool hasStream() const
Definition: Types.h:796
#define false
Definition: ordinals.h:83
Definition: Types.h:374
GLuint sampler
Definition: glext.h:7950
Definition: Types.h:337
void initType(const TSourceLoc &l)
Definition: Types.h:1116
#define true
Definition: ordinals.h:82
Definition: Common.h:175
virtual int getVectorSize() const
Definition: Types.h:1348
TType(const TType &type, int derefIndex, bool rowMajor=false)
Definition: Types.h:1225
Definition: Types.h:64
TPrecisionQualifier precision
Definition: Types.h:489
Definition: BaseTypes.h:62
bool image
Definition: Types.h:80
virtual bool isOpaque() const
Definition: Types.h:1389
unsigned int structReturnIndex
Definition: Types.h:93
virtual int getMatrixRows() const
Definition: Types.h:1350
int matrixCols
Definition: Types.h:1110
Definition: intermediate.h:1042
void clearStreamLayout()
Definition: Types.h:661
bool patch
Definition: Types.h:499
void clearMemory()
Definition: Types.h:462
Definition: Types.h:70
bool specConstant
Definition: Types.h:506
TString getBasicTypeString() const
Definition: Types.h:1766
void setMatrix(int c, int r)
Definition: Types.h:1149
unsigned int layoutXfbOffset
Definition: Types.h:714
bool blendEquation
Definition: Types.h:1017
Definition: Types.h:340
Definition: Types.h:379
GLdouble n
Definition: glext.h:8396
bool originUpperLeft
Definition: Types.h:1006
Definition: Types.h:321
void clearArraySizes()
Definition: Types.h:1506
TLayoutDepth
Definition: Types.h:384
bool sameInnerArrayness(const TType &right) const
Definition: Types.h:1856
const GLfloat * m
Definition: glext.h:11755
bool operator!=(const TSampler &right) const
Definition: Types.h:193
Definition: BaseTypes.h:84
Definition: Types.h:391
Definition: BaseTypes.h:85
Definition: Types.h:368
Definition: lobject.h:303
Definition: Types.h:325
Definition: Types.h:334
Definition: BaseTypes.h:57
GLboolean GLboolean GLboolean GLboolean a
Definition: glext.h:6844
TBasicType type
Definition: Types.h:75
virtual void hideMember()
Definition: Types.h:1325
bool isSubpass() const
Definition: Types.h:1163
Definition: Types.h:351
Definition: BaseTypes.h:48
Definition: Types.h:406
Definition: Types.h:387
bool isMultiSample() const
Definition: Types.h:105
Definition: ShaderLang.h:93
virtual ~TType()
Definition: Types.h:1278
void setPureSampler(bool s)
Definition: Types.h:171
unsigned int vectorSize
Definition: Types.h:84
Definition: Types.h:341
bool combined
Definition: Types.h:81
Definition: Types.h:362