Zhenyao Mo | cd68fe7 | 2014-07-11 10:45:44 -0700 | [diff] [blame] | 1 | // |
| 2 | // Copyright (c) 2002-2014 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_SCALARIZE_VEC_AND_MAT_CONSTRUCTOR_ARGS_H_ |
| 8 | #define COMPILER_TRANSLATOR_SCALARIZE_VEC_AND_MAT_CONSTRUCTOR_ARGS_H_ |
| 9 | |
Jamie Madill | b1a85f4 | 2014-08-19 15:23:24 -0400 | [diff] [blame] | 10 | #include "compiler/translator/IntermNode.h" |
Zhenyao Mo | cd68fe7 | 2014-07-11 10:45:44 -0700 | [diff] [blame] | 11 | |
| 12 | class ScalarizeVecAndMatConstructorArgs : public TIntermTraverser |
| 13 | { |
| 14 | public: |
Zhenyao Mo | daf5657 | 2014-08-06 16:18:30 -0700 | [diff] [blame] | 15 | ScalarizeVecAndMatConstructorArgs(sh::GLenum shaderType, |
| 16 | bool fragmentPrecisionHigh) |
| 17 | : mTempVarCount(0), |
| 18 | mShaderType(shaderType), |
| 19 | mFragmentPrecisionHigh(fragmentPrecisionHigh) {} |
Zhenyao Mo | cd68fe7 | 2014-07-11 10:45:44 -0700 | [diff] [blame] | 20 | |
| 21 | protected: |
| 22 | virtual bool visitAggregate(Visit visit, TIntermAggregate *node); |
| 23 | |
| 24 | private: |
| 25 | void scalarizeArgs(TIntermAggregate *aggregate, |
| 26 | bool scalarizeVector, bool scalarizeMatrix); |
| 27 | |
| 28 | // If we have the following code: |
| 29 | // mat4 m(0); |
| 30 | // vec4 v(1, m); |
| 31 | // We will rewrite to: |
| 32 | // mat4 m(0); |
| 33 | // mat4 _webgl_tmp_mat_0 = m; |
| 34 | // vec4 v(1, _webgl_tmp_mat_0[0][0], _webgl_tmp_mat_0[0][1], _webgl_tmp_mat_0[0][2]); |
| 35 | // This function is to create nodes for "mat4 _webgl_tmp_mat_0 = m;" and insert it to |
| 36 | // the code sequence. |
| 37 | // Return the temporary variable name. |
| 38 | TString createTempVariable(TIntermTyped *original); |
| 39 | |
| 40 | std::vector<TIntermSequence> mSequenceStack; |
| 41 | int mTempVarCount; |
Zhenyao Mo | daf5657 | 2014-08-06 16:18:30 -0700 | [diff] [blame] | 42 | |
| 43 | sh::GLenum mShaderType; |
| 44 | bool mFragmentPrecisionHigh; |
Zhenyao Mo | cd68fe7 | 2014-07-11 10:45:44 -0700 | [diff] [blame] | 45 | }; |
| 46 | |
| 47 | #endif // COMPILER_TRANSLATOR_SCALARIZE_VEC_AND_MAT_CONSTRUCTOR_ARGS_H_ |