In generated shaders, output +INF and -INF as largest single precision floating point number.

C++ streams seem to use the representation 1.$ for INF and that isn't valid syntax in GLSL or HLSL.

Also preserve the sign of INF in constant expressions that divide by zero. I can't figure out what to do about 0/0 because the shader models we are using do not support NaN. Treating it as +INF as before.
Review URL: https://codereview.appspot.com/7057046

git-svn-id: https://angleproject.googlecode.com/svn/branches/dx11proto@1706 736b8ea6-26fd-11df-bfd4-992fa37f6226
diff --git a/src/common/version.h b/src/common/version.h
index bbcc4f0..7bce548 100644
--- a/src/common/version.h
+++ b/src/common/version.h
@@ -1,7 +1,7 @@
 #define MAJOR_VERSION 1
 #define MINOR_VERSION 1
 #define BUILD_VERSION 0
-#define BUILD_REVISION 1643
+#define BUILD_REVISION 1644
 
 #define STRINGIFY(x) #x
 #define MACRO_STRINGIFY(x) STRINGIFY(x)
diff --git a/src/compiler/Intermediate.cpp b/src/compiler/Intermediate.cpp
index 9032b3a..c0b08c1 100644
--- a/src/compiler/Intermediate.cpp
+++ b/src/compiler/Intermediate.cpp
@@ -1162,7 +1162,7 @@
             case EbtFloat:
                 if (rightUnionArray[i] == 0.0f) {
                     infoSink.info.message(EPrefixWarning, "Divide by zero error during constant folding", getLine());
-                    tempConstArray[i].setFConst(FLT_MAX);
+                    tempConstArray[i].setFConst(unionArray[i].getFConst() < 0 ? -FLT_MAX : FLT_MAX);
                 } else
                     tempConstArray[i].setFConst(unionArray[i].getFConst() / rightUnionArray[i].getFConst());
                 break;
diff --git a/src/compiler/OutputGLSLBase.cpp b/src/compiler/OutputGLSLBase.cpp
index 3c3c9de..dbdc1f6 100644
--- a/src/compiler/OutputGLSLBase.cpp
+++ b/src/compiler/OutputGLSLBase.cpp
@@ -7,6 +7,8 @@
 #include "compiler/OutputGLSLBase.h"
 #include "compiler/debug.h"
 
+#include <limits.h>
+
 namespace
 {
 TString arrayBrackets(const TType& type)
@@ -155,7 +157,7 @@
         {
             switch (pConstUnion->getType())
             {
-                case EbtFloat: out << pConstUnion->getFConst(); break;
+                case EbtFloat: out << std::min(FLT_MAX, std::max(-FLT_MAX, pConstUnion->getFConst())); break;
                 case EbtInt: out << pConstUnion->getIConst(); break;
                 case EbtBool: out << pConstUnion->getBConst(); break;
                 default: UNREACHABLE();
diff --git a/src/compiler/OutputHLSL.cpp b/src/compiler/OutputHLSL.cpp
index 0a54952..e1b8092 100644
--- a/src/compiler/OutputHLSL.cpp
+++ b/src/compiler/OutputHLSL.cpp
@@ -13,6 +13,7 @@
 #include "compiler/SearchSymbol.h"
 #include "compiler/DetectDiscontinuity.h"
 
+#include <limits.h>
 #include <stdio.h>
 #include <algorithm>
 
@@ -2512,7 +2513,7 @@
         {
             switch (constUnion->getType())
             {
-              case EbtFloat: out << constUnion->getFConst(); break;
+              case EbtFloat: out << std::min(FLT_MAX, std::max(-FLT_MAX, constUnion->getFConst())); break;
               case EbtInt:   out << constUnion->getIConst(); break;
               case EbtBool:  out << constUnion->getBConst(); break;
               default: UNREACHABLE();