blob: 1e6dfba37060b08634176f5a6b32987e4c3ae751 [file] [log] [blame]
Zhenyao Mo4a667fe2014-02-11 12:35:01 -08001//
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 Lang0a73dd82014-11-19 16:18:08 -05007#ifndef COMPILER_TRANSLATOR_INITIALIZEVARIABLES_H_
8#define COMPILER_TRANSLATOR_INITIALIZEVARIABLES_H_
Zhenyao Mo4a667fe2014-02-11 12:35:01 -08009
Zhenyao Mo72111912016-07-20 17:45:56 -070010#include <GLSLANG/ShaderLang.h>
Zhenyao Mo4a667fe2014-02-11 12:35:01 -080011
Olli Etuaho9733cee2017-05-11 19:14:35 +030012#include "compiler/translator/IntermNode.h"
13
Jamie Madill45bcc782016-11-07 13:58:48 -050014namespace sh
15{
Zhenyao Mod7490962016-11-09 15:49:51 -080016class TSymbolTable;
Zhenyao Mo4a667fe2014-02-11 12:35:01 -080017
Zhenyao Mo72111912016-07-20 17:45:56 -070018typedef std::vector<sh::ShaderVariable> InitVariableList;
Zhenyao Mo4a667fe2014-02-11 12:35:01 -080019
Olli Etuaho9733cee2017-05-11 19:14:35 +030020// 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.
22TIntermSequence *CreateInitCode(const TIntermSymbol *initializedSymbol);
23
24// Initialize all uninitialized local variables, so that undefined behavior is avoided.
25void 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 Mod7490962016-11-09 15:49:51 -080030// For now it is used for the following two scenarios:
31// 1. initializing gl_Position;
Olli Etuaho9733cee2017-05-11 19:14:35 +030032// 2. initializing ESSL 3.00 shaders' output variables.
Olli Etuaho9cbc07c2017-05-10 18:22:01 +030033void InitializeVariables(TIntermBlock *root,
Zhenyao Mod7490962016-11-09 15:49:51 -080034 const InitVariableList &vars,
35 const TSymbolTable &symbolTable);
Olli Etuaho9733cee2017-05-11 19:14:35 +030036
Jamie Madill45bcc782016-11-07 13:58:48 -050037} // namespace sh
Zhenyao Mo4a667fe2014-02-11 12:35:01 -080038
Geoff Lang0a73dd82014-11-19 16:18:08 -050039#endif // COMPILER_TRANSLATOR_INITIALIZEVARIABLES_H_