SPV return from main: Simplify a legacy design such returns are not jumps to exit block.
Structured control-flow rules allow leaving the middle of a construct through a return, but not through a jump to a block that does a return. Addresses issue #58.
This commit is contained in:
parent
5f5b205ce9
commit
e770b3e6cf
74 changed files with 9648 additions and 9816 deletions
|
|
@ -454,7 +454,7 @@ TGlslangToSpvTraverser::~TGlslangToSpvTraverser()
|
|||
if (! mainTerminated) {
|
||||
spv::Block* lastMainBlock = shaderEntry->getLastBlock();
|
||||
builder.setBuildPoint(lastMainBlock);
|
||||
builder.leaveFunction(true);
|
||||
builder.leaveFunction();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -854,7 +854,7 @@ bool TGlslangToSpvTraverser::visitAggregate(glslang::TVisit visit, glslang::TInt
|
|||
} else {
|
||||
if (inMain)
|
||||
mainTerminated = true;
|
||||
builder.leaveFunction(inMain);
|
||||
builder.leaveFunction();
|
||||
inMain = false;
|
||||
}
|
||||
|
||||
|
|
@ -1276,12 +1276,10 @@ bool TGlslangToSpvTraverser::visitBranch(glslang::TVisit /* visit */, glslang::T
|
|||
builder.createLoopContinue();
|
||||
break;
|
||||
case glslang::EOpReturn:
|
||||
if (inMain)
|
||||
builder.makeMainReturn();
|
||||
else if (node->getExpression())
|
||||
if (node->getExpression())
|
||||
builder.makeReturn(false, builder.accessChainLoad(convertGlslangToSpvType(node->getExpression()->getType())));
|
||||
else
|
||||
builder.makeReturn();
|
||||
builder.makeReturn(false);
|
||||
|
||||
builder.clearAccessChain();
|
||||
break;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue