HLSL: Fix #1974: ignore input primitives on non-entry-point functions.

This commit is contained in:
John Kessenich 2020-01-17 00:11:12 -07:00
parent 3ed344dd78
commit b0ada80356
6 changed files with 244 additions and 80 deletions

View file

@ -2516,6 +2516,8 @@ bool HlslGrammar::acceptMemberFunctionDefinition(TIntermNode*& nodeList, const T
//
bool HlslGrammar::acceptFunctionParameters(TFunction& function)
{
parseContext.beginParameterParsing(function);
// LEFT_PAREN
if (! acceptTokenClass(EHTokLeftParen))
return false;

View file

@ -69,7 +69,8 @@ HlslParseContext::HlslParseContext(TSymbolTable& symbolTable, TIntermediate& int
clipDistanceOutput(nullptr),
cullDistanceOutput(nullptr),
clipDistanceInput(nullptr),
cullDistanceInput(nullptr)
cullDistanceInput(nullptr),
parsingEntrypointParameters(false)
{
globalUniformDefaults.clear();
globalUniformDefaults.layoutMatrix = ElmRowMajor;
@ -2049,7 +2050,7 @@ TIntermNode* HlslParseContext::transformEntryPoint(const TSourceLoc& loc, TFunct
};
// if we aren't in the entry point, fix the IO as such and exit
if (userFunction.getName().compare(intermediate.getEntryPointName().c_str()) != 0) {
if (! isEntrypointName(userFunction.getName())) {
remapNonEntryPointIO(userFunction);
return nullptr;
}
@ -8884,6 +8885,10 @@ void HlslParseContext::addQualifierToExisting(const TSourceLoc& loc, TQualifier
//
bool HlslParseContext::handleInputGeometry(const TSourceLoc& loc, const TLayoutGeometry& geometry)
{
// these can be declared on non-entry-points, in which case they lose their meaning
if (! parsingEntrypointParameters)
return true;
switch (geometry) {
case ElgPoints: // fall through
case ElgLines: // ...
@ -8914,6 +8919,10 @@ bool HlslParseContext::handleOutputGeometry(const TSourceLoc& loc, const TLayout
if (language != EShLangGeometry)
return true;
// these can be declared on non-entry-points, in which case they lose their meaning
if (! parsingEntrypointParameters)
return true;
switch (geometry) {
case ElgPoints:
case ElgLineStrip:

View file

@ -183,6 +183,11 @@ public:
void getFullNamespaceName(TString*&) const;
void addScopeMangler(TString&);
void beginParameterParsing(TFunction& function)
{
parsingEntrypointParameters = isEntrypointName(function.getName());
}
void pushSwitchSequence(TIntermSequence* sequence) { switchSequenceStack.push_back(sequence); }
void popSwitchSequence() { switchSequenceStack.pop_back(); }
@ -241,6 +246,7 @@ protected:
TIntermTyped* convertInitializerList(const TSourceLoc&, const TType&, TIntermTyped* initializer, TIntermTyped* scalarInit);
bool isScalarConstructor(const TIntermNode*);
TOperator mapAtomicOp(const TSourceLoc& loc, TOperator op, bool isImage);
bool isEntrypointName(const TString& name) { return name.compare(intermediate.getEntryPointName().c_str()) == 0; }
// Return true if this node requires L-value conversion (e.g, to an imageStore).
bool shouldConvertLValue(const TIntermNode*) const;
@ -494,6 +500,7 @@ protected:
};
TMap<int, tShadowTextureSymbols*> textureShadowVariant;
bool parsingEntrypointParameters;
};
// This is the prefix we use for built-in methods to avoid namespace collisions with