Generalize "main" to a settable entry point name.

This commit is contained in:
John Kessenich
2016-03-12 18:17:47 -07:00
parent 6cc7674b6d
commit 4d65ee31a6
8 changed files with 38 additions and 8 deletions

View File

@@ -590,8 +590,8 @@ TGlslangToSpvTraverser::TGlslangToSpvTraverser(const glslang::TIntermediate* gls
builder.setSource(TranslateSourceLanguage(glslangIntermediate->getProfile()), glslangIntermediate->getVersion());
stdBuiltins = builder.import("GLSL.std.450");
builder.setMemoryModel(spv::AddressingModelLogical, spv::MemoryModelGLSL450);
shaderEntry = builder.makeMain();
entryPoint = builder.addEntryPoint(executionModel, shaderEntry, "main");
shaderEntry = builder.makeEntrypoint(glslangIntermediate->getEntryPoint().c_str());
entryPoint = builder.addEntryPoint(executionModel, shaderEntry, glslangIntermediate->getEntryPoint().c_str());
// Add the source extensions
const auto& sourceExtensions = glslangIntermediate->getRequestedExtensions();
@@ -2082,7 +2082,9 @@ void TGlslangToSpvTraverser::updateMemberOffset(const glslang::TType& /*structTy
bool TGlslangToSpvTraverser::isShaderEntrypoint(const glslang::TIntermAggregate* node)
{
return node->getName() == "main(";
// have to ignore mangling and just look at the base name
int firstOpen = node->getName().find('(');
return node->getName().compare(0, firstOpen, glslangIntermediate->getEntryPoint()) == 0;
}
// Make all the functions, skeletally, without actually visiting their bodies.