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/HashNames.h"
16 #include "compiler/translator/Operator.h"
17 #include "compiler/translator/Types.h"
18 
19 // If overflow happens, clamp the value to UINT_MIN or UINT_MAX.
20 // Return false if overflow happens.
21 bool atoi_clamp(const char *str, unsigned int *value);
22 
23 namespace sh
24 {
25 class TSymbolTable;
26 
27 float NumericLexFloat32OutOfRangeToInfinity(const std::string &str);
28 
29 // strtof_clamp is like strtof but
30 //   1. it forces C locale, i.e. forcing '.' as decimal point.
31 //   2. it sets the value to infinity if overflow happens.
32 //   3. str should be guaranteed to be in the valid format for a floating point number as defined
33 //      by the grammar in the ESSL 3.00.6 spec section 4.1.4.
34 // Return false if overflow happens.
35 bool strtof_clamp(const std::string &str, float *value);
36 
37 GLenum GLVariableType(const TType &type);
38 GLenum GLVariablePrecision(const TType &type);
39 bool IsVaryingIn(TQualifier qualifier);
40 bool IsVaryingOut(TQualifier qualifier);
41 bool IsVarying(TQualifier qualifier);
42 bool IsGeometryShaderInput(GLenum shaderType, TQualifier qualifier);
43 InterpolationType GetInterpolationType(TQualifier qualifier);
44 
45 // Returns array brackets including size with outermost array size first, as specified in GLSL ES
46 // 3.10 section 4.1.9.
47 TString ArrayString(const TType &type);
48 
49 TString GetTypeName(const TType &type, ShHashFunction64 hashFunction, NameMap *nameMap);
50 
51 TType GetShaderVariableBasicType(const sh::ShaderVariable &var);
52 
53 bool IsBuiltinOutputVariable(TQualifier qualifier);
54 bool IsBuiltinFragmentInputVariable(TQualifier qualifier);
55 bool CanBeInvariantESSL1(TQualifier qualifier);
56 bool CanBeInvariantESSL3OrGreater(TQualifier qualifier);
57 bool IsOutputESSL(ShShaderOutput output);
58 bool IsOutputGLSL(ShShaderOutput output);
59 bool IsOutputHLSL(ShShaderOutput output);
60 bool IsOutputVulkan(ShShaderOutput output);
61 }  // namespace sh
62 
63 #endif  // COMPILER_TRANSLATOR_UTIL_H_
64