Commit b0ada803 by John Kessenich

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

parent 3ed344dd
hlsl.gs-hs-mix.tesc
Shader version: 500
vertices = 3
input primitive = triangles
vertex spacing = fractional_odd_spacing
triangle order = ccw
0:? Sequence
......@@ -402,7 +401,6 @@ Linked tessellation control stage:
Shader version: 500
vertices = 3
input primitive = triangles
vertex spacing = fractional_odd_spacing
triangle order = ccw
0:? Sequence
......
......@@ -14,3 +14,11 @@ void main(triangle in uint VertexID[3] : VertexID,
S s;
OutputStream.Append(s);
}
[maxvertexcount(4)]
void notmain(line in uint VertexID[2] : VertexID,
inout LineStream<S> OutputStream)
{
S s;
OutputStream.Append(s);
}
......@@ -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;
......
......@@ -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:
......
......@@ -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
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment