Commit 01cd8afa by Olli Etuaho

Add GLSL output of switch and case

BUG=angle:921 Change-Id: I0d752440ce6ffdfcc005f1a6123694bdfeb1b067 Reviewed-on: https://chromium-review.googlesource.com/251526Tested-by: 's avatarOlli Etuaho <oetuaho@nvidia.com> Reviewed-by: 's avatarZhenyao Mo <zmo@chromium.org> Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org>
parent c8716df9
...@@ -512,6 +512,8 @@ class TIntermSwitch : public TIntermNode ...@@ -512,6 +512,8 @@ class TIntermSwitch : public TIntermNode
TIntermSwitch *getAsSwitchNode() override { return this; } TIntermSwitch *getAsSwitchNode() override { return this; }
TIntermAggregate *getStatementList() { return mStatementList; }
protected: protected:
TIntermTyped *mInit; TIntermTyped *mInit;
TIntermAggregate *mStatementList; TIntermAggregate *mStatementList;
......
...@@ -36,6 +36,14 @@ bool isSingleStatement(TIntermNode *node) ...@@ -36,6 +36,14 @@ bool isSingleStatement(TIntermNode *node)
{ {
return false; return false;
} }
else if (node->getAsSwitchNode())
{
return false;
}
else if (node->getAsCaseNode())
{
return false;
}
return true; return true;
} }
} // namespace } // namespace
...@@ -638,16 +646,34 @@ bool TOutputGLSLBase::visitSelection(Visit visit, TIntermSelection *node) ...@@ -638,16 +646,34 @@ bool TOutputGLSLBase::visitSelection(Visit visit, TIntermSelection *node)
return false; return false;
} }
bool TOutputGLSLBase::visitSwitch(Visit, TIntermSwitch *) bool TOutputGLSLBase::visitSwitch(Visit visit, TIntermSwitch *node)
{ {
UNIMPLEMENTED(); if (node->getStatementList())
return false; {
writeTriplet(visit, "switch (", ") ", nullptr);
// The curly braces get written when visiting the statementList aggregate
}
else
{
// No statementList, so it won't output curly braces
writeTriplet(visit, "switch (", ") {", "}\n");
}
return true;
} }
bool TOutputGLSLBase::visitCase(Visit, TIntermCase *) bool TOutputGLSLBase::visitCase(Visit visit, TIntermCase *node)
{ {
UNIMPLEMENTED(); if (node->hasCondition())
return false; {
writeTriplet(visit, "case (", nullptr, "):\n");
return true;
}
else
{
TInfoSinkBase &out = objSink();
out << "default:\n";
return false;
}
} }
bool TOutputGLSLBase::visitAggregate(Visit visit, TIntermAggregate *node) bool TOutputGLSLBase::visitAggregate(Visit visit, TIntermAggregate *node)
......
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