| 38 | } |
| 39 | |
| 40 | char* VertexBuffer::GetChannel(VASemantic semantic, uint32_t unit, |
| 41 | std::set<DFType> const& requiredTypes) |
| 42 | { |
| 43 | char* data = (mSBuffer == nullptr ? mData : mSBuffer->GetData()); |
| 44 | if (!data) |
| 45 | { |
| 46 | // The system memory copy does not exist. You need to recreate it |
| 47 | // before populating it. |
| 48 | return nullptr; |
| 49 | } |
| 50 | |
| 51 | int32_t index = mVFormat.GetIndex(semantic, unit); |
| 52 | if (index < 0) |
| 53 | { |
| 54 | // The buffer does not have the specified semantic that uses the |
| 55 | // specified unit. |
| 56 | return nullptr; |
| 57 | } |
| 58 | |
| 59 | DFType type = mVFormat.GetType(index); |
| 60 | if (requiredTypes.size() > 0) |
| 61 | { |
| 62 | if (requiredTypes.find(type) == requiredTypes.end()) |
| 63 | { |
| 64 | // The type of the semantic is not in the set of required types. |
| 65 | return nullptr; |
| 66 | } |
| 67 | } |
| 68 | |
| 69 | return data + mVFormat.GetOffset(index); |
| 70 | } |
| 71 | |
| 72 |
no test coverage detected