Output Lod0 copies of functions containing gradient operations when the shader…

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
parent 79744f22
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
#include "compiler/InfoSink.h" #include "compiler/InfoSink.h"
#include "compiler/UnfoldShortCircuit.h" #include "compiler/UnfoldShortCircuit.h"
#include "compiler/SearchSymbol.h" #include "compiler/SearchSymbol.h"
#include "compiler/DetectDiscontinuity.h"
#include <stdio.h> #include <stdio.h>
#include <algorithm> #include <algorithm>
...@@ -82,6 +83,9 @@ OutputHLSL::OutputHLSL(TParseContext &context) : TIntermTraverser(true, true, tr ...@@ -82,6 +83,9 @@ OutputHLSL::OutputHLSL(TParseContext &context) : TIntermTraverser(true, true, tr
mScopeDepth = 0; mScopeDepth = 0;
mUniqueIndex = 0; mUniqueIndex = 0;
mContainsLoopDiscontinuity = false;
mOutputLod0Function = false;
} }
OutputHLSL::~OutputHLSL() OutputHLSL::~OutputHLSL()
...@@ -91,6 +95,8 @@ OutputHLSL::~OutputHLSL() ...@@ -91,6 +95,8 @@ OutputHLSL::~OutputHLSL()
void OutputHLSL::output() void OutputHLSL::output()
{ {
mContainsLoopDiscontinuity = containsLoopDiscontinuity(mContext.treeRoot);
mContext.treeRoot->traverse(this); // Output the body first to determine what has to go in the header mContext.treeRoot->traverse(this); // Output the body first to determine what has to go in the header
header(); header();
...@@ -1370,7 +1376,7 @@ bool OutputHLSL::visitAggregate(Visit visit, TIntermAggregate *node) ...@@ -1370,7 +1376,7 @@ bool OutputHLSL::visitAggregate(Visit visit, TIntermAggregate *node)
} }
else else
{ {
out << decorate(name) << "("; out << decorate(name) << (mOutputLod0Function ? "Lod0(" : "(");
} }
TIntermSequence &sequence = node->getSequence(); TIntermSequence &sequence = node->getSequence();
...@@ -1409,6 +1415,16 @@ bool OutputHLSL::visitAggregate(Visit visit, TIntermAggregate *node) ...@@ -1409,6 +1415,16 @@ bool OutputHLSL::visitAggregate(Visit visit, TIntermAggregate *node)
out << "}\n"; out << "}\n";
if (mContainsLoopDiscontinuity && !mOutputLod0Function)
{
if (name != "main" && containsGradientOperation(node))
{
mOutputLod0Function = true;
node->traverse(this);
mOutputLod0Function = false;
}
}
return false; return false;
} }
break; break;
......
...@@ -140,6 +140,9 @@ class OutputHLSL : public TIntermTraverser ...@@ -140,6 +140,9 @@ class OutputHLSL : public TIntermTraverser
unsigned int mScopeDepth; unsigned int mScopeDepth;
int mUniqueIndex; // For creating unique names int mUniqueIndex; // For creating unique names
bool mContainsLoopDiscontinuity;
bool mOutputLod0Function;
}; };
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment