SPV: Fix #904: Correctly check for built-in block redeclations for location check.

This commit is contained in:
John Kessenich 2017-05-24 23:10:28 -06:00
parent 84cc15f0d0
commit 7c9129bcb7
2 changed files with 14 additions and 6 deletions

View File

@ -1,11 +1,11 @@
#version 450
layout(location = 1) in vec4 in1;
in vec4 in2;
in vec4 in2; // ERROR
layout(location = 3) in vec4 in3;
layout(location = 1) out vec4 out1;
out vec4 out2;
out vec4 out2; // ERROR
layout(location = 3) out vec4 out3;
layout(location = 10) out inb1 {
@ -16,18 +16,24 @@ out inb2 {
layout(location = 12) vec4 a;
layout(location = 13) vec4 b;
} inbi2;
out inb3 {
out inb3 { // ERROR
vec4 a;
vec4 b;
} inbi3;
layout(location = 14) out struct S1 { vec4 a; } s1;
out struct S2 { vec4 a; } s2;
out struct S2 { vec4 a; } s2; // ERROR
struct SS { int a; };
out layout(location = 15) SS ss1;
out SS ss2;
out SS ss2; // ERROR
out gl_PerVertex {
vec4 gl_Position;
float gl_ClipDistance[2];
};
void main()
{
gl_ClipDistance[0] = 1.0;
}

View File

@ -4343,7 +4343,9 @@ void TParseContext::layoutObjectCheck(const TSourceLoc& loc, const TSymbol& symb
switch (qualifier.storage) {
case EvqVaryingIn:
case EvqVaryingOut:
if (type.getBasicType() != EbtBlock || !(*type.getStruct())[0].type->getQualifier().hasLocation())
if (type.getBasicType() != EbtBlock ||
(!(*type.getStruct())[0].type->getQualifier().hasLocation() &&
(*type.getStruct())[0].type->getQualifier().builtIn == EbvNone))
error(loc, "SPIR-V requires location for user input/output", "location", "");
break;
default: