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:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user