| 101 | } |
| 102 | |
| 103 | ShaderVar 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 | |
| 139 | ShaderVar ShaderVar::findMember(uint32_t index) const |
| 140 | { |
no test coverage detected