Commit 9b962f61 by Malcolm Bechard

Partial fix for inconsistencies re: #2578

gl_SecondaryPositionNV and gl_PositionPerViewNV are inconsistently declared inside and outside of gl_PerVertex. This breaks interface block matching. For now ignore these errors since it should be fixed with how they are declared.
parent d18bcd64
#version 460 core
layout(lines_adjacency) in;
layout(triangle_strip, max_vertices = 50) out;
in vs_output
{
vec4 color;
} gs_in[];
out gs_output
{
vec4 color;
} gs_out;
void main()
{
gl_Position = gl_in[0].gl_Position;
gs_out.color = gs_in[0].color;
EmitVertex();
gs_out.color = gs_in[1].color;
gl_Position = gl_in[1].gl_Position;
EmitVertex();
gs_out.color = gs_in[0].color;
gl_Position = gl_in[0].gl_Position;
EmitVertex();
}
#version 460 core
// This test is to test isInconsistentGLPerVertexMember() workarounds.
// Without that workaround this compile fails due to block declarations
// in gl_PerVertex not being consistent for:
// gl_SecondaryPositionNV
// gl_PositionPerViewNV
out vs_output
{
vec4 color;
} vs_out;
in vec4 P;
void main()
{
vs_out.color = vec4(1.);
gl_PointSize = 1.0;
gl_Position = P;
}
...@@ -2336,6 +2336,17 @@ public: ...@@ -2336,6 +2336,17 @@ public:
name += ';' ; name += ';' ;
} }
// These variables are inconsistently declared inside and outside of gl_PerVertex in glslang right now.
// They are declared inside of 'in gl_PerVertex', but sitting as standalone when they are 'out'puts.
bool isInconsistentGLPerVertexMember(const TString& name) const
{
if (name == "gl_SecondaryPositionNV" ||
name == "gl_PositionPerViewNV")
return true;
return false;
}
// Do two structure types match? They could be declared independently, // Do two structure types match? They could be declared independently,
// in different places, but still might satisfy the definition of matching. // in different places, but still might satisfy the definition of matching.
// From the spec: // From the spec:
...@@ -2351,22 +2362,48 @@ public: ...@@ -2351,22 +2362,48 @@ public:
(isStruct() && right.isStruct() && structure == right.structure)) (isStruct() && right.isStruct() && structure == right.structure))
return true; return true;
// Both being nullptr was caught above, now they both have to be structures of the same number of elements
if (!isStruct() || !right.isStruct() ||
structure->size() != right.structure->size())
return false;
// Structure names have to match // Structure names have to match
if (*typeName != *right.typeName) if (*typeName != *right.typeName)
return false; return false;
// Compare the names and types of all the members, which have to match // There are inconsistencies with how gl_PerVertex is setup. For now ignore those as errors if they
for (unsigned int i = 0; i < structure->size(); ++i) { // are known inconsistencies.
if ((*structure)[i].type->getFieldName() != (*right.structure)[i].type->getFieldName()) bool isGLPerVertex = *typeName == "gl_PerVertex";
return false;
if (*(*structure)[i].type != *(*right.structure)[i].type) // Both being nullptr was caught above, now they both have to be structures of the same number of elements
return false; if (!isStruct() || !right.isStruct() ||
(structure->size() != right.structure->size() && !isGLPerVertex))
return false;
// Compare the names and types of all the members, which have to match
for (int li = 0, ri = 0; li < structure->size() || ri < right.structure->size(); ++li, ++ri) {
if (li < structure->size() && ri < right.structure->size()) {
if ((*structure)[li].type->getFieldName() == (*right.structure)[ri].type->getFieldName()) {
if (*(*structure)[li].type != *(*right.structure)[ri].type)
return false;
} else {
// If one of the members is something that's inconsistently declared, skip over it
// for now.
if (isGLPerVertex) {
if (isInconsistentGLPerVertexMember((*structure)[li].type->getFieldName())) {
ri--;
continue;
} else if (isInconsistentGLPerVertexMember((*right.structure)[ri].type->getFieldName())) {
li--;
continue;
}
} else {
return false;
}
}
// If we get here, then there should only be inconsistently declared members left
} else if (li < structure->size()) {
if (!isInconsistentGLPerVertexMember((*structure)[li].type->getFieldName()))
return false;
} else {
if (!isInconsistentGLPerVertexMember((*right.structure)[ri].type->getFieldName()))
return false;
}
} }
return true; return true;
......
...@@ -124,6 +124,7 @@ INSTANTIATE_TEST_SUITE_P( ...@@ -124,6 +124,7 @@ INSTANTIATE_TEST_SUITE_P(
{"link.vk.pcNamingInvalid.0.0.vert", "link.vk.pcNamingInvalid.0.1.vert"}, {"link.vk.pcNamingInvalid.0.0.vert", "link.vk.pcNamingInvalid.0.1.vert"},
{"link.vk.multiBlocksValid.0.0.vert", "link.vk.multiBlocksValid.0.1.vert"}, {"link.vk.multiBlocksValid.0.0.vert", "link.vk.multiBlocksValid.0.1.vert"},
{"link.vk.multiBlocksValid.1.0.geom", "link.vk.multiBlocksValid.1.1.geom"}, {"link.vk.multiBlocksValid.1.0.geom", "link.vk.multiBlocksValid.1.1.geom"},
{"link.vk.inconsistentGLPerVertex.0.vert", "link.vk.inconsistentGLPerVertex.0.geom"},
})) }))
); );
// clang-format on // clang-format on
......
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