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 | |
| 7 | #ifndef COMPILER_UTIL_H |
| 8 | #define COMPILER_UTIL_H |
| 9 | |
Jamie Madill | 77f7485 | 2014-07-08 15:02:34 -0400 | [diff] [blame] | 10 | #include <stack> |
| 11 | |
Jamie Madill | 033dae6 | 2014-06-18 12:56:28 -0400 | [diff] [blame] | 12 | #include "compiler/translator/Types.h" |
Jamie Madill | f51639a | 2014-06-25 16:04:57 -0400 | [diff] [blame] | 13 | #include "angle_gl.h" |
Jamie Madill | 033dae6 | 2014-06-18 12:56:28 -0400 | [diff] [blame] | 14 | #include "common/shadervars.h" |
| 15 | |
Zhenyao Mo | f1d723c | 2013-09-23 14:57:07 -0400 | [diff] [blame] | 16 | // atof_clamp is like atof but |
| 17 | // 1. it forces C locale, i.e. forcing '.' as decimal point. |
| 18 | // 2. it clamps the value to -FLT_MAX or FLT_MAX if overflow happens. |
| 19 | // Return false if overflow happens. |
| 20 | extern bool atof_clamp(const char *str, float *value); |
daniel@transgaming.com | 91ed149 | 2010-10-29 03:11:43 +0000 | [diff] [blame] | 21 | |
Zhenyao Mo | f1d723c | 2013-09-23 14:57:07 -0400 | [diff] [blame] | 22 | // If overflow happens, clamp the value to INT_MIN or INT_MAX. |
| 23 | // Return false if overflow happens. |
| 24 | extern bool atoi_clamp(const char *str, int *value); |
daniel@transgaming.com | 91ed149 | 2010-10-29 03:11:43 +0000 | [diff] [blame] | 25 | |
Jamie Madill | 033dae6 | 2014-06-18 12:56:28 -0400 | [diff] [blame] | 26 | namespace sh |
| 27 | { |
| 28 | |
| 29 | GLenum GLVariableType(const TType &type); |
| 30 | GLenum GLVariablePrecision(const TType &type); |
| 31 | bool IsVaryingIn(TQualifier qualifier); |
| 32 | bool IsVaryingOut(TQualifier qualifier); |
| 33 | bool IsVarying(TQualifier qualifier); |
Jamie Madill | f257598 | 2014-06-25 16:04:54 -0400 | [diff] [blame] | 34 | InterpolationType GetInterpolationType(TQualifier qualifier); |
Jamie Madill | d5512cd | 2014-07-10 17:50:08 -0400 | [diff] [blame] | 35 | BlockLayoutType GetBlockLayoutType(TLayoutBlockStorage blockStorage); |
Jamie Madill | 033dae6 | 2014-06-18 12:56:28 -0400 | [diff] [blame] | 36 | TString ArrayString(const TType &type); |
| 37 | |
Jamie Madill | 77f7485 | 2014-07-08 15:02:34 -0400 | [diff] [blame] | 38 | template <typename VarT> |
| 39 | class GetVariableTraverser |
| 40 | { |
| 41 | public: |
Jamie Madill | 28f70c3 | 2014-07-18 10:33:10 -0400 | [diff] [blame] | 42 | GetVariableTraverser(std::vector<VarT> *output); |
Jamie Madill | 77f7485 | 2014-07-08 15:02:34 -0400 | [diff] [blame] | 43 | void traverse(const TType &type, const TString &name); |
| 44 | |
| 45 | protected: |
Jamie Madill | 28f70c3 | 2014-07-18 10:33:10 -0400 | [diff] [blame] | 46 | // May be overloaded |
| 47 | virtual void visitVariable(VarT *newVar) {} |
Jamie Madill | 77f7485 | 2014-07-08 15:02:34 -0400 | [diff] [blame] | 48 | |
| 49 | private: |
| 50 | std::stack<std::vector<VarT> *> mOutputStack; |
| 51 | }; |
| 52 | |
| 53 | struct GetInterfaceBlockFieldTraverser : public GetVariableTraverser<InterfaceBlockField> |
| 54 | { |
| 55 | public: |
| 56 | GetInterfaceBlockFieldTraverser(std::vector<InterfaceBlockField> *output, bool isRowMajorMatrix); |
| 57 | |
| 58 | private: |
| 59 | virtual void visitVariable(InterfaceBlockField *newField); |
| 60 | |
| 61 | bool mIsRowMajorMatrix; |
| 62 | }; |
| 63 | |
Jamie Madill | 033dae6 | 2014-06-18 12:56:28 -0400 | [diff] [blame] | 64 | } |
| 65 | |
daniel@transgaming.com | 91ed149 | 2010-10-29 03:11:43 +0000 | [diff] [blame] | 66 | #endif // COMPILER_UTIL_H |