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 #include "common/angleutils.h" 20 21 namespace sh 22 { 23 24 class TCompiler; 25 class TIntermBlock; 26 class TSymbolTable; 27 28 ANGLE_NO_DISCARD bool DeferGlobalInitializers(TCompiler *compiler, 29 TIntermBlock *root, 30 bool initializeUninitializedGlobals, 31 bool canUseLoopsToInitialize, 32 bool highPrecisionSupported, 33 bool forceDeferGlobalInitializers, 34 TSymbolTable *symbolTable); 35 36 } // namespace sh 37 38 #endif // COMPILER_TRANSLATOR_TREEOPS_DEFERGLOBALINITIALIZERS_H_ 39