• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 //
2 // Copyright 2002 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_TREEOPS_INITIALIZEVARIABLES_H_
8 #define COMPILER_TRANSLATOR_TREEOPS_INITIALIZEVARIABLES_H_
9 
10 #include <GLSLANG/ShaderLang.h>
11 
12 #include "compiler/translator/ExtensionBehavior.h"
13 #include "compiler/translator/IntermNode.h"
14 
15 namespace sh
16 {
17 class TCompiler;
18 class TSymbolTable;
19 
20 typedef std::vector<sh::ShaderVariable> InitVariableList;
21 
22 // For all of the functions below: If canUseLoopsToInitialize is set, for loops are used instead of
23 // a large number of initializers where it can make sense, such as for initializing large arrays.
24 
25 // Return a sequence of assignment operations to initialize "initializedSymbol". initializedSymbol
26 // may be an array, struct or any combination of these, as long as it contains only basic types.
27 TIntermSequence *CreateInitCode(const TIntermTyped *initializedSymbol,
28                                 bool canUseLoopsToInitialize,
29                                 bool highPrecisionSupported,
30                                 TSymbolTable *symbolTable);
31 
32 // Initialize all uninitialized local variables, so that undefined behavior is avoided.
33 ANGLE_NO_DISCARD bool InitializeUninitializedLocals(TCompiler *compiler,
34                                                     TIntermBlock *root,
35                                                     int shaderVersion,
36                                                     bool canUseLoopsToInitialize,
37                                                     bool highPrecisionSupported,
38                                                     TSymbolTable *symbolTable);
39 
40 // This function can initialize all the types that CreateInitCode is able to initialize. All
41 // variables must be globals which can be found in the symbol table. For now it is used for the
42 // following two scenarios:
43 //   1. Initializing gl_Position;
44 //   2. Initializing output variables referred to in the shader source.
45 // Note: The type of each lvalue in an initializer is retrieved from the symbol table. gl_FragData
46 // requires special handling because the number of indices which can be initialized is determined by
47 // enabled extensions.
48 ANGLE_NO_DISCARD bool InitializeVariables(TCompiler *compiler,
49                                           TIntermBlock *root,
50                                           const InitVariableList &vars,
51                                           TSymbolTable *symbolTable,
52                                           int shaderVersion,
53                                           const TExtensionBehavior &extensionBehavior,
54                                           bool canUseLoopsToInitialize,
55                                           bool highPrecisionSupported);
56 
57 }  // namespace sh
58 
59 #endif  // COMPILER_TRANSLATOR_TREEOPS_INITIALIZEVARIABLES_H_
60