summaryrefslogtreecommitdiffstats
path: root/src/3rdparty/angle/include/GLSLANG/ShaderVars.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/3rdparty/angle/include/GLSLANG/ShaderVars.h')
-rw-r--r--src/3rdparty/angle/include/GLSLANG/ShaderVars.h161
1 files changed, 129 insertions, 32 deletions
diff --git a/src/3rdparty/angle/include/GLSLANG/ShaderVars.h b/src/3rdparty/angle/include/GLSLANG/ShaderVars.h
index af9b65b7f5..709428aebf 100644
--- a/src/3rdparty/angle/include/GLSLANG/ShaderVars.h
+++ b/src/3rdparty/angle/include/GLSLANG/ShaderVars.h
@@ -10,15 +10,18 @@
#ifndef GLSLANG_SHADERVARS_H_
#define GLSLANG_SHADERVARS_H_
+#include <algorithm>
+#include <array>
#include <string>
#include <vector>
-#include <algorithm>
-// Assume ShaderLang.h is included before ShaderVars.h, for sh::GLenum
-// Note: make sure to increment ANGLE_SH_VERSION when changing ShaderVars.h
+// This type is defined here to simplify ANGLE's integration with glslang for SPIRv.
+using ShCompileOptions = uint64_t;
namespace sh
{
+// GLenum alias
+typedef unsigned int GLenum;
// Varying interpolation qualifier, see section 4.3.9 of the ESSL 3.00.4 spec
enum InterpolationType
@@ -29,30 +32,65 @@ enum InterpolationType
};
// Validate link & SSO consistency of interpolation qualifiers
-COMPILER_EXPORT bool InterpolationTypesMatch(InterpolationType a, InterpolationType b);
+bool InterpolationTypesMatch(InterpolationType a, InterpolationType b);
// Uniform block layout qualifier, see section 4.3.8.3 of the ESSL 3.00.4 spec
enum BlockLayoutType
{
BLOCKLAYOUT_STANDARD,
+ BLOCKLAYOUT_STD140 = BLOCKLAYOUT_STANDARD,
+ BLOCKLAYOUT_STD430, // Shader storage block layout qualifier
BLOCKLAYOUT_PACKED,
BLOCKLAYOUT_SHARED
};
+// Interface Blocks, see section 4.3.9 of the ESSL 3.10 spec
+enum class BlockType
+{
+ BLOCK_UNIFORM,
+ BLOCK_BUFFER,
+
+ // Required in OpenGL ES 3.1 extension GL_OES_shader_io_blocks.
+ // TODO(jiawei.shao@intel.com): add BLOCK_OUT.
+ BLOCK_IN
+};
+
// Base class for all variables defined in shaders, including Varyings, Uniforms, etc
// Note: we must override the copy constructor and assignment operator so we can
// work around excessive GCC binary bloating:
// See https://code.google.com/p/angleproject/issues/detail?id=697
-struct COMPILER_EXPORT ShaderVariable
+struct ShaderVariable
{
ShaderVariable();
+ ShaderVariable(GLenum typeIn);
ShaderVariable(GLenum typeIn, unsigned int arraySizeIn);
~ShaderVariable();
ShaderVariable(const ShaderVariable &other);
ShaderVariable &operator=(const ShaderVariable &other);
- bool isArray() const { return arraySize > 0; }
- unsigned int elementCount() const { return std::max(1u, arraySize); }
+ bool isArrayOfArrays() const { return arraySizes.size() >= 2u; }
+ bool isArray() const { return !arraySizes.empty(); }
+ unsigned int getArraySizeProduct() const;
+
+ // Array size 0 means not an array when passed to or returned from these functions.
+ // Note that setArraySize() is deprecated and should not be used inside ANGLE.
+ unsigned int getOutermostArraySize() const { return isArray() ? arraySizes.back() : 0; }
+ void setArraySize(unsigned int size);
+
+ // Turn this ShaderVariable from an array into a specific element in that array. Will update
+ // flattenedOffsetInParentArrays.
+ void indexIntoArray(unsigned int arrayIndex);
+
+ // Get the nth nested array size from the top. Caller is responsible for range checking
+ // arrayNestingIndex.
+ unsigned int getNestedArraySize(unsigned int arrayNestingIndex) const;
+
+ // This function should only be used with variables that are of a basic type or an array of a
+ // basic type. Shader interface variables that are enumerated according to rules in GLES 3.1
+ // spec section 7.3.1.1 page 77 are fine. For those variables the return value should match the
+ // ARRAY_SIZE value that can be queried through the API.
+ unsigned int getBasicTypeElementCount() const;
+
bool isStruct() const { return !fields.empty(); }
// All of the shader's variables are described using nested data
@@ -70,20 +108,32 @@ struct COMPILER_EXPORT ShaderVariable
const ShaderVariable **leafVar,
std::string* originalFullName) const;
- bool isBuiltIn() const { return name.compare(0, 3, "gl_") == 0; }
+ bool isBuiltIn() const;
GLenum type;
GLenum precision;
std::string name;
std::string mappedName;
- unsigned int arraySize;
+
+ // Used to make an array type. Outermost array size is stored at the end of the vector.
+ std::vector<unsigned int> arraySizes;
+
+ // Offset of this variable in parent arrays. In case the parent is an array of arrays, the
+ // offset is outerArrayElement * innerArraySize + innerArrayElement.
+ // For example, if there's a variable declared as size 3 array of size 4 array of int:
+ // int a[3][4];
+ // then the flattenedOffsetInParentArrays of a[2] would be 2.
+ // and flattenedOffsetInParentArrays of a[2][1] would be 2*4 + 1 = 9.
+ unsigned int flattenedOffsetInParentArrays;
+
bool staticUse;
std::vector<ShaderVariable> fields;
std::string structName;
protected:
bool isSameVariableAtLinkTime(const ShaderVariable &other,
- bool matchPrecision) const;
+ bool matchPrecision,
+ bool matchName) const;
bool operator==(const ShaderVariable &other) const;
bool operator!=(const ShaderVariable &other) const
@@ -92,7 +142,21 @@ struct COMPILER_EXPORT ShaderVariable
}
};
-struct COMPILER_EXPORT Uniform : public ShaderVariable
+// A variable with an integer location to pass back to the GL API: either uniform (can have location
+// in GLES3.1+), vertex shader input or fragment shader output.
+struct VariableWithLocation : public ShaderVariable
+{
+ VariableWithLocation();
+ ~VariableWithLocation();
+ VariableWithLocation(const VariableWithLocation &other);
+ VariableWithLocation &operator=(const VariableWithLocation &other);
+ bool operator==(const VariableWithLocation &other) const;
+ bool operator!=(const VariableWithLocation &other) const { return !operator==(other); }
+
+ int location;
+};
+
+struct Uniform : public VariableWithLocation
{
Uniform();
~Uniform();
@@ -104,28 +168,17 @@ struct COMPILER_EXPORT Uniform : public ShaderVariable
return !operator==(other);
}
+ int binding;
+ int offset;
+
// Decide whether two uniforms are the same at shader link time,
// assuming one from vertex shader and the other from fragment shader.
- // See GLSL ES Spec 3.00.3, sec 4.3.5.
+ // GLSL ES Spec 3.00.3, section 4.3.5.
+ // GLSL ES Spec 3.10.4, section 4.4.5
bool isSameUniformAtLinkTime(const Uniform &other) const;
};
-// An interface variable is a variable which passes data between the GL data structures and the
-// shader execution: either vertex shader inputs or fragment shader outputs. These variables can
-// have integer locations to pass back to the GL API.
-struct COMPILER_EXPORT InterfaceVariable : public ShaderVariable
-{
- InterfaceVariable();
- ~InterfaceVariable();
- InterfaceVariable(const InterfaceVariable &other);
- InterfaceVariable &operator=(const InterfaceVariable &other);
- bool operator==(const InterfaceVariable &other) const;
- bool operator!=(const InterfaceVariable &other) const { return !operator==(other); }
-
- int location;
-};
-
-struct COMPILER_EXPORT Attribute : public InterfaceVariable
+struct Attribute : public VariableWithLocation
{
Attribute();
~Attribute();
@@ -135,7 +188,7 @@ struct COMPILER_EXPORT Attribute : public InterfaceVariable
bool operator!=(const Attribute &other) const { return !operator==(other); }
};
-struct COMPILER_EXPORT OutputVariable : public InterfaceVariable
+struct OutputVariable : public VariableWithLocation
{
OutputVariable();
~OutputVariable();
@@ -145,7 +198,7 @@ struct COMPILER_EXPORT OutputVariable : public InterfaceVariable
bool operator!=(const OutputVariable &other) const { return !operator==(other); }
};
-struct COMPILER_EXPORT InterfaceBlockField : public ShaderVariable
+struct InterfaceBlockField : public ShaderVariable
{
InterfaceBlockField();
~InterfaceBlockField();
@@ -167,7 +220,7 @@ struct COMPILER_EXPORT InterfaceBlockField : public ShaderVariable
bool isRowMajorLayout;
};
-struct COMPILER_EXPORT Varying : public ShaderVariable
+struct Varying : public VariableWithLocation
{
Varying();
~Varying();
@@ -193,7 +246,7 @@ struct COMPILER_EXPORT Varying : public ShaderVariable
bool isInvariant;
};
-struct COMPILER_EXPORT InterfaceBlock
+struct InterfaceBlock
{
InterfaceBlock();
~InterfaceBlock();
@@ -202,6 +255,15 @@ struct COMPILER_EXPORT InterfaceBlock
// Fields from blocks with non-empty instance names are prefixed with the block name.
std::string fieldPrefix() const;
+ std::string fieldMappedPrefix() const;
+
+ // Decide whether two interface blocks are the same at shader link time.
+ bool isSameInterfaceBlockAtLinkTime(const InterfaceBlock &other) const;
+
+ bool isBuiltIn() const;
+
+ bool isArray() const { return arraySize > 0; }
+ unsigned int elementCount() const { return std::max(1u, arraySize); }
std::string name;
std::string mappedName;
@@ -209,10 +271,45 @@ struct COMPILER_EXPORT InterfaceBlock
unsigned int arraySize;
BlockLayoutType layout;
bool isRowMajorLayout;
+ int binding;
bool staticUse;
+ BlockType blockType;
std::vector<InterfaceBlockField> fields;
};
+struct WorkGroupSize
+{
+ // Must have a trivial default constructor since it is used in YYSTYPE.
+ WorkGroupSize() = default;
+ explicit constexpr WorkGroupSize(int initialSize)
+ : localSizeQualifiers{initialSize, initialSize, initialSize}
+ {
+ }
+
+ void fill(int fillValue);
+ void setLocalSize(int localSizeX, int localSizeY, int localSizeZ);
+
+ int &operator[](size_t index);
+ int operator[](size_t index) const;
+ size_t size() const;
+
+ // Checks whether two work group size declarations match.
+ // Two work group size declarations are the same if the explicitly specified elements are the
+ // same or if one of them is specified as one and the other one is not specified
+ bool isWorkGroupSizeMatching(const WorkGroupSize &right) const;
+
+ // Checks whether any of the values are set.
+ bool isAnyValueSet() const;
+
+ // Checks whether all of the values are set.
+ bool isDeclared() const;
+
+ // Checks whether either all of the values are set, or none of them are.
+ bool isLocalSizeValid() const;
+
+ std::array<int, 3> localSizeQualifiers;
+};
+
} // namespace sh
#endif // GLSLANG_SHADERVARS_H_