Workaround isnan() on Intel drivers

On some Intel drivers, calling function isnan() on highp float will get wrong
answer. This patch work arounds this bug by using an expression to emulate
this function.

BUG=chromium:650547

Change-Id: I5bc5e0352c434f42cd2c55103a74f9f7ba51a72c
Reviewed-on: https://chromium-review.googlesource.com/389834
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
diff --git a/src/compiler/translator/OutputHLSL.cpp b/src/compiler/translator/OutputHLSL.cpp
index 6835c2e..9da8720 100644
--- a/src/compiler/translator/OutputHLSL.cpp
+++ b/src/compiler/translator/OutputHLSL.cpp
@@ -161,6 +161,12 @@
 
     BuiltInFunctionEmulator builtInFunctionEmulator;
     InitBuiltInFunctionEmulatorForHLSL(&builtInFunctionEmulator);
+    if ((mCompileOptions & SH_EMULATE_ISNAN_FLOAT_FUNCTION) != 0)
+    {
+        InitBuiltInIsnanFunctionEmulatorForHLSLWorkarounds(&builtInFunctionEmulator,
+                                                           mShaderVersion);
+    }
+
     builtInFunctionEmulator.MarkBuiltInFunctionsForEmulation(treeRoot);
 
     // Now that we are done changing the AST, do the analyses need for HLSL generation
@@ -1299,9 +1305,12 @@
           outputTriplet(out, visit, "frac(", "", ")");
           break;
       case EOpIsNan:
-          outputTriplet(out, visit, "isnan(", "", ")");
-        mRequiresIEEEStrictCompiling = true;
-        break;
+          if (node->getUseEmulatedFunction())
+              writeEmulatedFunctionTriplet(out, visit, "isnan(");
+          else
+              outputTriplet(out, visit, "isnan(", "", ")");
+          mRequiresIEEEStrictCompiling = true;
+          break;
       case EOpIsInf:
           outputTriplet(out, visit, "isinf(", "", ")");
           break;