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

Class AccessChainTraverser

glslang/MachineIndependent/ParseHelper.cpp:9090–9131  ·  view source on GitHub ↗

Generates a valid GLSL dereferencing string for the input TIntermNode

Source from the content-addressed store, hash-verified

9088// Generates a valid GLSL dereferencing string for the input TIntermNode
9089//
9090struct AccessChainTraverser : public TIntermTraverser {
9091 AccessChainTraverser() : TIntermTraverser(false, false, true)
9092 {}
9093
9094 TString path = "";
9095 TStorageQualifier topLevelStorageQualifier = TStorageQualifier::EvqLast;
9096
9097 bool visitBinary(TVisit, TIntermBinary* binary) override {
9098 if (binary->getOp() == EOpIndexDirectStruct)
9099 {
9100 const TTypeList& members = *binary->getLeft()->getType().getStruct();
9101 const TTypeLoc& member =
9102 members[binary->getRight()->getAsConstantUnion()->getConstArray()[0].getIConst()];
9103 TString memberName = member.type->getFieldName();
9104
9105 if (path != "")
9106 path.append(".");
9107
9108 path.append(memberName);
9109 }
9110
9111 if (binary->getOp() == EOpIndexDirect)
9112 {
9113 const TConstUnionArray& indices = binary->getRight()->getAsConstantUnion()->getConstArray();
9114 for (int index = 0; index < indices.size(); ++index)
9115 {
9116 path.append("[");
9117 path.append(String(indices[index].getIConst()));
9118 path.append("]");
9119 }
9120 }
9121
9122 return true;
9123 }
9124
9125 void visitSymbol(TIntermSymbol* symbol) override {
9126 if (symbol->getType().isOpaque())
9127 topLevelStorageQualifier = symbol->getQualifier().storage;
9128 if (!IsAnonymous(symbol->getName()))
9129 path.append(symbol->getName());
9130 }
9131};
9132
9133TIntermNode* TParseContext::vkRelaxedRemapFunctionArgument(const TSourceLoc& loc, TFunction* function, TIntermTyped* intermTyped)
9134{

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected