Always correctly terminate main. Issue #588, PR #600.

This commit is contained in:
John Kessenich 2016-11-26 13:23:20 -07:00
parent 1c573fbcfb
commit fca826212c
11 changed files with 24 additions and 15 deletions

View File

@ -99,7 +99,7 @@ private:
class TGlslangToSpvTraverser : public glslang::TIntermTraverser {
public:
TGlslangToSpvTraverser(const glslang::TIntermediate*, spv::SpvBuildLogger* logger);
virtual ~TGlslangToSpvTraverser();
virtual ~TGlslangToSpvTraverser() { }
bool visitAggregate(glslang::TVisit, glslang::TIntermAggregate*);
bool visitBinary(glslang::TVisit, glslang::TIntermBinary*);
@ -111,6 +111,7 @@ public:
bool visitLoop(glslang::TVisit, glslang::TIntermLoop*);
bool visitBranch(glslang::TVisit visit, glslang::TIntermBranch*);
void finishSpv();
void dumpSpv(std::vector<unsigned int>& out);
protected:
@ -896,27 +897,27 @@ TGlslangToSpvTraverser::TGlslangToSpvTraverser(const glslang::TIntermediate* gls
default:
break;
}
}
// Finish everything and dump
void TGlslangToSpvTraverser::dumpSpv(std::vector<unsigned int>& out)
// Finish creating SPV, after the traversal is complete.
void TGlslangToSpvTraverser::finishSpv()
{
if (! mainTerminated) {
builder.setBuildPoint(shaderEntry->getLastBlock());
builder.leaveFunction();
}
// finish off the entry-point SPV instruction by adding the Input/Output <id>
for (auto it = iOSet.cbegin(); it != iOSet.cend(); ++it)
entryPoint->addIdOperand(*it);
builder.eliminateDeadDecorations();
builder.dump(out);
}
TGlslangToSpvTraverser::~TGlslangToSpvTraverser()
// Write the SPV into 'out'.
void TGlslangToSpvTraverser::dumpSpv(std::vector<unsigned int>& out)
{
if (! mainTerminated) {
spv::Block* lastMainBlock = shaderEntry->getLastBlock();
builder.setBuildPoint(lastMainBlock);
builder.leaveFunction();
}
builder.dump(out);
}
//
@ -5120,9 +5121,8 @@ void GlslangToSpv(const glslang::TIntermediate& intermediate, std::vector<unsign
glslang::GetThreadPoolAllocator().push();
TGlslangToSpvTraverser it(&intermediate, logger);
root->traverse(&it);
it.finishSpv();
it.dumpSpv(spirv);
glslang::GetThreadPoolAllocator().pop();

View File

@ -234,6 +234,7 @@ gl_FragCoord origin is upper left
Store 18(g_array) 24
Store 28(g_array_unused) 31
Store 37(g_mystruct) 42
Return
FunctionEnd
12(main(struct-PS_OUTPUT-vf41;): 2 Function None 10
11(ps_output): 9(ptr) FunctionParameter

View File

@ -92,6 +92,7 @@ gl_FragCoord origin is upper left
5: Label
Store 14(f1) 15
Store 16(scalar) 17
Return
FunctionEnd
11(ShaderFunction(vf1;f1;): 6(float) Function None 8
9(inFloat1): 7(ptr) FunctionParameter

View File

@ -82,6 +82,7 @@ gl_FragCoord origin is upper left
20: TypePointer Uniform 7(fvec4)
4(PixelShaderFunction): 2 Function None 3
5: Label
Return
FunctionEnd
11(ShaderFunction(vf4;): 7(fvec4) Function None 9
10(input): 8(ptr) FunctionParameter

View File

@ -3011,6 +3011,7 @@ Shader version: 450
1059: 76 ConstantComposite 1058 1058 1058 1058
4(VertexShaderFunction): 2 Function None 3
5: Label
Return
FunctionEnd
16(VertexShaderFunctionS(f1;f1;f1;u1;u1;): 6(float) Function None 10
11(inF0): 7(ptr) FunctionParameter

View File

@ -119,6 +119,7 @@ gl_FragCoord origin is upper left
38: 17(int) SpecConstant 10
4(main): 2 Function None 3
5: Label
Return
FunctionEnd
11(PixelShaderFunction(vf4;): 7(fvec4) Function None 9
10(input): 8(ptr) FunctionParameter

View File

@ -90,6 +90,7 @@ gl_FragCoord origin is upper left
29: 28(ptr) Variable Uniform
4(PixelShaderFunction): 2 Function None 3
5: Label
Return
FunctionEnd
11(ShaderFunction(vf1;f1;): 6(float) Function None 8
9(inFloat1): 7(ptr) FunctionParameter

View File

@ -282,6 +282,7 @@ gl_FragCoord origin is upper left
62: TypeVector 41(bool) 4
4(main): 2 Function None 3
5: Label
Return
FunctionEnd
13(PixelShaderFunction(vf4;f1;): 7(fvec4) Function None 10
11(input): 8(ptr) FunctionParameter

View File

@ -106,6 +106,7 @@ gl_FragCoord origin is upper left
4(PixelShaderFunction): 2 Function None 3
5: Label
Store 14(AmbientColor) 18
Return
FunctionEnd
11(ShaderFunction(vf4;): 7(fvec4) Function None 9
10(input): 8(ptr) FunctionParameter

View File

@ -106,6 +106,7 @@ gl_FragCoord origin is upper left
20: 9(int) Constant 2
4(PixelShaderFunction): 2 Function None 3
5: Label
Return
FunctionEnd
14(ShaderFunction(vf4;i1;): 7(fvec4) Function None 11
12(input): 8(ptr) FunctionParameter

View File

@ -2,5 +2,5 @@
// For the version, it uses the latest git tag followed by the number of commits.
// For the date, it uses the current date (when then script is run).
#define GLSLANG_REVISION "Overload400-PrecQual.1650"
#define GLSLANG_DATE "14-Nov-2016"
#define GLSLANG_REVISION "Overload400-PrecQual.1659"
#define GLSLANG_DATE "26-Nov-2016"