Fix issue with separable shader validation in iomapper

This commit is contained in:
Kevin McCullough
2021-10-13 15:32:38 -07:00
parent b9ba4c5743
commit cbab732905
15 changed files with 1350 additions and 2 deletions

View File

@@ -109,7 +109,50 @@ bool verifyIOMapping(std::string& linkingError, glslang::TProgram& program) {
success &= outQualifier.layoutLocation == inQualifier.layoutLocation;
}
else {
success &= false;
if (!in.getType()->isStruct()) {
bool found = false;
for (auto outIt : pipeOut) {
if (outIt.second->getType()->isStruct()) {
unsigned int baseLoc = outIt.second->getType()->getQualifier().hasLocation() ? outIt.second->getType()->getQualifier().layoutLocation : -1;
for (int j = 0; j < outIt.second->getType()->getStruct()->size(); j++) {
baseLoc = (*outIt.second->getType()->getStruct())[j].type->getQualifier().hasLocation() ?
(*outIt.second->getType()->getStruct())[j].type->getQualifier().layoutLocation : baseLoc;
if (baseLoc != -1) {
if (baseLoc == in.getType()->getQualifier().layoutLocation) {
found = true;
break;
}
baseLoc += glslang::TIntermediate::computeTypeLocationSize(*(*outIt.second->getType()->getStruct())[j].type, EShLangVertex);
}
}
if (found) {
break;
}
}
}
success &= found;
}
else {
unsigned int baseLoc = in.getType()->getQualifier().hasLocation() ? in.getType()->getQualifier().layoutLocation : -1;
for (int j = 0; j < in.getType()->getStruct()->size(); j++) {
baseLoc = (*in.getType()->getStruct())[j].type->getQualifier().hasLocation() ?
(*in.getType()->getStruct())[j].type->getQualifier().layoutLocation : baseLoc;
if (baseLoc != -1) {
bool isMemberFound = false;
for (auto outIt : pipeOut) {
if (baseLoc == outIt.second->getType()->getQualifier().layoutLocation) {
isMemberFound = true;
break;
}
}
if (!isMemberFound) {
success &= false;
break;
}
baseLoc += glslang::TIntermediate::computeTypeLocationSize(*(*in.getType()->getStruct())[j].type, EShLangVertex);
}
}
}
}
}
}
@@ -295,6 +338,10 @@ INSTANTIATE_TEST_SUITE_P(
::testing::ValuesIn(std::vector<IoMapData>({
{{"iomap.crossStage.vert", "iomap.crossStage.frag" }, Semantics::OpenGL},
{{"iomap.crossStage.2.vert", "iomap.crossStage.2.geom", "iomap.crossStage.2.frag" }, Semantics::OpenGL},
{{"iomap.blockOutVariableIn.vert", "iomap.blockOutVariableIn.frag"}, Semantics::OpenGL},
{{"iomap.variableOutBlockIn.vert", "iomap.variableOutBlockIn.frag"}, Semantics::OpenGL},
{{"iomap.blockOutVariableIn.2.vert", "iomap.blockOutVariableIn.geom"}, Semantics::OpenGL},
{{"iomap.variableOutBlockIn.2.vert", "iomap.variableOutBlockIn.geom"}, Semantics::OpenGL},
// vulkan semantics
{{"iomap.crossStage.vk.vert", "iomap.crossStage.vk.geom", "iomap.crossStage.vk.frag" }, Semantics::Vulkan},
}))