translator: Fail compilation if precision emu unsupported.
The fuzzer uncovered a case where we were trying to emulate precision
on HLSL 3.0, causing an ASSERT crash.
BUG=chromium:653276
Change-Id: I2e666a1ff4f605541e25f04264146063559cb835
Reviewed-on: https://chromium-review.googlesource.com/394237
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Olli Etuaho <oetuaho@nvidia.com>
Commit-Queue: Jamie Madill <jmadill@chromium.org>
diff --git a/src/compiler/translator/Compiler.cpp b/src/compiler/translator/Compiler.cpp
index 74c0104..547c09b 100644
--- a/src/compiler/translator/Compiler.cpp
+++ b/src/compiler/translator/Compiler.cpp
@@ -15,6 +15,7 @@
#include "compiler/translator/CallDAG.h"
#include "compiler/translator/DeferGlobalInitializers.h"
#include "compiler/translator/EmulateGLFragColorBroadcast.h"
+#include "compiler/translator/EmulatePrecision.h"
#include "compiler/translator/ForLoopUnroll.h"
#include "compiler/translator/Initialize.h"
#include "compiler/translator/InitializeParseContext.h"
@@ -329,6 +330,18 @@
if (success && shouldRunLoopAndIndexingValidation(compileOptions))
success = validateLimitations(root);
+ // Fail compilation if precision emulation not supported.
+ if (success && getResources().WEBGL_debug_shader_precision &&
+ getPragma().debugShaderPrecision)
+ {
+ if (!EmulatePrecision::SupportedInLanguage(outputType))
+ {
+ infoSink.info.prefix(EPrefixError);
+ infoSink.info << "Precision emulation not supported for this output type.";
+ success = false;
+ }
+ }
+
// Unroll for-loop markup needs to happen after validateLimitations pass.
if (success && (compileOptions & SH_UNROLL_FOR_LOOP_WITH_INTEGER_INDEX))
{