Track separate entry-point names and mangled names...

... and use each in the correct way at consumption sites.
This completes issue #513.
This commit is contained in:
John Kessenich 2016-09-19 18:09:30 -06:00
parent 632f575ecc
commit eee9d536bc
8 changed files with 32 additions and 25 deletions

View File

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

View File

@ -2,5 +2,5 @@
// For the version, it uses the latest git tag followed by the number of commits. // 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). // For the date, it uses the current date (when then script is run).
#define GLSLANG_REVISION "Overload400-PrecQual.1496" #define GLSLANG_REVISION "Overload400-PrecQual.1499"
#define GLSLANG_DATE "19-Sep-2016" #define GLSLANG_DATE "19-Sep-2016"

View File

@ -1051,19 +1051,24 @@ TIntermAggregate* TParseContext::handleFunctionDefinition(const TSourceLoc& loc,
currentFunctionType = new TType(EbtVoid); currentFunctionType = new TType(EbtVoid);
functionReturnsValue = false; functionReturnsValue = false;
// // Check for entry point
// Raise error message if main function takes any parameters or returns anything other than void if (function.getName().compare(intermediate.getEntryPointName().c_str()) == 0) {
// intermediate.setEntryPointMangledName(function.getMangledName().c_str());
if (function.getName() == intermediate.getEntryPoint().c_str()) {
if (function.getParamCount() > 0)
error(loc, "function cannot take any parameter(s)", function.getName().c_str(), "");
if (function.getType().getBasicType() != EbtVoid)
error(loc, "", function.getType().getBasicTypeString().c_str(), "entry point cannot return a value");
intermediate.incrementEntryPointCount(); intermediate.incrementEntryPointCount();
inMain = true; inMain = true;
} else } else
inMain = false; inMain = false;
//
// Raise error message if main function takes any parameters or returns anything other than void
//
if (inMain) {
if (function.getParamCount() > 0)
error(loc, "function cannot take any parameter(s)", function.getName().c_str(), "");
if (function.getType().getBasicType() != EbtVoid)
error(loc, "", function.getType().getBasicTypeString().c_str(), "entry point cannot return a value");
}
// //
// New symbol table scope for body of function plus its arguments // New symbol table scope for body of function plus its arguments
// //

View File

@ -697,7 +697,7 @@ bool ProcessDeferred(
parseContext = new HlslParseContext(symbolTable, intermediate, false, version, profile, spvVersion, parseContext = new HlslParseContext(symbolTable, intermediate, false, version, profile, spvVersion,
compiler->getLanguage(), compiler->infoSink, forwardCompatible, messages); compiler->getLanguage(), compiler->infoSink, forwardCompatible, messages);
} else { } else {
intermediate.setEntryPoint("main"); intermediate.setEntryPointName("main");
parseContext = new TParseContext(symbolTable, intermediate, false, version, profile, spvVersion, parseContext = new TParseContext(symbolTable, intermediate, false, version, profile, spvVersion,
compiler->getLanguage(), compiler->infoSink, forwardCompatible, messages); compiler->getLanguage(), compiler->infoSink, forwardCompatible, messages);
} }
@ -1485,7 +1485,7 @@ void TShader::setStringsWithLengthsAndNames(
void TShader::setEntryPoint(const char* entryPoint) void TShader::setEntryPoint(const char* entryPoint)
{ {
intermediate->setEntryPoint(entryPoint); intermediate->setEntryPointName(entryPoint);
} }
// //

View File

@ -75,11 +75,11 @@ void TIntermediate::merge(TInfoSink& infoSink, TIntermediate& unit)
if (source != unit.source) if (source != unit.source)
error(infoSink, "can't link compilation units from different source languages"); error(infoSink, "can't link compilation units from different source languages");
if (source == EShSourceHlsl && unit.entryPoint.size() > 0) { if (source == EShSourceHlsl && unit.entryPointName.size() > 0) {
if (entryPoint.size() > 0) if (entryPointName.size() > 0)
error(infoSink, "can't handle multiple entry points per stage"); error(infoSink, "can't handle multiple entry points per stage");
else else
entryPoint = unit.entryPoint; entryPointName = unit.entryPointName;
} }
numEntryPoints += unit.numEntryPoints; numEntryPoints += unit.numEntryPoints;
numErrors += unit.numErrors; numErrors += unit.numErrors;

View File

@ -159,8 +159,10 @@ public:
void setSource(EShSource s) { source = s; } void setSource(EShSource s) { source = s; }
EShSource getSource() const { return source; } EShSource getSource() const { return source; }
void setEntryPoint(const char* ep) { entryPoint = ep; } void setEntryPointName(const char* ep) { entryPointName = ep; }
const std::string& getEntryPoint() const { return entryPoint; } void setEntryPointMangledName(const char* ep) { entryPointMangledName = ep; }
const std::string& getEntryPointName() const { return entryPointName; }
const std::string& getEntryPointMangledName() const { return entryPointMangledName; }
void setVersion(int v) { version = v; } void setVersion(int v) { version = v; }
int getVersion() const { return version; } int getVersion() const { return version; }
void setProfile(EProfile p) { profile = p; } void setProfile(EProfile p) { profile = p; }
@ -363,7 +365,8 @@ protected:
const EShLanguage language; // stage, known at construction time const EShLanguage language; // stage, known at construction time
EShSource source; // source language, known a bit later EShSource source; // source language, known a bit later
std::string entryPoint; std::string entryPointName;
std::string entryPointMangledName;
EProfile profile; EProfile profile;
int version; int version;
SpvVersion spvVersion; SpvVersion spvVersion;

View File

@ -670,8 +670,8 @@ bool TReflection::addStage(EShLanguage, const TIntermediate& intermediate)
TReflectionTraverser it(intermediate, *this); TReflectionTraverser it(intermediate, *this);
// put the entry point on functions to process // put the entry point on the list of functions to process
it.pushFunction("main("); it.pushFunction(intermediate.getEntryPointMangledName().c_str());
// process all the functions // process all the functions
while (! it.functions.empty()) { while (! it.functions.empty()) {

View File

@ -850,8 +850,9 @@ TIntermAggregate* HlslParseContext::handleFunctionDefinition(const TSourceLoc& l
currentFunctionType = new TType(EbtVoid); currentFunctionType = new TType(EbtVoid);
functionReturnsValue = false; functionReturnsValue = false;
inEntryPoint = (function.getName() == intermediate.getEntryPoint().c_str()); inEntryPoint = function.getName().compare(intermediate.getEntryPointName().c_str()) == 0;
if (inEntryPoint) { if (inEntryPoint) {
intermediate.setEntryPointMangledName(function.getMangledName().c_str());
remapEntryPointIO(function); remapEntryPointIO(function);
if (entryPointOutput) { if (entryPointOutput) {
if (shouldFlatten(entryPointOutput->getType())) if (shouldFlatten(entryPointOutput->getType()))