daniel@transgaming.com | 91ed149 | 2010-10-29 03:11:43 +0000 | [diff] [blame] | 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 | |
Geoff Lang | 0a73dd8 | 2014-11-19 16:18:08 -0500 | [diff] [blame] | 7 | #ifndef COMPILER_TRANSLATOR_UTIL_H_ |
| 8 | #define COMPILER_TRANSLATOR_UTIL_H_ |
daniel@transgaming.com | 91ed149 | 2010-10-29 03:11:43 +0000 | [diff] [blame] | 9 | |
Jamie Madill | 77f7485 | 2014-07-08 15:02:34 -0400 | [diff] [blame] | 10 | #include <stack> |
| 11 | |
Jamie Madill | f51639a | 2014-06-25 16:04:57 -0400 | [diff] [blame] | 12 | #include "angle_gl.h" |
Jamie Madill | e294bb8 | 2014-07-17 14:16:26 -0400 | [diff] [blame] | 13 | #include <GLSLANG/ShaderLang.h> |
Jamie Madill | 13cfd27 | 2014-07-17 14:16:28 -0400 | [diff] [blame] | 14 | |
| 15 | #include "compiler/translator/Types.h" |
Jamie Madill | 033dae6 | 2014-06-18 12:56:28 -0400 | [diff] [blame] | 16 | |
Zhenyao Mo | f1d723c | 2013-09-23 14:57:07 -0400 | [diff] [blame] | 17 | // atof_clamp is like atof but |
| 18 | // 1. it forces C locale, i.e. forcing '.' as decimal point. |
| 19 | // 2. it clamps the value to -FLT_MAX or FLT_MAX if overflow happens. |
| 20 | // Return false if overflow happens. |
| 21 | extern bool atof_clamp(const char *str, float *value); |
daniel@transgaming.com | 91ed149 | 2010-10-29 03:11:43 +0000 | [diff] [blame] | 22 | |
Zhenyao Mo | f1d723c | 2013-09-23 14:57:07 -0400 | [diff] [blame] | 23 | // If overflow happens, clamp the value to INT_MIN or INT_MAX. |
| 24 | // Return false if overflow happens. |
| 25 | extern bool atoi_clamp(const char *str, int *value); |
daniel@transgaming.com | 91ed149 | 2010-10-29 03:11:43 +0000 | [diff] [blame] | 26 | |
Zhenyao Mo | 94ac7b7 | 2014-10-15 18:22:08 -0700 | [diff] [blame] | 27 | class TSymbolTable; |
| 28 | |
Jamie Madill | 033dae6 | 2014-06-18 12:56:28 -0400 | [diff] [blame] | 29 | namespace sh |
| 30 | { |
| 31 | |
| 32 | GLenum GLVariableType(const TType &type); |
| 33 | GLenum GLVariablePrecision(const TType &type); |
| 34 | bool IsVaryingIn(TQualifier qualifier); |
| 35 | bool IsVaryingOut(TQualifier qualifier); |
| 36 | bool IsVarying(TQualifier qualifier); |
Jamie Madill | f257598 | 2014-06-25 16:04:54 -0400 | [diff] [blame] | 37 | InterpolationType GetInterpolationType(TQualifier qualifier); |
Jamie Madill | 033dae6 | 2014-06-18 12:56:28 -0400 | [diff] [blame] | 38 | TString ArrayString(const TType &type); |
| 39 | |
Jamie Madill | f0d10f8 | 2015-03-31 12:56:52 -0400 | [diff] [blame^] | 40 | class GetVariableTraverser : angle::NonCopyable |
Jamie Madill | 77f7485 | 2014-07-08 15:02:34 -0400 | [diff] [blame] | 41 | { |
| 42 | public: |
Zhenyao Mo | 94ac7b7 | 2014-10-15 18:22:08 -0700 | [diff] [blame] | 43 | GetVariableTraverser(const TSymbolTable &symbolTable); |
Jamie Madill | 42bcf32 | 2014-08-25 16:20:46 -0400 | [diff] [blame] | 44 | |
| 45 | template <typename VarT> |
| 46 | void traverse(const TType &type, const TString &name, std::vector<VarT> *output); |
Jamie Madill | 77f7485 | 2014-07-08 15:02:34 -0400 | [diff] [blame] | 47 | |
| 48 | protected: |
Jamie Madill | 28f70c3 | 2014-07-18 10:33:10 -0400 | [diff] [blame] | 49 | // May be overloaded |
Jamie Madill | 42bcf32 | 2014-08-25 16:20:46 -0400 | [diff] [blame] | 50 | virtual void visitVariable(ShaderVariable *newVar) {} |
Jamie Madill | 77f7485 | 2014-07-08 15:02:34 -0400 | [diff] [blame] | 51 | |
| 52 | private: |
Zhenyao Mo | 94ac7b7 | 2014-10-15 18:22:08 -0700 | [diff] [blame] | 53 | // Helper function called by traverse() to fill specific fields |
| 54 | // for attributes/varyings/uniforms. |
| 55 | template <typename VarT> |
| 56 | void setTypeSpecificInfo( |
| 57 | const TType &type, const TString &name, VarT *variable) {} |
| 58 | |
| 59 | const TSymbolTable &mSymbolTable; |
Jamie Madill | 77f7485 | 2014-07-08 15:02:34 -0400 | [diff] [blame] | 60 | }; |
| 61 | |
Jamie Madill | 033dae6 | 2014-06-18 12:56:28 -0400 | [diff] [blame] | 62 | } |
| 63 | |
Geoff Lang | 0a73dd8 | 2014-11-19 16:18:08 -0500 | [diff] [blame] | 64 | #endif // COMPILER_TRANSLATOR_UTIL_H_ |