diff --git a/SPIRV/GlslangToSpv.cpp b/SPIRV/GlslangToSpv.cpp index eab7cec8..72865886 100755 --- a/SPIRV/GlslangToSpv.cpp +++ b/SPIRV/GlslangToSpv.cpp @@ -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. diff --git a/glslang/Include/revision.h b/glslang/Include/revision.h index 2058a258..a496025a 100644 --- a/glslang/Include/revision.h +++ b/glslang/Include/revision.h @@ -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" diff --git a/glslang/MachineIndependent/ParseHelper.cpp b/glslang/MachineIndependent/ParseHelper.cpp index c15d721e..3c9caf13 100644 --- a/glslang/MachineIndependent/ParseHelper.cpp +++ b/glslang/MachineIndependent/ParseHelper.cpp @@ -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 // diff --git a/glslang/MachineIndependent/ShaderLang.cpp b/glslang/MachineIndependent/ShaderLang.cpp index c0510c7a..414a62b3 100644 --- a/glslang/MachineIndependent/ShaderLang.cpp +++ b/glslang/MachineIndependent/ShaderLang.cpp @@ -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); } // diff --git a/glslang/MachineIndependent/linkValidate.cpp b/glslang/MachineIndependent/linkValidate.cpp index 9fd93a78..afffb374 100644 --- a/glslang/MachineIndependent/linkValidate.cpp +++ b/glslang/MachineIndependent/linkValidate.cpp @@ -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; diff --git a/glslang/MachineIndependent/localintermediate.h b/glslang/MachineIndependent/localintermediate.h index 0491bdd6..3ce615ee 100644 --- a/glslang/MachineIndependent/localintermediate.h +++ b/glslang/MachineIndependent/localintermediate.h @@ -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; diff --git a/glslang/MachineIndependent/reflection.cpp b/glslang/MachineIndependent/reflection.cpp index a951122a..d5577656 100644 --- a/glslang/MachineIndependent/reflection.cpp +++ b/glslang/MachineIndependent/reflection.cpp @@ -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()) { diff --git a/hlsl/hlslParseHelper.cpp b/hlsl/hlslParseHelper.cpp index edbb7060..4e43bff0 100755 --- a/hlsl/hlslParseHelper.cpp +++ b/hlsl/hlslParseHelper.cpp @@ -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()))