Propagate correct type to the lvalue in an output variable initializer
With the SH_INIT_OUTPUT_VARIABLES option enabled, vertex and fragment
shader outputs get initialized with zeros at the beginning of main.
However, previous to this patch the lvalues in the binary expression did
not receive the correct type. This can lead to incorrect modifications
of the AST in subsequent stages or incorrect output code from the
translator. The patch addresses the issue by copying the type
information from the symbol table.
BUG=angleproject:2081
TEST=angle_unittests
TEST=angle_end2end_tests
Change-Id: I9e062376bcfad7d57b637a5248caebce1c9a0688
Reviewed-on: https://chromium-review.googlesource.com/544982
Commit-Queue: Olli Etuaho <oetuaho@nvidia.com>
Reviewed-by: Jamie Madill <jmadill@chromium.org>
diff --git a/src/compiler/translator/InitializeVariables.h b/src/compiler/translator/InitializeVariables.h
index 1e6dfba..cc6a7ae 100644
--- a/src/compiler/translator/InitializeVariables.h
+++ b/src/compiler/translator/InitializeVariables.h
@@ -9,6 +9,7 @@
#include <GLSLANG/ShaderLang.h>
+#include "compiler/translator/ExtensionBehavior.h"
#include "compiler/translator/IntermNode.h"
namespace sh
@@ -24,15 +25,20 @@
// Initialize all uninitialized local variables, so that undefined behavior is avoided.
void InitializeUninitializedLocals(TIntermBlock *root, int shaderVersion);
-// This function can initialize all the types that CreateInitCode is able to initialize. For struct
-// typed variables it requires that the struct is found from the symbolTable, which is usually not
-// the case for locally defined struct types.
-// For now it is used for the following two scenarios:
-// 1. initializing gl_Position;
-// 2. initializing ESSL 3.00 shaders' output variables.
+// This function can initialize all the types that CreateInitCode is able to initialize. All
+// variables must be globals which can be found in the symbol table. For now it is used for the
+// following two scenarios:
+// 1. Initializing gl_Position;
+// 2. Initializing output variables referred to in the shader source.
+// Note: The type of each lvalue in an initializer is retrieved from the symbol table. gl_FragData
+// requires special handling because the number of indices which can be initialized is determined by
+// the API spec and extension support.
void InitializeVariables(TIntermBlock *root,
const InitVariableList &vars,
- const TSymbolTable &symbolTable);
+ const TSymbolTable &symbolTable,
+ int shaderVersion,
+ ShShaderSpec shaderSpec,
+ const TExtensionBehavior &extensionBehavior);
} // namespace sh