1 // 2 // Copyright 2016 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 // DeferGlobalInitializers is an AST traverser that moves global initializers into a separate 7 // function that is called in the beginning of main(). This enables initialization of globals with 8 // uniforms or non-constant globals, as allowed by the WebGL spec. Some initializers referencing 9 // non-constants may need to be unfolded into if statements in HLSL - this kind of steps should be 10 // done after DeferGlobalInitializers is run. Note that it's important that the function definition 11 // is at the end of the shader, as some globals may be declared after main(). 12 // 13 // It can also initialize all uninitialized globals. 14 // 15 16 #ifndef COMPILER_TRANSLATOR_TREEOPS_DEFERGLOBALINITIALIZERS_H_ 17 #define COMPILER_TRANSLATOR_TREEOPS_DEFERGLOBALINITIALIZERS_H_ 18 19 namespace sh 20 { 21 22 class TIntermBlock; 23 class TSymbolTable; 24 25 void DeferGlobalInitializers(TIntermBlock *root, 26 bool initializeUninitializedGlobals, 27 bool canUseLoopsToInitialize, 28 bool highPrecisionSupported, 29 TSymbolTable *symbolTable); 30 31 } // namespace sh 32 33 #endif // COMPILER_TRANSLATOR_TREEOPS_DEFERGLOBALINITIALIZERS_H_ 34