MCPcopy Create free account
hub / github.com/KhronosGroup/glslang / verifyIOMapping

Function verifyIOMapping

gtests/GlslMapIO.FromFile.cpp:61–235  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

59}
60
61bool verifyIOMapping(std::string& linkingError, glslang::TProgram& program) {
62 bool success = true;
63
64 // Verify IO Mapping by generating reflection for each stage individually
65 // and comparing layout qualifiers on the results
66
67
68 int reflectionOptions = EShReflectionDefault;
69 //reflectionOptions |= EShReflectionStrictArraySuffix;
70 //reflectionOptions |= EShReflectionBasicArraySuffix;
71 reflectionOptions |= EShReflectionIntermediateIO;
72 reflectionOptions |= EShReflectionSeparateBuffers;
73 reflectionOptions |= EShReflectionAllBlockVariables;
74 //reflectionOptions |= EShReflectionUnwrapIOBlocks;
75
76 success &= program.buildReflection(reflectionOptions);
77
78 // check that the reflection output from the individual stages all makes sense..
79 std::vector<glslang::TReflection> stageReflections;
80 for (int s = 0; s < EShLangCount; ++s) {
81 if (program.getIntermediate((EShLanguage)s)) {
82 stageReflections.emplace_back((EShReflectionOptions)reflectionOptions, (EShLanguage)s, (EShLanguage)s);
83 success &= stageReflections.back().addStage((EShLanguage)s, *program.getIntermediate((EShLanguage)s));
84 }
85 }
86
87 // check that input/output locations match between stages
88 auto it = stageReflections.begin();
89 auto nextIt = it + 1;
90 for (; nextIt != stageReflections.end(); it++, nextIt++) {
91 int numOut = it->getNumPipeOutputs();
92 std::map<std::string, const glslang::TObjectReflection*> pipeOut;
93
94 for (int i = 0; i < numOut; i++) {
95 const glslang::TObjectReflection& out = it->getPipeOutput(i);
96 std::string name = interfaceName(out);
97 pipeOut[name] = &out;
98 }
99
100 int numIn = nextIt->getNumPipeInputs();
101 for (int i = 0; i < numIn; i++) {
102 auto in = nextIt->getPipeInput(i);
103 std::string name = interfaceName(in);
104 auto out = pipeOut.find(name);
105
106 if (out != pipeOut.end()) {
107 auto inQualifier = in.getType()->getQualifier();
108 auto outQualifier = out->second->getType()->getQualifier();
109 success &= outQualifier.layoutLocation == inQualifier.layoutLocation;
110 }
111 else {
112 if (!in.getType()->isStruct()) {
113 bool found = false;
114 for (auto outIt : pipeOut) {
115 if (outIt.second->getType()->isStruct()) {
116 unsigned int baseLoc = outIt.second->getType()->getQualifier().hasLocation() ?
117 outIt.second->getType()->getQualifier().layoutLocation :
118 std::numeric_limits<unsigned int>::max();

Callers 1

TEST_PFunction · 0.70

Calls 15

buildReflectionMethod · 0.80
beginMethod · 0.80
endMethod · 0.80
getTypeMethod · 0.80
hasLocationMethod · 0.80
getStructMethod · 0.80
getNumUniformsMethod · 0.80
interfaceNameFunction · 0.70
addStageMethod · 0.45
getNumPipeOutputsMethod · 0.45
getNumPipeInputsMethod · 0.45

Tested by

no test coverage detected