MCPcopy Create free account
hub / github.com/NVIDIAGameWorks/Falcor / findMember

Method findMember

Source/Falcor/Core/Program/ShaderVar.cpp:103–137  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

101}
102
103ShaderVar ShaderVar::findMember(std::string_view name) const
104{
105 if (!isValid())
106 return *this;
107 const ReflectionType* pType = getType();
108
109 // If the user is applying `[]` to a `ShaderVar`
110 // that represents a constant buffer (or parameter block)
111 // then we assume they mean to look up a member
112 // inside the buffer/block, and thus implicitly
113 // dereference this `ShaderVar`.
114 //
115 if (auto pResourceType = pType->asResourceType())
116 {
117 switch (pResourceType->getType())
118 {
119 case ReflectionResourceType::Type::ConstantBuffer:
120 return getParameterBlock()->getRootVar().findMember(name);
121 default:
122 break;
123 }
124 }
125
126 if (auto pStructType = pType->asStructType())
127 {
128 if (auto pMember = pStructType->findMember(name))
129 {
130 // Need to apply the offsets from member
131 TypedShaderVarOffset newOffset = TypedShaderVarOffset(pMember->getType(), mOffset + pMember->getBindLocation());
132 return ShaderVar(mpBlock, newOffset);
133 }
134 }
135
136 return ShaderVar();
137}
138
139ShaderVar ShaderVar::findMember(uint32_t index) const
140{

Callers 3

createParameterBlockMethod · 0.45
findMemberFunction · 0.45

Calls 8

asResourceTypeMethod · 0.80
getRootVarMethod · 0.80
asStructTypeMethod · 0.80
isValidFunction · 0.70
getTypeFunction · 0.70
ShaderVarClass · 0.50
getTypeMethod · 0.45

Tested by

no test coverage detected