Support precision emulation on HLSL
Re-submit with missing virtual destructor and angle::NonCopyable
added.
Add precision emulation support to HLSL 4.1 output. This makes it
possible for developers to test their shaders for precision issues
easily on Chrome on Windows without having to use the GL backend. The
patch has been verified with Chrome on Windows to reproduce some
precision bugs in real-world WebGL content, including old versions of
the babylon.js library.
The EmulatePrecision AST transformation still relies on writing out
raw shader code for the rounding functions, with raw HLSL code added
alongside pre-existing GLSL and ESSL code. In some ways it would be
nicer to do the EmulatePrecision step as a pure AST transformation,
but on the other hand the raw code is much more readable and easier
to optimize.
To better support multiple output languages in EmulatePrecision, add a
RoundingHelperWriter class that has different subclasses for writing
the rounding functions in different languages.
The unit tests are expanded to cover the HLSL output of precision
emulation. The parts of the tests that require the HLSL output are
only active on Windows where ANGLE_ENABLE_HLSL define is added to the
unit tests. Putting the HLSL tests in an entirely separate file is a
worse alternative, since it would require either a lot of code
duplication or add a lot of boilerplate to the individual tests.
BUG=angleproject:1437
TEST=angle_unittests
Change-Id: I47d501037c206f4bd8b976d3acab9b21c717084c
Reviewed-on: https://chromium-review.googlesource.com/360152
Reviewed-by: Jamie Madill <jmadill@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Olli Etuaho <oetuaho@nvidia.com>
diff --git a/src/compiler/translator/OutputHLSL.cpp b/src/compiler/translator/OutputHLSL.cpp
index 3badefd..ff1c1a3 100644
--- a/src/compiler/translator/OutputHLSL.cpp
+++ b/src/compiler/translator/OutputHLSL.cpp
@@ -1677,6 +1677,12 @@
out << DisambiguateFunctionName(node->getSequence());
out << (lod0 ? "Lod0(" : "(");
}
+ else if (node->getNameObj().isInternal())
+ {
+ // This path is used for internal functions that don't have their definitions in the
+ // AST, such as precision emulation functions.
+ out << DecorateFunctionIfNeeded(node->getNameObj()) << "(";
+ }
else
{
TString name = TFunction::unmangleName(node->getNameObj().getString());