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