summaryrefslogtreecommitdiffstats
path: root/src/3rdparty/angle/src/compiler
diff options
context:
space:
mode:
Diffstat (limited to 'src/3rdparty/angle/src/compiler')
-rw-r--r--src/3rdparty/angle/src/compiler/CodeGenHLSL.cpp33
-rw-r--r--src/3rdparty/angle/src/compiler/DetectRecursion.cpp125
-rw-r--r--src/3rdparty/angle/src/compiler/DetectRecursion.h60
-rw-r--r--src/3rdparty/angle/src/compiler/InitializeGLPosition.cpp61
-rw-r--r--src/3rdparty/angle/src/compiler/InitializeGLPosition.h33
-rw-r--r--src/3rdparty/angle/src/compiler/IntermTraverse.cpp293
-rw-r--r--src/3rdparty/angle/src/compiler/preprocessor/DiagnosticsBase.cpp84
-rw-r--r--src/3rdparty/angle/src/compiler/preprocessor/DiagnosticsBase.h86
-rw-r--r--src/3rdparty/angle/src/compiler/preprocessor/DirectiveParser.cpp78
-rw-r--r--src/3rdparty/angle/src/compiler/preprocessor/ExpressionParser.y18
-rw-r--r--src/3rdparty/angle/src/compiler/preprocessor/MacroExpander.cpp6
-rw-r--r--src/3rdparty/angle/src/compiler/preprocessor/Preprocessor.cpp4
-rw-r--r--src/3rdparty/angle/src/compiler/preprocessor/Tokenizer.l4
-rw-r--r--src/3rdparty/angle/src/compiler/translator/BaseTypes.h (renamed from src/3rdparty/angle/src/compiler/BaseTypes.h)1
-rw-r--r--src/3rdparty/angle/src/compiler/translator/BuiltInFunctionEmulator.cpp (renamed from src/3rdparty/angle/src/compiler/BuiltInFunctionEmulator.cpp)4
-rw-r--r--src/3rdparty/angle/src/compiler/translator/BuiltInFunctionEmulator.h (renamed from src/3rdparty/angle/src/compiler/BuiltInFunctionEmulator.h)4
-rw-r--r--src/3rdparty/angle/src/compiler/translator/CodeGen.cpp (renamed from src/3rdparty/angle/src/compiler/CodeGenGLSL.cpp)12
-rw-r--r--src/3rdparty/angle/src/compiler/translator/Common.h (renamed from src/3rdparty/angle/src/compiler/Common.h)17
-rw-r--r--src/3rdparty/angle/src/compiler/translator/Compiler.cpp (renamed from src/3rdparty/angle/src/compiler/Compiler.cpp)216
-rw-r--r--src/3rdparty/angle/src/compiler/translator/ConstantUnion.h (renamed from src/3rdparty/angle/src/compiler/ConstantUnion.h)0
-rw-r--r--src/3rdparty/angle/src/compiler/translator/DetectCallDepth.cpp (renamed from src/3rdparty/angle/src/compiler/DetectCallDepth.cpp)4
-rw-r--r--src/3rdparty/angle/src/compiler/translator/DetectCallDepth.h (renamed from src/3rdparty/angle/src/compiler/DetectCallDepth.h)4
-rw-r--r--src/3rdparty/angle/src/compiler/translator/DetectDiscontinuity.cpp (renamed from src/3rdparty/angle/src/compiler/DetectDiscontinuity.cpp)4
-rw-r--r--src/3rdparty/angle/src/compiler/translator/DetectDiscontinuity.h (renamed from src/3rdparty/angle/src/compiler/DetectDiscontinuity.h)2
-rw-r--r--src/3rdparty/angle/src/compiler/translator/Diagnostics.cpp (renamed from src/3rdparty/angle/src/compiler/Diagnostics.cpp)10
-rw-r--r--src/3rdparty/angle/src/compiler/translator/Diagnostics.h (renamed from src/3rdparty/angle/src/compiler/Diagnostics.h)0
-rw-r--r--src/3rdparty/angle/src/compiler/translator/DirectiveHandler.cpp (renamed from src/3rdparty/angle/src/compiler/DirectiveHandler.cpp)26
-rw-r--r--src/3rdparty/angle/src/compiler/translator/DirectiveHandler.h (renamed from src/3rdparty/angle/src/compiler/DirectiveHandler.h)4
-rw-r--r--src/3rdparty/angle/src/compiler/translator/ExtensionBehavior.h (renamed from src/3rdparty/angle/src/compiler/ExtensionBehavior.h)0
-rw-r--r--src/3rdparty/angle/src/compiler/translator/ForLoopUnroll.cpp (renamed from src/3rdparty/angle/src/compiler/ForLoopUnroll.cpp)2
-rw-r--r--src/3rdparty/angle/src/compiler/translator/ForLoopUnroll.h (renamed from src/3rdparty/angle/src/compiler/ForLoopUnroll.h)6
-rw-r--r--src/3rdparty/angle/src/compiler/translator/HashNames.h (renamed from src/3rdparty/angle/src/compiler/HashNames.h)2
-rw-r--r--src/3rdparty/angle/src/compiler/translator/InfoSink.cpp (renamed from src/3rdparty/angle/src/compiler/InfoSink.cpp)2
-rw-r--r--src/3rdparty/angle/src/compiler/translator/InfoSink.h (renamed from src/3rdparty/angle/src/compiler/InfoSink.h)3
-rw-r--r--src/3rdparty/angle/src/compiler/translator/Initialize.cpp (renamed from src/3rdparty/angle/src/compiler/Initialize.cpp)6
-rw-r--r--src/3rdparty/angle/src/compiler/translator/Initialize.h (renamed from src/3rdparty/angle/src/compiler/Initialize.h)6
-rw-r--r--src/3rdparty/angle/src/compiler/translator/InitializeDll.cpp (renamed from src/3rdparty/angle/src/compiler/InitializeDll.cpp)8
-rw-r--r--src/3rdparty/angle/src/compiler/translator/InitializeDll.h (renamed from src/3rdparty/angle/src/compiler/InitializeDll.h)0
-rw-r--r--src/3rdparty/angle/src/compiler/translator/InitializeGlobals.h (renamed from src/3rdparty/angle/src/compiler/InitializeGlobals.h)0
-rw-r--r--src/3rdparty/angle/src/compiler/translator/InitializeParseContext.cpp (renamed from src/3rdparty/angle/src/compiler/InitializeParseContext.cpp)4
-rw-r--r--src/3rdparty/angle/src/compiler/translator/InitializeParseContext.h (renamed from src/3rdparty/angle/src/compiler/InitializeParseContext.h)0
-rw-r--r--src/3rdparty/angle/src/compiler/translator/InitializeVariables.cpp116
-rw-r--r--src/3rdparty/angle/src/compiler/translator/InitializeVariables.h50
-rw-r--r--src/3rdparty/angle/src/compiler/translator/IntermTraverse.cpp259
-rw-r--r--src/3rdparty/angle/src/compiler/translator/Intermediate.cpp (renamed from src/3rdparty/angle/src/compiler/Intermediate.cpp)76
-rw-r--r--src/3rdparty/angle/src/compiler/translator/MMap.h (renamed from src/3rdparty/angle/src/compiler/MMap.h)0
-rw-r--r--src/3rdparty/angle/src/compiler/translator/MapLongVariableNames.cpp (renamed from src/3rdparty/angle/src/compiler/MapLongVariableNames.cpp)9
-rw-r--r--src/3rdparty/angle/src/compiler/translator/MapLongVariableNames.h (renamed from src/3rdparty/angle/src/compiler/MapLongVariableNames.h)5
-rw-r--r--src/3rdparty/angle/src/compiler/translator/NodeSearch.h80
-rw-r--r--src/3rdparty/angle/src/compiler/translator/OutputESSL.cpp (renamed from src/3rdparty/angle/src/compiler/OutputESSL.cpp)2
-rw-r--r--src/3rdparty/angle/src/compiler/translator/OutputESSL.h (renamed from src/3rdparty/angle/src/compiler/OutputESSL.h)2
-rw-r--r--src/3rdparty/angle/src/compiler/translator/OutputGLSL.cpp (renamed from src/3rdparty/angle/src/compiler/OutputGLSL.cpp)2
-rw-r--r--src/3rdparty/angle/src/compiler/translator/OutputGLSL.h (renamed from src/3rdparty/angle/src/compiler/OutputGLSL.h)2
-rw-r--r--src/3rdparty/angle/src/compiler/translator/OutputGLSLBase.cpp (renamed from src/3rdparty/angle/src/compiler/OutputGLSLBase.cpp)12
-rw-r--r--src/3rdparty/angle/src/compiler/translator/OutputGLSLBase.h (renamed from src/3rdparty/angle/src/compiler/OutputGLSLBase.h)6
-rw-r--r--src/3rdparty/angle/src/compiler/translator/OutputHLSL.cpp (renamed from src/3rdparty/angle/src/compiler/OutputHLSL.cpp)90
-rw-r--r--src/3rdparty/angle/src/compiler/translator/OutputHLSL.h (renamed from src/3rdparty/angle/src/compiler/OutputHLSL.h)7
-rw-r--r--src/3rdparty/angle/src/compiler/translator/ParseContext.cpp (renamed from src/3rdparty/angle/src/compiler/ParseHelper.cpp)10
-rw-r--r--src/3rdparty/angle/src/compiler/translator/ParseContext.h (renamed from src/3rdparty/angle/src/compiler/ParseHelper.h)10
-rw-r--r--src/3rdparty/angle/src/compiler/translator/PoolAlloc.cpp (renamed from src/3rdparty/angle/src/compiler/PoolAlloc.cpp)6
-rw-r--r--src/3rdparty/angle/src/compiler/translator/PoolAlloc.h (renamed from src/3rdparty/angle/src/compiler/PoolAlloc.h)0
-rw-r--r--src/3rdparty/angle/src/compiler/translator/Pragma.h (renamed from src/3rdparty/angle/src/compiler/Pragma.h)0
-rw-r--r--src/3rdparty/angle/src/compiler/translator/QualifierAlive.cpp (renamed from src/3rdparty/angle/src/compiler/QualifierAlive.cpp)2
-rw-r--r--src/3rdparty/angle/src/compiler/translator/QualifierAlive.h (renamed from src/3rdparty/angle/src/compiler/QualifierAlive.h)0
-rw-r--r--src/3rdparty/angle/src/compiler/translator/RemoveTree.cpp (renamed from src/3rdparty/angle/src/compiler/RemoveTree.cpp)4
-rw-r--r--src/3rdparty/angle/src/compiler/translator/RemoveTree.h (renamed from src/3rdparty/angle/src/compiler/RemoveTree.h)0
-rw-r--r--src/3rdparty/angle/src/compiler/translator/RenameFunction.h (renamed from src/3rdparty/angle/src/compiler/RenameFunction.h)2
-rw-r--r--src/3rdparty/angle/src/compiler/translator/RewriteElseBlocks.cpp98
-rw-r--r--src/3rdparty/angle/src/compiler/translator/RewriteElseBlocks.h39
-rw-r--r--src/3rdparty/angle/src/compiler/translator/SearchSymbol.cpp (renamed from src/3rdparty/angle/src/compiler/SearchSymbol.cpp)6
-rw-r--r--src/3rdparty/angle/src/compiler/translator/SearchSymbol.h (renamed from src/3rdparty/angle/src/compiler/SearchSymbol.h)4
-rw-r--r--src/3rdparty/angle/src/compiler/translator/ShHandle.h (renamed from src/3rdparty/angle/src/compiler/ShHandle.h)22
-rw-r--r--src/3rdparty/angle/src/compiler/translator/ShaderLang.cpp (renamed from src/3rdparty/angle/src/compiler/ShaderLang.cpp)11
-rw-r--r--src/3rdparty/angle/src/compiler/translator/SymbolTable.cpp (renamed from src/3rdparty/angle/src/compiler/SymbolTable.cpp)2
-rw-r--r--src/3rdparty/angle/src/compiler/translator/SymbolTable.h (renamed from src/3rdparty/angle/src/compiler/SymbolTable.h)4
-rw-r--r--src/3rdparty/angle/src/compiler/translator/TranslatorESSL.cpp (renamed from src/3rdparty/angle/src/compiler/TranslatorESSL.cpp)4
-rw-r--r--src/3rdparty/angle/src/compiler/translator/TranslatorESSL.h (renamed from src/3rdparty/angle/src/compiler/TranslatorESSL.h)2
-rw-r--r--src/3rdparty/angle/src/compiler/translator/TranslatorGLSL.cpp (renamed from src/3rdparty/angle/src/compiler/TranslatorGLSL.cpp)6
-rw-r--r--src/3rdparty/angle/src/compiler/translator/TranslatorGLSL.h (renamed from src/3rdparty/angle/src/compiler/TranslatorGLSL.h)2
-rw-r--r--src/3rdparty/angle/src/compiler/translator/TranslatorHLSL.cpp (renamed from src/3rdparty/angle/src/compiler/TranslatorHLSL.cpp)6
-rw-r--r--src/3rdparty/angle/src/compiler/translator/TranslatorHLSL.h (renamed from src/3rdparty/angle/src/compiler/TranslatorHLSL.h)4
-rw-r--r--src/3rdparty/angle/src/compiler/translator/Types.h (renamed from src/3rdparty/angle/src/compiler/Types.h)26
-rw-r--r--src/3rdparty/angle/src/compiler/translator/UnfoldShortCircuit.cpp (renamed from src/3rdparty/angle/src/compiler/UnfoldShortCircuit.cpp)20
-rw-r--r--src/3rdparty/angle/src/compiler/translator/UnfoldShortCircuit.h (renamed from src/3rdparty/angle/src/compiler/UnfoldShortCircuit.h)4
-rw-r--r--src/3rdparty/angle/src/compiler/translator/UnfoldShortCircuitAST.cpp81
-rw-r--r--src/3rdparty/angle/src/compiler/translator/UnfoldShortCircuitAST.h51
-rw-r--r--src/3rdparty/angle/src/compiler/translator/Uniform.cpp (renamed from src/3rdparty/angle/src/compiler/Uniform.cpp)2
-rw-r--r--src/3rdparty/angle/src/compiler/translator/Uniform.h (renamed from src/3rdparty/angle/src/compiler/Uniform.h)0
-rw-r--r--src/3rdparty/angle/src/compiler/translator/ValidateLimitations.cpp (renamed from src/3rdparty/angle/src/compiler/ValidateLimitations.cpp)10
-rw-r--r--src/3rdparty/angle/src/compiler/translator/ValidateLimitations.h (renamed from src/3rdparty/angle/src/compiler/ValidateLimitations.h)2
-rw-r--r--src/3rdparty/angle/src/compiler/translator/VariableInfo.cpp (renamed from src/3rdparty/angle/src/compiler/VariableInfo.cpp)6
-rw-r--r--src/3rdparty/angle/src/compiler/translator/VariableInfo.h (renamed from src/3rdparty/angle/src/compiler/VariableInfo.h)3
-rw-r--r--src/3rdparty/angle/src/compiler/translator/VariablePacker.cpp (renamed from src/3rdparty/angle/src/compiler/VariablePacker.cpp)4
-rw-r--r--src/3rdparty/angle/src/compiler/translator/VariablePacker.h (renamed from src/3rdparty/angle/src/compiler/VariablePacker.h)2
-rw-r--r--src/3rdparty/angle/src/compiler/translator/VersionGLSL.cpp (renamed from src/3rdparty/angle/src/compiler/VersionGLSL.cpp)2
-rw-r--r--src/3rdparty/angle/src/compiler/translator/VersionGLSL.h (renamed from src/3rdparty/angle/src/compiler/VersionGLSL.h)2
-rw-r--r--src/3rdparty/angle/src/compiler/translator/compilerdebug.cpp (renamed from src/3rdparty/angle/src/compiler/debug.cpp)8
-rw-r--r--src/3rdparty/angle/src/compiler/translator/compilerdebug.h (renamed from src/3rdparty/angle/src/compiler/debug.h)0
-rw-r--r--src/3rdparty/angle/src/compiler/translator/depgraph/DependencyGraph.cpp (renamed from src/3rdparty/angle/src/compiler/depgraph/DependencyGraph.cpp)4
-rw-r--r--src/3rdparty/angle/src/compiler/translator/depgraph/DependencyGraph.h (renamed from src/3rdparty/angle/src/compiler/depgraph/DependencyGraph.h)2
-rw-r--r--src/3rdparty/angle/src/compiler/translator/depgraph/DependencyGraphBuilder.cpp (renamed from src/3rdparty/angle/src/compiler/depgraph/DependencyGraphBuilder.cpp)4
-rw-r--r--src/3rdparty/angle/src/compiler/translator/depgraph/DependencyGraphBuilder.h (renamed from src/3rdparty/angle/src/compiler/depgraph/DependencyGraphBuilder.h)2
-rw-r--r--src/3rdparty/angle/src/compiler/translator/depgraph/DependencyGraphOutput.cpp (renamed from src/3rdparty/angle/src/compiler/depgraph/DependencyGraphOutput.cpp)2
-rw-r--r--src/3rdparty/angle/src/compiler/translator/depgraph/DependencyGraphOutput.h (renamed from src/3rdparty/angle/src/compiler/depgraph/DependencyGraphOutput.h)4
-rw-r--r--src/3rdparty/angle/src/compiler/translator/depgraph/DependencyGraphTraverse.cpp (renamed from src/3rdparty/angle/src/compiler/depgraph/DependencyGraphTraverse.cpp)2
-rw-r--r--src/3rdparty/angle/src/compiler/translator/glslang.h (renamed from src/3rdparty/angle/src/compiler/glslang.h)0
-rw-r--r--src/3rdparty/angle/src/compiler/translator/glslang.l (renamed from src/3rdparty/angle/src/compiler/glslang.l)6
-rw-r--r--src/3rdparty/angle/src/compiler/translator/glslang.y (renamed from src/3rdparty/angle/src/compiler/glslang.y)54
-rw-r--r--src/3rdparty/angle/src/compiler/translator/intermOut.cpp (renamed from src/3rdparty/angle/src/compiler/intermOut.cpp)6
-rw-r--r--src/3rdparty/angle/src/compiler/translator/intermediate.h (renamed from src/3rdparty/angle/src/compiler/intermediate.h)80
-rw-r--r--src/3rdparty/angle/src/compiler/translator/localintermediate.h (renamed from src/3rdparty/angle/src/compiler/localintermediate.h)6
-rw-r--r--src/3rdparty/angle/src/compiler/translator/osinclude.h (renamed from src/3rdparty/angle/src/compiler/osinclude.h)20
-rw-r--r--src/3rdparty/angle/src/compiler/translator/ossource_posix.cpp (renamed from src/3rdparty/angle/src/compiler/ossource_posix.cpp)2
-rw-r--r--src/3rdparty/angle/src/compiler/translator/ossource_win.cpp (renamed from src/3rdparty/angle/src/compiler/ossource_win.cpp)2
-rw-r--r--src/3rdparty/angle/src/compiler/translator/ossource_winrt.cpp (renamed from src/3rdparty/angle/src/compiler/ossource_winrt.cpp)2
-rw-r--r--src/3rdparty/angle/src/compiler/translator/parseConst.cpp (renamed from src/3rdparty/angle/src/compiler/parseConst.cpp)2
-rw-r--r--src/3rdparty/angle/src/compiler/translator/timing/RestrictFragmentShaderTiming.cpp (renamed from src/3rdparty/angle/src/compiler/timing/RestrictFragmentShaderTiming.cpp)8
-rw-r--r--src/3rdparty/angle/src/compiler/translator/timing/RestrictFragmentShaderTiming.h (renamed from src/3rdparty/angle/src/compiler/timing/RestrictFragmentShaderTiming.h)4
-rw-r--r--src/3rdparty/angle/src/compiler/translator/timing/RestrictVertexShaderTiming.cpp (renamed from src/3rdparty/angle/src/compiler/timing/RestrictVertexShaderTiming.cpp)2
-rw-r--r--src/3rdparty/angle/src/compiler/translator/timing/RestrictVertexShaderTiming.h (renamed from src/3rdparty/angle/src/compiler/timing/RestrictVertexShaderTiming.h)4
-rw-r--r--src/3rdparty/angle/src/compiler/translator/util.cpp (renamed from src/3rdparty/angle/src/compiler/util.cpp)2
-rw-r--r--src/3rdparty/angle/src/compiler/translator/util.h (renamed from src/3rdparty/angle/src/compiler/util.h)0
122 files changed, 1563 insertions, 1074 deletions
diff --git a/src/3rdparty/angle/src/compiler/CodeGenHLSL.cpp b/src/3rdparty/angle/src/compiler/CodeGenHLSL.cpp
deleted file mode 100644
index 637ccc5e37..0000000000
--- a/src/3rdparty/angle/src/compiler/CodeGenHLSL.cpp
+++ /dev/null
@@ -1,33 +0,0 @@
-//
-// Copyright (c) 2002-2013 The ANGLE Project Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-//
-
-#include "compiler/TranslatorHLSL.h"
-
-//
-// This function must be provided to create the actual
-// compile object used by higher level code. It returns
-// a subclass of TCompiler.
-//
-TCompiler* ConstructCompiler(
- ShShaderType type, ShShaderSpec spec, ShShaderOutput output)
-{
- switch (output)
- {
- case SH_HLSL9_OUTPUT:
- case SH_HLSL11_OUTPUT:
- return new TranslatorHLSL(type, spec, output);
- default:
- return NULL;
- }
-}
-
-//
-// Delete the compiler made by ConstructCompiler
-//
-void DeleteCompiler(TCompiler* compiler)
-{
- delete compiler;
-}
diff --git a/src/3rdparty/angle/src/compiler/DetectRecursion.cpp b/src/3rdparty/angle/src/compiler/DetectRecursion.cpp
deleted file mode 100644
index c09780dd92..0000000000
--- a/src/3rdparty/angle/src/compiler/DetectRecursion.cpp
+++ /dev/null
@@ -1,125 +0,0 @@
-//
-// Copyright (c) 2002-2011 The ANGLE Project Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-//
-
-#include "compiler/DetectRecursion.h"
-
-DetectRecursion::FunctionNode::FunctionNode(const TString& fname)
- : name(fname),
- visit(PreVisit)
-{
-}
-
-const TString& DetectRecursion::FunctionNode::getName() const
-{
- return name;
-}
-
-void DetectRecursion::FunctionNode::addCallee(
- DetectRecursion::FunctionNode* callee)
-{
- for (size_t i = 0; i < callees.size(); ++i) {
- if (callees[i] == callee)
- return;
- }
- callees.push_back(callee);
-}
-
-bool DetectRecursion::FunctionNode::detectRecursion()
-{
- ASSERT(visit == PreVisit);
- visit = InVisit;
- for (size_t i = 0; i < callees.size(); ++i) {
- switch (callees[i]->visit) {
- case InVisit:
- // cycle detected, i.e., recursion detected.
- return true;
- case PostVisit:
- break;
- case PreVisit: {
- bool recursion = callees[i]->detectRecursion();
- if (recursion)
- return true;
- break;
- }
- default:
- UNREACHABLE();
- break;
- }
- }
- visit = PostVisit;
- return false;
-}
-
-DetectRecursion::DetectRecursion()
- : currentFunction(NULL)
-{
-}
-
-DetectRecursion::~DetectRecursion()
-{
- for (size_t i = 0; i < functions.size(); ++i)
- delete functions[i];
-}
-
-bool DetectRecursion::visitAggregate(Visit visit, TIntermAggregate* node)
-{
- switch (node->getOp())
- {
- case EOpPrototype:
- // Function declaration.
- // Don't add FunctionNode here because node->getName() is the
- // unmangled function name.
- break;
- case EOpFunction: {
- // Function definition.
- if (visit == PreVisit) {
- currentFunction = findFunctionByName(node->getName());
- if (currentFunction == NULL) {
- currentFunction = new FunctionNode(node->getName());
- functions.push_back(currentFunction);
- }
- }
- break;
- }
- case EOpFunctionCall: {
- // Function call.
- if (visit == PreVisit) {
- ASSERT(currentFunction != NULL);
- FunctionNode* func = findFunctionByName(node->getName());
- if (func == NULL) {
- func = new FunctionNode(node->getName());
- functions.push_back(func);
- }
- currentFunction->addCallee(func);
- }
- break;
- }
- default:
- break;
- }
- return true;
-}
-
-DetectRecursion::ErrorCode DetectRecursion::detectRecursion()
-{
- FunctionNode* main = findFunctionByName("main(");
- if (main == NULL)
- return kErrorMissingMain;
- if (main->detectRecursion())
- return kErrorRecursion;
- return kErrorNone;
-}
-
-DetectRecursion::FunctionNode* DetectRecursion::findFunctionByName(
- const TString& name)
-{
- for (size_t i = 0; i < functions.size(); ++i) {
- if (functions[i]->getName() == name)
- return functions[i];
- }
- return NULL;
-}
-
diff --git a/src/3rdparty/angle/src/compiler/DetectRecursion.h b/src/3rdparty/angle/src/compiler/DetectRecursion.h
deleted file mode 100644
index bbac79dc9c..0000000000
--- a/src/3rdparty/angle/src/compiler/DetectRecursion.h
+++ /dev/null
@@ -1,60 +0,0 @@
-//
-// Copyright (c) 2002-2011 The ANGLE Project Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-//
-
-#ifndef COMPILER_DETECT_RECURSION_H_
-#define COMPILER_DETECT_RECURSION_H_
-
-#include "GLSLANG/ShaderLang.h"
-
-#include "compiler/intermediate.h"
-#include "compiler/VariableInfo.h"
-
-// Traverses intermediate tree to detect function recursion.
-class DetectRecursion : public TIntermTraverser {
-public:
- enum ErrorCode {
- kErrorMissingMain,
- kErrorRecursion,
- kErrorNone
- };
-
- DetectRecursion();
- ~DetectRecursion();
-
- virtual bool visitAggregate(Visit, TIntermAggregate*);
-
- ErrorCode detectRecursion();
-
-private:
- class FunctionNode {
- public:
- FunctionNode(const TString& fname);
-
- const TString& getName() const;
-
- // If a function is already in the callee list, this becomes a no-op.
- void addCallee(FunctionNode* callee);
-
- // Return true if recursive function calls are detected.
- bool detectRecursion();
-
- private:
- // mangled function name is unique.
- TString name;
-
- // functions that are directly called by this function.
- TVector<FunctionNode*> callees;
-
- Visit visit;
- };
-
- FunctionNode* findFunctionByName(const TString& name);
-
- TVector<FunctionNode*> functions;
- FunctionNode* currentFunction;
-};
-
-#endif // COMPILER_DETECT_RECURSION_H_
diff --git a/src/3rdparty/angle/src/compiler/InitializeGLPosition.cpp b/src/3rdparty/angle/src/compiler/InitializeGLPosition.cpp
deleted file mode 100644
index e0193e39d2..0000000000
--- a/src/3rdparty/angle/src/compiler/InitializeGLPosition.cpp
+++ /dev/null
@@ -1,61 +0,0 @@
-//
-// Copyright (c) 2002-2013 The ANGLE Project Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-//
-
-#include "compiler/InitializeGLPosition.h"
-#include "compiler/debug.h"
-
-bool InitializeGLPosition::visitAggregate(Visit visit, TIntermAggregate* node)
-{
- bool visitChildren = !mCodeInserted;
- switch (node->getOp())
- {
- case EOpSequence: break;
- case EOpFunction:
- {
- // Function definition.
- ASSERT(visit == PreVisit);
- if (node->getName() == "main(")
- {
- TIntermSequence &sequence = node->getSequence();
- ASSERT((sequence.size() == 1) || (sequence.size() == 2));
- TIntermAggregate *body = NULL;
- if (sequence.size() == 1)
- {
- body = new TIntermAggregate(EOpSequence);
- sequence.push_back(body);
- }
- else
- {
- body = sequence[1]->getAsAggregate();
- }
- ASSERT(body);
- insertCode(body->getSequence());
- mCodeInserted = true;
- }
- break;
- }
- default: visitChildren = false; break;
- }
- return visitChildren;
-}
-
-void InitializeGLPosition::insertCode(TIntermSequence& sequence)
-{
- TIntermBinary *binary = new TIntermBinary(EOpAssign);
- sequence.insert(sequence.begin(), binary);
-
- TIntermSymbol *left = new TIntermSymbol(
- 0, "gl_Position", TType(EbtFloat, EbpUndefined, EvqPosition, 4));
- binary->setLeft(left);
-
- ConstantUnion *u = new ConstantUnion[4];
- for (int ii = 0; ii < 3; ++ii)
- u[ii].setFConst(0.0f);
- u[3].setFConst(1.0f);
- TIntermConstantUnion *right = new TIntermConstantUnion(
- u, TType(EbtFloat, EbpUndefined, EvqConst, 4));
- binary->setRight(right);
-}
diff --git a/src/3rdparty/angle/src/compiler/InitializeGLPosition.h b/src/3rdparty/angle/src/compiler/InitializeGLPosition.h
deleted file mode 100644
index 1b11075a13..0000000000
--- a/src/3rdparty/angle/src/compiler/InitializeGLPosition.h
+++ /dev/null
@@ -1,33 +0,0 @@
-//
-// Copyright (c) 2002-2013 The ANGLE Project Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-//
-
-#ifndef COMPILER_INITIALIZE_GL_POSITION_H_
-#define COMPILER_INITIALIZE_GL_POSITION_H_
-
-#include "compiler/intermediate.h"
-
-class InitializeGLPosition : public TIntermTraverser
-{
-public:
- InitializeGLPosition() : mCodeInserted(false) { }
-
-protected:
- virtual bool visitBinary(Visit visit, TIntermBinary* node) { return false; }
- virtual bool visitUnary(Visit visit, TIntermUnary* node) { return false; }
- virtual bool visitSelection(Visit visit, TIntermSelection* node) { return false; }
- virtual bool visitLoop(Visit visit, TIntermLoop* node) { return false; }
- virtual bool visitBranch(Visit visit, TIntermBranch* node) { return false; }
-
- virtual bool visitAggregate(Visit visit, TIntermAggregate* node);
-
-private:
- // Insert AST node in the beginning of main() for "gl_Position = vec4(0.0, 0.0, 0.0, 1.0);".
- void insertCode(TIntermSequence& sequence);
-
- bool mCodeInserted;
-};
-
-#endif // COMPILER_INITIALIZE_GL_POSITION_H_
diff --git a/src/3rdparty/angle/src/compiler/IntermTraverse.cpp b/src/3rdparty/angle/src/compiler/IntermTraverse.cpp
deleted file mode 100644
index a13877f18f..0000000000
--- a/src/3rdparty/angle/src/compiler/IntermTraverse.cpp
+++ /dev/null
@@ -1,293 +0,0 @@
-//
-// Copyright (c) 2002-2010 The ANGLE Project Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-//
-
-#include "compiler/intermediate.h"
-
-//
-// Traverse the intermediate representation tree, and
-// call a node type specific function for each node.
-// Done recursively through the member function Traverse().
-// Node types can be skipped if their function to call is 0,
-// but their subtree will still be traversed.
-// Nodes with children can have their whole subtree skipped
-// if preVisit is turned on and the type specific function
-// returns false.
-//
-// preVisit, postVisit, and rightToLeft control what order
-// nodes are visited in.
-//
-
-//
-// Traversal functions for terminals are straighforward....
-//
-void TIntermSymbol::traverse(TIntermTraverser* it)
-{
- it->visitSymbol(this);
-}
-
-void TIntermConstantUnion::traverse(TIntermTraverser* it)
-{
- it->visitConstantUnion(this);
-}
-
-//
-// Traverse a binary node.
-//
-void TIntermBinary::traverse(TIntermTraverser* it)
-{
- bool visit = true;
-
- //
- // visit the node before children if pre-visiting.
- //
- if(it->preVisit)
- {
- visit = it->visitBinary(PreVisit, this);
- }
-
- //
- // Visit the children, in the right order.
- //
- if(visit)
- {
- it->incrementDepth();
-
- if(it->rightToLeft)
- {
- if(right)
- {
- right->traverse(it);
- }
-
- if(it->inVisit)
- {
- visit = it->visitBinary(InVisit, this);
- }
-
- if(visit && left)
- {
- left->traverse(it);
- }
- }
- else
- {
- if(left)
- {
- left->traverse(it);
- }
-
- if(it->inVisit)
- {
- visit = it->visitBinary(InVisit, this);
- }
-
- if(visit && right)
- {
- right->traverse(it);
- }
- }
-
- it->decrementDepth();
- }
-
- //
- // Visit the node after the children, if requested and the traversal
- // hasn't been cancelled yet.
- //
- if(visit && it->postVisit)
- {
- it->visitBinary(PostVisit, this);
- }
-}
-
-//
-// Traverse a unary node. Same comments in binary node apply here.
-//
-void TIntermUnary::traverse(TIntermTraverser* it)
-{
- bool visit = true;
-
- if (it->preVisit)
- visit = it->visitUnary(PreVisit, this);
-
- if (visit) {
- it->incrementDepth();
- operand->traverse(it);
- it->decrementDepth();
- }
-
- if (visit && it->postVisit)
- it->visitUnary(PostVisit, this);
-}
-
-//
-// Traverse an aggregate node. Same comments in binary node apply here.
-//
-void TIntermAggregate::traverse(TIntermTraverser* it)
-{
- bool visit = true;
-
- if(it->preVisit)
- {
- visit = it->visitAggregate(PreVisit, this);
- }
-
- if(visit)
- {
- it->incrementDepth();
-
- if(it->rightToLeft)
- {
- for(TIntermSequence::reverse_iterator sit = sequence.rbegin(); sit != sequence.rend(); sit++)
- {
- (*sit)->traverse(it);
-
- if(visit && it->inVisit)
- {
- if(*sit != sequence.front())
- {
- visit = it->visitAggregate(InVisit, this);
- }
- }
- }
- }
- else
- {
- for(TIntermSequence::iterator sit = sequence.begin(); sit != sequence.end(); sit++)
- {
- (*sit)->traverse(it);
-
- if(visit && it->inVisit)
- {
- if(*sit != sequence.back())
- {
- visit = it->visitAggregate(InVisit, this);
- }
- }
- }
- }
-
- it->decrementDepth();
- }
-
- if(visit && it->postVisit)
- {
- it->visitAggregate(PostVisit, this);
- }
-}
-
-//
-// Traverse a selection node. Same comments in binary node apply here.
-//
-void TIntermSelection::traverse(TIntermTraverser* it)
-{
- bool visit = true;
-
- if (it->preVisit)
- visit = it->visitSelection(PreVisit, this);
-
- if (visit) {
- it->incrementDepth();
- if (it->rightToLeft) {
- if (falseBlock)
- falseBlock->traverse(it);
- if (trueBlock)
- trueBlock->traverse(it);
- condition->traverse(it);
- } else {
- condition->traverse(it);
- if (trueBlock)
- trueBlock->traverse(it);
- if (falseBlock)
- falseBlock->traverse(it);
- }
- it->decrementDepth();
- }
-
- if (visit && it->postVisit)
- it->visitSelection(PostVisit, this);
-}
-
-//
-// Traverse a loop node. Same comments in binary node apply here.
-//
-void TIntermLoop::traverse(TIntermTraverser* it)
-{
- bool visit = true;
-
- if(it->preVisit)
- {
- visit = it->visitLoop(PreVisit, this);
- }
-
- if(visit)
- {
- it->incrementDepth();
-
- if(it->rightToLeft)
- {
- if(expr)
- {
- expr->traverse(it);
- }
-
- if(body)
- {
- body->traverse(it);
- }
-
- if(cond)
- {
- cond->traverse(it);
- }
- }
- else
- {
- if(cond)
- {
- cond->traverse(it);
- }
-
- if(body)
- {
- body->traverse(it);
- }
-
- if(expr)
- {
- expr->traverse(it);
- }
- }
-
- it->decrementDepth();
- }
-
- if(visit && it->postVisit)
- {
- it->visitLoop(PostVisit, this);
- }
-}
-
-//
-// Traverse a branch node. Same comments in binary node apply here.
-//
-void TIntermBranch::traverse(TIntermTraverser* it)
-{
- bool visit = true;
-
- if (it->preVisit)
- visit = it->visitBranch(PreVisit, this);
-
- if (visit && expression) {
- it->incrementDepth();
- expression->traverse(it);
- it->decrementDepth();
- }
-
- if (visit && it->postVisit)
- it->visitBranch(PostVisit, this);
-}
-
diff --git a/src/3rdparty/angle/src/compiler/preprocessor/DiagnosticsBase.cpp b/src/3rdparty/angle/src/compiler/preprocessor/DiagnosticsBase.cpp
index 3e22e1f1c5..a7ce862bcb 100644
--- a/src/3rdparty/angle/src/compiler/preprocessor/DiagnosticsBase.cpp
+++ b/src/3rdparty/angle/src/compiler/preprocessor/DiagnosticsBase.cpp
@@ -25,14 +25,14 @@ void Diagnostics::report(ID id,
Diagnostics::Severity Diagnostics::severity(ID id)
{
- if ((id > ERROR_BEGIN) && (id < ERROR_END))
- return ERROR;
+ if ((id > PP_ERROR_BEGIN) && (id < PP_ERROR_END))
+ return PP_ERROR;
- if ((id > WARNING_BEGIN) && (id < WARNING_END))
- return WARNING;
+ if ((id > PP_WARNING_BEGIN) && (id < PP_WARNING_END))
+ return PP_WARNING;
assert(false);
- return ERROR;
+ return PP_ERROR;
}
std::string Diagnostics::message(ID id)
@@ -40,82 +40,82 @@ std::string Diagnostics::message(ID id)
switch (id)
{
// Errors begin.
- case INTERNAL_ERROR:
+ case PP_INTERNAL_ERROR:
return "internal error";
- case OUT_OF_MEMORY:
+ case PP_OUT_OF_MEMORY:
return "out of memory";
- case INVALID_CHARACTER:
+ case PP_INVALID_CHARACTER:
return "invalid character";
- case INVALID_NUMBER:
+ case PP_INVALID_NUMBER:
return "invalid number";
- case INTEGER_OVERFLOW:
+ case PP_INTEGER_OVERFLOW:
return "integer overflow";
- case FLOAT_OVERFLOW:
+ case PP_FLOAT_OVERFLOW:
return "float overflow";
- case TOKEN_TOO_LONG:
+ case PP_TOKEN_TOO_LONG:
return "token too long";
- case INVALID_EXPRESSION:
+ case PP_INVALID_EXPRESSION:
return "invalid expression";
- case DIVISION_BY_ZERO:
+ case PP_DIVISION_BY_ZERO:
return "division by zero";
- case EOF_IN_COMMENT:
+ case PP_EOF_IN_COMMENT:
return "unexpected end of file found in comment";
- case UNEXPECTED_TOKEN:
+ case PP_UNEXPECTED_TOKEN:
return "unexpected token";
- case DIRECTIVE_INVALID_NAME:
+ case PP_DIRECTIVE_INVALID_NAME:
return "invalid directive name";
- case MACRO_NAME_RESERVED:
+ case PP_MACRO_NAME_RESERVED:
return "macro name is reserved";
- case MACRO_REDEFINED:
+ case PP_MACRO_REDEFINED:
return "macro redefined";
- case MACRO_PREDEFINED_REDEFINED:
+ case PP_MACRO_PREDEFINED_REDEFINED:
return "predefined macro redefined";
- case MACRO_PREDEFINED_UNDEFINED:
+ case PP_MACRO_PREDEFINED_UNDEFINED:
return "predefined macro undefined";
- case MACRO_UNTERMINATED_INVOCATION:
+ case PP_MACRO_UNTERMINATED_INVOCATION:
return "unterminated macro invocation";
- case MACRO_TOO_FEW_ARGS:
+ case PP_MACRO_TOO_FEW_ARGS:
return "Not enough arguments for macro";
- case MACRO_TOO_MANY_ARGS:
+ case PP_MACRO_TOO_MANY_ARGS:
return "Too many arguments for macro";
- case CONDITIONAL_ENDIF_WITHOUT_IF:
+ case PP_CONDITIONAL_ENDIF_WITHOUT_IF:
return "unexpected #endif found without a matching #if";
- case CONDITIONAL_ELSE_WITHOUT_IF:
+ case PP_CONDITIONAL_ELSE_WITHOUT_IF:
return "unexpected #else found without a matching #if";
- case CONDITIONAL_ELSE_AFTER_ELSE:
+ case PP_CONDITIONAL_ELSE_AFTER_ELSE:
return "unexpected #else found after another #else";
- case CONDITIONAL_ELIF_WITHOUT_IF:
+ case PP_CONDITIONAL_ELIF_WITHOUT_IF:
return "unexpected #elif found without a matching #if";
- case CONDITIONAL_ELIF_AFTER_ELSE:
+ case PP_CONDITIONAL_ELIF_AFTER_ELSE:
return "unexpected #elif found after #else";
- case CONDITIONAL_UNTERMINATED:
+ case PP_CONDITIONAL_UNTERMINATED:
return "unexpected end of file found in conditional block";
- case INVALID_EXTENSION_NAME:
+ case PP_INVALID_EXTENSION_NAME:
return "invalid extension name";
- case INVALID_EXTENSION_BEHAVIOR:
+ case PP_INVALID_EXTENSION_BEHAVIOR:
return "invalid extension behavior";
- case INVALID_EXTENSION_DIRECTIVE:
+ case PP_INVALID_EXTENSION_DIRECTIVE:
return "invalid extension directive";
- case INVALID_VERSION_NUMBER:
+ case PP_INVALID_VERSION_NUMBER:
return "invalid version number";
- case INVALID_VERSION_DIRECTIVE:
+ case PP_INVALID_VERSION_DIRECTIVE:
return "invalid version directive";
- case VERSION_NOT_FIRST_STATEMENT:
+ case PP_VERSION_NOT_FIRST_STATEMENT:
return "#version directive must occur before anything else, "
"except for comments and white space";
- case INVALID_LINE_NUMBER:
+ case PP_INVALID_LINE_NUMBER:
return "invalid line number";
- case INVALID_FILE_NUMBER:
+ case PP_INVALID_FILE_NUMBER:
return "invalid file number";
- case INVALID_LINE_DIRECTIVE:
+ case PP_INVALID_LINE_DIRECTIVE:
return "invalid line directive";
// Errors end.
// Warnings begin.
- case EOF_IN_DIRECTIVE:
+ case PP_EOF_IN_DIRECTIVE:
return "unexpected end of file found in directive";
- case CONDITIONAL_UNEXPECTED_TOKEN:
+ case PP_CONDITIONAL_UNEXPECTED_TOKEN:
return "unexpected token after conditional expression";
- case UNRECOGNIZED_PRAGMA:
+ case PP_UNRECOGNIZED_PRAGMA:
return "unrecognized pragma";
// Warnings end.
default:
diff --git a/src/3rdparty/angle/src/compiler/preprocessor/DiagnosticsBase.h b/src/3rdparty/angle/src/compiler/preprocessor/DiagnosticsBase.h
index 07bc411846..2c8c539137 100644
--- a/src/3rdparty/angle/src/compiler/preprocessor/DiagnosticsBase.h
+++ b/src/3rdparty/angle/src/compiler/preprocessor/DiagnosticsBase.h
@@ -21,53 +21,53 @@ class Diagnostics
public:
enum Severity
{
- ERROR,
- WARNING
+ PP_ERROR,
+ PP_WARNING
};
enum ID
{
- ERROR_BEGIN,
- INTERNAL_ERROR,
- OUT_OF_MEMORY,
- INVALID_CHARACTER,
- INVALID_NUMBER,
- INTEGER_OVERFLOW,
- FLOAT_OVERFLOW,
- TOKEN_TOO_LONG,
- INVALID_EXPRESSION,
- DIVISION_BY_ZERO,
- EOF_IN_COMMENT,
- UNEXPECTED_TOKEN,
- DIRECTIVE_INVALID_NAME,
- MACRO_NAME_RESERVED,
- MACRO_REDEFINED,
- MACRO_PREDEFINED_REDEFINED,
- MACRO_PREDEFINED_UNDEFINED,
- MACRO_UNTERMINATED_INVOCATION,
- MACRO_TOO_FEW_ARGS,
- MACRO_TOO_MANY_ARGS,
- CONDITIONAL_ENDIF_WITHOUT_IF,
- CONDITIONAL_ELSE_WITHOUT_IF,
- CONDITIONAL_ELSE_AFTER_ELSE,
- CONDITIONAL_ELIF_WITHOUT_IF,
- CONDITIONAL_ELIF_AFTER_ELSE,
- CONDITIONAL_UNTERMINATED,
- INVALID_EXTENSION_NAME,
- INVALID_EXTENSION_BEHAVIOR,
- INVALID_EXTENSION_DIRECTIVE,
- INVALID_VERSION_NUMBER,
- INVALID_VERSION_DIRECTIVE,
- VERSION_NOT_FIRST_STATEMENT,
- INVALID_LINE_NUMBER,
- INVALID_FILE_NUMBER,
- INVALID_LINE_DIRECTIVE,
- ERROR_END,
+ PP_ERROR_BEGIN,
+ PP_INTERNAL_ERROR,
+ PP_OUT_OF_MEMORY,
+ PP_INVALID_CHARACTER,
+ PP_INVALID_NUMBER,
+ PP_INTEGER_OVERFLOW,
+ PP_FLOAT_OVERFLOW,
+ PP_TOKEN_TOO_LONG,
+ PP_INVALID_EXPRESSION,
+ PP_DIVISION_BY_ZERO,
+ PP_EOF_IN_COMMENT,
+ PP_UNEXPECTED_TOKEN,
+ PP_DIRECTIVE_INVALID_NAME,
+ PP_MACRO_NAME_RESERVED,
+ PP_MACRO_REDEFINED,
+ PP_MACRO_PREDEFINED_REDEFINED,
+ PP_MACRO_PREDEFINED_UNDEFINED,
+ PP_MACRO_UNTERMINATED_INVOCATION,
+ PP_MACRO_TOO_FEW_ARGS,
+ PP_MACRO_TOO_MANY_ARGS,
+ PP_CONDITIONAL_ENDIF_WITHOUT_IF,
+ PP_CONDITIONAL_ELSE_WITHOUT_IF,
+ PP_CONDITIONAL_ELSE_AFTER_ELSE,
+ PP_CONDITIONAL_ELIF_WITHOUT_IF,
+ PP_CONDITIONAL_ELIF_AFTER_ELSE,
+ PP_CONDITIONAL_UNTERMINATED,
+ PP_INVALID_EXTENSION_NAME,
+ PP_INVALID_EXTENSION_BEHAVIOR,
+ PP_INVALID_EXTENSION_DIRECTIVE,
+ PP_INVALID_VERSION_NUMBER,
+ PP_INVALID_VERSION_DIRECTIVE,
+ PP_VERSION_NOT_FIRST_STATEMENT,
+ PP_INVALID_LINE_NUMBER,
+ PP_INVALID_FILE_NUMBER,
+ PP_INVALID_LINE_DIRECTIVE,
+ PP_ERROR_END,
- WARNING_BEGIN,
- EOF_IN_DIRECTIVE,
- CONDITIONAL_UNEXPECTED_TOKEN,
- UNRECOGNIZED_PRAGMA,
- WARNING_END
+ PP_WARNING_BEGIN,
+ PP_EOF_IN_DIRECTIVE,
+ PP_CONDITIONAL_UNEXPECTED_TOKEN,
+ PP_UNRECOGNIZED_PRAGMA,
+ PP_WARNING_END
};
virtual ~Diagnostics();
diff --git a/src/3rdparty/angle/src/compiler/preprocessor/DirectiveParser.cpp b/src/3rdparty/angle/src/compiler/preprocessor/DirectiveParser.cpp
index 94dfdf513d..ebec79804d 100644
--- a/src/3rdparty/angle/src/compiler/preprocessor/DirectiveParser.cpp
+++ b/src/3rdparty/angle/src/compiler/preprocessor/DirectiveParser.cpp
@@ -172,7 +172,7 @@ class DefinedParser : public Lexer
if (token->type != Token::IDENTIFIER)
{
- mDiagnostics->report(Diagnostics::UNEXPECTED_TOKEN,
+ mDiagnostics->report(Diagnostics::PP_UNEXPECTED_TOKEN,
token->location, token->text);
skipUntilEOD(mLexer, token);
return;
@@ -185,7 +185,7 @@ class DefinedParser : public Lexer
mLexer->lex(token);
if (token->type != ')')
{
- mDiagnostics->report(Diagnostics::UNEXPECTED_TOKEN,
+ mDiagnostics->report(Diagnostics::PP_UNEXPECTED_TOKEN,
token->location, token->text);
skipUntilEOD(mLexer, token);
return;
@@ -233,7 +233,7 @@ void DirectiveParser::lex(Token* token)
if (!mConditionalStack.empty())
{
const ConditionalBlock& block = mConditionalStack.back();
- mDiagnostics->report(Diagnostics::CONDITIONAL_UNTERMINATED,
+ mDiagnostics->report(Diagnostics::PP_CONDITIONAL_UNTERMINATED,
block.location, block.type);
}
break;
@@ -268,7 +268,7 @@ void DirectiveParser::parseDirective(Token* token)
switch(directive)
{
case DIRECTIVE_NONE:
- mDiagnostics->report(Diagnostics::DIRECTIVE_INVALID_NAME,
+ mDiagnostics->report(Diagnostics::PP_DIRECTIVE_INVALID_NAME,
token->location, token->text);
skipUntilEOD(mTokenizer, token);
break;
@@ -319,7 +319,7 @@ void DirectiveParser::parseDirective(Token* token)
skipUntilEOD(mTokenizer, token);
if (token->type == Token::LAST)
{
- mDiagnostics->report(Diagnostics::EOF_IN_DIRECTIVE,
+ mDiagnostics->report(Diagnostics::PP_EOF_IN_DIRECTIVE,
token->location, token->text);
}
}
@@ -331,19 +331,19 @@ void DirectiveParser::parseDefine(Token* token)
mTokenizer->lex(token);
if (token->type != Token::IDENTIFIER)
{
- mDiagnostics->report(Diagnostics::UNEXPECTED_TOKEN,
+ mDiagnostics->report(Diagnostics::PP_UNEXPECTED_TOKEN,
token->location, token->text);
return;
}
if (isMacroPredefined(token->text, *mMacroSet))
{
- mDiagnostics->report(Diagnostics::MACRO_PREDEFINED_REDEFINED,
+ mDiagnostics->report(Diagnostics::PP_MACRO_PREDEFINED_REDEFINED,
token->location, token->text);
return;
}
if (isMacroNameReserved(token->text))
{
- mDiagnostics->report(Diagnostics::MACRO_NAME_RESERVED,
+ mDiagnostics->report(Diagnostics::PP_MACRO_NAME_RESERVED,
token->location, token->text);
return;
}
@@ -368,7 +368,7 @@ void DirectiveParser::parseDefine(Token* token)
if (token->type != ')')
{
- mDiagnostics->report(Diagnostics::UNEXPECTED_TOKEN,
+ mDiagnostics->report(Diagnostics::PP_UNEXPECTED_TOKEN,
token->location,
token->text);
return;
@@ -396,7 +396,7 @@ void DirectiveParser::parseDefine(Token* token)
MacroSet::const_iterator iter = mMacroSet->find(macro.name);
if (iter != mMacroSet->end() && !macro.equals(iter->second))
{
- mDiagnostics->report(Diagnostics::MACRO_REDEFINED,
+ mDiagnostics->report(Diagnostics::PP_MACRO_REDEFINED,
token->location,
macro.name);
return;
@@ -411,7 +411,7 @@ void DirectiveParser::parseUndef(Token* token)
mTokenizer->lex(token);
if (token->type != Token::IDENTIFIER)
{
- mDiagnostics->report(Diagnostics::UNEXPECTED_TOKEN,
+ mDiagnostics->report(Diagnostics::PP_UNEXPECTED_TOKEN,
token->location, token->text);
return;
}
@@ -421,7 +421,7 @@ void DirectiveParser::parseUndef(Token* token)
{
if (iter->second.predefined)
{
- mDiagnostics->report(Diagnostics::MACRO_PREDEFINED_UNDEFINED,
+ mDiagnostics->report(Diagnostics::PP_MACRO_PREDEFINED_UNDEFINED,
token->location, token->text);
}
else
@@ -457,7 +457,7 @@ void DirectiveParser::parseElse(Token* token)
if (mConditionalStack.empty())
{
- mDiagnostics->report(Diagnostics::CONDITIONAL_ELSE_WITHOUT_IF,
+ mDiagnostics->report(Diagnostics::PP_CONDITIONAL_ELSE_WITHOUT_IF,
token->location, token->text);
skipUntilEOD(mTokenizer, token);
return;
@@ -472,7 +472,7 @@ void DirectiveParser::parseElse(Token* token)
}
if (block.foundElseGroup)
{
- mDiagnostics->report(Diagnostics::CONDITIONAL_ELSE_AFTER_ELSE,
+ mDiagnostics->report(Diagnostics::PP_CONDITIONAL_ELSE_AFTER_ELSE,
token->location, token->text);
skipUntilEOD(mTokenizer, token);
return;
@@ -486,7 +486,7 @@ void DirectiveParser::parseElse(Token* token)
mTokenizer->lex(token);
if (!isEOD(token))
{
- mDiagnostics->report(Diagnostics::CONDITIONAL_UNEXPECTED_TOKEN,
+ mDiagnostics->report(Diagnostics::PP_CONDITIONAL_UNEXPECTED_TOKEN,
token->location, token->text);
skipUntilEOD(mTokenizer, token);
}
@@ -498,7 +498,7 @@ void DirectiveParser::parseElif(Token* token)
if (mConditionalStack.empty())
{
- mDiagnostics->report(Diagnostics::CONDITIONAL_ELIF_WITHOUT_IF,
+ mDiagnostics->report(Diagnostics::PP_CONDITIONAL_ELIF_WITHOUT_IF,
token->location, token->text);
skipUntilEOD(mTokenizer, token);
return;
@@ -513,7 +513,7 @@ void DirectiveParser::parseElif(Token* token)
}
if (block.foundElseGroup)
{
- mDiagnostics->report(Diagnostics::CONDITIONAL_ELIF_AFTER_ELSE,
+ mDiagnostics->report(Diagnostics::PP_CONDITIONAL_ELIF_AFTER_ELSE,
token->location, token->text);
skipUntilEOD(mTokenizer, token);
return;
@@ -538,7 +538,7 @@ void DirectiveParser::parseEndif(Token* token)
if (mConditionalStack.empty())
{
- mDiagnostics->report(Diagnostics::CONDITIONAL_ENDIF_WITHOUT_IF,
+ mDiagnostics->report(Diagnostics::PP_CONDITIONAL_ENDIF_WITHOUT_IF,
token->location, token->text);
skipUntilEOD(mTokenizer, token);
return;
@@ -550,7 +550,7 @@ void DirectiveParser::parseEndif(Token* token)
mTokenizer->lex(token);
if (!isEOD(token))
{
- mDiagnostics->report(Diagnostics::CONDITIONAL_UNEXPECTED_TOKEN,
+ mDiagnostics->report(Diagnostics::PP_CONDITIONAL_UNEXPECTED_TOKEN,
token->location, token->text);
skipUntilEOD(mTokenizer, token);
}
@@ -618,7 +618,7 @@ void DirectiveParser::parsePragma(Token* token)
(state == RIGHT_PAREN + 1)); // With value.
if (!valid)
{
- mDiagnostics->report(Diagnostics::UNRECOGNIZED_PRAGMA,
+ mDiagnostics->report(Diagnostics::PP_UNRECOGNIZED_PRAGMA,
token->location, name);
}
else if (state > PRAGMA_NAME) // Do not notify for empty pragma.
@@ -650,7 +650,7 @@ void DirectiveParser::parseExtension(Token* token)
case EXT_NAME:
if (valid && (token->type != Token::IDENTIFIER))
{
- mDiagnostics->report(Diagnostics::INVALID_EXTENSION_NAME,
+ mDiagnostics->report(Diagnostics::PP_INVALID_EXTENSION_NAME,
token->location, token->text);
valid = false;
}
@@ -659,7 +659,7 @@ void DirectiveParser::parseExtension(Token* token)
case COLON:
if (valid && (token->type != ':'))
{
- mDiagnostics->report(Diagnostics::UNEXPECTED_TOKEN,
+ mDiagnostics->report(Diagnostics::PP_UNEXPECTED_TOKEN,
token->location, token->text);
valid = false;
}
@@ -667,7 +667,7 @@ void DirectiveParser::parseExtension(Token* token)
case EXT_BEHAVIOR:
if (valid && (token->type != Token::IDENTIFIER))
{
- mDiagnostics->report(Diagnostics::INVALID_EXTENSION_BEHAVIOR,
+ mDiagnostics->report(Diagnostics::PP_INVALID_EXTENSION_BEHAVIOR,
token->location, token->text);
valid = false;
}
@@ -676,7 +676,7 @@ void DirectiveParser::parseExtension(Token* token)
default:
if (valid)
{
- mDiagnostics->report(Diagnostics::UNEXPECTED_TOKEN,
+ mDiagnostics->report(Diagnostics::PP_UNEXPECTED_TOKEN,
token->location, token->text);
valid = false;
}
@@ -686,7 +686,7 @@ void DirectiveParser::parseExtension(Token* token)
}
if (valid && (state != EXT_BEHAVIOR + 1))
{
- mDiagnostics->report(Diagnostics::INVALID_EXTENSION_DIRECTIVE,
+ mDiagnostics->report(Diagnostics::PP_INVALID_EXTENSION_DIRECTIVE,
token->location, token->text);
valid = false;
}
@@ -700,7 +700,7 @@ void DirectiveParser::parseVersion(Token* token)
if (mPastFirstStatement)
{
- mDiagnostics->report(Diagnostics::VERSION_NOT_FIRST_STATEMENT,
+ mDiagnostics->report(Diagnostics::PP_VERSION_NOT_FIRST_STATEMENT,
token->location, token->text);
skipUntilEOD(mTokenizer, token);
return;
@@ -723,13 +723,13 @@ void DirectiveParser::parseVersion(Token* token)
case VERSION_NUMBER:
if (valid && (token->type != Token::CONST_INT))
{
- mDiagnostics->report(Diagnostics::INVALID_VERSION_NUMBER,
+ mDiagnostics->report(Diagnostics::PP_INVALID_VERSION_NUMBER,
token->location, token->text);
valid = false;
}
if (valid && !token->iValue(&version))
{
- mDiagnostics->report(Diagnostics::INTEGER_OVERFLOW,
+ mDiagnostics->report(Diagnostics::PP_INTEGER_OVERFLOW,
token->location, token->text);
valid = false;
}
@@ -737,7 +737,7 @@ void DirectiveParser::parseVersion(Token* token)
default:
if (valid)
{
- mDiagnostics->report(Diagnostics::UNEXPECTED_TOKEN,
+ mDiagnostics->report(Diagnostics::PP_UNEXPECTED_TOKEN,
token->location, token->text);
valid = false;
}
@@ -747,7 +747,7 @@ void DirectiveParser::parseVersion(Token* token)
}
if (valid && (state != VERSION_NUMBER + 1))
{
- mDiagnostics->report(Diagnostics::INVALID_VERSION_DIRECTIVE,
+ mDiagnostics->report(Diagnostics::PP_INVALID_VERSION_DIRECTIVE,
token->location, token->text);
valid = false;
}
@@ -778,13 +778,13 @@ void DirectiveParser::parseLine(Token* token)
case LINE_NUMBER:
if (valid && (token->type != Token::CONST_INT))
{
- mDiagnostics->report(Diagnostics::INVALID_LINE_NUMBER,
+ mDiagnostics->report(Diagnostics::PP_INVALID_LINE_NUMBER,
token->location, token->text);
valid = false;
}
if (valid && !token->iValue(&line))
{
- mDiagnostics->report(Diagnostics::INTEGER_OVERFLOW,
+ mDiagnostics->report(Diagnostics::PP_INTEGER_OVERFLOW,
token->location, token->text);
valid = false;
}
@@ -792,13 +792,13 @@ void DirectiveParser::parseLine(Token* token)
case FILE_NUMBER:
if (valid && (token->type != Token::CONST_INT))
{
- mDiagnostics->report(Diagnostics::INVALID_FILE_NUMBER,
+ mDiagnostics->report(Diagnostics::PP_INVALID_FILE_NUMBER,
token->location, token->text);
valid = false;
}
if (valid && !token->iValue(&file))
{
- mDiagnostics->report(Diagnostics::INTEGER_OVERFLOW,
+ mDiagnostics->report(Diagnostics::PP_INTEGER_OVERFLOW,
token->location, token->text);
valid = false;
}
@@ -806,7 +806,7 @@ void DirectiveParser::parseLine(Token* token)
default:
if (valid)
{
- mDiagnostics->report(Diagnostics::UNEXPECTED_TOKEN,
+ mDiagnostics->report(Diagnostics::PP_UNEXPECTED_TOKEN,
token->location, token->text);
valid = false;
}
@@ -817,7 +817,7 @@ void DirectiveParser::parseLine(Token* token)
if (valid && (state != FILE_NUMBER) && (state != FILE_NUMBER + 1))
{
- mDiagnostics->report(Diagnostics::INVALID_LINE_DIRECTIVE,
+ mDiagnostics->report(Diagnostics::PP_INVALID_LINE_DIRECTIVE,
token->location, token->text);
valid = false;
}
@@ -893,7 +893,7 @@ int DirectiveParser::parseExpressionIf(Token* token)
// Warn if there are tokens after #if expression.
if (!isEOD(token))
{
- mDiagnostics->report(Diagnostics::CONDITIONAL_UNEXPECTED_TOKEN,
+ mDiagnostics->report(Diagnostics::PP_CONDITIONAL_UNEXPECTED_TOKEN,
token->location, token->text);
skipUntilEOD(mTokenizer, token);
}
@@ -909,7 +909,7 @@ int DirectiveParser::parseExpressionIfdef(Token* token)
mTokenizer->lex(token);
if (token->type != Token::IDENTIFIER)
{
- mDiagnostics->report(Diagnostics::UNEXPECTED_TOKEN,
+ mDiagnostics->report(Diagnostics::PP_UNEXPECTED_TOKEN,
token->location, token->text);
skipUntilEOD(mTokenizer, token);
return 0;
@@ -922,7 +922,7 @@ int DirectiveParser::parseExpressionIfdef(Token* token)
mTokenizer->lex(token);
if (!isEOD(token))
{
- mDiagnostics->report(Diagnostics::CONDITIONAL_UNEXPECTED_TOKEN,
+ mDiagnostics->report(Diagnostics::PP_CONDITIONAL_UNEXPECTED_TOKEN,
token->location, token->text);
skipUntilEOD(mTokenizer, token);
}
diff --git a/src/3rdparty/angle/src/compiler/preprocessor/ExpressionParser.y b/src/3rdparty/angle/src/compiler/preprocessor/ExpressionParser.y
index b6d3143e60..9fa0f0bf80 100644
--- a/src/3rdparty/angle/src/compiler/preprocessor/ExpressionParser.y
+++ b/src/3rdparty/angle/src/compiler/preprocessor/ExpressionParser.y
@@ -33,6 +33,12 @@ WHICH GENERATES THE GLSL ES preprocessor expression parser.
#include "ExpressionParser.h"
+#if defined(_MSC_VER)
+#include <malloc.h>
+#else
+#include <stdlib.h>
+#endif
+
#include <cassert>
#include <sstream>
@@ -146,7 +152,7 @@ expression
std::ostringstream stream;
stream << $1 << " % " << $3;
std::string text = stream.str();
- context->diagnostics->report(pp::Diagnostics::DIVISION_BY_ZERO,
+ context->diagnostics->report(pp::Diagnostics::PP_DIVISION_BY_ZERO,
context->token->location,
text.c_str());
YYABORT;
@@ -159,7 +165,7 @@ expression
std::ostringstream stream;
stream << $1 << " / " << $3;
std::string text = stream.str();
- context->diagnostics->report(pp::Diagnostics::DIVISION_BY_ZERO,
+ context->diagnostics->report(pp::Diagnostics::PP_DIVISION_BY_ZERO,
context->token->location,
text.c_str());
YYABORT;
@@ -201,7 +207,7 @@ int yylex(YYSTYPE* lvalp, Context* context)
unsigned int val = 0;
if (!token->uValue(&val))
{
- context->diagnostics->report(pp::Diagnostics::INTEGER_OVERFLOW,
+ context->diagnostics->report(pp::Diagnostics::PP_INTEGER_OVERFLOW,
token->location, token->text);
}
*lvalp = static_cast<YYSTYPE>(val);
@@ -242,7 +248,7 @@ int yylex(YYSTYPE* lvalp, Context* context)
void yyerror(Context* context, const char* reason)
{
- context->diagnostics->report(pp::Diagnostics::INVALID_EXPRESSION,
+ context->diagnostics->report(pp::Diagnostics::PP_INVALID_EXPRESSION,
context->token->location,
reason);
}
@@ -270,12 +276,12 @@ bool ExpressionParser::parse(Token* token, int* result)
break;
case 2:
- mDiagnostics->report(Diagnostics::OUT_OF_MEMORY, token->location, "");
+ mDiagnostics->report(Diagnostics::PP_OUT_OF_MEMORY, token->location, "");
break;
default:
assert(false);
- mDiagnostics->report(Diagnostics::INTERNAL_ERROR, token->location, "");
+ mDiagnostics->report(Diagnostics::PP_INTERNAL_ERROR, token->location, "");
break;
}
diff --git a/src/3rdparty/angle/src/compiler/preprocessor/MacroExpander.cpp b/src/3rdparty/angle/src/compiler/preprocessor/MacroExpander.cpp
index 1116c516ff..b789260af9 100644
--- a/src/3rdparty/angle/src/compiler/preprocessor/MacroExpander.cpp
+++ b/src/3rdparty/angle/src/compiler/preprocessor/MacroExpander.cpp
@@ -254,7 +254,7 @@ bool MacroExpander::collectMacroArgs(const Macro& macro,
if (token.type == Token::LAST)
{
- mDiagnostics->report(Diagnostics::MACRO_UNTERMINATED_INVOCATION,
+ mDiagnostics->report(Diagnostics::PP_MACRO_UNTERMINATED_INVOCATION,
identifier.location, identifier.text);
// Do not lose EOF token.
ungetToken(token);
@@ -302,8 +302,8 @@ bool MacroExpander::collectMacroArgs(const Macro& macro,
if (args->size() != params.size())
{
Diagnostics::ID id = args->size() < macro.parameters.size() ?
- Diagnostics::MACRO_TOO_FEW_ARGS :
- Diagnostics::MACRO_TOO_MANY_ARGS;
+ Diagnostics::PP_MACRO_TOO_FEW_ARGS :
+ Diagnostics::PP_MACRO_TOO_MANY_ARGS;
mDiagnostics->report(id, identifier.location, identifier.text);
return false;
}
diff --git a/src/3rdparty/angle/src/compiler/preprocessor/Preprocessor.cpp b/src/3rdparty/angle/src/compiler/preprocessor/Preprocessor.cpp
index b615c85dce..580ffba459 100644
--- a/src/3rdparty/angle/src/compiler/preprocessor/Preprocessor.cpp
+++ b/src/3rdparty/angle/src/compiler/preprocessor/Preprocessor.cpp
@@ -101,11 +101,11 @@ void Preprocessor::lex(Token* token)
assert(false);
break;
case Token::PP_NUMBER:
- mImpl->diagnostics->report(Diagnostics::INVALID_NUMBER,
+ mImpl->diagnostics->report(Diagnostics::PP_INVALID_NUMBER,
token->location, token->text);
break;
case Token::PP_OTHER:
- mImpl->diagnostics->report(Diagnostics::INVALID_CHARACTER,
+ mImpl->diagnostics->report(Diagnostics::PP_INVALID_CHARACTER,
token->location, token->text);
break;
default:
diff --git a/src/3rdparty/angle/src/compiler/preprocessor/Tokenizer.l b/src/3rdparty/angle/src/compiler/preprocessor/Tokenizer.l
index 01f0177b6c..f1380b26b7 100644
--- a/src/3rdparty/angle/src/compiler/preprocessor/Tokenizer.l
+++ b/src/3rdparty/angle/src/compiler/preprocessor/Tokenizer.l
@@ -256,7 +256,7 @@ FRACTIONAL_CONSTANT ({DIGIT}*"."{DIGIT}+)|({DIGIT}+".")
if (YY_START == COMMENT)
{
- yyextra->diagnostics->report(pp::Diagnostics::EOF_IN_COMMENT,
+ yyextra->diagnostics->report(pp::Diagnostics::PP_EOF_IN_COMMENT,
pp::SourceLocation(yyfileno, yylineno),
"");
}
@@ -304,7 +304,7 @@ void Tokenizer::lex(Token* token)
token->type = yylex(&token->text, &token->location, mHandle);
if (token->text.size() > mMaxTokenLength)
{
- mContext.diagnostics->report(Diagnostics::TOKEN_TOO_LONG,
+ mContext.diagnostics->report(Diagnostics::PP_TOKEN_TOO_LONG,
token->location, token->text);
token->text.erase(mMaxTokenLength);
}
diff --git a/src/3rdparty/angle/src/compiler/BaseTypes.h b/src/3rdparty/angle/src/compiler/translator/BaseTypes.h
index 1631f4f779..7bdaf14983 100644
--- a/src/3rdparty/angle/src/compiler/BaseTypes.h
+++ b/src/3rdparty/angle/src/compiler/translator/BaseTypes.h
@@ -82,6 +82,7 @@ enum TQualifier
{
EvqTemporary, // For temporaries (within a function), read/write
EvqGlobal, // For globals read/write
+ EvqInternal, // For internal use, not visible to the user
EvqConst, // User defined constants and non-output parameters in functions
EvqAttribute, // Readonly
EvqVaryingIn, // readonly, fragment shaders only
diff --git a/src/3rdparty/angle/src/compiler/BuiltInFunctionEmulator.cpp b/src/3rdparty/angle/src/compiler/translator/BuiltInFunctionEmulator.cpp
index 1c4b25f13f..92b71c6bdb 100644
--- a/src/3rdparty/angle/src/compiler/BuiltInFunctionEmulator.cpp
+++ b/src/3rdparty/angle/src/compiler/translator/BuiltInFunctionEmulator.cpp
@@ -4,9 +4,9 @@
// found in the LICENSE file.
//
-#include "compiler/BuiltInFunctionEmulator.h"
+#include "compiler/translator/BuiltInFunctionEmulator.h"
-#include "compiler/SymbolTable.h"
+#include "compiler/translator/SymbolTable.h"
namespace {
diff --git a/src/3rdparty/angle/src/compiler/BuiltInFunctionEmulator.h b/src/3rdparty/angle/src/compiler/translator/BuiltInFunctionEmulator.h
index 0d904f41d0..cfb71a803a 100644
--- a/src/3rdparty/angle/src/compiler/BuiltInFunctionEmulator.h
+++ b/src/3rdparty/angle/src/compiler/translator/BuiltInFunctionEmulator.h
@@ -9,8 +9,8 @@
#include "GLSLANG/ShaderLang.h"
-#include "compiler/InfoSink.h"
-#include "compiler/intermediate.h"
+#include "compiler/translator/InfoSink.h"
+#include "compiler/translator/intermediate.h"
//
// This class decides which built-in functions need to be replaced with the
diff --git a/src/3rdparty/angle/src/compiler/CodeGenGLSL.cpp b/src/3rdparty/angle/src/compiler/translator/CodeGen.cpp
index 226bf8f0fc..8f5d129104 100644
--- a/src/3rdparty/angle/src/compiler/CodeGenGLSL.cpp
+++ b/src/3rdparty/angle/src/compiler/translator/CodeGen.cpp
@@ -4,8 +4,9 @@
// found in the LICENSE file.
//
-#include "compiler/TranslatorGLSL.h"
-#include "compiler/TranslatorESSL.h"
+#include "compiler/translator/TranslatorESSL.h"
+#include "compiler/translator/TranslatorGLSL.h"
+#include "compiler/translator/TranslatorHLSL.h"
//
// This function must be provided to create the actual
@@ -16,10 +17,13 @@ TCompiler* ConstructCompiler(
ShShaderType type, ShShaderSpec spec, ShShaderOutput output)
{
switch (output) {
- case SH_GLSL_OUTPUT:
- return new TranslatorGLSL(type, spec);
case SH_ESSL_OUTPUT:
return new TranslatorESSL(type, spec);
+ case SH_GLSL_OUTPUT:
+ return new TranslatorGLSL(type, spec);
+ case SH_HLSL9_OUTPUT:
+ case SH_HLSL11_OUTPUT:
+ return new TranslatorHLSL(type, spec, output);
default:
return NULL;
}
diff --git a/src/3rdparty/angle/src/compiler/Common.h b/src/3rdparty/angle/src/compiler/translator/Common.h
index 46f9440fff..1e4503e340 100644
--- a/src/3rdparty/angle/src/compiler/Common.h
+++ b/src/3rdparty/angle/src/compiler/translator/Common.h
@@ -11,8 +11,12 @@
#include <sstream>
#include <string>
#include <vector>
+#include <limits>
+#include <stdio.h>
-#include "compiler/PoolAlloc.h"
+#include "compiler/translator/PoolAlloc.h"
+#include "compiler/translator/compilerdebug.h"
+#include "common/angleutils.h"
struct TSourceLoc {
int first_file;
@@ -74,4 +78,15 @@ public:
TMap(const tAllocator& a) : std::map<K, D, CMP, tAllocator>(std::map<K, D, CMP, tAllocator>::key_compare(), a) {}
};
+// Integer to TString conversion
+template <typename T>
+inline TString str(T i)
+{
+ ASSERT(std::numeric_limits<T>::is_integer);
+ char buffer[((8 * sizeof(T)) / 3) + 3];
+ const char *formatStr = std::numeric_limits<T>::is_signed ? "%d" : "%u";
+ snprintf(buffer, sizeof(buffer), formatStr, i);
+ return buffer;
+}
+
#endif // _COMMON_INCLUDED_
diff --git a/src/3rdparty/angle/src/compiler/Compiler.cpp b/src/3rdparty/angle/src/compiler/translator/Compiler.cpp
index ee64057ac4..eb7465e35c 100644
--- a/src/3rdparty/angle/src/compiler/Compiler.cpp
+++ b/src/3rdparty/angle/src/compiler/translator/Compiler.cpp
@@ -4,22 +4,23 @@
// found in the LICENSE file.
//
-#include "compiler/BuiltInFunctionEmulator.h"
-#include "compiler/DetectCallDepth.h"
-#include "compiler/ForLoopUnroll.h"
-#include "compiler/Initialize.h"
-#include "compiler/InitializeGLPosition.h"
-#include "compiler/InitializeParseContext.h"
-#include "compiler/MapLongVariableNames.h"
-#include "compiler/ParseHelper.h"
-#include "compiler/RenameFunction.h"
-#include "compiler/ShHandle.h"
-#include "compiler/ValidateLimitations.h"
-#include "compiler/VariablePacker.h"
-#include "compiler/depgraph/DependencyGraph.h"
-#include "compiler/depgraph/DependencyGraphOutput.h"
-#include "compiler/timing/RestrictFragmentShaderTiming.h"
-#include "compiler/timing/RestrictVertexShaderTiming.h"
+#include "compiler/translator/BuiltInFunctionEmulator.h"
+#include "compiler/translator/DetectCallDepth.h"
+#include "compiler/translator/ForLoopUnroll.h"
+#include "compiler/translator/Initialize.h"
+#include "compiler/translator/InitializeParseContext.h"
+#include "compiler/translator/InitializeVariables.h"
+#include "compiler/translator/MapLongVariableNames.h"
+#include "compiler/translator/ParseContext.h"
+#include "compiler/translator/RenameFunction.h"
+#include "compiler/translator/ShHandle.h"
+#include "compiler/translator/UnfoldShortCircuitAST.h"
+#include "compiler/translator/ValidateLimitations.h"
+#include "compiler/translator/VariablePacker.h"
+#include "compiler/translator/depgraph/DependencyGraph.h"
+#include "compiler/translator/depgraph/DependencyGraphOutput.h"
+#include "compiler/translator/timing/RestrictFragmentShaderTiming.h"
+#include "compiler/translator/timing/RestrictVertexShaderTiming.h"
#include "third_party/compiler/ArrayBoundsClamper.h"
bool isWebGLBasedSpec(ShShaderSpec spec)
@@ -28,43 +29,51 @@ bool isWebGLBasedSpec(ShShaderSpec spec)
}
namespace {
-class TScopedPoolAllocator {
-public:
- TScopedPoolAllocator(TPoolAllocator* allocator) : mAllocator(allocator) {
+class TScopedPoolAllocator
+{
+ public:
+ TScopedPoolAllocator(TPoolAllocator* allocator) : mAllocator(allocator)
+ {
mAllocator->push();
SetGlobalPoolAllocator(mAllocator);
}
- ~TScopedPoolAllocator() {
+ ~TScopedPoolAllocator()
+ {
SetGlobalPoolAllocator(NULL);
mAllocator->pop();
}
-private:
+ private:
TPoolAllocator* mAllocator;
};
-class TScopedSymbolTableLevel {
-public:
- TScopedSymbolTableLevel(TSymbolTable* table) : mTable(table) {
+class TScopedSymbolTableLevel
+{
+ public:
+ TScopedSymbolTableLevel(TSymbolTable* table) : mTable(table)
+ {
ASSERT(mTable->atBuiltInLevel());
mTable->push();
}
- ~TScopedSymbolTableLevel() {
+ ~TScopedSymbolTableLevel()
+ {
while (!mTable->atBuiltInLevel())
mTable->pop();
}
-private:
+ private:
TSymbolTable* mTable;
};
} // namespace
-TShHandleBase::TShHandleBase() {
+TShHandleBase::TShHandleBase()
+{
allocator.push();
SetGlobalPoolAllocator(&allocator);
}
-TShHandleBase::~TShHandleBase() {
+TShHandleBase::~TShHandleBase()
+{
SetGlobalPoolAllocator(NULL);
allocator.popAll();
}
@@ -150,7 +159,8 @@ bool TCompiler::compile(const char* const shaderStrings[],
bool success =
(PaParseStrings(numStrings - firstSource, &shaderStrings[firstSource], NULL, &parseContext) == 0) &&
(parseContext.treeRoot != NULL);
- if (success) {
+ if (success)
+ {
TIntermNode* root = parseContext.treeRoot;
success = intermediate.postProcess(root);
@@ -189,20 +199,31 @@ bool TCompiler::compile(const char* const shaderStrings[],
if (success && (compileOptions & SH_MAP_LONG_VARIABLE_NAMES) && hashFunction == NULL)
mapLongVariableNames(root);
- if (success && shaderType == SH_VERTEX_SHADER && (compileOptions & SH_INIT_GL_POSITION)) {
- InitializeGLPosition initGLPosition;
- root->traverse(&initGLPosition);
+ if (success && shaderType == SH_VERTEX_SHADER && (compileOptions & SH_INIT_GL_POSITION))
+ initializeGLPosition(root);
+
+ if (success && (compileOptions & SH_UNFOLD_SHORT_CIRCUIT))
+ {
+ UnfoldShortCircuitAST unfoldShortCircuit;
+ root->traverse(&unfoldShortCircuit);
+ unfoldShortCircuit.updateTree();
}
- if (success && (compileOptions & SH_VARIABLES)) {
+ if (success && (compileOptions & SH_VARIABLES))
+ {
collectVariables(root);
- if (compileOptions & SH_ENFORCE_PACKING_RESTRICTIONS) {
+ if (compileOptions & SH_ENFORCE_PACKING_RESTRICTIONS)
+ {
success = enforcePackingRestrictions();
- if (!success) {
+ if (!success)
+ {
infoSink.info.prefix(EPrefixError);
infoSink.info << "too many uniforms";
}
}
+ if (success && shaderType == SH_VERTEX_SHADER &&
+ (compileOptions & SH_INIT_VARYINGS_WITHOUT_STATIC_USE))
+ initializeVaryingsWithoutStaticUse(root);
}
if (success && (compileOptions & SH_INTERMEDIATE_TREE))
@@ -251,12 +272,14 @@ bool TCompiler::InitBuiltInSymbolTable(const ShBuiltInResources &resources)
symbolTable.setDefaultPrecision(integer, EbpHigh);
symbolTable.setDefaultPrecision(floatingPoint, EbpHigh);
break;
- default: assert(false && "Language not supported");
+ default:
+ assert(false && "Language not supported");
}
// We set defaults for all the sampler types, even those that are
// only available if an extension exists.
for (int samplerType = EbtGuardSamplerBegin + 1;
- samplerType < EbtGuardSamplerEnd; ++samplerType) {
+ samplerType < EbtGuardSamplerEnd; ++samplerType)
+ {
sampler.type = static_cast<TBasicType>(samplerType);
symbolTable.setDefaultPrecision(sampler, EbpLow);
}
@@ -288,24 +311,25 @@ bool TCompiler::detectCallDepth(TIntermNode* root, TInfoSink& infoSink, bool lim
{
DetectCallDepth detect(infoSink, limitCallStackDepth, maxCallStackDepth);
root->traverse(&detect);
- switch (detect.detectCallDepth()) {
- case DetectCallDepth::kErrorNone:
- return true;
- case DetectCallDepth::kErrorMissingMain:
- infoSink.info.prefix(EPrefixError);
- infoSink.info << "Missing main()";
- return false;
- case DetectCallDepth::kErrorRecursion:
- infoSink.info.prefix(EPrefixError);
- infoSink.info << "Function recursion detected";
- return false;
- case DetectCallDepth::kErrorMaxDepthExceeded:
- infoSink.info.prefix(EPrefixError);
- infoSink.info << "Function call stack too deep";
- return false;
- default:
- UNREACHABLE();
- return false;
+ switch (detect.detectCallDepth())
+ {
+ case DetectCallDepth::kErrorNone:
+ return true;
+ case DetectCallDepth::kErrorMissingMain:
+ infoSink.info.prefix(EPrefixError);
+ infoSink.info << "Missing main()";
+ return false;
+ case DetectCallDepth::kErrorRecursion:
+ infoSink.info.prefix(EPrefixError);
+ infoSink.info << "Function recursion detected";
+ return false;
+ case DetectCallDepth::kErrorMaxDepthExceeded:
+ infoSink.info.prefix(EPrefixError);
+ infoSink.info << "Function call stack too deep";
+ return false;
+ default:
+ UNREACHABLE();
+ return false;
}
}
@@ -315,7 +339,8 @@ void TCompiler::rewriteCSSShader(TIntermNode* root)
root->traverse(&renamer);
}
-bool TCompiler::validateLimitations(TIntermNode* root) {
+bool TCompiler::validateLimitations(TIntermNode* root)
+{
ValidateLimitations validate(shaderType, infoSink.info);
root->traverse(&validate);
return validate.numErrors() == 0;
@@ -323,26 +348,30 @@ bool TCompiler::validateLimitations(TIntermNode* root) {
bool TCompiler::enforceTimingRestrictions(TIntermNode* root, bool outputGraph)
{
- if (shaderSpec != SH_WEBGL_SPEC) {
+ if (shaderSpec != SH_WEBGL_SPEC)
+ {
infoSink.info << "Timing restrictions must be enforced under the WebGL spec.";
return false;
}
- if (shaderType == SH_FRAGMENT_SHADER) {
+ if (shaderType == SH_FRAGMENT_SHADER)
+ {
TDependencyGraph graph(root);
// Output any errors first.
bool success = enforceFragmentShaderTimingRestrictions(graph);
// Then, output the dependency graph.
- if (outputGraph) {
+ if (outputGraph)
+ {
TDependencyGraphOutput output(infoSink.info);
output.outputAllSpanningTrees(graph);
}
return success;
}
- else {
+ else
+ {
return enforceVertexShaderTimingRestrictions(root);
}
}
@@ -362,7 +391,8 @@ bool TCompiler::limitExpressionComplexity(TIntermNode* root)
samplerSymbol->traverse(&graphTraverser);
}
- if (traverser.getMaxDepth() > maxExpressionComplexity) {
+ if (traverser.getMaxDepth() > maxExpressionComplexity)
+ {
infoSink.info << "Expression too complex.";
return false;
}
@@ -395,6 +425,70 @@ bool TCompiler::enforcePackingRestrictions()
return packer.CheckVariablesWithinPackingLimits(maxUniformVectors, uniforms);
}
+void TCompiler::initializeGLPosition(TIntermNode* root)
+{
+ InitializeVariables::InitVariableInfoList variables;
+ InitializeVariables::InitVariableInfo var(
+ "gl_Position", TType(EbtFloat, EbpUndefined, EvqPosition, 4));
+ variables.push_back(var);
+ InitializeVariables initializer(variables);
+ root->traverse(&initializer);
+}
+
+void TCompiler::initializeVaryingsWithoutStaticUse(TIntermNode* root)
+{
+ InitializeVariables::InitVariableInfoList variables;
+ for (size_t ii = 0; ii < varyings.size(); ++ii)
+ {
+ const TVariableInfo& varying = varyings[ii];
+ if (varying.staticUse)
+ continue;
+ unsigned char size = 0;
+ bool matrix = false;
+ switch (varying.type)
+ {
+ case SH_FLOAT:
+ size = 1;
+ break;
+ case SH_FLOAT_VEC2:
+ size = 2;
+ break;
+ case SH_FLOAT_VEC3:
+ size = 3;
+ break;
+ case SH_FLOAT_VEC4:
+ size = 4;
+ break;
+ case SH_FLOAT_MAT2:
+ size = 2;
+ matrix = true;
+ break;
+ case SH_FLOAT_MAT3:
+ size = 3;
+ matrix = true;
+ break;
+ case SH_FLOAT_MAT4:
+ size = 4;
+ matrix = true;
+ break;
+ default:
+ ASSERT(false);
+ }
+ TType type(EbtFloat, EbpUndefined, EvqVaryingOut, size, matrix, varying.isArray);
+ TString name = varying.name.c_str();
+ if (varying.isArray)
+ {
+ type.setArraySize(varying.size);
+ name = name.substr(0, name.find_first_of('['));
+ }
+
+ InitializeVariables::InitVariableInfo var(name, type);
+ variables.push_back(var);
+ }
+ InitializeVariables initializer(variables);
+ root->traverse(&initializer);
+}
+
void TCompiler::mapLongVariableNames(TIntermNode* root)
{
ASSERT(longNameMap);
diff --git a/src/3rdparty/angle/src/compiler/ConstantUnion.h b/src/3rdparty/angle/src/compiler/translator/ConstantUnion.h
index b1e37885f9..b1e37885f9 100644
--- a/src/3rdparty/angle/src/compiler/ConstantUnion.h
+++ b/src/3rdparty/angle/src/compiler/translator/ConstantUnion.h
diff --git a/src/3rdparty/angle/src/compiler/DetectCallDepth.cpp b/src/3rdparty/angle/src/compiler/translator/DetectCallDepth.cpp
index 60df52c715..bfc1d5852f 100644
--- a/src/3rdparty/angle/src/compiler/DetectCallDepth.cpp
+++ b/src/3rdparty/angle/src/compiler/translator/DetectCallDepth.cpp
@@ -4,8 +4,8 @@
// found in the LICENSE file.
//
-#include "compiler/DetectCallDepth.h"
-#include "compiler/InfoSink.h"
+#include "compiler/translator/DetectCallDepth.h"
+#include "compiler/translator/InfoSink.h"
DetectCallDepth::FunctionNode::FunctionNode(const TString& fname)
: name(fname),
diff --git a/src/3rdparty/angle/src/compiler/DetectCallDepth.h b/src/3rdparty/angle/src/compiler/translator/DetectCallDepth.h
index 89e85f88f6..5e7f23d15f 100644
--- a/src/3rdparty/angle/src/compiler/DetectCallDepth.h
+++ b/src/3rdparty/angle/src/compiler/translator/DetectCallDepth.h
@@ -10,8 +10,8 @@
#include "GLSLANG/ShaderLang.h"
#include <limits.h>
-#include "compiler/intermediate.h"
-#include "compiler/VariableInfo.h"
+#include "compiler/translator/intermediate.h"
+#include "compiler/translator/VariableInfo.h"
class TInfoSink;
diff --git a/src/3rdparty/angle/src/compiler/DetectDiscontinuity.cpp b/src/3rdparty/angle/src/compiler/translator/DetectDiscontinuity.cpp
index 7c3b68a0b3..334eb0bfa8 100644
--- a/src/3rdparty/angle/src/compiler/DetectDiscontinuity.cpp
+++ b/src/3rdparty/angle/src/compiler/translator/DetectDiscontinuity.cpp
@@ -8,9 +8,9 @@
// gradients of functions with discontinuities.
//
-#include "compiler/DetectDiscontinuity.h"
+#include "compiler/translator/DetectDiscontinuity.h"
-#include "compiler/ParseHelper.h"
+#include "compiler/translator/ParseContext.h"
namespace sh
{
diff --git a/src/3rdparty/angle/src/compiler/DetectDiscontinuity.h b/src/3rdparty/angle/src/compiler/translator/DetectDiscontinuity.h
index e5520bd5b0..1dd8be9233 100644
--- a/src/3rdparty/angle/src/compiler/DetectDiscontinuity.h
+++ b/src/3rdparty/angle/src/compiler/translator/DetectDiscontinuity.h
@@ -11,7 +11,7 @@
#ifndef COMPILER_DETECTDISCONTINUITY_H_
#define COMPILER_DETECTDISCONTINUITY_H_
-#include "compiler/intermediate.h"
+#include "compiler/translator/intermediate.h"
namespace sh
{
diff --git a/src/3rdparty/angle/src/compiler/Diagnostics.cpp b/src/3rdparty/angle/src/compiler/translator/Diagnostics.cpp
index 8a38c41a65..99506c0849 100644
--- a/src/3rdparty/angle/src/compiler/Diagnostics.cpp
+++ b/src/3rdparty/angle/src/compiler/translator/Diagnostics.cpp
@@ -4,10 +4,10 @@
// found in the LICENSE file.
//
-#include "compiler/Diagnostics.h"
+#include "compiler/translator/Diagnostics.h"
-#include "compiler/debug.h"
-#include "compiler/InfoSink.h"
+#include "compiler/translator/compilerdebug.h"
+#include "compiler/translator/InfoSink.h"
#include "compiler/preprocessor/SourceLocation.h"
TDiagnostics::TDiagnostics(TInfoSink& infoSink) :
@@ -30,11 +30,11 @@ void TDiagnostics::writeInfo(Severity severity,
TPrefixType prefix = EPrefixNone;
switch (severity)
{
- case ERROR:
+ case PP_ERROR:
++mNumErrors;
prefix = EPrefixError;
break;
- case WARNING:
+ case PP_WARNING:
++mNumWarnings;
prefix = EPrefixWarning;
break;
diff --git a/src/3rdparty/angle/src/compiler/Diagnostics.h b/src/3rdparty/angle/src/compiler/translator/Diagnostics.h
index cb71bb1204..cb71bb1204 100644
--- a/src/3rdparty/angle/src/compiler/Diagnostics.h
+++ b/src/3rdparty/angle/src/compiler/translator/Diagnostics.h
diff --git a/src/3rdparty/angle/src/compiler/DirectiveHandler.cpp b/src/3rdparty/angle/src/compiler/translator/DirectiveHandler.cpp
index d1f6ab3af5..662c8ae624 100644
--- a/src/3rdparty/angle/src/compiler/DirectiveHandler.cpp
+++ b/src/3rdparty/angle/src/compiler/translator/DirectiveHandler.cpp
@@ -4,12 +4,12 @@
// found in the LICENSE file.
//
-#include "compiler/DirectiveHandler.h"
+#include "compiler/translator/DirectiveHandler.h"
#include <sstream>
-#include "compiler/debug.h"
-#include "compiler/Diagnostics.h"
+#include "compiler/translator/compilerdebug.h"
+#include "compiler/translator/Diagnostics.h"
static TBehavior getBehavior(const std::string& str)
{
@@ -39,7 +39,7 @@ TDirectiveHandler::~TDirectiveHandler()
void TDirectiveHandler::handleError(const pp::SourceLocation& loc,
const std::string& msg)
{
- mDiagnostics.writeInfo(pp::Diagnostics::ERROR, loc, msg, "", "");
+ mDiagnostics.writeInfo(pp::Diagnostics::PP_ERROR, loc, msg, "", "");
}
void TDirectiveHandler::handlePragma(const pp::SourceLocation& loc,
@@ -73,12 +73,12 @@ void TDirectiveHandler::handlePragma(const pp::SourceLocation& loc,
}
else
{
- mDiagnostics.report(pp::Diagnostics::UNRECOGNIZED_PRAGMA, loc, name);
+ mDiagnostics.report(pp::Diagnostics::PP_UNRECOGNIZED_PRAGMA, loc, name);
return;
}
if (invalidValue)
- mDiagnostics.writeInfo(pp::Diagnostics::ERROR, loc,
+ mDiagnostics.writeInfo(pp::Diagnostics::PP_ERROR, loc,
"invalid pragma value", value,
"'on' or 'off' expected");
}
@@ -92,7 +92,7 @@ void TDirectiveHandler::handleExtension(const pp::SourceLocation& loc,
TBehavior behaviorVal = getBehavior(behavior);
if (behaviorVal == EBhUndefined)
{
- mDiagnostics.writeInfo(pp::Diagnostics::ERROR, loc,
+ mDiagnostics.writeInfo(pp::Diagnostics::PP_ERROR, loc,
"behavior", name, "invalid");
return;
}
@@ -101,13 +101,13 @@ void TDirectiveHandler::handleExtension(const pp::SourceLocation& loc,
{
if (behaviorVal == EBhRequire)
{
- mDiagnostics.writeInfo(pp::Diagnostics::ERROR, loc,
+ mDiagnostics.writeInfo(pp::Diagnostics::PP_ERROR, loc,
"extension", name,
"cannot have 'require' behavior");
}
else if (behaviorVal == EBhEnable)
{
- mDiagnostics.writeInfo(pp::Diagnostics::ERROR, loc,
+ mDiagnostics.writeInfo(pp::Diagnostics::PP_ERROR, loc,
"extension", name,
"cannot have 'enable' behavior");
}
@@ -127,15 +127,15 @@ void TDirectiveHandler::handleExtension(const pp::SourceLocation& loc,
return;
}
- pp::Diagnostics::Severity severity = pp::Diagnostics::ERROR;
+ pp::Diagnostics::Severity severity = pp::Diagnostics::PP_ERROR;
switch (behaviorVal) {
case EBhRequire:
- severity = pp::Diagnostics::ERROR;
+ severity = pp::Diagnostics::PP_ERROR;
break;
case EBhEnable:
case EBhWarn:
case EBhDisable:
- severity = pp::Diagnostics::WARNING;
+ severity = pp::Diagnostics::PP_WARNING;
break;
default:
UNREACHABLE();
@@ -155,7 +155,7 @@ void TDirectiveHandler::handleVersion(const pp::SourceLocation& loc,
std::stringstream stream;
stream << version;
std::string str = stream.str();
- mDiagnostics.writeInfo(pp::Diagnostics::ERROR, loc,
+ mDiagnostics.writeInfo(pp::Diagnostics::PP_ERROR, loc,
"version number", str, "not supported");
}
}
diff --git a/src/3rdparty/angle/src/compiler/DirectiveHandler.h b/src/3rdparty/angle/src/compiler/translator/DirectiveHandler.h
index 95ca59d6fe..eb5f055494 100644
--- a/src/3rdparty/angle/src/compiler/DirectiveHandler.h
+++ b/src/3rdparty/angle/src/compiler/translator/DirectiveHandler.h
@@ -7,8 +7,8 @@
#ifndef COMPILER_DIRECTIVE_HANDLER_H_
#define COMPILER_DIRECTIVE_HANDLER_H_
-#include "compiler/ExtensionBehavior.h"
-#include "compiler/Pragma.h"
+#include "compiler/translator/ExtensionBehavior.h"
+#include "compiler/translator/Pragma.h"
#include "compiler/preprocessor/DirectiveHandlerBase.h"
class TDiagnostics;
diff --git a/src/3rdparty/angle/src/compiler/ExtensionBehavior.h b/src/3rdparty/angle/src/compiler/translator/ExtensionBehavior.h
index 5c1595fb21..5c1595fb21 100644
--- a/src/3rdparty/angle/src/compiler/ExtensionBehavior.h
+++ b/src/3rdparty/angle/src/compiler/translator/ExtensionBehavior.h
diff --git a/src/3rdparty/angle/src/compiler/ForLoopUnroll.cpp b/src/3rdparty/angle/src/compiler/translator/ForLoopUnroll.cpp
index 27a13eabab..89e6f1a62b 100644
--- a/src/3rdparty/angle/src/compiler/ForLoopUnroll.cpp
+++ b/src/3rdparty/angle/src/compiler/translator/ForLoopUnroll.cpp
@@ -4,7 +4,7 @@
// found in the LICENSE file.
//
-#include "compiler/ForLoopUnroll.h"
+#include "compiler/translator/ForLoopUnroll.h"
namespace {
diff --git a/src/3rdparty/angle/src/compiler/ForLoopUnroll.h b/src/3rdparty/angle/src/compiler/translator/ForLoopUnroll.h
index e800e25b1f..afd70d1fd2 100644
--- a/src/3rdparty/angle/src/compiler/ForLoopUnroll.h
+++ b/src/3rdparty/angle/src/compiler/translator/ForLoopUnroll.h
@@ -4,7 +4,10 @@
// found in the LICENSE file.
//
-#include "compiler/intermediate.h"
+#ifndef COMPILER_FORLOOPUNROLL_H_
+#define COMPILER_FORLOOPUNROLL_H_
+
+#include "compiler/translator/intermediate.h"
struct TLoopIndexInfo {
int id;
@@ -46,3 +49,4 @@ private:
TVector<TLoopIndexInfo> mLoopIndexStack;
};
+#endif
diff --git a/src/3rdparty/angle/src/compiler/HashNames.h b/src/3rdparty/angle/src/compiler/translator/HashNames.h
index d2141e2d85..751265b759 100644
--- a/src/3rdparty/angle/src/compiler/HashNames.h
+++ b/src/3rdparty/angle/src/compiler/translator/HashNames.h
@@ -9,7 +9,7 @@
#include <map>
-#include "compiler/intermediate.h"
+#include "compiler/translator/intermediate.h"
#include "GLSLANG/ShaderLang.h"
#define HASHED_NAME_PREFIX "webgl_"
diff --git a/src/3rdparty/angle/src/compiler/InfoSink.cpp b/src/3rdparty/angle/src/compiler/translator/InfoSink.cpp
index d20a6c0175..cd59658ff7 100644
--- a/src/3rdparty/angle/src/compiler/InfoSink.cpp
+++ b/src/3rdparty/angle/src/compiler/translator/InfoSink.cpp
@@ -4,7 +4,7 @@
// found in the LICENSE file.
//
-#include "compiler/InfoSink.h"
+#include "compiler/translator/InfoSink.h"
void TInfoSinkBase::prefix(TPrefixType p) {
switch(p) {
diff --git a/src/3rdparty/angle/src/compiler/InfoSink.h b/src/3rdparty/angle/src/compiler/translator/InfoSink.h
index 6888838142..698a8b454b 100644
--- a/src/3rdparty/angle/src/compiler/InfoSink.h
+++ b/src/3rdparty/angle/src/compiler/translator/InfoSink.h
@@ -8,7 +8,8 @@
#define _INFOSINK_INCLUDED_
#include <math.h>
-#include "compiler/Common.h"
+#include <stdlib.h>
+#include "compiler/translator/Common.h"
// Returns the fractional part of the given floating-point number.
inline float fractionalPart(float f) {
diff --git a/src/3rdparty/angle/src/compiler/Initialize.cpp b/src/3rdparty/angle/src/compiler/translator/Initialize.cpp
index 236383d874..db728b2129 100644
--- a/src/3rdparty/angle/src/compiler/Initialize.cpp
+++ b/src/3rdparty/angle/src/compiler/translator/Initialize.cpp
@@ -10,9 +10,9 @@
// built-in functions and operators.
//
-#include "compiler/Initialize.h"
+#include "compiler/translator/Initialize.h"
-#include "compiler/intermediate.h"
+#include "compiler/translator/intermediate.h"
void InsertBuiltInFunctions(ShShaderType type, ShShaderSpec spec, const ShBuiltInResources &resources, TSymbolTable &symbolTable)
{
@@ -363,7 +363,7 @@ void InsertBuiltInFunctions(ShShaderType type, ShShaderSpec spec, const ShBuiltI
symbolTable.insertBuiltIn(float2, "dFdx", float2);
symbolTable.insertBuiltIn(float3, "dFdx", float3);
symbolTable.insertBuiltIn(float4, "dFdx", float4);
-
+
symbolTable.insertBuiltIn(float1, "dFdy", float1);
symbolTable.insertBuiltIn(float2, "dFdy", float2);
symbolTable.insertBuiltIn(float3, "dFdy", float3);
diff --git a/src/3rdparty/angle/src/compiler/Initialize.h b/src/3rdparty/angle/src/compiler/translator/Initialize.h
index 4aa13466ac..b5642869aa 100644
--- a/src/3rdparty/angle/src/compiler/Initialize.h
+++ b/src/3rdparty/angle/src/compiler/translator/Initialize.h
@@ -7,9 +7,9 @@
#ifndef _INITIALIZE_INCLUDED_
#define _INITIALIZE_INCLUDED_
-#include "compiler/Common.h"
-#include "compiler/ShHandle.h"
-#include "compiler/SymbolTable.h"
+#include "compiler/translator/Common.h"
+#include "compiler/translator/ShHandle.h"
+#include "compiler/translator/SymbolTable.h"
void InsertBuiltInFunctions(ShShaderType type, ShShaderSpec spec, const ShBuiltInResources &resources, TSymbolTable &table);
diff --git a/src/3rdparty/angle/src/compiler/InitializeDll.cpp b/src/3rdparty/angle/src/compiler/translator/InitializeDll.cpp
index 6c7f27fced..43f81784d0 100644
--- a/src/3rdparty/angle/src/compiler/InitializeDll.cpp
+++ b/src/3rdparty/angle/src/compiler/translator/InitializeDll.cpp
@@ -4,11 +4,11 @@
// found in the LICENSE file.
//
-#include "compiler/InitializeDll.h"
+#include "compiler/translator/InitializeDll.h"
-#include "compiler/InitializeGlobals.h"
-#include "compiler/InitializeParseContext.h"
-#include "compiler/osinclude.h"
+#include "compiler/translator/InitializeGlobals.h"
+#include "compiler/translator/InitializeParseContext.h"
+#include "compiler/translator/osinclude.h"
bool InitProcess()
{
diff --git a/src/3rdparty/angle/src/compiler/InitializeDll.h b/src/3rdparty/angle/src/compiler/translator/InitializeDll.h
index 43070cc3ff..43070cc3ff 100644
--- a/src/3rdparty/angle/src/compiler/InitializeDll.h
+++ b/src/3rdparty/angle/src/compiler/translator/InitializeDll.h
diff --git a/src/3rdparty/angle/src/compiler/InitializeGlobals.h b/src/3rdparty/angle/src/compiler/translator/InitializeGlobals.h
index 0715941424..0715941424 100644
--- a/src/3rdparty/angle/src/compiler/InitializeGlobals.h
+++ b/src/3rdparty/angle/src/compiler/translator/InitializeGlobals.h
diff --git a/src/3rdparty/angle/src/compiler/InitializeParseContext.cpp b/src/3rdparty/angle/src/compiler/translator/InitializeParseContext.cpp
index dfab027330..b4defae569 100644
--- a/src/3rdparty/angle/src/compiler/InitializeParseContext.cpp
+++ b/src/3rdparty/angle/src/compiler/translator/InitializeParseContext.cpp
@@ -4,9 +4,9 @@
// found in the LICENSE file.
//
-#include "compiler/InitializeParseContext.h"
+#include "compiler/translator/InitializeParseContext.h"
-#include "compiler/osinclude.h"
+#include "compiler/translator/osinclude.h"
OS_TLSIndex GlobalParseContextIndex = OS_INVALID_TLS_INDEX;
diff --git a/src/3rdparty/angle/src/compiler/InitializeParseContext.h b/src/3rdparty/angle/src/compiler/translator/InitializeParseContext.h
index bffbab87d0..bffbab87d0 100644
--- a/src/3rdparty/angle/src/compiler/InitializeParseContext.h
+++ b/src/3rdparty/angle/src/compiler/translator/InitializeParseContext.h
diff --git a/src/3rdparty/angle/src/compiler/translator/InitializeVariables.cpp b/src/3rdparty/angle/src/compiler/translator/InitializeVariables.cpp
new file mode 100644
index 0000000000..115c561c77
--- /dev/null
+++ b/src/3rdparty/angle/src/compiler/translator/InitializeVariables.cpp
@@ -0,0 +1,116 @@
+//
+// Copyright (c) 2002-2013 The ANGLE Project Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+//
+
+#include "compiler/translator/InitializeVariables.h"
+#include "compiler/translator/compilerdebug.h"
+
+namespace
+{
+
+TIntermConstantUnion* constructFloatConstUnionNode(const TType& type)
+{
+ TType myType = type;
+ unsigned char size = myType.getNominalSize();
+ if (myType.isMatrix())
+ size *= size;
+ ConstantUnion *u = new ConstantUnion[size];
+ for (int ii = 0; ii < size; ++ii)
+ u[ii].setFConst(0.0f);
+
+ myType.clearArrayness();
+ myType.setQualifier(EvqConst);
+ TIntermConstantUnion *node = new TIntermConstantUnion(u, myType);
+ return node;
+}
+
+TIntermConstantUnion* constructIndexNode(int index)
+{
+ ConstantUnion *u = new ConstantUnion[1];
+ u[0].setIConst(index);
+
+ TType type(EbtInt, EbpUndefined, EvqConst, 1);
+ TIntermConstantUnion *node = new TIntermConstantUnion(u, type);
+ return node;
+}
+
+} // namespace anonymous
+
+bool InitializeVariables::visitAggregate(Visit visit, TIntermAggregate* node)
+{
+ bool visitChildren = !mCodeInserted;
+ switch (node->getOp())
+ {
+ case EOpSequence:
+ break;
+ case EOpFunction:
+ {
+ // Function definition.
+ ASSERT(visit == PreVisit);
+ if (node->getName() == "main(")
+ {
+ TIntermSequence &sequence = node->getSequence();
+ ASSERT((sequence.size() == 1) || (sequence.size() == 2));
+ TIntermAggregate *body = NULL;
+ if (sequence.size() == 1)
+ {
+ body = new TIntermAggregate(EOpSequence);
+ sequence.push_back(body);
+ }
+ else
+ {
+ body = sequence[1]->getAsAggregate();
+ }
+ ASSERT(body);
+ insertInitCode(body->getSequence());
+ mCodeInserted = true;
+ }
+ break;
+ }
+ default:
+ visitChildren = false;
+ break;
+ }
+ return visitChildren;
+}
+
+void InitializeVariables::insertInitCode(TIntermSequence& sequence)
+{
+ for (size_t ii = 0; ii < mVariables.size(); ++ii)
+ {
+ const InitVariableInfo& varInfo = mVariables[ii];
+
+ if (varInfo.type.isArray())
+ {
+ for (int index = varInfo.type.getArraySize() - 1; index >= 0; --index)
+ {
+ TIntermBinary *assign = new TIntermBinary(EOpAssign);
+ sequence.insert(sequence.begin(), assign);
+
+ TIntermBinary *indexDirect = new TIntermBinary(EOpIndexDirect);
+ TIntermSymbol *symbol = new TIntermSymbol(0, varInfo.name, varInfo.type);
+ indexDirect->setLeft(symbol);
+ TIntermConstantUnion *indexNode = constructIndexNode(index);
+ indexDirect->setRight(indexNode);
+
+ assign->setLeft(indexDirect);
+
+ TIntermConstantUnion *zeroConst = constructFloatConstUnionNode(varInfo.type);
+ assign->setRight(zeroConst);
+ }
+ }
+ else
+ {
+ TIntermBinary *assign = new TIntermBinary(EOpAssign);
+ sequence.insert(sequence.begin(), assign);
+ TIntermSymbol *symbol = new TIntermSymbol(0, varInfo.name, varInfo.type);
+ assign->setLeft(symbol);
+ TIntermConstantUnion *zeroConst = constructFloatConstUnionNode(varInfo.type);
+ assign->setRight(zeroConst);
+ }
+
+ }
+}
+
diff --git a/src/3rdparty/angle/src/compiler/translator/InitializeVariables.h b/src/3rdparty/angle/src/compiler/translator/InitializeVariables.h
new file mode 100644
index 0000000000..1cd6d7e1b5
--- /dev/null
+++ b/src/3rdparty/angle/src/compiler/translator/InitializeVariables.h
@@ -0,0 +1,50 @@
+//
+// Copyright (c) 2002-2013 The ANGLE Project Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+//
+
+#ifndef COMPILER_INITIALIZE_VARIABLES_H_
+#define COMPILER_INITIALIZE_VARIABLES_H_
+
+#include "compiler/translator/intermediate.h"
+
+class InitializeVariables : public TIntermTraverser
+{
+ public:
+ struct InitVariableInfo
+ {
+ TString name;
+ TType type;
+
+ InitVariableInfo(const TString& _name, const TType& _type)
+ : name(_name),
+ type(_type)
+ {
+ }
+ };
+ typedef TVector<InitVariableInfo> InitVariableInfoList;
+
+ InitializeVariables(const InitVariableInfoList& vars)
+ : mCodeInserted(false),
+ mVariables(vars)
+ {
+ }
+
+ protected:
+ virtual bool visitBinary(Visit visit, TIntermBinary* node) { return false; }
+ virtual bool visitUnary(Visit visit, TIntermUnary* node) { return false; }
+ virtual bool visitSelection(Visit visit, TIntermSelection* node) { return false; }
+ virtual bool visitLoop(Visit visit, TIntermLoop* node) { return false; }
+ virtual bool visitBranch(Visit visit, TIntermBranch* node) { return false; }
+
+ virtual bool visitAggregate(Visit visit, TIntermAggregate* node);
+
+ private:
+ void insertInitCode(TIntermSequence& sequence);
+
+ InitVariableInfoList mVariables;
+ bool mCodeInserted;
+};
+
+#endif // COMPILER_INITIALIZE_VARIABLES_H_
diff --git a/src/3rdparty/angle/src/compiler/translator/IntermTraverse.cpp b/src/3rdparty/angle/src/compiler/translator/IntermTraverse.cpp
new file mode 100644
index 0000000000..554b83409a
--- /dev/null
+++ b/src/3rdparty/angle/src/compiler/translator/IntermTraverse.cpp
@@ -0,0 +1,259 @@
+//
+// Copyright (c) 2002-2010 The ANGLE Project Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+//
+
+#include "compiler/translator/intermediate.h"
+
+//
+// Traverse the intermediate representation tree, and
+// call a node type specific function for each node.
+// Done recursively through the member function Traverse().
+// Node types can be skipped if their function to call is 0,
+// but their subtree will still be traversed.
+// Nodes with children can have their whole subtree skipped
+// if preVisit is turned on and the type specific function
+// returns false.
+//
+// preVisit, postVisit, and rightToLeft control what order
+// nodes are visited in.
+//
+
+//
+// Traversal functions for terminals are straighforward....
+//
+void TIntermSymbol::traverse(TIntermTraverser *it)
+{
+ it->visitSymbol(this);
+}
+
+void TIntermConstantUnion::traverse(TIntermTraverser *it)
+{
+ it->visitConstantUnion(this);
+}
+
+//
+// Traverse a binary node.
+//
+void TIntermBinary::traverse(TIntermTraverser *it)
+{
+ bool visit = true;
+
+ //
+ // visit the node before children if pre-visiting.
+ //
+ if (it->preVisit)
+ visit = it->visitBinary(PreVisit, this);
+
+ //
+ // Visit the children, in the right order.
+ //
+ if (visit)
+ {
+ it->incrementDepth(this);
+
+ if (it->rightToLeft)
+ {
+ if (right)
+ right->traverse(it);
+
+ if (it->inVisit)
+ visit = it->visitBinary(InVisit, this);
+
+ if (visit && left)
+ left->traverse(it);
+ }
+ else
+ {
+ if (left)
+ left->traverse(it);
+
+ if (it->inVisit)
+ visit = it->visitBinary(InVisit, this);
+
+ if (visit && right)
+ right->traverse(it);
+ }
+
+ it->decrementDepth();
+ }
+
+ //
+ // Visit the node after the children, if requested and the traversal
+ // hasn't been cancelled yet.
+ //
+ if (visit && it->postVisit)
+ it->visitBinary(PostVisit, this);
+}
+
+//
+// Traverse a unary node. Same comments in binary node apply here.
+//
+void TIntermUnary::traverse(TIntermTraverser *it)
+{
+ bool visit = true;
+
+ if (it->preVisit)
+ visit = it->visitUnary(PreVisit, this);
+
+ if (visit) {
+ it->incrementDepth(this);
+ operand->traverse(it);
+ it->decrementDepth();
+ }
+
+ if (visit && it->postVisit)
+ it->visitUnary(PostVisit, this);
+}
+
+//
+// Traverse an aggregate node. Same comments in binary node apply here.
+//
+void TIntermAggregate::traverse(TIntermTraverser *it)
+{
+ bool visit = true;
+
+ if (it->preVisit)
+ visit = it->visitAggregate(PreVisit, this);
+
+ if (visit)
+ {
+ it->incrementDepth(this);
+
+ if (it->rightToLeft)
+ {
+ for (TIntermSequence::reverse_iterator sit = sequence.rbegin(); sit != sequence.rend(); sit++)
+ {
+ (*sit)->traverse(it);
+
+ if (visit && it->inVisit)
+ {
+ if (*sit != sequence.front())
+ visit = it->visitAggregate(InVisit, this);
+ }
+ }
+ }
+ else
+ {
+ for (TIntermSequence::iterator sit = sequence.begin(); sit != sequence.end(); sit++)
+ {
+ (*sit)->traverse(it);
+
+ if (visit && it->inVisit)
+ {
+ if (*sit != sequence.back())
+ visit = it->visitAggregate(InVisit, this);
+ }
+ }
+ }
+
+ it->decrementDepth();
+ }
+
+ if (visit && it->postVisit)
+ it->visitAggregate(PostVisit, this);
+}
+
+//
+// Traverse a selection node. Same comments in binary node apply here.
+//
+void TIntermSelection::traverse(TIntermTraverser *it)
+{
+ bool visit = true;
+
+ if (it->preVisit)
+ visit = it->visitSelection(PreVisit, this);
+
+ if (visit) {
+ it->incrementDepth(this);
+ if (it->rightToLeft) {
+ if (falseBlock)
+ falseBlock->traverse(it);
+ if (trueBlock)
+ trueBlock->traverse(it);
+ condition->traverse(it);
+ } else {
+ condition->traverse(it);
+ if (trueBlock)
+ trueBlock->traverse(it);
+ if (falseBlock)
+ falseBlock->traverse(it);
+ }
+ it->decrementDepth();
+ }
+
+ if (visit && it->postVisit)
+ it->visitSelection(PostVisit, this);
+}
+
+//
+// Traverse a loop node. Same comments in binary node apply here.
+//
+void TIntermLoop::traverse(TIntermTraverser *it)
+{
+ bool visit = true;
+
+ if (it->preVisit)
+ visit = it->visitLoop(PreVisit, this);
+
+ if (visit)
+ {
+ it->incrementDepth(this);
+
+ if (it->rightToLeft)
+ {
+ if (expr)
+ expr->traverse(it);
+
+ if (body)
+ body->traverse(it);
+
+ if (cond)
+ cond->traverse(it);
+
+ if (init)
+ init->traverse(it);
+ }
+ else
+ {
+ if (init)
+ init->traverse(it);
+
+ if (cond)
+ cond->traverse(it);
+
+ if (body)
+ body->traverse(it);
+
+ if (expr)
+ expr->traverse(it);
+ }
+
+ it->decrementDepth();
+ }
+
+ if (visit && it->postVisit)
+ it->visitLoop(PostVisit, this);
+}
+
+//
+// Traverse a branch node. Same comments in binary node apply here.
+//
+void TIntermBranch::traverse(TIntermTraverser *it)
+{
+ bool visit = true;
+
+ if (it->preVisit)
+ visit = it->visitBranch(PreVisit, this);
+
+ if (visit && expression) {
+ it->incrementDepth(this);
+ expression->traverse(it);
+ it->decrementDepth();
+ }
+
+ if (visit && it->postVisit)
+ it->visitBranch(PostVisit, this);
+}
+
diff --git a/src/3rdparty/angle/src/compiler/Intermediate.cpp b/src/3rdparty/angle/src/compiler/translator/Intermediate.cpp
index 3b6622185d..777cab5458 100644
--- a/src/3rdparty/angle/src/compiler/Intermediate.cpp
+++ b/src/3rdparty/angle/src/compiler/translator/Intermediate.cpp
@@ -12,18 +12,20 @@
#include <limits.h>
#include <algorithm>
-#include "compiler/HashNames.h"
-#include "compiler/localintermediate.h"
-#include "compiler/QualifierAlive.h"
-#include "compiler/RemoveTree.h"
+#include "compiler/translator/HashNames.h"
+#include "compiler/translator/localintermediate.h"
+#include "compiler/translator/QualifierAlive.h"
+#include "compiler/translator/RemoveTree.h"
bool CompareStructure(const TType& leftNodeType, ConstantUnion* rightUnionArray, ConstantUnion* leftUnionArray);
-static TPrecision GetHigherPrecision( TPrecision left, TPrecision right ){
+static TPrecision GetHigherPrecision(TPrecision left, TPrecision right)
+{
return left > right ? left : right;
}
-const char* getOperatorString(TOperator op) {
+const char* getOperatorString(TOperator op)
+{
switch (op) {
case EOpInitialize: return "=";
case EOpAssign: return "=";
@@ -742,12 +744,67 @@ void TIntermediate::remove(TIntermNode* root)
//
////////////////////////////////////////////////////////////////
+#define REPLACE_IF_IS(node, type, original, replacement) \
+ if (node == original) { \
+ node = static_cast<type *>(replacement); \
+ return true; \
+ }
+
+bool TIntermLoop::replaceChildNode(
+ TIntermNode *original, TIntermNode *replacement)
+{
+ REPLACE_IF_IS(init, TIntermNode, original, replacement);
+ REPLACE_IF_IS(cond, TIntermTyped, original, replacement);
+ REPLACE_IF_IS(expr, TIntermTyped, original, replacement);
+ REPLACE_IF_IS(body, TIntermNode, original, replacement);
+ return false;
+}
+
+bool TIntermBranch::replaceChildNode(
+ TIntermNode *original, TIntermNode *replacement)
+{
+ REPLACE_IF_IS(expression, TIntermTyped, original, replacement);
+ return false;
+}
+
+bool TIntermBinary::replaceChildNode(
+ TIntermNode *original, TIntermNode *replacement)
+{
+ REPLACE_IF_IS(left, TIntermTyped, original, replacement);
+ REPLACE_IF_IS(right, TIntermTyped, original, replacement);
+ return false;
+}
+
+bool TIntermUnary::replaceChildNode(
+ TIntermNode *original, TIntermNode *replacement)
+{
+ REPLACE_IF_IS(operand, TIntermTyped, original, replacement);
+ return false;
+}
+
+bool TIntermAggregate::replaceChildNode(
+ TIntermNode *original, TIntermNode *replacement)
+{
+ for (size_t ii = 0; ii < sequence.size(); ++ii)
+ {
+ REPLACE_IF_IS(sequence[ii], TIntermNode, original, replacement);
+ }
+ return false;
+}
+
+bool TIntermSelection::replaceChildNode(
+ TIntermNode *original, TIntermNode *replacement)
+{
+ REPLACE_IF_IS(condition, TIntermTyped, original, replacement);
+ REPLACE_IF_IS(trueBlock, TIntermNode, original, replacement);
+ REPLACE_IF_IS(falseBlock, TIntermNode, original, replacement);
+ return false;
+}
+
//
// Say whether or not an operation node changes the value of a variable.
//
-// Returns true if state is modified.
-//
-bool TIntermOperator::modifiesState() const
+bool TIntermOperator::isAssignment() const
{
switch (op) {
case EOpPostIncrement:
@@ -796,6 +853,7 @@ bool TIntermOperator::isConstructor() const
return false;
}
}
+
//
// Make sure the type of a unary operator is appropriate for its
// combination of operation and operand type.
diff --git a/src/3rdparty/angle/src/compiler/MMap.h b/src/3rdparty/angle/src/compiler/translator/MMap.h
index a308671514..a308671514 100644
--- a/src/3rdparty/angle/src/compiler/MMap.h
+++ b/src/3rdparty/angle/src/compiler/translator/MMap.h
diff --git a/src/3rdparty/angle/src/compiler/MapLongVariableNames.cpp b/src/3rdparty/angle/src/compiler/translator/MapLongVariableNames.cpp
index a41d20f4e8..ef629c26b1 100644
--- a/src/3rdparty/angle/src/compiler/MapLongVariableNames.cpp
+++ b/src/3rdparty/angle/src/compiler/translator/MapLongVariableNames.cpp
@@ -4,7 +4,7 @@
// found in the LICENSE file.
//
-#include "compiler/MapLongVariableNames.h"
+#include "compiler/translator/MapLongVariableNames.h"
namespace {
@@ -102,13 +102,6 @@ void MapLongVariableNames::visitSymbol(TIntermSymbol* symbol)
}
}
-bool MapLongVariableNames::visitLoop(Visit, TIntermLoop* node)
-{
- if (node->getInit())
- node->getInit()->traverse(this);
- return true;
-}
-
TString MapLongVariableNames::mapGlobalLongName(const TString& name)
{
ASSERT(mGlobalMap);
diff --git a/src/3rdparty/angle/src/compiler/MapLongVariableNames.h b/src/3rdparty/angle/src/compiler/translator/MapLongVariableNames.h
index d6352acb4b..3b085a3687 100644
--- a/src/3rdparty/angle/src/compiler/MapLongVariableNames.h
+++ b/src/3rdparty/angle/src/compiler/translator/MapLongVariableNames.h
@@ -9,8 +9,8 @@
#include "GLSLANG/ShaderLang.h"
-#include "compiler/intermediate.h"
-#include "compiler/VariableInfo.h"
+#include "compiler/translator/intermediate.h"
+#include "compiler/translator/VariableInfo.h"
// This size does not include '\0' in the end.
#define MAX_SHORTENED_IDENTIFIER_SIZE 32
@@ -48,7 +48,6 @@ public:
MapLongVariableNames(LongNameMap* globalMap);
virtual void visitSymbol(TIntermSymbol*);
- virtual bool visitLoop(Visit, TIntermLoop*);
private:
TString mapGlobalLongName(const TString& name);
diff --git a/src/3rdparty/angle/src/compiler/translator/NodeSearch.h b/src/3rdparty/angle/src/compiler/translator/NodeSearch.h
new file mode 100644
index 0000000000..b58c7ec689
--- /dev/null
+++ b/src/3rdparty/angle/src/compiler/translator/NodeSearch.h
@@ -0,0 +1,80 @@
+//
+// Copyright (c) 2002-2013 The ANGLE Project Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+//
+// NodeSearch.h: Utilities for searching translator node graphs
+//
+
+#ifndef TRANSLATOR_NODESEARCH_H_
+#define TRANSLATOR_NODESEARCH_H_
+
+#include "compiler/translator/intermediate.h"
+
+namespace sh
+{
+
+template <class Parent>
+class NodeSearchTraverser : public TIntermTraverser
+{
+ public:
+ NodeSearchTraverser()
+ : mFound(false)
+ {}
+
+ bool found() const { return mFound; }
+
+ static bool search(TIntermNode *node)
+ {
+ Parent searchTraverser;
+ node->traverse(&searchTraverser);
+ return searchTraverser.found();
+ }
+
+ protected:
+ bool mFound;
+};
+
+class FindDiscard : public NodeSearchTraverser<FindDiscard>
+{
+ public:
+ virtual bool visitBranch(Visit visit, TIntermBranch *node)
+ {
+ switch (node->getFlowOp())
+ {
+ case EOpKill:
+ mFound = true;
+ break;
+
+ default: break;
+ }
+
+ return !mFound;
+ }
+};
+
+class FindSideEffectRewriting : public NodeSearchTraverser<FindSideEffectRewriting>
+{
+ public:
+ virtual bool visitBinary(Visit visit, TIntermBinary *node)
+ {
+ switch (node->getOp())
+ {
+ case EOpLogicalOr:
+ case EOpLogicalAnd:
+ if (node->getRight()->hasSideEffects())
+ {
+ mFound = true;
+ }
+ break;
+
+ default: break;
+ }
+
+ return !mFound;
+ }
+};
+
+}
+
+#endif // TRANSLATOR_NODESEARCH_H_
diff --git a/src/3rdparty/angle/src/compiler/OutputESSL.cpp b/src/3rdparty/angle/src/compiler/translator/OutputESSL.cpp
index c2048f1cec..8367412462 100644
--- a/src/3rdparty/angle/src/compiler/OutputESSL.cpp
+++ b/src/3rdparty/angle/src/compiler/translator/OutputESSL.cpp
@@ -4,7 +4,7 @@
// found in the LICENSE file.
//
-#include "compiler/OutputESSL.h"
+#include "compiler/translator/OutputESSL.h"
TOutputESSL::TOutputESSL(TInfoSinkBase& objSink,
ShArrayIndexClampingStrategy clampingStrategy,
diff --git a/src/3rdparty/angle/src/compiler/OutputESSL.h b/src/3rdparty/angle/src/compiler/translator/OutputESSL.h
index 05db96e497..2f02979a05 100644
--- a/src/3rdparty/angle/src/compiler/OutputESSL.h
+++ b/src/3rdparty/angle/src/compiler/translator/OutputESSL.h
@@ -7,7 +7,7 @@
#ifndef CROSSCOMPILERGLSL_OUTPUTESSL_H_
#define CROSSCOMPILERGLSL_OUTPUTESSL_H_
-#include "compiler/OutputGLSLBase.h"
+#include "compiler/translator/OutputGLSLBase.h"
class TOutputESSL : public TOutputGLSLBase
{
diff --git a/src/3rdparty/angle/src/compiler/OutputGLSL.cpp b/src/3rdparty/angle/src/compiler/translator/OutputGLSL.cpp
index 10a451c0d7..5589560682 100644
--- a/src/3rdparty/angle/src/compiler/OutputGLSL.cpp
+++ b/src/3rdparty/angle/src/compiler/translator/OutputGLSL.cpp
@@ -4,7 +4,7 @@
// found in the LICENSE file.
//
-#include "compiler/OutputGLSL.h"
+#include "compiler/translator/OutputGLSL.h"
TOutputGLSL::TOutputGLSL(TInfoSinkBase& objSink,
ShArrayIndexClampingStrategy clampingStrategy,
diff --git a/src/3rdparty/angle/src/compiler/OutputGLSL.h b/src/3rdparty/angle/src/compiler/translator/OutputGLSL.h
index fa68ac8103..e1f114d347 100644
--- a/src/3rdparty/angle/src/compiler/OutputGLSL.h
+++ b/src/3rdparty/angle/src/compiler/translator/OutputGLSL.h
@@ -7,7 +7,7 @@
#ifndef CROSSCOMPILERGLSL_OUTPUTGLSL_H_
#define CROSSCOMPILERGLSL_OUTPUTGLSL_H_
-#include "compiler/OutputGLSLBase.h"
+#include "compiler/translator/OutputGLSLBase.h"
class TOutputGLSL : public TOutputGLSLBase
{
diff --git a/src/3rdparty/angle/src/compiler/OutputGLSLBase.cpp b/src/3rdparty/angle/src/compiler/translator/OutputGLSLBase.cpp
index d677c75633..f2f0a3d6be 100644
--- a/src/3rdparty/angle/src/compiler/OutputGLSLBase.cpp
+++ b/src/3rdparty/angle/src/compiler/translator/OutputGLSLBase.cpp
@@ -4,8 +4,8 @@
// found in the LICENSE file.
//
-#include "compiler/OutputGLSLBase.h"
-#include "compiler/debug.h"
+#include "compiler/translator/OutputGLSLBase.h"
+#include "compiler/translator/compilerdebug.h"
#include <cfloat>
@@ -435,7 +435,7 @@ bool TOutputGLSLBase::visitSelection(Visit visit, TIntermSelection* node)
node->getCondition()->traverse(this);
out << ")\n";
- incrementDepth();
+ incrementDepth(node);
visitCodeBlock(node->getTrueBlock());
if (node->getFalseBlock())
@@ -460,7 +460,7 @@ bool TOutputGLSLBase::visitAggregate(Visit visit, TIntermAggregate* node)
// Scope the sequences except when at the global scope.
if (depth > 0) out << "{\n";
- incrementDepth();
+ incrementDepth(node);
const TIntermSequence& sequence = node->getSequence();
for (TIntermSequence::const_iterator iter = sequence.begin();
iter != sequence.end(); ++iter)
@@ -498,7 +498,7 @@ bool TOutputGLSLBase::visitAggregate(Visit visit, TIntermAggregate* node)
writeVariableType(node->getType());
out << " " << hashFunctionName(node->getName());
- incrementDepth();
+ incrementDepth(node);
// Function definition node contains one or two children nodes
// representing function parameters and function body. The latter
// is not present in case of empty function bodies.
@@ -638,7 +638,7 @@ bool TOutputGLSLBase::visitLoop(Visit visit, TIntermLoop* node)
{
TInfoSinkBase& out = objSink();
- incrementDepth();
+ incrementDepth(node);
// Loop header.
TLoopType loopType = node->getType();
if (loopType == ELoopFor) // for loop
diff --git a/src/3rdparty/angle/src/compiler/OutputGLSLBase.h b/src/3rdparty/angle/src/compiler/translator/OutputGLSLBase.h
index df4ad68c2c..76bec4de61 100644
--- a/src/3rdparty/angle/src/compiler/OutputGLSLBase.h
+++ b/src/3rdparty/angle/src/compiler/translator/OutputGLSLBase.h
@@ -9,9 +9,9 @@
#include <set>
-#include "compiler/ForLoopUnroll.h"
-#include "compiler/intermediate.h"
-#include "compiler/ParseHelper.h"
+#include "compiler/translator/ForLoopUnroll.h"
+#include "compiler/translator/intermediate.h"
+#include "compiler/translator/ParseContext.h"
class TOutputGLSLBase : public TIntermTraverser
{
diff --git a/src/3rdparty/angle/src/compiler/OutputHLSL.cpp b/src/3rdparty/angle/src/compiler/translator/OutputHLSL.cpp
index 79a373ebab..af996df719 100644
--- a/src/3rdparty/angle/src/compiler/OutputHLSL.cpp
+++ b/src/3rdparty/angle/src/compiler/translator/OutputHLSL.cpp
@@ -4,14 +4,16 @@
// found in the LICENSE file.
//
-#include "compiler/OutputHLSL.h"
+#include "compiler/translator/OutputHLSL.h"
#include "common/angleutils.h"
-#include "compiler/debug.h"
-#include "compiler/DetectDiscontinuity.h"
-#include "compiler/InfoSink.h"
-#include "compiler/SearchSymbol.h"
-#include "compiler/UnfoldShortCircuit.h"
+#include "compiler/translator/compilerdebug.h"
+#include "compiler/translator/DetectDiscontinuity.h"
+#include "compiler/translator/InfoSink.h"
+#include "compiler/translator/SearchSymbol.h"
+#include "compiler/translator/UnfoldShortCircuit.h"
+#include "compiler/translator/NodeSearch.h"
+#include "compiler/translator/RewriteElseBlocks.h"
#include <algorithm>
#include <cfloat>
@@ -19,13 +21,6 @@
namespace sh
{
-// Integer to TString conversion
-TString str(int i)
-{
- char buffer[20];
- snprintf(buffer, sizeof(buffer), "%d", i);
- return buffer;
-}
OutputHLSL::OutputHLSL(TParseContext &context, const ShBuiltInResources& resources, ShShaderOutput outputType)
: TIntermTraverser(true, true, true), mContext(context), mOutputType(outputType)
@@ -72,6 +67,7 @@ OutputHLSL::OutputHLSL(TParseContext &context, const ShBuiltInResources& resourc
mUsesAtan2_2 = false;
mUsesAtan2_3 = false;
mUsesAtan2_4 = false;
+ mUsesDiscardRewriting = false;
mNumRenderTargets = resources.EXT_draw_buffers ? resources.MaxDrawBuffers : 1;
@@ -113,6 +109,13 @@ void OutputHLSL::output()
{
mContainsLoopDiscontinuity = mContext.shaderType == SH_FRAGMENT_SHADER && containsLoopDiscontinuity(mContext.treeRoot);
+ // Work around D3D9 bug that would manifest in vertex shaders with selection blocks which
+ // use a vertex attribute as a condition, and some related computation in the else block.
+ if (mOutputType == SH_HLSL9_OUTPUT && mContext.shaderType == SH_VERTEX_SHADER)
+ {
+ RewriteElseBlocks(mContext.treeRoot);
+ }
+
mContext.treeRoot->traverse(this); // Output the body first to determine what has to go in the header
header();
@@ -196,6 +199,11 @@ void OutputHLSL::header()
attributes += "static " + typeString(type) + " " + decorate(name) + arrayString(type) + " = " + initializer(type) + ";\n";
}
+ if (mUsesDiscardRewriting)
+ {
+ out << "#define ANGLE_USES_DISCARD_REWRITING" << "\n";
+ }
+
if (shaderType == SH_FRAGMENT_SHADER)
{
TExtensionBehavior::const_iterator iter = mContext.extensionBehavior().find("GL_EXT_draw_buffers");
@@ -761,12 +769,12 @@ void OutputHLSL::header()
}
else if (mOutputType == SH_HLSL11_OUTPUT)
{
- out << "float4 gl_texture2DProj(Texture2D t, SamplerState s, float3 uvw, float lod)\n"
+ out << "float4 gl_texture2DProjLod(Texture2D t, SamplerState s, float3 uvw, float lod)\n"
"{\n"
" return t.SampleLevel(s, float2(uvw.x / uvw.z, uvw.y / uvw.z), lod);\n"
"}\n"
"\n"
- "float4 gl_texture2DProj(Texture2D t, SamplerState s, float4 uvw)\n"
+ "float4 gl_texture2DProjLod(Texture2D t, SamplerState s, float4 uvw, float lod)\n"
"{\n"
" return t.SampleLevel(s, float2(uvw.x / uvw.w, uvw.y / uvw.w), lod);\n"
"}\n"
@@ -1092,6 +1100,10 @@ void OutputHLSL::visitSymbol(TIntermSymbol *node)
mReferencedVaryings[name] = node;
out << decorate(name);
}
+ else if (qualifier == EvqInternal)
+ {
+ out << name;
+ }
else
{
out << decorate(name);
@@ -1299,15 +1311,31 @@ bool OutputHLSL::visitBinary(Visit visit, TIntermBinary *node)
case EOpMatrixTimesVector: outputTriplet(visit, "mul(transpose(", "), ", ")"); break;
case EOpMatrixTimesMatrix: outputTriplet(visit, "transpose(mul(transpose(", "), transpose(", ")))"); break;
case EOpLogicalOr:
- out << "s" << mUnfoldShortCircuit->getNextTemporaryIndex();
- return false;
+ if (node->getRight()->hasSideEffects())
+ {
+ out << "s" << mUnfoldShortCircuit->getNextTemporaryIndex();
+ return false;
+ }
+ else
+ {
+ outputTriplet(visit, "(", " || ", ")");
+ return true;
+ }
case EOpLogicalXor:
mUsesXor = true;
outputTriplet(visit, "xor(", ", ", ")");
break;
case EOpLogicalAnd:
- out << "s" << mUnfoldShortCircuit->getNextTemporaryIndex();
- return false;
+ if (node->getRight()->hasSideEffects())
+ {
+ out << "s" << mUnfoldShortCircuit->getNextTemporaryIndex();
+ return false;
+ }
+ else
+ {
+ outputTriplet(visit, "(", " && ", ")");
+ return true;
+ }
default: UNREACHABLE();
}
@@ -1491,7 +1519,7 @@ bool OutputHLSL::visitAggregate(Visit visit, TIntermAggregate *node)
{
symbol->traverse(this);
out << arrayString(symbol->getType());
- out << " = " + initializer(variable->getType());
+ out << " = " + initializer(symbol->getType());
}
else
{
@@ -1944,7 +1972,7 @@ bool OutputHLSL::visitSelection(Visit visit, TIntermSelection *node)
{
mUnfoldShortCircuit->traverse(node->getCondition());
- out << "if(";
+ out << "if (";
node->getCondition()->traverse(this);
@@ -1953,9 +1981,14 @@ bool OutputHLSL::visitSelection(Visit visit, TIntermSelection *node)
outputLineDirective(node->getLine().first_line);
out << "{\n";
+ bool discard = false;
+
if (node->getTrueBlock())
{
traverseStatements(node->getTrueBlock());
+
+ // Detect true discard
+ discard = (discard || FindDiscard::search(node->getTrueBlock()));
}
outputLineDirective(node->getLine().first_line);
@@ -1973,6 +2006,15 @@ bool OutputHLSL::visitSelection(Visit visit, TIntermSelection *node)
outputLineDirective(node->getFalseBlock()->getLine().first_line);
out << ";\n}\n";
+
+ // Detect false discard
+ discard = (discard || FindDiscard::search(node->getFalseBlock()));
+ }
+
+ // ANGLE issue 486: Detect problematic conditional discard
+ if (discard && FindSideEffectRewriting::search(node))
+ {
+ mUsesDiscardRewriting = true;
}
}
@@ -2070,7 +2112,9 @@ bool OutputHLSL::visitBranch(Visit visit, TIntermBranch *node)
switch (node->getFlowOp())
{
- case EOpKill: outputTriplet(visit, "discard;\n", "", ""); break;
+ case EOpKill:
+ outputTriplet(visit, "discard;\n", "", "");
+ break;
case EOpBreak:
if (visit == PreVisit)
{
@@ -2293,7 +2337,7 @@ bool OutputHLSL::handleExcessiveLoop(TIntermLoop *node)
if (!firstLoopFragment)
{
- out << "if(!Break";
+ out << "if (!Break";
index->traverse(this);
out << ") {\n";
}
diff --git a/src/3rdparty/angle/src/compiler/OutputHLSL.h b/src/3rdparty/angle/src/compiler/translator/OutputHLSL.h
index cde4120718..3afd8e9ada 100644
--- a/src/3rdparty/angle/src/compiler/OutputHLSL.h
+++ b/src/3rdparty/angle/src/compiler/translator/OutputHLSL.h
@@ -14,9 +14,9 @@
#define GL_APICALL
#include <GLES2/gl2.h>
-#include "compiler/intermediate.h"
-#include "compiler/ParseHelper.h"
-#include "compiler/Uniform.h"
+#include "compiler/translator/intermediate.h"
+#include "compiler/translator/ParseContext.h"
+#include "compiler/translator/Uniform.h"
namespace sh
{
@@ -125,6 +125,7 @@ class OutputHLSL : public TIntermTraverser
bool mUsesAtan2_2;
bool mUsesAtan2_3;
bool mUsesAtan2_4;
+ bool mUsesDiscardRewriting;
int mNumRenderTargets;
diff --git a/src/3rdparty/angle/src/compiler/ParseHelper.cpp b/src/3rdparty/angle/src/compiler/translator/ParseContext.cpp
index 1f8538e6a4..1a1e0d140c 100644
--- a/src/3rdparty/angle/src/compiler/ParseHelper.cpp
+++ b/src/3rdparty/angle/src/compiler/translator/ParseContext.cpp
@@ -4,12 +4,12 @@
// found in the LICENSE file.
//
-#include "compiler/ParseHelper.h"
+#include "compiler/translator/ParseContext.h"
#include <stdarg.h>
#include <stdio.h>
-#include "compiler/glslang.h"
+#include "compiler/translator/glslang.h"
#include "compiler/preprocessor/SourceLocation.h"
///////////////////////////////////////////////////////////////////////
@@ -182,7 +182,7 @@ void TParseContext::error(const TSourceLoc& loc,
pp::SourceLocation srcLoc;
srcLoc.file = loc.first_file;
srcLoc.line = loc.first_line;
- diagnostics.writeInfo(pp::Diagnostics::ERROR,
+ diagnostics.writeInfo(pp::Diagnostics::PP_ERROR,
srcLoc, reason, token, extraInfo);
}
@@ -193,7 +193,7 @@ void TParseContext::warning(const TSourceLoc& loc,
pp::SourceLocation srcLoc;
srcLoc.file = loc.first_file;
srcLoc.line = loc.first_line;
- diagnostics.writeInfo(pp::Diagnostics::WARNING,
+ diagnostics.writeInfo(pp::Diagnostics::PP_WARNING,
srcLoc, reason, token, extraInfo);
}
@@ -535,7 +535,7 @@ bool TParseContext::constructorErrorCheck(const TSourceLoc& line, TIntermNode* n
return true;
}
- if (op == EOpConstructStruct && !type->isArray() && int(type->getStruct()->fields().size()) != function.getParamCount()) {
+ if (op == EOpConstructStruct && !type->isArray() && type->getStruct()->fields().size() != function.getParamCount()) {
error(line, "Number of constructor parameters does not match the number of structure fields", "constructor");
return true;
}
diff --git a/src/3rdparty/angle/src/compiler/ParseHelper.h b/src/3rdparty/angle/src/compiler/translator/ParseContext.h
index c2b3c3f7ec..b324e575d3 100644
--- a/src/3rdparty/angle/src/compiler/ParseHelper.h
+++ b/src/3rdparty/angle/src/compiler/translator/ParseContext.h
@@ -6,12 +6,12 @@
#ifndef _PARSER_HELPER_INCLUDED_
#define _PARSER_HELPER_INCLUDED_
-#include "compiler/Diagnostics.h"
-#include "compiler/DirectiveHandler.h"
-#include "compiler/localintermediate.h"
+#include "compiler/translator/Diagnostics.h"
+#include "compiler/translator/DirectiveHandler.h"
+#include "compiler/translator/localintermediate.h"
#include "compiler/preprocessor/Preprocessor.h"
-#include "compiler/ShHandle.h"
-#include "compiler/SymbolTable.h"
+#include "compiler/translator/ShHandle.h"
+#include "compiler/translator/SymbolTable.h"
struct TMatrixFields {
bool wholeRow;
diff --git a/src/3rdparty/angle/src/compiler/PoolAlloc.cpp b/src/3rdparty/angle/src/compiler/translator/PoolAlloc.cpp
index eb993567b3..abe70262f2 100644
--- a/src/3rdparty/angle/src/compiler/PoolAlloc.cpp
+++ b/src/3rdparty/angle/src/compiler/translator/PoolAlloc.cpp
@@ -4,7 +4,7 @@
// found in the LICENSE file.
//
-#include "compiler/PoolAlloc.h"
+#include "compiler/translator/PoolAlloc.h"
#ifndef _MSC_VER
#include <stdint.h>
@@ -12,8 +12,8 @@
#include <stdio.h>
#include "common/angleutils.h"
-#include "compiler/InitializeGlobals.h"
-#include "compiler/osinclude.h"
+#include "compiler/translator/InitializeGlobals.h"
+#include "compiler/translator/osinclude.h"
OS_TLSIndex PoolIndex = OS_INVALID_TLS_INDEX;
diff --git a/src/3rdparty/angle/src/compiler/PoolAlloc.h b/src/3rdparty/angle/src/compiler/translator/PoolAlloc.h
index edd249c4d3..edd249c4d3 100644
--- a/src/3rdparty/angle/src/compiler/PoolAlloc.h
+++ b/src/3rdparty/angle/src/compiler/translator/PoolAlloc.h
diff --git a/src/3rdparty/angle/src/compiler/Pragma.h b/src/3rdparty/angle/src/compiler/translator/Pragma.h
index 2f744123b8..2f744123b8 100644
--- a/src/3rdparty/angle/src/compiler/Pragma.h
+++ b/src/3rdparty/angle/src/compiler/translator/Pragma.h
diff --git a/src/3rdparty/angle/src/compiler/QualifierAlive.cpp b/src/3rdparty/angle/src/compiler/translator/QualifierAlive.cpp
index 92a6874eb7..1ba087e176 100644
--- a/src/3rdparty/angle/src/compiler/QualifierAlive.cpp
+++ b/src/3rdparty/angle/src/compiler/translator/QualifierAlive.cpp
@@ -4,7 +4,7 @@
// found in the LICENSE file.
//
-#include "compiler/intermediate.h"
+#include "compiler/translator/intermediate.h"
class TAliveTraverser : public TIntermTraverser {
public:
diff --git a/src/3rdparty/angle/src/compiler/QualifierAlive.h b/src/3rdparty/angle/src/compiler/translator/QualifierAlive.h
index 872a06f721..872a06f721 100644
--- a/src/3rdparty/angle/src/compiler/QualifierAlive.h
+++ b/src/3rdparty/angle/src/compiler/translator/QualifierAlive.h
diff --git a/src/3rdparty/angle/src/compiler/RemoveTree.cpp b/src/3rdparty/angle/src/compiler/translator/RemoveTree.cpp
index a4b8c1e63e..92e5dbbfe1 100644
--- a/src/3rdparty/angle/src/compiler/RemoveTree.cpp
+++ b/src/3rdparty/angle/src/compiler/translator/RemoveTree.cpp
@@ -4,8 +4,8 @@
// found in the LICENSE file.
//
-#include "compiler/intermediate.h"
-#include "compiler/RemoveTree.h"
+#include "compiler/translator/intermediate.h"
+#include "compiler/translator/RemoveTree.h"
//
// Code to recursively delete the intermediate tree.
diff --git a/src/3rdparty/angle/src/compiler/RemoveTree.h b/src/3rdparty/angle/src/compiler/translator/RemoveTree.h
index 97a821679c..97a821679c 100644
--- a/src/3rdparty/angle/src/compiler/RemoveTree.h
+++ b/src/3rdparty/angle/src/compiler/translator/RemoveTree.h
diff --git a/src/3rdparty/angle/src/compiler/RenameFunction.h b/src/3rdparty/angle/src/compiler/translator/RenameFunction.h
index 3908bfddb8..1f7fb16c45 100644
--- a/src/3rdparty/angle/src/compiler/RenameFunction.h
+++ b/src/3rdparty/angle/src/compiler/translator/RenameFunction.h
@@ -7,7 +7,7 @@
#ifndef COMPILER_RENAME_FUNCTION
#define COMPILER_RENAME_FUNCTION
-#include "compiler/intermediate.h"
+#include "compiler/translator/intermediate.h"
//
// Renames a function, including its declaration and any calls to it.
diff --git a/src/3rdparty/angle/src/compiler/translator/RewriteElseBlocks.cpp b/src/3rdparty/angle/src/compiler/translator/RewriteElseBlocks.cpp
new file mode 100644
index 0000000000..48e87cd57a
--- /dev/null
+++ b/src/3rdparty/angle/src/compiler/translator/RewriteElseBlocks.cpp
@@ -0,0 +1,98 @@
+//
+// Copyright (c) 2014 The ANGLE Project Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+//
+// RewriteElseBlocks.cpp: Implementation for tree transform to change
+// all if-else blocks to if-if blocks.
+//
+
+#include "compiler/translator/RewriteElseBlocks.h"
+#include "compiler/translator/NodeSearch.h"
+#include "compiler/translator/SymbolTable.h"
+
+namespace sh
+{
+
+TIntermSymbol *MakeNewTemporary(const TString &name, TBasicType type)
+{
+ TType variableType(type, EbpHigh, EvqInternal);
+ return new TIntermSymbol(-1, name, variableType);
+}
+
+TIntermBinary *MakeNewBinary(TOperator op, TIntermTyped *left, TIntermTyped *right, const TType &resultType)
+{
+ TIntermBinary *binary = new TIntermBinary(op);
+ binary->setLeft(left);
+ binary->setRight(right);
+ binary->setType(resultType);
+ return binary;
+}
+
+TIntermUnary *MakeNewUnary(TOperator op, TIntermTyped *operand)
+{
+ TIntermUnary *unary = new TIntermUnary(op, operand->getType());
+ unary->setOperand(operand);
+ return unary;
+}
+
+bool ElseBlockRewriter::visitAggregate(Visit visit, TIntermAggregate *node)
+{
+ switch (node->getOp())
+ {
+ case EOpSequence:
+ {
+ for (size_t statementIndex = 0; statementIndex != node->getSequence().size(); statementIndex++)
+ {
+ TIntermNode *statement = node->getSequence()[statementIndex];
+ TIntermSelection *selection = statement->getAsSelectionNode();
+ if (selection && selection->getFalseBlock() != NULL)
+ {
+ node->getSequence()[statementIndex] = rewriteSelection(selection);
+ delete selection;
+ }
+ }
+ }
+ break;
+
+ default: break;
+ }
+
+ return true;
+}
+
+TIntermNode *ElseBlockRewriter::rewriteSelection(TIntermSelection *selection)
+{
+ ASSERT(selection->getFalseBlock() != NULL);
+
+ TString temporaryName = "cond_" + str(mTemporaryIndex++);
+ TIntermTyped *typedCondition = selection->getCondition()->getAsTyped();
+ TType resultType(EbtBool, EbpUndefined);
+ TIntermSymbol *conditionSymbolA = MakeNewTemporary(temporaryName, EbtBool);
+ TIntermSymbol *conditionSymbolB = MakeNewTemporary(temporaryName, EbtBool);
+ TIntermSymbol *conditionSymbolC = MakeNewTemporary(temporaryName, EbtBool);
+ TIntermBinary *storeCondition = MakeNewBinary(EOpInitialize, conditionSymbolA,
+ typedCondition, resultType);
+ TIntermUnary *negatedCondition = MakeNewUnary(EOpLogicalNot, conditionSymbolB);
+ TIntermSelection *falseBlock = new TIntermSelection(negatedCondition,
+ selection->getFalseBlock(), NULL);
+ TIntermSelection *newIfElse = new TIntermSelection(conditionSymbolC,
+ selection->getTrueBlock(), falseBlock);
+
+ TIntermAggregate *declaration = new TIntermAggregate(EOpDeclaration);
+ declaration->getSequence().push_back(storeCondition);
+
+ TIntermAggregate *block = new TIntermAggregate(EOpSequence);
+ block->getSequence().push_back(declaration);
+ block->getSequence().push_back(newIfElse);
+
+ return block;
+}
+
+void RewriteElseBlocks(TIntermNode *node)
+{
+ ElseBlockRewriter rewriter;
+ node->traverse(&rewriter);
+}
+
+}
diff --git a/src/3rdparty/angle/src/compiler/translator/RewriteElseBlocks.h b/src/3rdparty/angle/src/compiler/translator/RewriteElseBlocks.h
new file mode 100644
index 0000000000..10221335ce
--- /dev/null
+++ b/src/3rdparty/angle/src/compiler/translator/RewriteElseBlocks.h
@@ -0,0 +1,39 @@
+//
+// Copyright (c) 2014 The ANGLE Project Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+//
+// RewriteElseBlocks.h: Prototype for tree transform to change
+// all if-else blocks to if-if blocks.
+//
+
+#ifndef COMPILER_REWRITE_ELSE_BLOCKS_H_
+#define COMPILER_REWRITE_ELSE_BLOCKS_H_
+
+#include "compiler/translator/intermediate.h"
+
+namespace sh
+{
+
+class ElseBlockRewriter : public TIntermTraverser
+{
+ public:
+ ElseBlockRewriter()
+ : TIntermTraverser(false, false, true, false)
+ , mTemporaryIndex(0)
+ {}
+
+ protected:
+ bool visitAggregate(Visit visit, TIntermAggregate *aggregate);
+
+ private:
+ int mTemporaryIndex;
+
+ TIntermNode *rewriteSelection(TIntermSelection *selection);
+};
+
+void RewriteElseBlocks(TIntermNode *node);
+
+}
+
+#endif // COMPILER_REWRITE_ELSE_BLOCKS_H_
diff --git a/src/3rdparty/angle/src/compiler/SearchSymbol.cpp b/src/3rdparty/angle/src/compiler/translator/SearchSymbol.cpp
index 9368f1a4fa..f78c84e370 100644
--- a/src/3rdparty/angle/src/compiler/SearchSymbol.cpp
+++ b/src/3rdparty/angle/src/compiler/translator/SearchSymbol.cpp
@@ -6,10 +6,10 @@
// SearchSymbol is an AST traverser to detect the use of a given symbol name
//
-#include "compiler/SearchSymbol.h"
+#include "compiler/translator/SearchSymbol.h"
-#include "compiler/InfoSink.h"
-#include "compiler/OutputHLSL.h"
+#include "compiler/translator/InfoSink.h"
+#include "compiler/translator/OutputHLSL.h"
namespace sh
{
diff --git a/src/3rdparty/angle/src/compiler/SearchSymbol.h b/src/3rdparty/angle/src/compiler/translator/SearchSymbol.h
index 6bc0b90feb..8ddd3cb1ac 100644
--- a/src/3rdparty/angle/src/compiler/SearchSymbol.h
+++ b/src/3rdparty/angle/src/compiler/translator/SearchSymbol.h
@@ -9,8 +9,8 @@
#ifndef COMPILER_SEARCHSYMBOL_H_
#define COMPILER_SEARCHSYMBOL_H_
-#include "compiler/intermediate.h"
-#include "compiler/ParseHelper.h"
+#include "compiler/translator/intermediate.h"
+#include "compiler/translator/ParseContext.h"
namespace sh
{
diff --git a/src/3rdparty/angle/src/compiler/ShHandle.h b/src/3rdparty/angle/src/compiler/translator/ShHandle.h
index 873580a99c..54ae27852d 100644
--- a/src/3rdparty/angle/src/compiler/ShHandle.h
+++ b/src/3rdparty/angle/src/compiler/translator/ShHandle.h
@@ -16,12 +16,12 @@
#include "GLSLANG/ShaderLang.h"
-#include "compiler/BuiltInFunctionEmulator.h"
-#include "compiler/ExtensionBehavior.h"
-#include "compiler/HashNames.h"
-#include "compiler/InfoSink.h"
-#include "compiler/SymbolTable.h"
-#include "compiler/VariableInfo.h"
+#include "compiler/translator/BuiltInFunctionEmulator.h"
+#include "compiler/translator/ExtensionBehavior.h"
+#include "compiler/translator/HashNames.h"
+#include "compiler/translator/InfoSink.h"
+#include "compiler/translator/SymbolTable.h"
+#include "compiler/translator/VariableInfo.h"
#include "third_party/compiler/ArrayBoundsClamper.h"
class LongNameMap;
@@ -100,6 +100,16 @@ protected:
// Returns true if, after applying the packing rules in the GLSL 1.017 spec
// Appendix A, section 7, the shader does not use too many uniforms.
bool enforcePackingRestrictions();
+ // Insert statements to initialize varyings without static use in the beginning
+ // of main(). It is to work around a Mac driver where such varyings in a vertex
+ // shader may be optimized out incorrectly at compile time, causing a link failure.
+ // This function should only be applied to vertex shaders.
+ void initializeVaryingsWithoutStaticUse(TIntermNode* root);
+ // Insert gl_Position = vec4(0,0,0,0) to the beginning of main().
+ // It is to work around a Linux driver bug where missing this causes compile failure
+ // while spec says it is allowed.
+ // This function should only be applied to vertex shaders.
+ void initializeGLPosition(TIntermNode* root);
// Returns true if the shader passes the restrictions that aim to prevent timing attacks.
bool enforceTimingRestrictions(TIntermNode* root, bool outputGraph);
// Returns true if the shader does not use samplers.
diff --git a/src/3rdparty/angle/src/compiler/ShaderLang.cpp b/src/3rdparty/angle/src/compiler/translator/ShaderLang.cpp
index 42cd5cc5c1..608237860c 100644
--- a/src/3rdparty/angle/src/compiler/ShaderLang.cpp
+++ b/src/3rdparty/angle/src/compiler/translator/ShaderLang.cpp
@@ -11,11 +11,11 @@
#include "GLSLANG/ShaderLang.h"
-#include "compiler/InitializeDll.h"
+#include "compiler/translator/InitializeDll.h"
#include "compiler/preprocessor/length_limits.h"
-#include "compiler/ShHandle.h"
-#include "compiler/TranslatorHLSL.h"
-#include "compiler/VariablePacker.h"
+#include "compiler/translator/ShHandle.h"
+#include "compiler/translator/TranslatorHLSL.h"
+#include "compiler/translator/VariablePacker.h"
//
// This is the platform independent interface between an OGL driver
@@ -91,6 +91,9 @@ void ShInitBuiltInResources(ShBuiltInResources* resources)
resources->HashFunction = NULL;
resources->ArrayIndexClampingStrategy = SH_CLAMP_WITH_CLAMP_INTRINSIC;
+
+ resources->MaxExpressionComplexity = 256;
+ resources->MaxCallStackDepth = 256;
}
//
diff --git a/src/3rdparty/angle/src/compiler/SymbolTable.cpp b/src/3rdparty/angle/src/compiler/translator/SymbolTable.cpp
index a7ce21680f..d04fe5d355 100644
--- a/src/3rdparty/angle/src/compiler/SymbolTable.cpp
+++ b/src/3rdparty/angle/src/compiler/translator/SymbolTable.cpp
@@ -13,7 +13,7 @@
#pragma warning(disable: 4718)
#endif
-#include "compiler/SymbolTable.h"
+#include "compiler/translator/SymbolTable.h"
#include <stdio.h>
#include <algorithm>
diff --git a/src/3rdparty/angle/src/compiler/SymbolTable.h b/src/3rdparty/angle/src/compiler/translator/SymbolTable.h
index bebad4b92e..6c7211f2a9 100644
--- a/src/3rdparty/angle/src/compiler/SymbolTable.h
+++ b/src/3rdparty/angle/src/compiler/translator/SymbolTable.h
@@ -33,8 +33,8 @@
#include <assert.h>
#include "common/angleutils.h"
-#include "compiler/InfoSink.h"
-#include "compiler/intermediate.h"
+#include "compiler/translator/InfoSink.h"
+#include "compiler/translator/intermediate.h"
//
// Symbol base class. (Can build functions or variables out of these...)
diff --git a/src/3rdparty/angle/src/compiler/TranslatorESSL.cpp b/src/3rdparty/angle/src/compiler/translator/TranslatorESSL.cpp
index 2900f8a8ed..9262f7af8c 100644
--- a/src/3rdparty/angle/src/compiler/TranslatorESSL.cpp
+++ b/src/3rdparty/angle/src/compiler/translator/TranslatorESSL.cpp
@@ -4,9 +4,9 @@
// found in the LICENSE file.
//
-#include "compiler/TranslatorESSL.h"
+#include "compiler/translator/TranslatorESSL.h"
-#include "compiler/OutputESSL.h"
+#include "compiler/translator/OutputESSL.h"
TranslatorESSL::TranslatorESSL(ShShaderType type, ShShaderSpec spec)
: TCompiler(type, spec) {
diff --git a/src/3rdparty/angle/src/compiler/TranslatorESSL.h b/src/3rdparty/angle/src/compiler/translator/TranslatorESSL.h
index a1196bd001..e18f3c25ec 100644
--- a/src/3rdparty/angle/src/compiler/TranslatorESSL.h
+++ b/src/3rdparty/angle/src/compiler/translator/TranslatorESSL.h
@@ -7,7 +7,7 @@
#ifndef COMPILER_TRANSLATORESSL_H_
#define COMPILER_TRANSLATORESSL_H_
-#include "compiler/ShHandle.h"
+#include "compiler/translator/ShHandle.h"
class TranslatorESSL : public TCompiler {
public:
diff --git a/src/3rdparty/angle/src/compiler/TranslatorGLSL.cpp b/src/3rdparty/angle/src/compiler/translator/TranslatorGLSL.cpp
index 7ca4341dcd..6688d7f362 100644
--- a/src/3rdparty/angle/src/compiler/TranslatorGLSL.cpp
+++ b/src/3rdparty/angle/src/compiler/translator/TranslatorGLSL.cpp
@@ -4,10 +4,10 @@
// found in the LICENSE file.
//
-#include "compiler/TranslatorGLSL.h"
+#include "compiler/translator/TranslatorGLSL.h"
-#include "compiler/OutputGLSL.h"
-#include "compiler/VersionGLSL.h"
+#include "compiler/translator/OutputGLSL.h"
+#include "compiler/translator/VersionGLSL.h"
static void writeVersion(ShShaderType type, TIntermNode* root,
TInfoSinkBase& sink) {
diff --git a/src/3rdparty/angle/src/compiler/TranslatorGLSL.h b/src/3rdparty/angle/src/compiler/translator/TranslatorGLSL.h
index c2ce06d192..40bb3145e8 100644
--- a/src/3rdparty/angle/src/compiler/TranslatorGLSL.h
+++ b/src/3rdparty/angle/src/compiler/translator/TranslatorGLSL.h
@@ -7,7 +7,7 @@
#ifndef COMPILER_TRANSLATORGLSL_H_
#define COMPILER_TRANSLATORGLSL_H_
-#include "compiler/ShHandle.h"
+#include "compiler/translator/ShHandle.h"
class TranslatorGLSL : public TCompiler {
public:
diff --git a/src/3rdparty/angle/src/compiler/TranslatorHLSL.cpp b/src/3rdparty/angle/src/compiler/translator/TranslatorHLSL.cpp
index 37408a07c4..3c1db011b6 100644
--- a/src/3rdparty/angle/src/compiler/TranslatorHLSL.cpp
+++ b/src/3rdparty/angle/src/compiler/translator/TranslatorHLSL.cpp
@@ -4,10 +4,10 @@
// found in the LICENSE file.
//
-#include "compiler/TranslatorHLSL.h"
+#include "compiler/translator/TranslatorHLSL.h"
-#include "compiler/InitializeParseContext.h"
-#include "compiler/OutputHLSL.h"
+#include "compiler/translator/InitializeParseContext.h"
+#include "compiler/translator/OutputHLSL.h"
TranslatorHLSL::TranslatorHLSL(ShShaderType type, ShShaderSpec spec, ShShaderOutput output)
: TCompiler(type, spec), mOutputType(output)
diff --git a/src/3rdparty/angle/src/compiler/TranslatorHLSL.h b/src/3rdparty/angle/src/compiler/translator/TranslatorHLSL.h
index 9550e15e8e..6204b30cc2 100644
--- a/src/3rdparty/angle/src/compiler/TranslatorHLSL.h
+++ b/src/3rdparty/angle/src/compiler/translator/TranslatorHLSL.h
@@ -7,8 +7,8 @@
#ifndef COMPILER_TRANSLATORHLSL_H_
#define COMPILER_TRANSLATORHLSL_H_
-#include "compiler/ShHandle.h"
-#include "compiler/Uniform.h"
+#include "compiler/translator/ShHandle.h"
+#include "compiler/translator/Uniform.h"
class TranslatorHLSL : public TCompiler {
public:
diff --git a/src/3rdparty/angle/src/compiler/Types.h b/src/3rdparty/angle/src/compiler/translator/Types.h
index 505fa8e3bf..119f4f29e5 100644
--- a/src/3rdparty/angle/src/compiler/Types.h
+++ b/src/3rdparty/angle/src/compiler/translator/Types.h
@@ -1,5 +1,5 @@
//
-// Copyright (c) 2002-2012 The ANGLE Project Authors. All rights reserved.
+// Copyright (c) 2002-2013 The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
@@ -9,9 +9,9 @@
#include "common/angleutils.h"
-#include "compiler/BaseTypes.h"
-#include "compiler/Common.h"
-#include "compiler/debug.h"
+#include "compiler/translator/BaseTypes.h"
+#include "compiler/translator/Common.h"
+#include "compiler/translator/compilerdebug.h"
struct TPublicType;
class TType;
@@ -95,7 +95,7 @@ class TType
public:
POOL_ALLOCATOR_NEW_DELETE();
TType() {}
- TType(TBasicType t, TPrecision p, TQualifier q = EvqTemporary, int s = 1, bool m = false, bool a = false) :
+ TType(TBasicType t, TPrecision p, TQualifier q = EvqTemporary, unsigned char s = 1, bool m = false, bool a = false) :
type(t), precision(p), qualifier(q), size(s), matrix(m), array(a), arraySize(0), structure(0)
{
}
@@ -116,7 +116,7 @@ public:
// One-dimensional size of single instance type
int getNominalSize() const { return size; }
- void setNominalSize(int s) { size = s; }
+ void setNominalSize(unsigned char s) { size = s; }
// Full size of single instance of type
size_t getObjectSize() const;
@@ -234,12 +234,12 @@ public:
private:
TString buildMangledName() const;
- TBasicType type : 6;
+ TBasicType type;
TPrecision precision;
- TQualifier qualifier : 7;
- int size : 8; // size of vector or matrix, not size of array
- unsigned int matrix : 1;
- unsigned int array : 1;
+ TQualifier qualifier;
+ unsigned char size;
+ bool matrix;
+ bool array;
int arraySize;
TStructure* structure; // 0 unless this is a struct
@@ -261,7 +261,7 @@ struct TPublicType
TBasicType type;
TQualifier qualifier;
TPrecision precision;
- int size; // size of vector or matrix, not size of array
+ unsigned char size; // size of vector or matrix, not size of array
bool matrix;
bool array;
int arraySize;
@@ -281,7 +281,7 @@ struct TPublicType
line = ln;
}
- void setAggregate(int s, bool m = false)
+ void setAggregate(unsigned char s, bool m = false)
{
size = s;
matrix = m;
diff --git a/src/3rdparty/angle/src/compiler/UnfoldShortCircuit.cpp b/src/3rdparty/angle/src/compiler/translator/UnfoldShortCircuit.cpp
index 47f0afca6a..b7826119ae 100644
--- a/src/3rdparty/angle/src/compiler/UnfoldShortCircuit.cpp
+++ b/src/3rdparty/angle/src/compiler/translator/UnfoldShortCircuit.cpp
@@ -8,10 +8,10 @@
// the original expression.
//
-#include "compiler/UnfoldShortCircuit.h"
+#include "compiler/translator/UnfoldShortCircuit.h"
-#include "compiler/InfoSink.h"
-#include "compiler/OutputHLSL.h"
+#include "compiler/translator/InfoSink.h"
+#include "compiler/translator/OutputHLSL.h"
namespace sh
{
@@ -31,6 +31,14 @@ bool UnfoldShortCircuit::visitBinary(Visit visit, TIntermBinary *node)
{
TInfoSinkBase &out = mOutputHLSL->getBodyStream();
+ // If our right node doesn't have side effects, we know we don't need to unfold this
+ // expression: there will be no short-circuiting side effects to avoid
+ // (note: unfolding doesn't depend on the left node -- it will always be evaluated)
+ if (!node->getRight()->hasSideEffects())
+ {
+ return true;
+ }
+
switch (node->getOp())
{
case EOpLogicalOr:
@@ -49,7 +57,7 @@ bool UnfoldShortCircuit::visitBinary(Visit visit, TIntermBinary *node)
mTemporaryIndex = i + 1;
node->getLeft()->traverse(mOutputHLSL);
out << ";\n";
- out << "if(!s" << i << ")\n"
+ out << "if (!s" << i << ")\n"
"{\n";
mTemporaryIndex = i + 1;
node->getRight()->traverse(this);
@@ -80,7 +88,7 @@ bool UnfoldShortCircuit::visitBinary(Visit visit, TIntermBinary *node)
mTemporaryIndex = i + 1;
node->getLeft()->traverse(mOutputHLSL);
out << ";\n";
- out << "if(s" << i << ")\n"
+ out << "if (s" << i << ")\n"
"{\n";
mTemporaryIndex = i + 1;
node->getRight()->traverse(this);
@@ -115,7 +123,7 @@ bool UnfoldShortCircuit::visitSelection(Visit visit, TIntermSelection *node)
mTemporaryIndex = i + 1;
node->getCondition()->traverse(this);
- out << "if(";
+ out << "if (";
mTemporaryIndex = i + 1;
node->getCondition()->traverse(mOutputHLSL);
out << ")\n"
diff --git a/src/3rdparty/angle/src/compiler/UnfoldShortCircuit.h b/src/3rdparty/angle/src/compiler/translator/UnfoldShortCircuit.h
index cb176a5f1c..1e416bc04c 100644
--- a/src/3rdparty/angle/src/compiler/UnfoldShortCircuit.h
+++ b/src/3rdparty/angle/src/compiler/translator/UnfoldShortCircuit.h
@@ -9,8 +9,8 @@
#ifndef COMPILER_UNFOLDSHORTCIRCUIT_H_
#define COMPILER_UNFOLDSHORTCIRCUIT_H_
-#include "compiler/intermediate.h"
-#include "compiler/ParseHelper.h"
+#include "compiler/translator/intermediate.h"
+#include "compiler/translator/ParseContext.h"
namespace sh
{
diff --git a/src/3rdparty/angle/src/compiler/translator/UnfoldShortCircuitAST.cpp b/src/3rdparty/angle/src/compiler/translator/UnfoldShortCircuitAST.cpp
new file mode 100644
index 0000000000..29c4397d56
--- /dev/null
+++ b/src/3rdparty/angle/src/compiler/translator/UnfoldShortCircuitAST.cpp
@@ -0,0 +1,81 @@
+//
+// Copyright (c) 2002-2013 The ANGLE Project Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+//
+
+#include "compiler/translator/UnfoldShortCircuitAST.h"
+
+namespace
+{
+
+// "x || y" is equivalent to "x ? true : y".
+TIntermSelection *UnfoldOR(TIntermTyped *x, TIntermTyped *y)
+{
+ const TType boolType(EbtBool, EbpUndefined);
+ ConstantUnion *u = new ConstantUnion;
+ u->setBConst(true);
+ TIntermConstantUnion *trueNode = new TIntermConstantUnion(
+ u, TType(EbtBool, EbpUndefined, EvqConst, 1));
+ return new TIntermSelection(x, trueNode, y, boolType);
+}
+
+// "x && y" is equivalent to "x ? y : false".
+TIntermSelection *UnfoldAND(TIntermTyped *x, TIntermTyped *y)
+{
+ const TType boolType(EbtBool, EbpUndefined);
+ ConstantUnion *u = new ConstantUnion;
+ u->setBConst(false);
+ TIntermConstantUnion *falseNode = new TIntermConstantUnion(
+ u, TType(EbtBool, EbpUndefined, EvqConst, 1));
+ return new TIntermSelection(x, y, falseNode, boolType);
+}
+
+} // namespace anonymous
+
+bool UnfoldShortCircuitAST::visitBinary(Visit visit, TIntermBinary *node)
+{
+ TIntermSelection *replacement = NULL;
+
+ switch (node->getOp())
+ {
+ case EOpLogicalOr:
+ replacement = UnfoldOR(node->getLeft(), node->getRight());
+ break;
+ case EOpLogicalAnd:
+ replacement = UnfoldAND(node->getLeft(), node->getRight());
+ break;
+ default:
+ break;
+ }
+ if (replacement)
+ {
+ replacements.push_back(
+ NodeUpdateEntry(getParentNode(), node, replacement));
+ }
+ return true;
+}
+
+void UnfoldShortCircuitAST::updateTree()
+{
+ for (size_t ii = 0; ii < replacements.size(); ++ii)
+ {
+ const NodeUpdateEntry& entry = replacements[ii];
+ ASSERT(entry.parent);
+ bool replaced = entry.parent->replaceChildNode(
+ entry.original, entry.replacement);
+ ASSERT(replaced);
+
+ // In AST traversing, a parent is visited before its children.
+ // After we replace a node, if an immediate child is to
+ // be replaced, we need to make sure we don't update the replaced
+ // node; instead, we update the replacement node.
+ for (size_t jj = ii + 1; jj < replacements.size(); ++jj)
+ {
+ NodeUpdateEntry& entry2 = replacements[jj];
+ if (entry2.parent == entry.original)
+ entry2.parent = entry.replacement;
+ }
+ }
+}
+
diff --git a/src/3rdparty/angle/src/compiler/translator/UnfoldShortCircuitAST.h b/src/3rdparty/angle/src/compiler/translator/UnfoldShortCircuitAST.h
new file mode 100644
index 0000000000..24c14a60e3
--- /dev/null
+++ b/src/3rdparty/angle/src/compiler/translator/UnfoldShortCircuitAST.h
@@ -0,0 +1,51 @@
+//
+// Copyright (c) 2002-2013 The ANGLE Project Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+//
+// UnfoldShortCircuitAST is an AST traverser to replace short-circuiting
+// operations with ternary operations.
+//
+
+#ifndef COMPILER_UNFOLD_SHORT_CIRCUIT_AST_H_
+#define COMPILER_UNFOLD_SHORT_CIRCUIT_AST_H_
+
+#include "common/angleutils.h"
+#include "compiler/translator/intermediate.h"
+
+// This traverser identifies all the short circuit binary nodes that need to
+// be replaced, and creates the corresponding replacement nodes. However,
+// the actual replacements happen after the traverse through updateTree().
+
+class UnfoldShortCircuitAST : public TIntermTraverser
+{
+ public:
+ UnfoldShortCircuitAST() { }
+
+ virtual bool visitBinary(Visit visit, TIntermBinary *);
+
+ void updateTree();
+
+ private:
+ struct NodeUpdateEntry
+ {
+ NodeUpdateEntry(TIntermNode *_parent,
+ TIntermNode *_original,
+ TIntermNode *_replacement)
+ : parent(_parent),
+ original(_original),
+ replacement(_replacement) {}
+
+ TIntermNode *parent;
+ TIntermNode *original;
+ TIntermNode *replacement;
+ };
+
+ // During traversing, save all the replacements that need to happen;
+ // then replace them by calling updateNodes().
+ std::vector<NodeUpdateEntry> replacements;
+
+ DISALLOW_COPY_AND_ASSIGN(UnfoldShortCircuitAST);
+};
+
+#endif // COMPILER_UNFOLD_SHORT_CIRCUIT_AST_H_
diff --git a/src/3rdparty/angle/src/compiler/Uniform.cpp b/src/3rdparty/angle/src/compiler/translator/Uniform.cpp
index f367db2be8..922e13f071 100644
--- a/src/3rdparty/angle/src/compiler/Uniform.cpp
+++ b/src/3rdparty/angle/src/compiler/translator/Uniform.cpp
@@ -4,7 +4,7 @@
// found in the LICENSE file.
//
-#include "compiler/Uniform.h"
+#include "compiler/translator/Uniform.h"
namespace sh
{
diff --git a/src/3rdparty/angle/src/compiler/Uniform.h b/src/3rdparty/angle/src/compiler/translator/Uniform.h
index 4c53ffa7d2..4c53ffa7d2 100644
--- a/src/3rdparty/angle/src/compiler/Uniform.h
+++ b/src/3rdparty/angle/src/compiler/translator/Uniform.h
diff --git a/src/3rdparty/angle/src/compiler/ValidateLimitations.cpp b/src/3rdparty/angle/src/compiler/translator/ValidateLimitations.cpp
index 736ceeaefc..3c2cc41cda 100644
--- a/src/3rdparty/angle/src/compiler/ValidateLimitations.cpp
+++ b/src/3rdparty/angle/src/compiler/translator/ValidateLimitations.cpp
@@ -4,10 +4,10 @@
// found in the LICENSE file.
//
-#include "compiler/ValidateLimitations.h"
-#include "compiler/InfoSink.h"
-#include "compiler/InitializeParseContext.h"
-#include "compiler/ParseHelper.h"
+#include "compiler/translator/ValidateLimitations.h"
+#include "compiler/translator/InfoSink.h"
+#include "compiler/translator/InitializeParseContext.h"
+#include "compiler/translator/ParseContext.h"
namespace {
bool IsLoopIndex(const TIntermSymbol* symbol, const TLoopStack& stack) {
@@ -457,7 +457,7 @@ bool ValidateLimitations::validateFunctionCall(TIntermAggregate* node)
bool ValidateLimitations::validateOperation(TIntermOperator* node,
TIntermNode* operand) {
// Check if loop index is modified in the loop body.
- if (!withinLoopBody() || !node->modifiesState())
+ if (!withinLoopBody() || !node->isAssignment())
return true;
const TIntermSymbol* symbol = operand->getAsSymbolNode();
diff --git a/src/3rdparty/angle/src/compiler/ValidateLimitations.h b/src/3rdparty/angle/src/compiler/translator/ValidateLimitations.h
index a835cb3c22..8839dd8b8a 100644
--- a/src/3rdparty/angle/src/compiler/ValidateLimitations.h
+++ b/src/3rdparty/angle/src/compiler/translator/ValidateLimitations.h
@@ -5,7 +5,7 @@
//
#include "GLSLANG/ShaderLang.h"
-#include "compiler/intermediate.h"
+#include "compiler/translator/intermediate.h"
class TInfoSinkBase;
diff --git a/src/3rdparty/angle/src/compiler/VariableInfo.cpp b/src/3rdparty/angle/src/compiler/translator/VariableInfo.cpp
index f3f7b1ef35..ef888aff11 100644
--- a/src/3rdparty/angle/src/compiler/VariableInfo.cpp
+++ b/src/3rdparty/angle/src/compiler/translator/VariableInfo.cpp
@@ -4,7 +4,7 @@
// found in the LICENSE file.
//
-#include "compiler/VariableInfo.h"
+#include "compiler/translator/VariableInfo.h"
namespace {
@@ -116,10 +116,12 @@ void getBuiltInVariableInfo(const TType& type,
varInfo.name = (name + "[0]").c_str();
varInfo.mappedName = (mappedName + "[0]").c_str();
varInfo.size = type.getArraySize();
+ varInfo.isArray = true;
} else {
varInfo.name = name.c_str();
varInfo.mappedName = mappedName.c_str();
varInfo.size = 1;
+ varInfo.isArray = false;
}
varInfo.precision = type.getPrecision();
varInfo.type = getVariableDataType(type);
@@ -167,6 +169,7 @@ TVariableInfo* findVariable(const TType& type,
TVariableInfo::TVariableInfo()
: type(SH_NONE),
size(0),
+ isArray(false),
precision(EbpUndefined),
staticUse(false)
{
@@ -175,6 +178,7 @@ TVariableInfo::TVariableInfo()
TVariableInfo::TVariableInfo(ShDataType type, int size)
: type(type),
size(size),
+ isArray(false),
precision(EbpUndefined),
staticUse(false)
{
diff --git a/src/3rdparty/angle/src/compiler/VariableInfo.h b/src/3rdparty/angle/src/compiler/translator/VariableInfo.h
index 3c7f2a5f84..37216cd142 100644
--- a/src/3rdparty/angle/src/compiler/VariableInfo.h
+++ b/src/3rdparty/angle/src/compiler/translator/VariableInfo.h
@@ -8,7 +8,7 @@
#define COMPILER_VARIABLE_INFO_H_
#include "GLSLANG/ShaderLang.h"
-#include "compiler/intermediate.h"
+#include "compiler/translator/intermediate.h"
// Provides information about a variable.
// It is currently being used to store info about active attribs and uniforms.
@@ -20,6 +20,7 @@ struct TVariableInfo {
TPersistString mappedName;
ShDataType type;
int size;
+ bool isArray;
TPrecision precision;
bool staticUse;
};
diff --git a/src/3rdparty/angle/src/compiler/VariablePacker.cpp b/src/3rdparty/angle/src/compiler/translator/VariablePacker.cpp
index 8957287763..5634d86337 100644
--- a/src/3rdparty/angle/src/compiler/VariablePacker.cpp
+++ b/src/3rdparty/angle/src/compiler/translator/VariablePacker.cpp
@@ -3,10 +3,10 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
-#include "compiler/VariablePacker.h"
+#include "compiler/translator/VariablePacker.h"
#include <algorithm>
-#include "compiler/ShHandle.h"
+#include "compiler/translator/ShHandle.h"
namespace {
int GetSortOrder(ShDataType type)
diff --git a/src/3rdparty/angle/src/compiler/VariablePacker.h b/src/3rdparty/angle/src/compiler/translator/VariablePacker.h
index 8987066cc3..fd6090827c 100644
--- a/src/3rdparty/angle/src/compiler/VariablePacker.h
+++ b/src/3rdparty/angle/src/compiler/translator/VariablePacker.h
@@ -8,7 +8,7 @@
#define _VARIABLEPACKER_INCLUDED_
#include <vector>
-#include "compiler/ShHandle.h"
+#include "compiler/translator/ShHandle.h"
class VariablePacker {
public:
diff --git a/src/3rdparty/angle/src/compiler/VersionGLSL.cpp b/src/3rdparty/angle/src/compiler/translator/VersionGLSL.cpp
index 7a82bb4dc1..dd11f99eb8 100644
--- a/src/3rdparty/angle/src/compiler/VersionGLSL.cpp
+++ b/src/3rdparty/angle/src/compiler/translator/VersionGLSL.cpp
@@ -4,7 +4,7 @@
// found in the LICENSE file.
//
-#include "compiler/VersionGLSL.h"
+#include "compiler/translator/VersionGLSL.h"
static const int GLSL_VERSION_110 = 110;
static const int GLSL_VERSION_120 = 120;
diff --git a/src/3rdparty/angle/src/compiler/VersionGLSL.h b/src/3rdparty/angle/src/compiler/translator/VersionGLSL.h
index 1c1cb1ab97..d310066171 100644
--- a/src/3rdparty/angle/src/compiler/VersionGLSL.h
+++ b/src/3rdparty/angle/src/compiler/translator/VersionGLSL.h
@@ -8,7 +8,7 @@
#define COMPILER_VERSIONGLSL_H_
#include "GLSLANG/ShaderLang.h"
-#include "compiler/intermediate.h"
+#include "compiler/translator/intermediate.h"
// Traverses the intermediate tree to return the minimum GLSL version
// required to legally access all built-in features used in the shader.
diff --git a/src/3rdparty/angle/src/compiler/debug.cpp b/src/3rdparty/angle/src/compiler/translator/compilerdebug.cpp
index 53778bd3eb..10cbe43b8d 100644
--- a/src/3rdparty/angle/src/compiler/debug.cpp
+++ b/src/3rdparty/angle/src/compiler/translator/compilerdebug.cpp
@@ -6,17 +6,17 @@
// debug.cpp: Debugging utilities.
-#include "compiler/debug.h"
+#include "compiler/translator/compilerdebug.h"
#include <stdarg.h>
#include <stdio.h>
-#include "compiler/InitializeParseContext.h"
-#include "compiler/ParseHelper.h"
+#include "compiler/translator/InitializeParseContext.h"
+#include "compiler/translator/ParseContext.h"
+#ifdef TRACE_ENABLED
static const int kTraceBufferLen = 1024;
-#ifdef TRACE_ENABLED
extern "C" {
void Trace(const char *format, ...) {
if (!format) return;
diff --git a/src/3rdparty/angle/src/compiler/debug.h b/src/3rdparty/angle/src/compiler/translator/compilerdebug.h
index 7a371516af..7a371516af 100644
--- a/src/3rdparty/angle/src/compiler/debug.h
+++ b/src/3rdparty/angle/src/compiler/translator/compilerdebug.h
diff --git a/src/3rdparty/angle/src/compiler/depgraph/DependencyGraph.cpp b/src/3rdparty/angle/src/compiler/translator/depgraph/DependencyGraph.cpp
index ca661d6767..19ddf5c439 100644
--- a/src/3rdparty/angle/src/compiler/depgraph/DependencyGraph.cpp
+++ b/src/3rdparty/angle/src/compiler/translator/depgraph/DependencyGraph.cpp
@@ -6,8 +6,8 @@
#pragma warning(disable: 4718)
-#include "compiler/depgraph/DependencyGraph.h"
-#include "compiler/depgraph/DependencyGraphBuilder.h"
+#include "compiler/translator/depgraph/DependencyGraph.h"
+#include "compiler/translator/depgraph/DependencyGraphBuilder.h"
TDependencyGraph::TDependencyGraph(TIntermNode* intermNode)
{
diff --git a/src/3rdparty/angle/src/compiler/depgraph/DependencyGraph.h b/src/3rdparty/angle/src/compiler/translator/depgraph/DependencyGraph.h
index 5a9c35d00b..5ea1cbb837 100644
--- a/src/3rdparty/angle/src/compiler/depgraph/DependencyGraph.h
+++ b/src/3rdparty/angle/src/compiler/translator/depgraph/DependencyGraph.h
@@ -7,7 +7,7 @@
#ifndef COMPILER_DEPGRAPH_DEPENDENCY_GRAPH_H
#define COMPILER_DEPGRAPH_DEPENDENCY_GRAPH_H
-#include "compiler/intermediate.h"
+#include "compiler/translator/intermediate.h"
#include <set>
#include <stack>
diff --git a/src/3rdparty/angle/src/compiler/depgraph/DependencyGraphBuilder.cpp b/src/3rdparty/angle/src/compiler/translator/depgraph/DependencyGraphBuilder.cpp
index d586cfd03c..d5f2cba5fc 100644
--- a/src/3rdparty/angle/src/compiler/depgraph/DependencyGraphBuilder.cpp
+++ b/src/3rdparty/angle/src/compiler/translator/depgraph/DependencyGraphBuilder.cpp
@@ -4,7 +4,7 @@
// found in the LICENSE file.
//
-#include "compiler/depgraph/DependencyGraphBuilder.h"
+#include "compiler/translator/depgraph/DependencyGraphBuilder.h"
void TDependencyGraphBuilder::build(TIntermNode* node, TDependencyGraph* graph)
{
@@ -94,7 +94,7 @@ void TDependencyGraphBuilder::visitSymbol(TIntermSymbol* intermSymbol)
bool TDependencyGraphBuilder::visitBinary(Visit visit, TIntermBinary* intermBinary)
{
TOperator op = intermBinary->getOp();
- if (op == EOpInitialize || intermBinary->modifiesState())
+ if (op == EOpInitialize || intermBinary->isAssignment())
visitAssignment(intermBinary);
else if (op == EOpLogicalAnd || op == EOpLogicalOr)
visitLogicalOp(intermBinary);
diff --git a/src/3rdparty/angle/src/compiler/depgraph/DependencyGraphBuilder.h b/src/3rdparty/angle/src/compiler/translator/depgraph/DependencyGraphBuilder.h
index c5f232cb21..3e928fb77e 100644
--- a/src/3rdparty/angle/src/compiler/depgraph/DependencyGraphBuilder.h
+++ b/src/3rdparty/angle/src/compiler/translator/depgraph/DependencyGraphBuilder.h
@@ -7,7 +7,7 @@
#ifndef COMPILER_DEPGRAPH_DEPENDENCY_GRAPH_BUILDER_H
#define COMPILER_DEPGRAPH_DEPENDENCY_GRAPH_BUILDER_H
-#include "compiler/depgraph/DependencyGraph.h"
+#include "compiler/translator/depgraph/DependencyGraph.h"
//
// Creates a dependency graph of symbols, function calls, conditions etc. by traversing a
diff --git a/src/3rdparty/angle/src/compiler/depgraph/DependencyGraphOutput.cpp b/src/3rdparty/angle/src/compiler/translator/depgraph/DependencyGraphOutput.cpp
index 6fc489e7b6..e226333545 100644
--- a/src/3rdparty/angle/src/compiler/depgraph/DependencyGraphOutput.cpp
+++ b/src/3rdparty/angle/src/compiler/translator/depgraph/DependencyGraphOutput.cpp
@@ -4,7 +4,7 @@
// found in the LICENSE file.
//
-#include "compiler/depgraph/DependencyGraphOutput.h"
+#include "compiler/translator/depgraph/DependencyGraphOutput.h"
void TDependencyGraphOutput::outputIndentation()
{
diff --git a/src/3rdparty/angle/src/compiler/depgraph/DependencyGraphOutput.h b/src/3rdparty/angle/src/compiler/translator/depgraph/DependencyGraphOutput.h
index 01447da987..c3a4112278 100644
--- a/src/3rdparty/angle/src/compiler/depgraph/DependencyGraphOutput.h
+++ b/src/3rdparty/angle/src/compiler/translator/depgraph/DependencyGraphOutput.h
@@ -7,8 +7,8 @@
#ifndef COMPILER_DEPGRAPH_DEPENDENCY_GRAPH_OUTPUT_H
#define COMPILER_DEPGRAPH_DEPENDENCY_GRAPH_OUTPUT_H
-#include "compiler/depgraph/DependencyGraph.h"
-#include "compiler/InfoSink.h"
+#include "compiler/translator/depgraph/DependencyGraph.h"
+#include "compiler/translator/InfoSink.h"
class TDependencyGraphOutput : public TDependencyGraphTraverser {
public:
diff --git a/src/3rdparty/angle/src/compiler/depgraph/DependencyGraphTraverse.cpp b/src/3rdparty/angle/src/compiler/translator/depgraph/DependencyGraphTraverse.cpp
index b158575cec..197fde97e2 100644
--- a/src/3rdparty/angle/src/compiler/depgraph/DependencyGraphTraverse.cpp
+++ b/src/3rdparty/angle/src/compiler/translator/depgraph/DependencyGraphTraverse.cpp
@@ -4,7 +4,7 @@
// found in the LICENSE file.
//
-#include "compiler/depgraph/DependencyGraph.h"
+#include "compiler/translator/depgraph/DependencyGraph.h"
// These methods do a breadth-first traversal through the graph and mark visited nodes.
diff --git a/src/3rdparty/angle/src/compiler/glslang.h b/src/3rdparty/angle/src/compiler/translator/glslang.h
index f221199093..f221199093 100644
--- a/src/3rdparty/angle/src/compiler/glslang.h
+++ b/src/3rdparty/angle/src/compiler/translator/glslang.h
diff --git a/src/3rdparty/angle/src/compiler/glslang.l b/src/3rdparty/angle/src/compiler/translator/glslang.l
index 60663f9a6b..ffc1aa18ac 100644
--- a/src/3rdparty/angle/src/compiler/glslang.l
+++ b/src/3rdparty/angle/src/compiler/translator/glslang.l
@@ -36,10 +36,10 @@ WHICH GENERATES THE GLSL ES LEXER (glslang_lex.cpp).
}
%{
-#include "compiler/glslang.h"
-#include "compiler/ParseHelper.h"
+#include "compiler/translator/glslang.h"
+#include "compiler/translator/ParseContext.h"
#include "compiler/preprocessor/Token.h"
-#include "compiler/util.h"
+#include "compiler/translator/util.h"
#include "glslang_tab.h"
/* windows only pragma */
diff --git a/src/3rdparty/angle/src/compiler/glslang.y b/src/3rdparty/angle/src/compiler/translator/glslang.y
index c64f736f41..7614ff3447 100644
--- a/src/3rdparty/angle/src/compiler/glslang.y
+++ b/src/3rdparty/angle/src/compiler/translator/glslang.y
@@ -34,8 +34,8 @@ WHICH GENERATES THE GLSL ES PARSER (glslang_tab.cpp AND glslang_tab.h).
#pragma warning(disable: 4701)
#endif
-#include "compiler/SymbolTable.h"
-#include "compiler/ParseHelper.h"
+#include "compiler/translator/SymbolTable.h"
+#include "compiler/translator/ParseContext.h"
#include "GLSLANG/ShaderLang.h"
#define YYENABLE_NLS 0
@@ -183,43 +183,55 @@ identifier
variable_identifier
: IDENTIFIER {
// The symbol table search was done in the lexical phase
- const TSymbol* symbol = $1.symbol;
- const TVariable* variable;
- if (symbol == 0) {
+ const TSymbol *symbol = $1.symbol;
+ const TVariable *variable = 0;
+
+ if (!symbol)
+ {
context->error(@1, "undeclared identifier", $1.string->c_str());
context->recover();
- TType type(EbtFloat, EbpUndefined);
- TVariable* fakeVariable = new TVariable($1.string, type);
- context->symbolTable.insert(*fakeVariable);
- variable = fakeVariable;
- } else {
- // This identifier can only be a variable type symbol
- if (! symbol->isVariable()) {
- context->error(@1, "variable expected", $1.string->c_str());
- context->recover();
- }
-
+ }
+ else if (!symbol->isVariable())
+ {
+ context->error(@1, "variable expected", $1.string->c_str());
+ context->recover();
+ }
+ else
+ {
variable = static_cast<const TVariable*>(symbol);
if (context->symbolTable.findBuiltIn(variable->getName()) &&
!variable->getExtension().empty() &&
- context->extensionErrorCheck(@1, variable->getExtension())) {
+ context->extensionErrorCheck(@1, variable->getExtension()))
+ {
context->recover();
}
}
- // don't delete $1.string, it's used by error recovery, and the pool
- // pop will reclaim the memory
+ if (!variable)
+ {
+ TType type(EbtFloat, EbpUndefined);
+ TVariable *fakeVariable = new TVariable($1.string, type);
+ context->symbolTable.insert(*fakeVariable);
+ variable = fakeVariable;
+ }
- if (variable->getType().getQualifier() == EvqConst ) {
+ if (variable->getType().getQualifier() == EvqConst)
+ {
ConstantUnion* constArray = variable->getConstPointer();
TType t(variable->getType());
$$ = context->intermediate.addConstantUnion(constArray, t, @1);
- } else
+ }
+ else
+ {
$$ = context->intermediate.addSymbol(variable->getUniqueId(),
variable->getName(),
variable->getType(),
@1);
+ }
+
+ // don't delete $1.string, it's used by error recovery, and the pool
+ // pop will reclaim the memory
}
;
diff --git a/src/3rdparty/angle/src/compiler/intermOut.cpp b/src/3rdparty/angle/src/compiler/translator/intermOut.cpp
index 13aa96af6d..f2f918d77a 100644
--- a/src/3rdparty/angle/src/compiler/intermOut.cpp
+++ b/src/3rdparty/angle/src/compiler/translator/intermOut.cpp
@@ -4,7 +4,7 @@
// found in the LICENSE file.
//
-#include "compiler/localintermediate.h"
+#include "compiler/translator/localintermediate.h"
//
// Two purposes:
@@ -44,9 +44,9 @@ TString TType::getCompleteString() const
if (array)
stream << "array[" << getArraySize() << "] of ";
if (matrix)
- stream << size << "X" << size << " matrix of ";
+ stream << static_cast<int>(size) << "X" << static_cast<int>(size) << " matrix of ";
else if (size > 1)
- stream << size << "-component vector of ";
+ stream << static_cast<int>(size) << "-component vector of ";
stream << getBasicString();
return stream.str();
diff --git a/src/3rdparty/angle/src/compiler/intermediate.h b/src/3rdparty/angle/src/compiler/translator/intermediate.h
index 738621fe70..8f9fe23d3b 100644
--- a/src/3rdparty/angle/src/compiler/intermediate.h
+++ b/src/3rdparty/angle/src/compiler/translator/intermediate.h
@@ -19,9 +19,9 @@
#include "GLSLANG/ShaderLang.h"
#include <algorithm>
-#include "compiler/Common.h"
-#include "compiler/Types.h"
-#include "compiler/ConstantUnion.h"
+#include "compiler/translator/Common.h"
+#include "compiler/translator/Types.h"
+#include "compiler/translator/ConstantUnion.h"
//
// Operators used by the high-level (parse tree) representation.
@@ -227,6 +227,11 @@ public:
virtual TIntermSymbol* getAsSymbolNode() { return 0; }
virtual TIntermLoop* getAsLoopNode() { return 0; }
+ // Replace a child node. Return true if |original| is a child
+ // node and it is replaced; otherwise, return false.
+ virtual bool replaceChildNode(
+ TIntermNode *original, TIntermNode *replacement) = 0;
+
protected:
TSourceLoc line;
};
@@ -247,6 +252,8 @@ public:
TIntermTyped(const TType& t) : type(t) { }
virtual TIntermTyped* getAsTyped() { return this; }
+ virtual bool hasSideEffects() const = 0;
+
void setType(const TType& t) { type = t; }
const TType& getType() const { return type; }
TType* getTypePointer() { return &type; }
@@ -295,6 +302,8 @@ public:
virtual TIntermLoop* getAsLoopNode() { return this; }
virtual void traverse(TIntermTraverser*);
+ virtual bool replaceChildNode(
+ TIntermNode *original, TIntermNode *replacement);
TLoopType getType() const { return type; }
TIntermNode* getInit() { return init; }
@@ -325,6 +334,8 @@ public:
expression(e) { }
virtual void traverse(TIntermTraverser*);
+ virtual bool replaceChildNode(
+ TIntermNode *original, TIntermNode *replacement);
TOperator getFlowOp() { return flowOp; }
TIntermTyped* getExpression() { return expression; }
@@ -345,6 +356,8 @@ public:
TIntermSymbol(int i, const TString& sym, const TType& t) :
TIntermTyped(t), id(i) { symbol = sym; originalSymbol = sym; }
+ virtual bool hasSideEffects() const { return false; }
+
int getId() const { return id; }
const TString& getSymbol() const { return symbol; }
@@ -355,6 +368,7 @@ public:
virtual void traverse(TIntermTraverser*);
virtual TIntermSymbol* getAsSymbolNode() { return this; }
+ virtual bool replaceChildNode(TIntermNode *, TIntermNode *) { return false; }
protected:
int id;
@@ -366,14 +380,17 @@ class TIntermConstantUnion : public TIntermTyped {
public:
TIntermConstantUnion(ConstantUnion *unionPointer, const TType& t) : TIntermTyped(t), unionArrayPointer(unionPointer) { }
+ virtual bool hasSideEffects() const { return false; }
+
ConstantUnion* getUnionArrayPointer() const { return unionArrayPointer; }
- int getIConst(int index) const { return unionArrayPointer ? unionArrayPointer[index].getIConst() : 0; }
- float getFConst(int index) const { return unionArrayPointer ? unionArrayPointer[index].getFConst() : 0.0f; }
- bool getBConst(int index) const { return unionArrayPointer ? unionArrayPointer[index].getBConst() : false; }
+ int getIConst(size_t index) const { return unionArrayPointer ? unionArrayPointer[index].getIConst() : 0; }
+ float getFConst(size_t index) const { return unionArrayPointer ? unionArrayPointer[index].getFConst() : 0.0f; }
+ bool getBConst(size_t index) const { return unionArrayPointer ? unionArrayPointer[index].getBConst() : false; }
virtual TIntermConstantUnion* getAsConstantUnion() { return this; }
virtual void traverse(TIntermTraverser*);
+ virtual bool replaceChildNode(TIntermNode *, TIntermNode *) { return false; }
TIntermTyped* fold(TOperator, TIntermTyped*, TInfoSink&);
@@ -389,12 +406,14 @@ public:
TOperator getOp() const { return op; }
void setOp(TOperator o) { op = o; }
- bool modifiesState() const;
+ bool isAssignment() const;
bool isConstructor() const;
+ virtual bool hasSideEffects() const { return isAssignment(); }
+
protected:
TIntermOperator(TOperator o) : TIntermTyped(TType(EbtFloat, EbpUndefined)), op(o) {}
- TIntermOperator(TOperator o, TType& t) : TIntermTyped(t), op(o) {}
+ TIntermOperator(TOperator o, const TType& t) : TIntermTyped(t), op(o) {}
TOperator op;
};
@@ -407,6 +426,10 @@ public:
virtual TIntermBinary* getAsBinaryNode() { return this; }
virtual void traverse(TIntermTraverser*);
+ virtual bool replaceChildNode(
+ TIntermNode *original, TIntermNode *replacement);
+
+ virtual bool hasSideEffects() const { return (isAssignment() || left->hasSideEffects() || right->hasSideEffects()); }
void setLeft(TIntermTyped* n) { left = n; }
void setRight(TIntermTyped* n) { right = n; }
@@ -430,11 +453,15 @@ protected:
//
class TIntermUnary : public TIntermOperator {
public:
- TIntermUnary(TOperator o, TType& t) : TIntermOperator(o, t), operand(0), useEmulatedFunction(false) {}
+ TIntermUnary(TOperator o, const TType& t) : TIntermOperator(o, t), operand(0), useEmulatedFunction(false) {}
TIntermUnary(TOperator o) : TIntermOperator(o), operand(0), useEmulatedFunction(false) {}
virtual void traverse(TIntermTraverser*);
virtual TIntermUnary* getAsUnaryNode() { return this; }
+ virtual bool replaceChildNode(
+ TIntermNode *original, TIntermNode *replacement);
+
+ virtual bool hasSideEffects() const { return (isAssignment() || operand->hasSideEffects()); }
void setOperand(TIntermTyped* o) { operand = o; }
TIntermTyped* getOperand() { return operand; }
@@ -465,6 +492,11 @@ public:
virtual TIntermAggregate* getAsAggregate() { return this; }
virtual void traverse(TIntermTraverser*);
+ virtual bool replaceChildNode(
+ TIntermNode *original, TIntermNode *replacement);
+
+ // Conservatively assume function calls and other aggregate operators have side-effects
+ virtual bool hasSideEffects() const { return true; }
TIntermSequence& getSequence() { return sequence; }
@@ -508,6 +540,11 @@ public:
TIntermTyped(type), condition(cond), trueBlock(trueB), falseBlock(falseB) {}
virtual void traverse(TIntermTraverser*);
+ virtual bool replaceChildNode(
+ TIntermNode *original, TIntermNode *replacement);
+
+ // Conservatively assume selections have side-effects
+ virtual bool hasSideEffects() const { return true; }
bool usesTernaryOperator() const { return getBasicType() != EbtVoid; }
TIntermNode* getCondition() const { return condition; }
@@ -547,7 +584,7 @@ public:
rightToLeft(rightToLeft),
depth(0),
maxDepth(0) {}
- virtual ~TIntermTraverser() {};
+ virtual ~TIntermTraverser() {}
virtual void visitSymbol(TIntermSymbol*) {}
virtual void visitConstantUnion(TIntermConstantUnion*) {}
@@ -559,8 +596,24 @@ public:
virtual bool visitBranch(Visit visit, TIntermBranch*) {return true;}
int getMaxDepth() const {return maxDepth;}
- void incrementDepth() {depth++; maxDepth = std::max(maxDepth, depth); }
- void decrementDepth() {depth--;}
+
+ void incrementDepth(TIntermNode *current)
+ {
+ depth++;
+ maxDepth = std::max(maxDepth, depth);
+ path.push_back(current);
+ }
+
+ void decrementDepth()
+ {
+ depth--;
+ path.pop_back();
+ }
+
+ TIntermNode *getParentNode()
+ {
+ return path.size() == 0 ? NULL : path.back();
+ }
// Return the original name if hash function pointer is NULL;
// otherwise return the hashed name.
@@ -574,6 +627,9 @@ public:
protected:
int depth;
int maxDepth;
+
+ // All the nodes from root to the current node's parent during traversing.
+ TVector<TIntermNode *> path;
};
#endif // __INTERMEDIATE_H
diff --git a/src/3rdparty/angle/src/compiler/localintermediate.h b/src/3rdparty/angle/src/compiler/translator/localintermediate.h
index 1214d821eb..b582e02f5d 100644
--- a/src/3rdparty/angle/src/compiler/localintermediate.h
+++ b/src/3rdparty/angle/src/compiler/translator/localintermediate.h
@@ -8,8 +8,8 @@
#define _LOCAL_INTERMEDIATE_INCLUDED_
#include "GLSLANG/ShaderLang.h"
-#include "compiler/intermediate.h"
-#include "compiler/SymbolTable.h"
+#include "compiler/translator/intermediate.h"
+#include "compiler/translator/SymbolTable.h"
struct TVectorFields {
int offsets[4];
@@ -39,7 +39,7 @@ public:
TIntermTyped* addComma(TIntermTyped* left, TIntermTyped* right, const TSourceLoc&);
TIntermConstantUnion* addConstantUnion(ConstantUnion*, const TType&, const TSourceLoc&);
TIntermTyped* promoteConstantUnion(TBasicType, TIntermConstantUnion*) ;
- bool parseConstTree(const TSourceLoc&, TIntermNode*, ConstantUnion*, TOperator, TSymbolTable&, TType, bool singleConstantParam = false);
+ bool parseConstTree(const TSourceLoc&, TIntermNode*, ConstantUnion*, TOperator, TSymbolTable&, TType, bool singleConstantParam = false);
TIntermNode* addLoop(TLoopType, TIntermNode*, TIntermTyped*, TIntermTyped*, TIntermNode*, const TSourceLoc&);
TIntermBranch* addBranch(TOperator, const TSourceLoc&);
TIntermBranch* addBranch(TOperator, TIntermTyped*, const TSourceLoc&);
diff --git a/src/3rdparty/angle/src/compiler/osinclude.h b/src/3rdparty/angle/src/compiler/translator/osinclude.h
index 60177d5fe5..cccfa6355c 100644
--- a/src/3rdparty/angle/src/compiler/osinclude.h
+++ b/src/3rdparty/angle/src/compiler/translator/osinclude.h
@@ -13,9 +13,6 @@
//
#if defined(_WIN32) || defined(_WIN64)
-#define STRICT
-#define VC_EXTRALEAN 1
-#include <windows.h>
#if defined(WINAPI_FAMILY) && (WINAPI_FAMILY==WINAPI_FAMILY_APP || WINAPI_FAMILY==WINAPI_FAMILY_PHONE_APP)
#define ANGLE_OS_WINRT
#else
@@ -23,18 +20,27 @@
#endif
#elif defined(__APPLE__) || defined(__linux__) || \
defined(__FreeBSD__) || defined(__OpenBSD__) || \
+ defined(__NetBSD__) || defined(__DragonFly__) || \
defined(__sun) || defined(ANDROID) || \
defined(__GLIBC__) || defined(__GNU__) || \
defined(__QNX__)
#define ANGLE_OS_POSIX
-#include <pthread.h>
-#include <semaphore.h>
-#include <errno.h>
#else
#error Unsupported platform.
#endif
-#include "compiler/debug.h"
+#if defined(ANGLE_OS_WIN) || defined(ANGLE_OS_WINRT)
+#define STRICT
+#define VC_EXTRALEAN 1
+#include <windows.h>
+#elif defined(ANGLE_OS_POSIX)
+#include <pthread.h>
+#include <semaphore.h>
+#include <errno.h>
+#endif // ANGLE_OS_WIN
+
+
+#include "compiler/translator/compilerdebug.h"
//
// Thread Local Storage Operations
diff --git a/src/3rdparty/angle/src/compiler/ossource_posix.cpp b/src/3rdparty/angle/src/compiler/translator/ossource_posix.cpp
index 35510c1af5..d4bba4c70e 100644
--- a/src/3rdparty/angle/src/compiler/ossource_posix.cpp
+++ b/src/3rdparty/angle/src/compiler/translator/ossource_posix.cpp
@@ -7,7 +7,7 @@
//
// This file contains the posix specific functions
//
-#include "compiler/osinclude.h"
+#include "compiler/translator/osinclude.h"
#if !defined(ANGLE_OS_POSIX)
#error Trying to build a posix specific file in a non-posix build.
diff --git a/src/3rdparty/angle/src/compiler/ossource_win.cpp b/src/3rdparty/angle/src/compiler/translator/ossource_win.cpp
index 708a1ad311..abd8bc7833 100644
--- a/src/3rdparty/angle/src/compiler/ossource_win.cpp
+++ b/src/3rdparty/angle/src/compiler/translator/ossource_win.cpp
@@ -4,7 +4,7 @@
// found in the LICENSE file.
//
-#include "compiler/osinclude.h"
+#include "compiler/translator/osinclude.h"
//
// This file contains contains the window's specific functions
//
diff --git a/src/3rdparty/angle/src/compiler/ossource_winrt.cpp b/src/3rdparty/angle/src/compiler/translator/ossource_winrt.cpp
index 84443abc02..bb061ca85d 100644
--- a/src/3rdparty/angle/src/compiler/ossource_winrt.cpp
+++ b/src/3rdparty/angle/src/compiler/translator/ossource_winrt.cpp
@@ -4,7 +4,7 @@
// found in the LICENSE file.
//
-#include "compiler/osinclude.h"
+#include "compiler/translator/osinclude.h"
//
// This file contains contains Windows Runtime specific functions
//
diff --git a/src/3rdparty/angle/src/compiler/parseConst.cpp b/src/3rdparty/angle/src/compiler/translator/parseConst.cpp
index 1cc5db8d77..a59f0be9d8 100644
--- a/src/3rdparty/angle/src/compiler/parseConst.cpp
+++ b/src/3rdparty/angle/src/compiler/translator/parseConst.cpp
@@ -4,7 +4,7 @@
// found in the LICENSE file.
//
-#include "compiler/ParseHelper.h"
+#include "compiler/translator/ParseContext.h"
//
// Use this class to carry along data from node to node in
diff --git a/src/3rdparty/angle/src/compiler/timing/RestrictFragmentShaderTiming.cpp b/src/3rdparty/angle/src/compiler/translator/timing/RestrictFragmentShaderTiming.cpp
index 538b731b8e..a9f3f49ef3 100644
--- a/src/3rdparty/angle/src/compiler/timing/RestrictFragmentShaderTiming.cpp
+++ b/src/3rdparty/angle/src/compiler/translator/timing/RestrictFragmentShaderTiming.cpp
@@ -4,10 +4,10 @@
// found in the LICENSE file.
//
-#include "compiler/InfoSink.h"
-#include "compiler/ParseHelper.h"
-#include "compiler/depgraph/DependencyGraphOutput.h"
-#include "compiler/timing/RestrictFragmentShaderTiming.h"
+#include "compiler/translator/InfoSink.h"
+#include "compiler/translator/ParseContext.h"
+#include "compiler/translator/depgraph/DependencyGraphOutput.h"
+#include "compiler/translator/timing/RestrictFragmentShaderTiming.h"
RestrictFragmentShaderTiming::RestrictFragmentShaderTiming(TInfoSinkBase& sink)
: mSink(sink)
diff --git a/src/3rdparty/angle/src/compiler/timing/RestrictFragmentShaderTiming.h b/src/3rdparty/angle/src/compiler/translator/timing/RestrictFragmentShaderTiming.h
index 899165ca28..323cb62d8a 100644
--- a/src/3rdparty/angle/src/compiler/timing/RestrictFragmentShaderTiming.h
+++ b/src/3rdparty/angle/src/compiler/translator/timing/RestrictFragmentShaderTiming.h
@@ -9,8 +9,8 @@
#include "GLSLANG/ShaderLang.h"
-#include "compiler/intermediate.h"
-#include "compiler/depgraph/DependencyGraph.h"
+#include "compiler/translator/intermediate.h"
+#include "compiler/translator/depgraph/DependencyGraph.h"
class TInfoSinkBase;
diff --git a/src/3rdparty/angle/src/compiler/timing/RestrictVertexShaderTiming.cpp b/src/3rdparty/angle/src/compiler/translator/timing/RestrictVertexShaderTiming.cpp
index 355eb62d65..ee78c35450 100644
--- a/src/3rdparty/angle/src/compiler/timing/RestrictVertexShaderTiming.cpp
+++ b/src/3rdparty/angle/src/compiler/translator/timing/RestrictVertexShaderTiming.cpp
@@ -4,7 +4,7 @@
// found in the LICENSE file.
//
-#include "compiler/timing/RestrictVertexShaderTiming.h"
+#include "compiler/translator/timing/RestrictVertexShaderTiming.h"
void RestrictVertexShaderTiming::visitSymbol(TIntermSymbol* node)
{
diff --git a/src/3rdparty/angle/src/compiler/timing/RestrictVertexShaderTiming.h b/src/3rdparty/angle/src/compiler/translator/timing/RestrictVertexShaderTiming.h
index 19a05fa68b..5f0dd3197a 100644
--- a/src/3rdparty/angle/src/compiler/timing/RestrictVertexShaderTiming.h
+++ b/src/3rdparty/angle/src/compiler/translator/timing/RestrictVertexShaderTiming.h
@@ -9,8 +9,8 @@
#include "GLSLANG/ShaderLang.h"
-#include "compiler/intermediate.h"
-#include "compiler/InfoSink.h"
+#include "compiler/translator/intermediate.h"
+#include "compiler/translator/InfoSink.h"
class TInfoSinkBase;
diff --git a/src/3rdparty/angle/src/compiler/util.cpp b/src/3rdparty/angle/src/compiler/translator/util.cpp
index d6e5eeed91..077bdcc48b 100644
--- a/src/3rdparty/angle/src/compiler/util.cpp
+++ b/src/3rdparty/angle/src/compiler/translator/util.cpp
@@ -4,7 +4,7 @@
// found in the LICENSE file.
//
-#include "compiler/util.h"
+#include "compiler/translator/util.h"
#include <limits>
diff --git a/src/3rdparty/angle/src/compiler/util.h b/src/3rdparty/angle/src/compiler/translator/util.h
index dc69f39060..dc69f39060 100644
--- a/src/3rdparty/angle/src/compiler/util.h
+++ b/src/3rdparty/angle/src/compiler/translator/util.h