Commit 6896e35c by Nicolas Capens Committed by Nicolas Capens

Fix validation of statically referenced varyings.

Varyings and in/out variables that are passed between shader pipeline stages are verified to have matching types at link-time, even when only statically referenced (this includes trivially optimized out branches) or even just declared. GLSL ES 3.00 - 4.3.10 Linking of Vertex Outputs and Fragment Inputs Change-Id: I122b1cdcc4630c86a8ebfb4d4e37f3a7a335afbe Reviewed-on: https://swiftshader-review.googlesource.com/16070Tested-by: 's avatarNicolas Capens <nicolascapens@google.com> Reviewed-by: 's avatarAlexis Hétu <sugoi@google.com> Reviewed-by: 's avatarNicolas Capens <nicolascapens@google.com>
parent 2d261a56
......@@ -661,14 +661,23 @@ namespace glsl
void OutputASM::visitSymbol(TIntermSymbol *symbol)
{
// Vertex varyings don't have to be actively used to successfully link
// against pixel shaders that use them. So make sure they're declared.
if(symbol->getQualifier() == EvqVaryingOut || symbol->getQualifier() == EvqInvariantVaryingOut || symbol->getQualifier() == EvqVertexOut)
{
// The type of vertex outputs and fragment inputs with the same name must match (validated at link time),
// so declare them but don't assign a register index yet (one will be assigned when referenced in reachable code).
switch(symbol->getQualifier())
{
case EvqVaryingIn:
case EvqVaryingOut:
case EvqInvariantVaryingIn:
case EvqInvariantVaryingOut:
case EvqVertexOut:
case EvqFragmentIn:
if(symbol->getBasicType() != EbtInvariant) // Typeless declarations are not new varyings
{
declareVarying(symbol, -1);
}
break;
default:
break;
}
TInterfaceBlock* block = symbol->getType().getInterfaceBlock();
......
......@@ -208,10 +208,10 @@ public:
bool insert(TSymbol *symbol);
// Insert a function using its unmangled name as the key.
bool insertUnmangled(TFunction *function);
// Insert a function using its unmangled name as the key.
bool insertUnmangled(TFunction *function);
TSymbol *find(const TString &name) const;
TSymbol *find(const TString &name) const;
static int nextUniqueId()
{
......
......@@ -1349,9 +1349,13 @@ namespace es2
if(!matched)
{
appendToInfoLog("Fragment varying %s does not match any vertex varying", input.name.c_str());
// If a fragment varying is declared but not statically used, it's not an error to not have a matching vertex varying.
if(input.registerIndex >= 0)
{
appendToInfoLog("Fragment varying %s does not match any vertex varying", input.name.c_str());
return false;
return false;
}
}
}
......
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