| 134 | // Adapts raw Buffer::Read method to read data into a vector. |
| 135 | template <typename T> |
| 136 | Status AppendFromBuffer(const GlBuffer& buffer, std::vector<T>* data) { |
| 137 | if (buffer.bytes_size() % sizeof(T) != 0) { |
| 138 | return InvalidArgumentError("Buffer is not aligned"); |
| 139 | } |
| 140 | size_t num_elements = buffer.bytes_size() / sizeof(T); |
| 141 | data->resize(data->size() + num_elements); |
| 142 | return buffer.Read<T>( |
| 143 | absl::MakeSpan(data->data() + data->size() - num_elements, num_elements)); |
| 144 | } |
| 145 | |
| 146 | // Persistent buffer provides CPU pointer to the buffer that is valid all the |
| 147 | // time. A user should properly synchronize the access to the buffer on CPU and |