2 // Copyright (c) 2013-2014 The ANGLE Project Authors. All rights reserved.
3 // Use of this source code is governed by a BSD-style license that can be
4 // found in the LICENSE file.
7 // Types to represent GL variables (varyings, uniforms, etc)
10 #ifndef _COMPILER_INTERFACE_VARIABLES_
11 #define _COMPILER_INTERFACE_VARIABLES_
17 // Assume ShaderLang.h is included before ShaderVars.h, for sh::GLenum
18 // Note: make sure to increment ANGLE_SH_VERSION when changing ShaderVars.h
23 // Varying interpolation qualifier, see section 4.3.9 of the ESSL 3.00.4 spec
24 enum InterpolationType
27 INTERPOLATION_CENTROID,
31 // Uniform block layout qualifier, see section 4.3.8.3 of the ESSL 3.00.4 spec
39 // Base class for all variables defined in shaders, including Varyings, Uniforms, etc
40 // Note: we must override the copy constructor and assignment operator so we can
41 // work around excessive GCC binary bloating:
42 // See https://code.google.com/p/angleproject/issues/detail?id=697
43 struct COMPILER_EXPORT ShaderVariable
46 ShaderVariable(GLenum typeIn, unsigned int arraySizeIn);
48 ShaderVariable(const ShaderVariable &other);
49 ShaderVariable &operator=(const ShaderVariable &other);
51 bool isArray() const { return arraySize > 0; }
52 unsigned int elementCount() const { return std::max(1u, arraySize); }
53 bool isStruct() const { return !fields.empty(); }
58 std::string mappedName;
59 unsigned int arraySize;
61 std::vector<ShaderVariable> fields;
62 std::string structName;
65 struct COMPILER_EXPORT Uniform : public ShaderVariable
69 Uniform(const Uniform &other);
70 Uniform &operator=(const Uniform &other);
73 struct COMPILER_EXPORT Attribute : public ShaderVariable
77 Attribute(const Attribute &other);
78 Attribute &operator=(const Attribute &other);
83 struct COMPILER_EXPORT InterfaceBlockField : public ShaderVariable
85 InterfaceBlockField();
86 ~InterfaceBlockField();
87 InterfaceBlockField(const InterfaceBlockField &other);
88 InterfaceBlockField &operator=(const InterfaceBlockField &other);
90 bool isRowMajorLayout;
93 struct COMPILER_EXPORT Varying : public ShaderVariable
97 Varying(const Varying &other);
98 Varying &operator=(const Varying &other);
100 InterpolationType interpolation;
104 struct COMPILER_EXPORT InterfaceBlock
108 InterfaceBlock(const InterfaceBlock &other);
109 InterfaceBlock &operator=(const InterfaceBlock &other);
112 std::string mappedName;
113 std::string instanceName;
114 unsigned int arraySize;
115 BlockLayoutType layout;
116 bool isRowMajorLayout;
118 std::vector<InterfaceBlockField> fields;
123 #endif // _COMPILER_INTERFACE_VARIABLES_