GLSL: Promote HLSL entry-point renaming code to be used by GLSL as well.

Fixes #1045.
This commit is contained in:
John Kessenich
2017-09-11 21:48:19 -06:00
parent 4f4683d251
commit 9855bdad00
16 changed files with 1066 additions and 957 deletions

View File

@@ -387,7 +387,7 @@ bool HlslGrammar::acceptDeclaration(TIntermNode*& nodeList)
HlslToken idToken;
TIntermAggregate* initializers = nullptr;
while (acceptIdentifier(idToken)) {
const TString *fullName = idToken.string;
TString *fullName = idToken.string;
if (parseContext.symbolTable.atGlobalLevel())
parseContext.getFullNamespaceName(fullName);
if (peekTokenClass(EHTokLeftParen)) {
@@ -2263,12 +2263,12 @@ bool HlslGrammar::acceptStructDeclarationList(TTypeList*& typeList, TIntermNode*
//
// Expects type to have EvqGlobal for a static member and
// EvqTemporary for non-static member.
bool HlslGrammar::acceptMemberFunctionDefinition(TIntermNode*& nodeList, const TType& type, const TString& memberName,
bool HlslGrammar::acceptMemberFunctionDefinition(TIntermNode*& nodeList, const TType& type, TString& memberName,
TFunctionDeclarator& declarator)
{
bool accepted = false;
const TString* functionName = &memberName;
TString* functionName = &memberName;
parseContext.getFullNamespaceName(functionName);
declarator.function = new TFunction(functionName, type);
if (type.getQualifier().storage == EvqTemporary)

View File

@@ -91,7 +91,7 @@ namespace glslang {
bool acceptConstantBufferType(TType&);
bool acceptStruct(TType&, TIntermNode*& nodeList);
bool acceptStructDeclarationList(TTypeList*&, TIntermNode*& nodeList, TVector<TFunctionDeclarator>&);
bool acceptMemberFunctionDefinition(TIntermNode*& nodeList, const TType&, const TString& memberName,
bool acceptMemberFunctionDefinition(TIntermNode*& nodeList, const TType&, TString& memberName,
TFunctionDeclarator&);
bool acceptFunctionParameters(TFunction&);
bool acceptParameterDeclaration(TFunction&);

View File

@@ -58,11 +58,10 @@ HlslParseContext::HlslParseContext(TSymbolTable& symbolTable, TIntermediate& int
const TString sourceEntryPointName,
bool forwardCompatible, EShMessages messages) :
TParseContextBase(symbolTable, interm, parsingBuiltins, version, profile, spvVersion, language, infoSink,
forwardCompatible, messages),
forwardCompatible, messages, &sourceEntryPointName),
annotationNestingLevel(0),
inputPatch(nullptr),
nextInLocation(0), nextOutLocation(0),
sourceEntryPointName(sourceEntryPointName),
entryPointFunction(nullptr),
entryPointFunctionBody(nullptr),
gsStreamOutput(nullptr),
@@ -8710,7 +8709,7 @@ void HlslParseContext::popNamespace()
// Use the class/struct nesting string to create a global name for
// a member of a class/struct.
void HlslParseContext::getFullNamespaceName(const TString*& name) const
void HlslParseContext::getFullNamespaceName(TString*& name) const
{
if (currentTypePrefix.size() == 0)
return;
@@ -8726,15 +8725,6 @@ void HlslParseContext::addScopeMangler(TString& name)
name.append(scopeMangler);
}
// Potentially rename shader entry point function
void HlslParseContext::renameShaderFunction(const TString*& name) const
{
// Replace the entry point name given in the shader with the real entry point name,
// if there is a substitution.
if (name != nullptr && *name == sourceEntryPointName)
name = NewPoolTString(intermediate.getEntryPointName().c_str());
}
// Return true if this has uniform-interface like decorations.
bool HlslParseContext::hasUniform(const TQualifier& qualifier) const
{

View File

@@ -182,7 +182,7 @@ public:
void pushNamespace(const TString& name);
void popNamespace();
void getFullNamespaceName(const TString*&) const;
void getFullNamespaceName(TString*&) const;
void addScopeMangler(TString&);
void pushSwitchSequence(TIntermSequence* sequence) { switchSequenceStack.push_back(sequence); }
@@ -207,9 +207,6 @@ public:
// Determine loop control from attributes
TLoopControl handleLoopControl(const TAttributeMap& attributes) const;
// Potentially rename shader entry point function
void renameShaderFunction(const TString*& name) const;
// Share struct buffer deep types
void shareStructBufferType(TType&);
@@ -423,7 +420,6 @@ protected:
unsigned int nextInLocation;
unsigned int nextOutLocation;
TString sourceEntryPointName;
TFunction* entryPointFunction;
TIntermNode* entryPointFunctionBody;