Zhenyao Mo | 4a667fe | 2014-02-11 12:35:01 -0800 | [diff] [blame] | 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 | |
Geoff Lang | 0a73dd8 | 2014-11-19 16:18:08 -0500 | [diff] [blame] | 7 | #ifndef COMPILER_TRANSLATOR_INITIALIZEVARIABLES_H_ |
| 8 | #define COMPILER_TRANSLATOR_INITIALIZEVARIABLES_H_ |
Zhenyao Mo | 4a667fe | 2014-02-11 12:35:01 -0800 | [diff] [blame] | 9 | |
Zhenyao Mo | 7211191 | 2016-07-20 17:45:56 -0700 | [diff] [blame] | 10 | #include <GLSLANG/ShaderLang.h> |
Zhenyao Mo | 4a667fe | 2014-02-11 12:35:01 -0800 | [diff] [blame] | 11 | |
Olli Etuaho | 9733cee | 2017-05-11 19:14:35 +0300 | [diff] [blame] | 12 | #include "compiler/translator/IntermNode.h" |
| 13 | |
Jamie Madill | 45bcc78 | 2016-11-07 13:58:48 -0500 | [diff] [blame] | 14 | namespace sh |
| 15 | { |
Zhenyao Mo | d749096 | 2016-11-09 15:49:51 -0800 | [diff] [blame] | 16 | class TSymbolTable; |
Zhenyao Mo | 4a667fe | 2014-02-11 12:35:01 -0800 | [diff] [blame] | 17 | |
Zhenyao Mo | 7211191 | 2016-07-20 17:45:56 -0700 | [diff] [blame] | 18 | typedef std::vector<sh::ShaderVariable> InitVariableList; |
Zhenyao Mo | 4a667fe | 2014-02-11 12:35:01 -0800 | [diff] [blame] | 19 | |
Olli Etuaho | 9733cee | 2017-05-11 19:14:35 +0300 | [diff] [blame] | 20 | // Return a sequence of assignment operations to initialize "initializedSymbol". initializedSymbol |
| 21 | // may be an array, struct or any combination of these, as long as it contains only basic types. |
| 22 | TIntermSequence *CreateInitCode(const TIntermSymbol *initializedSymbol); |
| 23 | |
| 24 | // Initialize all uninitialized local variables, so that undefined behavior is avoided. |
| 25 | void InitializeUninitializedLocals(TIntermBlock *root, int shaderVersion); |
| 26 | |
| 27 | // This function can initialize all the types that CreateInitCode is able to initialize. For struct |
| 28 | // typed variables it requires that the struct is found from the symbolTable, which is usually not |
| 29 | // the case for locally defined struct types. |
Zhenyao Mo | d749096 | 2016-11-09 15:49:51 -0800 | [diff] [blame] | 30 | // For now it is used for the following two scenarios: |
| 31 | // 1. initializing gl_Position; |
Olli Etuaho | 9733cee | 2017-05-11 19:14:35 +0300 | [diff] [blame] | 32 | // 2. initializing ESSL 3.00 shaders' output variables. |
Olli Etuaho | 9cbc07c | 2017-05-10 18:22:01 +0300 | [diff] [blame] | 33 | void InitializeVariables(TIntermBlock *root, |
Zhenyao Mo | d749096 | 2016-11-09 15:49:51 -0800 | [diff] [blame] | 34 | const InitVariableList &vars, |
| 35 | const TSymbolTable &symbolTable); |
Olli Etuaho | 9733cee | 2017-05-11 19:14:35 +0300 | [diff] [blame] | 36 | |
Jamie Madill | 45bcc78 | 2016-11-07 13:58:48 -0500 | [diff] [blame] | 37 | } // namespace sh |
Zhenyao Mo | 4a667fe | 2014-02-11 12:35:01 -0800 | [diff] [blame] | 38 | |
Geoff Lang | 0a73dd8 | 2014-11-19 16:18:08 -0500 | [diff] [blame] | 39 | #endif // COMPILER_TRANSLATOR_INITIALIZEVARIABLES_H_ |