Output Lod0 copies of functions containing gradient operations when the shader contains a discontinuity.
TRAC #20737
Signed-off-by: Daniel Koch
Author: Nicolas Capens
git-svn-id: https://angleproject.googlecode.com/svn/trunk@1122 736b8ea6-26fd-11df-bfd4-992fa37f6226
diff --git a/src/compiler/OutputHLSL.cpp b/src/compiler/OutputHLSL.cpp
index f306e04..d64a242 100644
--- a/src/compiler/OutputHLSL.cpp
+++ b/src/compiler/OutputHLSL.cpp
@@ -11,6 +11,7 @@
#include "compiler/InfoSink.h"
#include "compiler/UnfoldShortCircuit.h"
#include "compiler/SearchSymbol.h"
+#include "compiler/DetectDiscontinuity.h"
#include <stdio.h>
#include <algorithm>
@@ -82,6 +83,9 @@
mScopeDepth = 0;
mUniqueIndex = 0;
+
+ mContainsLoopDiscontinuity = false;
+ mOutputLod0Function = false;
}
OutputHLSL::~OutputHLSL()
@@ -91,6 +95,8 @@
void OutputHLSL::output()
{
+ mContainsLoopDiscontinuity = containsLoopDiscontinuity(mContext.treeRoot);
+
mContext.treeRoot->traverse(this); // Output the body first to determine what has to go in the header
header();
@@ -1370,7 +1376,7 @@
}
else
{
- out << decorate(name) << "(";
+ out << decorate(name) << (mOutputLod0Function ? "Lod0(" : "(");
}
TIntermSequence &sequence = node->getSequence();
@@ -1409,6 +1415,16 @@
out << "}\n";
+ if (mContainsLoopDiscontinuity && !mOutputLod0Function)
+ {
+ if (name != "main" && containsGradientOperation(node))
+ {
+ mOutputLod0Function = true;
+ node->traverse(this);
+ mOutputLod0Function = false;
+ }
+ }
+
return false;
}
break;