Call Lod0 functions when inside a loop with a discontinuity.

TRAC #20737 Signed-off-by: Daniel Koch Author: Nicolas Capens git-svn-id: https://angleproject.googlecode.com/svn/trunk@1123 736b8ea6-26fd-11df-bfd4-992fa37f6226
parent 89431aa5
...@@ -86,6 +86,7 @@ OutputHLSL::OutputHLSL(TParseContext &context) : TIntermTraverser(true, true, tr ...@@ -86,6 +86,7 @@ OutputHLSL::OutputHLSL(TParseContext &context) : TIntermTraverser(true, true, tr
mContainsLoopDiscontinuity = false; mContainsLoopDiscontinuity = false;
mOutputLod0Function = false; mOutputLod0Function = false;
mInsideDiscontinuousLoop = false;
} }
OutputHLSL::~OutputHLSL() OutputHLSL::~OutputHLSL()
...@@ -1433,54 +1434,106 @@ bool OutputHLSL::visitAggregate(Visit visit, TIntermAggregate *node) ...@@ -1433,54 +1434,106 @@ bool OutputHLSL::visitAggregate(Visit visit, TIntermAggregate *node)
if (visit == PreVisit) if (visit == PreVisit)
{ {
TString name = TFunction::unmangleName(node->getName()); TString name = TFunction::unmangleName(node->getName());
bool lod0 = mInsideDiscontinuousLoop || mOutputLod0Function;
if (node->isUserDefined()) if (node->isUserDefined())
{ {
out << decorate(name) << "("; out << decorate(name) << (lod0 ? "Lod0(" : "(");
} }
else else
{ {
if (name == "texture2D") if (name == "texture2D")
{ {
if (node->getSequence().size() == 2) if (!lod0)
{ {
mUsesTexture2D = true; if (node->getSequence().size() == 2)
{
mUsesTexture2D = true;
}
else if (node->getSequence().size() == 3)
{
mUsesTexture2D_bias = true;
}
else UNREACHABLE();
out << "gl_texture2D(";
} }
else if (node->getSequence().size() == 3) else
{ {
mUsesTexture2D_bias = true; if (node->getSequence().size() == 2)
} {
else UNREACHABLE(); mUsesTexture2DLod0 = true;
}
else if (node->getSequence().size() == 3)
{
mUsesTexture2DLod0_bias = true;
}
else UNREACHABLE();
out << "gl_texture2D("; out << "gl_texture2DLod0(";
}
} }
else if (name == "texture2DProj") else if (name == "texture2DProj")
{ {
if (node->getSequence().size() == 2) if (!lod0)
{ {
mUsesTexture2DProj = true; if (node->getSequence().size() == 2)
{
mUsesTexture2DProj = true;
}
else if (node->getSequence().size() == 3)
{
mUsesTexture2DProj_bias = true;
}
else UNREACHABLE();
out << "gl_texture2DProj(";
} }
else if (node->getSequence().size() == 3) else
{ {
mUsesTexture2DProj_bias = true; if (node->getSequence().size() == 2)
} {
else UNREACHABLE(); mUsesTexture2DProjLod0 = true;
}
else if (node->getSequence().size() == 3)
{
mUsesTexture2DProjLod0_bias = true;
}
else UNREACHABLE();
out << "gl_texture2DProj("; out << "gl_texture2DProjLod0(";
}
} }
else if (name == "textureCube") else if (name == "textureCube")
{ {
if (node->getSequence().size() == 2) if (!lod0)
{ {
mUsesTextureCube = true; if (node->getSequence().size() == 2)
{
mUsesTextureCube = true;
}
else if (node->getSequence().size() == 3)
{
mUsesTextureCube_bias = true;
}
else UNREACHABLE();
out << "gl_textureCube(";
} }
else if (node->getSequence().size() == 3) else
{ {
mUsesTextureCube_bias = true; if (node->getSequence().size() == 2)
} {
else UNREACHABLE(); mUsesTextureCubeLod0 = true;
}
else if (node->getSequence().size() == 3)
{
mUsesTextureCubeLod0_bias = true;
}
else UNREACHABLE();
out << "gl_textureCube("; out << "gl_textureCubeLod0(";
}
} }
else if (name == "texture2DLod") else if (name == "texture2DLod")
{ {
...@@ -1714,6 +1767,13 @@ void OutputHLSL::visitConstantUnion(TIntermConstantUnion *node) ...@@ -1714,6 +1767,13 @@ void OutputHLSL::visitConstantUnion(TIntermConstantUnion *node)
bool OutputHLSL::visitLoop(Visit visit, TIntermLoop *node) bool OutputHLSL::visitLoop(Visit visit, TIntermLoop *node)
{ {
bool wasDiscontinuous = mInsideDiscontinuousLoop;
if (!mInsideDiscontinuousLoop)
{
mInsideDiscontinuousLoop = containsLoopDiscontinuity(node);
}
if (handleExcessiveLoop(node)) if (handleExcessiveLoop(node))
{ {
return false; return false;
...@@ -1777,6 +1837,8 @@ bool OutputHLSL::visitLoop(Visit visit, TIntermLoop *node) ...@@ -1777,6 +1837,8 @@ bool OutputHLSL::visitLoop(Visit visit, TIntermLoop *node)
out << "}\n"; out << "}\n";
mInsideDiscontinuousLoop = wasDiscontinuous;
return false; return false;
} }
......
...@@ -143,6 +143,7 @@ class OutputHLSL : public TIntermTraverser ...@@ -143,6 +143,7 @@ class OutputHLSL : public TIntermTraverser
bool mContainsLoopDiscontinuity; bool mContainsLoopDiscontinuity;
bool mOutputLod0Function; bool mOutputLod0Function;
bool mInsideDiscontinuousLoop;
}; };
} }
......
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