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