Incorporated patch from haixia@ changing the default implementation of
array index clamping to use the clamp intrinsic. This works more
reliably on pure OpenGL ES devices and on Windows.

Added a mechanism in ShBuiltInResources to choose the strategy for
array index clamping.

BUG=none
TEST=various out-of-bounds array indexing tests and various WebGL content
Review URL: https://codereview.appspot.com/7194051

git-svn-id: https://angleproject.googlecode.com/svn/branches/dx11proto@1798 736b8ea6-26fd-11df-bfd4-992fa37f6226
diff --git a/src/third_party/compiler/ArrayBoundsClamper.cpp b/src/third_party/compiler/ArrayBoundsClamper.cpp
index 2229cd2..288f552 100644
--- a/src/third_party/compiler/ArrayBoundsClamper.cpp
+++ b/src/third_party/compiler/ArrayBoundsClamper.cpp
@@ -70,17 +70,14 @@
 }  // anonymous namespace
 
 ArrayBoundsClamper::ArrayBoundsClamper()
-    : mArrayBoundsClampDefinitionNeeded(false)
+    : mClampingStrategy(SH_CLAMP_WITH_CLAMP_INTRINSIC)
+    , mArrayBoundsClampDefinitionNeeded(false)
 {
 }
 
-void ArrayBoundsClamper::OutputClampingFunctionDefinition(TInfoSinkBase& out) const
+void ArrayBoundsClamper::SetClampingStrategy(ShArrayIndexClampingStrategy clampingStrategy)
 {
-    if (!mArrayBoundsClampDefinitionNeeded)
-    {
-        return;
-    }
-    out << kIntClampBegin << kIntClampDefinition << kIntClampEnd;
+    mClampingStrategy = clampingStrategy;
 }
 
 void ArrayBoundsClamper::MarkIndirectArrayBoundsForClamping(TIntermNode* root)
@@ -95,3 +92,15 @@
     }
 }
 
+void ArrayBoundsClamper::OutputClampingFunctionDefinition(TInfoSinkBase& out) const
+{
+    if (!mArrayBoundsClampDefinitionNeeded)
+    {
+        return;
+    }
+    if (mClampingStrategy != SH_CLAMP_WITH_USER_DEFINED_INT_CLAMP_FUNCTION)
+    {
+        return;
+    }
+    out << kIntClampBegin << kIntClampDefinition << kIntClampEnd;
+}