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 10 #include "compiler/translator/IntermNode.h" 11 12 class ScalarizeVecAndMatConstructorArgs : public TIntermTraverser 13 { 14 public: 15 ScalarizeVecAndMatConstructorArgs(sh::GLenum shaderType, 16 bool fragmentPrecisionHigh) 17 : mTempVarCount(0), 18 mShaderType(shaderType), 19 mFragmentPrecisionHigh(fragmentPrecisionHigh) {} 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; 42 43 sh::GLenum mShaderType; 44 bool mFragmentPrecisionHigh; 45 }; 46 47 #endif // COMPILER_TRANSLATOR_SCALARIZE_VEC_AND_MAT_CONSTRUCTOR_ARGS_H_ 48