Line data Source code
1 : //
2 : // Copyright (c) 2002-2010 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.
5 : //
6 :
7 : #ifndef COMPILER_TRANSLATOR_UTIL_H_
8 : #define COMPILER_TRANSLATOR_UTIL_H_
9 :
10 : #include <stack>
11 :
12 : #include "angle_gl.h"
13 : #include <GLSLANG/ShaderLang.h>
14 :
15 : #include "compiler/translator/Operator.h"
16 : #include "compiler/translator/Types.h"
17 :
18 : // If overflow happens, clamp the value to UINT_MIN or UINT_MAX.
19 : // Return false if overflow happens.
20 : bool atoi_clamp(const char *str, unsigned int *value);
21 :
22 : namespace sh
23 : {
24 : class TSymbolTable;
25 :
26 : float NumericLexFloat32OutOfRangeToInfinity(const std::string &str);
27 :
28 : // strtof_clamp is like strtof but
29 : // 1. it forces C locale, i.e. forcing '.' as decimal point.
30 : // 2. it sets the value to infinity if overflow happens.
31 : // 3. str should be guaranteed to be in the valid format for a floating point number as defined
32 : // by the grammar in the ESSL 3.00.6 spec section 4.1.4.
33 : // Return false if overflow happens.
34 : bool strtof_clamp(const std::string &str, float *value);
35 :
36 : GLenum GLVariableType(const TType &type);
37 : GLenum GLVariablePrecision(const TType &type);
38 : bool IsVaryingIn(TQualifier qualifier);
39 : bool IsVaryingOut(TQualifier qualifier);
40 : bool IsVarying(TQualifier qualifier);
41 : InterpolationType GetInterpolationType(TQualifier qualifier);
42 : TString ArrayString(const TType &type);
43 :
44 : TType GetShaderVariableBasicType(const sh::ShaderVariable &var);
45 :
46 : TOperator TypeToConstructorOperator(const TType &type);
47 :
48 : class GetVariableTraverser : angle::NonCopyable
49 : {
50 : public:
51 : GetVariableTraverser(const TSymbolTable &symbolTable);
52 0 : virtual ~GetVariableTraverser() {}
53 :
54 : template <typename VarT>
55 : void traverse(const TType &type, const TString &name, std::vector<VarT> *output);
56 :
57 : protected:
58 : // May be overloaded
59 0 : virtual void visitVariable(ShaderVariable *newVar) {}
60 :
61 : private:
62 : // Helper function called by traverse() to fill specific fields
63 : // for attributes/varyings/uniforms.
64 : template <typename VarT>
65 0 : void setTypeSpecificInfo(
66 0 : const TType &type, const TString &name, VarT *variable) {}
67 :
68 : const TSymbolTable &mSymbolTable;
69 : };
70 :
71 : bool IsBuiltinOutputVariable(TQualifier qualifier);
72 : bool IsBuiltinFragmentInputVariable(TQualifier qualifier);
73 : bool CanBeInvariantESSL1(TQualifier qualifier);
74 : bool CanBeInvariantESSL3OrGreater(TQualifier qualifier);
75 : } // namespace sh
76 :
77 : #endif // COMPILER_TRANSLATOR_UTIL_H_
|