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());
stdBuiltins = builder.import("GLSL.std.450");
builder.setMemoryModel(spv::AddressingModelLogical, spv::MemoryModelGLSL450);
shaderEntry = builder.makeEntryPoint(glslangIntermediate->getEntryPoint().c_str());
entryPoint = builder.addEntryPoint(executionModel, shaderEntry, glslangIntermediate->getEntryPoint().c_str());
shaderEntry = builder.makeEntryPoint(glslangIntermediate->getEntryPointName().c_str());
entryPoint = builder.addEntryPoint(executionModel, shaderEntry, glslangIntermediate->getEntryPointName().c_str());
// Add the source extensions
const auto& sourceExtensions = glslangIntermediate->getRequestedExtensions();
@ -2453,9 +2453,7 @@ void TGlslangToSpvTraverser::declareUseOfStructMember(const glslang::TTypeList&
bool TGlslangToSpvTraverser::isShaderEntryPoint(const glslang::TIntermAggregate* node)
{
// have to ignore mangling and just look at the base name
size_t firstOpen = node->getName().find('(');
return node->getName().compare(0, firstOpen, glslangIntermediate->getEntryPoint().c_str()) == 0;
return node->getName().compare(glslangIntermediate->getEntryPointMangledName().c_str()) == 0;
}
// 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 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"

View File

@ -1051,19 +1051,24 @@ TIntermAggregate* TParseContext::handleFunctionDefinition(const TSourceLoc& loc,
currentFunctionType = new TType(EbtVoid);
functionReturnsValue = false;
//
// Raise error message if main function takes any parameters or returns anything other than void
//
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");
// Check for entry point
if (function.getName().compare(intermediate.getEntryPointName().c_str()) == 0) {
intermediate.setEntryPointMangledName(function.getMangledName().c_str());
intermediate.incrementEntryPointCount();
inMain = true;
} else
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
//

View File

@ -697,7 +697,7 @@ bool ProcessDeferred(
parseContext = new HlslParseContext(symbolTable, intermediate, false, version, profile, spvVersion,
compiler->getLanguage(), compiler->infoSink, forwardCompatible, messages);
} else {
intermediate.setEntryPoint("main");
intermediate.setEntryPointName("main");
parseContext = new TParseContext(symbolTable, intermediate, false, version, profile, spvVersion,
compiler->getLanguage(), compiler->infoSink, forwardCompatible, messages);
}
@ -1485,7 +1485,7 @@ void TShader::setStringsWithLengthsAndNames(
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)
error(infoSink, "can't link compilation units from different source languages");
if (source == EShSourceHlsl && unit.entryPoint.size() > 0) {
if (entryPoint.size() > 0)
if (source == EShSourceHlsl && unit.entryPointName.size() > 0) {
if (entryPointName.size() > 0)
error(infoSink, "can't handle multiple entry points per stage");
else
entryPoint = unit.entryPoint;
entryPointName = unit.entryPointName;
}
numEntryPoints += unit.numEntryPoints;
numErrors += unit.numErrors;

View File

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

View File

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

View File

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