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