summaryrefslogtreecommitdiff
path: root/Source/ThirdParty
diff options
context:
space:
mode:
authorSimon Hausmann <simon.hausmann@digia.com>2012-10-22 15:40:17 +0200
committerSimon Hausmann <simon.hausmann@digia.com>2012-10-22 15:40:17 +0200
commit43a42f108af6bcbd91f2672731c3047c26213af1 (patch)
tree7fa092e5f5d873c72f2486a70e26be26f7a38bec /Source/ThirdParty
parentd9cf437c840c6eb7417bdd97e6c40979255d3158 (diff)
downloadqtwebkit-43a42f108af6bcbd91f2672731c3047c26213af1.tar.gz
Imported WebKit commit 302e7806bff028bd1167a1ec7c86a1ee00ecfb49 (http://svn.webkit.org/repository/webkit/trunk@132067)
New snapshot that fixes build without QtWidgets
Diffstat (limited to 'Source/ThirdParty')
-rw-r--r--Source/ThirdParty/ANGLE/ANGLE.xcodeproj/project.pbxproj8
-rw-r--r--Source/ThirdParty/ANGLE/ChangeLog56
-rw-r--r--Source/ThirdParty/ANGLE/Target.pri2
-rw-r--r--Source/ThirdParty/ANGLE/include/GLSLANG/ShaderLang.h8
-rw-r--r--Source/ThirdParty/ANGLE/src/compiler/ArrayBoundsClamper.cpp88
-rw-r--r--Source/ThirdParty/ANGLE/src/compiler/ArrayBoundsClamper.h57
-rw-r--r--Source/ThirdParty/ANGLE/src/compiler/Compiler.cpp12
-rw-r--r--Source/ThirdParty/ANGLE/src/compiler/OutputGLSLBase.cpp31
-rw-r--r--Source/ThirdParty/ANGLE/src/compiler/ShHandle.h3
-rw-r--r--Source/ThirdParty/ANGLE/src/compiler/TranslatorESSL.cpp3
-rw-r--r--Source/ThirdParty/ANGLE/src/compiler/TranslatorGLSL.cpp3
-rw-r--r--Source/ThirdParty/ANGLE/src/compiler/intermOut.cpp2
-rw-r--r--Source/ThirdParty/ANGLE/src/compiler/intermediate.h6
13 files changed, 276 insertions, 3 deletions
diff --git a/Source/ThirdParty/ANGLE/ANGLE.xcodeproj/project.pbxproj b/Source/ThirdParty/ANGLE/ANGLE.xcodeproj/project.pbxproj
index 8f2be60f5..3207eca8a 100644
--- a/Source/ThirdParty/ANGLE/ANGLE.xcodeproj/project.pbxproj
+++ b/Source/ThirdParty/ANGLE/ANGLE.xcodeproj/project.pbxproj
@@ -9,6 +9,8 @@
/* Begin PBXBuildFile section */
312BDB0C15FECAC90097EBC7 /* ANGLE.plist in CopyFiles */ = {isa = PBXBuildFile; fileRef = 312BDB0915FEC91E0097EBC7 /* ANGLE.plist */; };
312BDB0E15FECAE50097EBC7 /* ANGLE.txt in CopyFiles */ = {isa = PBXBuildFile; fileRef = 312BDB0A15FECA3A0097EBC7 /* ANGLE.txt */; };
+ 3158EA0E1630968D006BE5EE /* ArrayBoundsClamper.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3158EA0C1630968D006BE5EE /* ArrayBoundsClamper.cpp */; };
+ 3158EA0F1630968D006BE5EE /* ArrayBoundsClamper.h in Headers */ = {isa = PBXBuildFile; fileRef = 3158EA0D1630968D006BE5EE /* ArrayBoundsClamper.h */; };
49951C0314B7AAB30060E96E /* length_limits.h in Headers */ = {isa = PBXBuildFile; fileRef = 49951C0214B7AAB30060E96E /* length_limits.h */; };
49951C0914B7AAD80060E96E /* BuiltInFunctionEmulator.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 49951C0514B7AAD70060E96E /* BuiltInFunctionEmulator.cpp */; };
49951C0A14B7AAD80060E96E /* BuiltInFunctionEmulator.h in Headers */ = {isa = PBXBuildFile; fileRef = 49951C0614B7AAD80060E96E /* BuiltInFunctionEmulator.h */; };
@@ -136,6 +138,8 @@
/* Begin PBXFileReference section */
312BDB0915FEC91E0097EBC7 /* ANGLE.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = ANGLE.plist; sourceTree = "<group>"; };
312BDB0A15FECA3A0097EBC7 /* ANGLE.txt */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = ANGLE.txt; sourceTree = "<group>"; };
+ 3158EA0C1630968D006BE5EE /* ArrayBoundsClamper.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ArrayBoundsClamper.cpp; sourceTree = "<group>"; };
+ 3158EA0D1630968D006BE5EE /* ArrayBoundsClamper.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ArrayBoundsClamper.h; sourceTree = "<group>"; };
49951C0214B7AAB30060E96E /* length_limits.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = length_limits.h; sourceTree = "<group>"; };
49951C0514B7AAD70060E96E /* BuiltInFunctionEmulator.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = BuiltInFunctionEmulator.cpp; sourceTree = "<group>"; };
49951C0614B7AAD80060E96E /* BuiltInFunctionEmulator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BuiltInFunctionEmulator.h; sourceTree = "<group>"; };
@@ -544,6 +548,8 @@
FB39D2201200F35A00088E69 /* compiler */ = {
isa = PBXGroup;
children = (
+ 3158EA0C1630968D006BE5EE /* ArrayBoundsClamper.cpp */,
+ 3158EA0D1630968D006BE5EE /* ArrayBoundsClamper.h */,
FB39D2211200F35A00088E69 /* BaseTypes.h */,
49951C0514B7AAD70060E96E /* BuiltInFunctionEmulator.cpp */,
49951C0614B7AAD80060E96E /* BuiltInFunctionEmulator.h */,
@@ -712,6 +718,7 @@
A265683E159C23E100398539 /* DependencyGraphOutput.h in Headers */,
A2656841159C23E100398539 /* RestrictFragmentShaderTiming.h in Headers */,
A2656843159C23E100398539 /* RestrictVertexShaderTiming.h in Headers */,
+ 3158EA0F1630968D006BE5EE /* ArrayBoundsClamper.h in Headers */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -829,6 +836,7 @@
A265683F159C23E100398539 /* DependencyGraphTraverse.cpp in Sources */,
A2656840159C23E100398539 /* RestrictFragmentShaderTiming.cpp in Sources */,
A2656842159C23E100398539 /* RestrictVertexShaderTiming.cpp in Sources */,
+ 3158EA0E1630968D006BE5EE /* ArrayBoundsClamper.cpp in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
diff --git a/Source/ThirdParty/ANGLE/ChangeLog b/Source/ThirdParty/ANGLE/ChangeLog
index dbb15212d..bc892b5c1 100644
--- a/Source/ThirdParty/ANGLE/ChangeLog
+++ b/Source/ThirdParty/ANGLE/ChangeLog
@@ -1,3 +1,59 @@
+2012-10-18 Dean Jackson <dino@apple.com>
+
+ Shader translator needs option to clamp uniform array accesses in vertex shaders
+ https://bugs.webkit.org/show_bug.cgi?id=98977
+ https://code.google.com/p/angleproject/issues/detail?id=49
+
+ Reviewed by Alok Priyadarshi and Ken Russell.
+
+ WebGL does not allow GLSL code to index a uniform array outside its bounds. Add a
+ flag to the ANGLE compiler to insert clamp statements around such indexing.
+ Since it is possible to access vec2/3/4 and mat2/3/4 components by array indexing,
+ they must be similarly clamped.
+
+ Unfortunately, it is currently not possible to always determine that the indexing is
+ operating on a uniform variable. For example, suppose we have "uniform mat4 a". ANGLE
+ is currently not able to tell us that the rvalue of "a[0]" is a uniform, just that
+ it has a size of 4. Therefore, the clamping is done on all indirect array indexing.
+
+ This will have a performance impact. Future enhancements may be able to determine
+ cases where the clamping is not necessary. Currently only direct indexing is skipped
+ (i.e. looking up a value using a constant index).
+
+ The clamp insertion is only performed on the GLSL output. Direct3D already guarantees
+ that out-of-bounds uniform array access returns a zero value.
+
+ * ANGLE.xcodeproj/project.pbxproj:
+ * Target.pri:
+ * include/GLSLANG/ShaderLang.h: New compiler option.
+ * src/compiler/ArrayBoundsClamper.cpp: Added.
+ (ArrayBoundsClamper::ArrayBoundsClamper):
+ (ArrayBoundsClamper::OutputClampingFunctionDefinition): Injects a clamping function for integers into GLSL source.
+ (ArrayBoundsClamper::MarkIndirectArrayBoundsForClamping): Examines the AST looking for non-direct array indexing.
+ * src/compiler/ArrayBoundsClamper.h: Added.
+ (ArrayBoundsClamper):
+ (ArrayBoundsClamper::GetArrayBoundsClampDefinitionNeeded):
+ (ArrayBoundsClamper::SetArrayBoundsClampDefinitionNeeded): Marks the object as needing to output the clamping function.
+ (ArrayBoundsClamper::Cleanup): Resets the state so that subsequent runs start fresh.
+ * src/compiler/Compiler.cpp:
+ (TCompiler::compile): Run the clamping code if the compile option was set.
+ (TCompiler::clearResults):
+ (TCompiler::getArrayBoundsClamper):
+ * src/compiler/OutputGLSLBase.cpp:
+ (TOutputGLSLBase::visitBinary): If the expression has been flagged, insert an appropriate "clamp" statement.
+ * src/compiler/ShHandle.h:
+ (TCompiler):
+ * src/compiler/TranslatorESSL.cpp:
+ (TranslatorESSL::translate):
+ * src/compiler/TranslatorGLSL.cpp:
+ (TranslatorGLSL::translate):
+ * src/compiler/intermOut.cpp:
+ (TType::getCompleteString): Add array size to intermediate tree output.
+ * src/compiler/intermediate.h:
+ (TIntermBinary::setAddIndexClamp): New flag for indicating a binary expression needs clamping.
+ (TIntermBinary::getAddIndexClamp):
+ (TIntermBinary):
+
2012-09-13 Mark Rowe <mrowe@apple.com>
<rdar://problem/12255720> Fix the build with newer Clang
diff --git a/Source/ThirdParty/ANGLE/Target.pri b/Source/ThirdParty/ANGLE/Target.pri
index 4e9303ab7..eaa936d88 100644
--- a/Source/ThirdParty/ANGLE/Target.pri
+++ b/Source/ThirdParty/ANGLE/Target.pri
@@ -17,6 +17,7 @@ INCLUDEPATH += \
$$SOURCE_DIR/include
HEADERS += \
+ src/compiler/ArrayBoundsClamper.h \
src/compiler/BaseTypes.h \
src/compiler/BuiltInFunctionEmulator.h \
src/compiler/Common.h \
@@ -90,6 +91,7 @@ HEADERS += \
src/compiler/VersionGLSL.h
SOURCES += \
+ src/compiler/ArrayBoundsClamper.cpp \
src/compiler/BuiltInFunctionEmulator.cpp \
src/compiler/CodeGenGLSL.cpp \
src/compiler/Compiler.cpp \
diff --git a/Source/ThirdParty/ANGLE/include/GLSLANG/ShaderLang.h b/Source/ThirdParty/ANGLE/include/GLSLANG/ShaderLang.h
index 9a4a36dbf..d82931ea1 100644
--- a/Source/ThirdParty/ANGLE/include/GLSLANG/ShaderLang.h
+++ b/Source/ThirdParty/ANGLE/include/GLSLANG/ShaderLang.h
@@ -142,7 +142,13 @@ typedef enum {
// - The shader spec is SH_WEBGL_SPEC.
// - The compile options contain the SH_TIMING_RESTRICTIONS flag.
// - The shader type is SH_FRAGMENT_SHADER.
- SH_DEPENDENCY_GRAPH = 0x0400
+ SH_DEPENDENCY_GRAPH = 0x0400,
+
+ // This flag ensures all indirect (expression-based) array indexing
+ // is clamped to the bounds of the array. This ensures, for example,
+ // that you cannot read off the end of a uniform, whether an array
+ // vec234, or mat234 type.
+ SH_CLAMP_INDIRECT_ARRAY_BOUNDS = 0x0800
} ShCompileOptions;
//
diff --git a/Source/ThirdParty/ANGLE/src/compiler/ArrayBoundsClamper.cpp b/Source/ThirdParty/ANGLE/src/compiler/ArrayBoundsClamper.cpp
new file mode 100644
index 000000000..6a317217c
--- /dev/null
+++ b/Source/ThirdParty/ANGLE/src/compiler/ArrayBoundsClamper.cpp
@@ -0,0 +1,88 @@
+/*
+ * Copyright (C) 2012 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "compiler/ArrayBoundsClamper.h"
+
+const char* kIntClampBegin = "// BEGIN: Generated code for array bounds clamping\n\n";
+const char* kIntClampEnd = "// END: Generated code for array bounds clamping\n\n";
+const char* kIntClampDefinition = "int webgl_int_clamp(int value, int minValue, int maxValue) { return ((value < minValue) ? minValue : ((value > maxValue) ? maxValue : value)); }\n\n";
+
+namespace {
+
+class ArrayBoundsClamperMarker : public TIntermTraverser {
+public:
+ ArrayBoundsClamperMarker()
+ : mNeedsClamp(false)
+ {
+ }
+
+ virtual bool visitBinary(Visit visit, TIntermBinary* node)
+ {
+ if (node->getOp() == EOpIndexIndirect)
+ {
+ TIntermTyped* left = node->getLeft();
+ if (left->isArray() || left->isVector() || left->isMatrix())
+ {
+ node->setAddIndexClamp();
+ mNeedsClamp = true;
+ }
+ }
+ return true;
+ }
+
+ bool GetNeedsClamp() { return mNeedsClamp; }
+
+private:
+ bool mNeedsClamp;
+};
+
+} // anonymous namespace
+
+ArrayBoundsClamper::ArrayBoundsClamper()
+ : mArrayBoundsClampDefinitionNeeded(false)
+{
+}
+
+void ArrayBoundsClamper::OutputClampingFunctionDefinition(TInfoSinkBase& out) const
+{
+ if (!mArrayBoundsClampDefinitionNeeded)
+ {
+ return;
+ }
+ out << kIntClampBegin << kIntClampDefinition << kIntClampEnd;
+}
+
+void ArrayBoundsClamper::MarkIndirectArrayBoundsForClamping(TIntermNode* root)
+{
+ ASSERT(root);
+
+ ArrayBoundsClamperMarker clamper;
+ root->traverse(&clamper);
+ if (clamper.GetNeedsClamp())
+ {
+ SetArrayBoundsClampDefinitionNeeded();
+ }
+}
+
diff --git a/Source/ThirdParty/ANGLE/src/compiler/ArrayBoundsClamper.h b/Source/ThirdParty/ANGLE/src/compiler/ArrayBoundsClamper.h
new file mode 100644
index 000000000..d4a8d6994
--- /dev/null
+++ b/Source/ThirdParty/ANGLE/src/compiler/ArrayBoundsClamper.h
@@ -0,0 +1,57 @@
+/*
+ * Copyright (C) 2012 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef COMPILER_ARRAY_BOUNDS_CLAMPER_H_
+#define COMPILER_ARRAY_BOUNDS_CLAMPER_H_
+
+#include "GLSLANG/ShaderLang.h"
+
+#include "compiler/InfoSink.h"
+#include "compiler/intermediate.h"
+
+class ArrayBoundsClamper {
+public:
+ ArrayBoundsClamper();
+
+ // Output array clamp function source into the shader source.
+ void OutputClampingFunctionDefinition(TInfoSinkBase& out) const;
+
+ // Marks nodes in the tree that index arrays indirectly as
+ // requiring clamping.
+ void MarkIndirectArrayBoundsForClamping(TIntermNode* root);
+
+ void Cleanup()
+ {
+ mArrayBoundsClampDefinitionNeeded = false;
+ }
+
+private:
+ bool GetArrayBoundsClampDefinitionNeeded() const { return mArrayBoundsClampDefinitionNeeded; }
+ void SetArrayBoundsClampDefinitionNeeded() { mArrayBoundsClampDefinitionNeeded = true; }
+
+ bool mArrayBoundsClampDefinitionNeeded;
+};
+
+#endif // COMPILER_ARRAY_BOUNDS_CLAMPER_H_
diff --git a/Source/ThirdParty/ANGLE/src/compiler/Compiler.cpp b/Source/ThirdParty/ANGLE/src/compiler/Compiler.cpp
index cab8056bc..db5f7290f 100644
--- a/Source/ThirdParty/ANGLE/src/compiler/Compiler.cpp
+++ b/Source/ThirdParty/ANGLE/src/compiler/Compiler.cpp
@@ -4,6 +4,7 @@
// found in the LICENSE file.
//
+#include "compiler/ArrayBoundsClamper.h"
#include "compiler/BuiltInFunctionEmulator.h"
#include "compiler/DetectRecursion.h"
#include "compiler/ForLoopUnroll.h"
@@ -186,6 +187,10 @@ bool TCompiler::compile(const char* const shaderStrings[],
if (success && (compileOptions & SH_EMULATE_BUILT_IN_FUNCTIONS))
builtInFunctionEmulator.MarkBuiltInFunctionsForEmulation(root);
+ // Clamping uniform array bounds needs to happen after validateLimitations pass.
+ if (success && (compileOptions & SH_CLAMP_INDIRECT_ARRAY_BOUNDS))
+ arrayBoundsClamper.MarkIndirectArrayBoundsForClamping(root);
+
// Call mapLongVariableNames() before collectAttribsUniforms() so in
// collectAttribsUniforms() we already have the mapped symbol names and
// we could composite mapped and original variable names.
@@ -231,6 +236,7 @@ void TCompiler::clearResults()
uniforms.clear();
builtInFunctionEmulator.Cleanup();
+ arrayBoundsClamper.Cleanup();
}
bool TCompiler::detectRecursion(TIntermNode* root)
@@ -331,3 +337,9 @@ const BuiltInFunctionEmulator& TCompiler::getBuiltInFunctionEmulator() const
{
return builtInFunctionEmulator;
}
+
+const ArrayBoundsClamper& TCompiler::getArrayBoundsClamper() const
+{
+ return arrayBoundsClamper;
+}
+
diff --git a/Source/ThirdParty/ANGLE/src/compiler/OutputGLSLBase.cpp b/Source/ThirdParty/ANGLE/src/compiler/OutputGLSLBase.cpp
index 552fa5066..2100eaa0a 100644
--- a/Source/ThirdParty/ANGLE/src/compiler/OutputGLSLBase.cpp
+++ b/Source/ThirdParty/ANGLE/src/compiler/OutputGLSLBase.cpp
@@ -235,9 +235,38 @@ bool TOutputGLSLBase::visitBinary(Visit visit, TIntermBinary* node)
break;
case EOpIndexDirect:
- case EOpIndexIndirect:
writeTriplet(visit, NULL, "[", "]");
break;
+ case EOpIndexIndirect:
+ if (node->getAddIndexClamp())
+ {
+ if (visit == InVisit)
+ {
+ out << "[webgl_int_clamp(";
+ }
+ else if (visit == PostVisit)
+ {
+ int maxSize;
+ TIntermTyped *left = node->getLeft();
+ TType leftType = left->getType();
+
+ if (left->isArray())
+ {
+ // The shader will fail validation if the array length is not > 0.
+ maxSize = leftType.getArraySize() - 1;
+ }
+ else
+ {
+ maxSize = leftType.getNominalSize() - 1;
+ }
+ out << ", 0, " << maxSize << ")]";
+ }
+ }
+ else
+ {
+ writeTriplet(visit, NULL, "[", "]");
+ }
+ break;
case EOpIndexDirectStruct:
if (visit == InVisit)
{
diff --git a/Source/ThirdParty/ANGLE/src/compiler/ShHandle.h b/Source/ThirdParty/ANGLE/src/compiler/ShHandle.h
index 26528b8db..3eaf19f56 100644
--- a/Source/ThirdParty/ANGLE/src/compiler/ShHandle.h
+++ b/Source/ThirdParty/ANGLE/src/compiler/ShHandle.h
@@ -16,6 +16,7 @@
#include "GLSLANG/ShaderLang.h"
+#include "compiler/ArrayBoundsClamper.h"
#include "compiler/BuiltInFunctionEmulator.h"
#include "compiler/ExtensionBehavior.h"
#include "compiler/InfoSink.h"
@@ -98,6 +99,7 @@ protected:
// Get built-in extensions with default behavior.
const TExtensionBehavior& getExtensionBehavior() const;
+ const ArrayBoundsClamper& getArrayBoundsClamper() const;
const BuiltInFunctionEmulator& getBuiltInFunctionEmulator() const;
private:
@@ -110,6 +112,7 @@ private:
// Built-in extensions with default behavior.
TExtensionBehavior extensionBehavior;
+ ArrayBoundsClamper arrayBoundsClamper;
BuiltInFunctionEmulator builtInFunctionEmulator;
// Results of compilation.
diff --git a/Source/ThirdParty/ANGLE/src/compiler/TranslatorESSL.cpp b/Source/ThirdParty/ANGLE/src/compiler/TranslatorESSL.cpp
index e3a2c2a80..d90c70cb2 100644
--- a/Source/ThirdParty/ANGLE/src/compiler/TranslatorESSL.cpp
+++ b/Source/ThirdParty/ANGLE/src/compiler/TranslatorESSL.cpp
@@ -22,6 +22,9 @@ void TranslatorESSL::translate(TIntermNode* root) {
getBuiltInFunctionEmulator().OutputEmulatedFunctionDefinition(
sink, getShaderType() == SH_FRAGMENT_SHADER);
+ // Write array bounds clamping emulation if needed.
+ getArrayBoundsClamper().OutputClampingFunctionDefinition(sink);
+
// Write translated shader.
TOutputESSL outputESSL(sink);
root->traverse(&outputESSL);
diff --git a/Source/ThirdParty/ANGLE/src/compiler/TranslatorGLSL.cpp b/Source/ThirdParty/ANGLE/src/compiler/TranslatorGLSL.cpp
index bb07a1eb4..ba38112c2 100644
--- a/Source/ThirdParty/ANGLE/src/compiler/TranslatorGLSL.cpp
+++ b/Source/ThirdParty/ANGLE/src/compiler/TranslatorGLSL.cpp
@@ -35,6 +35,9 @@ void TranslatorGLSL::translate(TIntermNode* root) {
getBuiltInFunctionEmulator().OutputEmulatedFunctionDefinition(
sink, false);
+ // Write array bounds clamping emulation if needed.
+ getArrayBoundsClamper().OutputClampingFunctionDefinition(sink);
+
// Write translated shader.
TOutputGLSL outputGLSL(sink);
root->traverse(&outputGLSL);
diff --git a/Source/ThirdParty/ANGLE/src/compiler/intermOut.cpp b/Source/ThirdParty/ANGLE/src/compiler/intermOut.cpp
index e83c7b72f..f48a049c6 100644
--- a/Source/ThirdParty/ANGLE/src/compiler/intermOut.cpp
+++ b/Source/ThirdParty/ANGLE/src/compiler/intermOut.cpp
@@ -42,7 +42,7 @@ TString TType::getCompleteString() const
if (qualifier != EvqTemporary && qualifier != EvqGlobal)
stream << getQualifierString() << " " << getPrecisionString() << " ";
if (array)
- stream << "array of ";
+ stream << "array[" << getArraySize() << "] of ";
if (matrix)
stream << size << "X" << size << " matrix of ";
else if (size > 1)
diff --git a/Source/ThirdParty/ANGLE/src/compiler/intermediate.h b/Source/ThirdParty/ANGLE/src/compiler/intermediate.h
index 843c40ebb..9e9abbc3a 100644
--- a/Source/ThirdParty/ANGLE/src/compiler/intermediate.h
+++ b/Source/ThirdParty/ANGLE/src/compiler/intermediate.h
@@ -400,9 +400,15 @@ public:
TIntermTyped* getRight() const { return right; }
bool promote(TInfoSink&);
+ void setAddIndexClamp() { addIndexClamp = true; }
+ bool getAddIndexClamp() { return addIndexClamp; }
+
protected:
TIntermTyped* left;
TIntermTyped* right;
+
+ // If set to true, wrap any EOpIndexIndirect with a clamp to bounds.
+ bool addIndexClamp;
};
//