| 83 | |
| 84 | template <typename T> |
| 85 | Status Texture2D::WriteData(CLCommandQueue* queue, const absl::Span<T> data) { |
| 86 | const int element_size = ChannelTypeToSizeInBytes(channel_type_); |
| 87 | if (sizeof(T) % element_size != 0) { |
| 88 | return InvalidArgumentError( |
| 89 | "Template type T has not suitable element type for created texture."); |
| 90 | } |
| 91 | if (4 * width_ * height_ * element_size != data.size() * sizeof(T)) { |
| 92 | return InvalidArgumentError( |
| 93 | "absl::Span<T> data size is different from texture allocated size."); |
| 94 | } |
| 95 | |
| 96 | RETURN_IF_ERROR(queue->EnqueueWriteImage(texture_, int3(width_, height_, 1), |
| 97 | data.data())); |
| 98 | |
| 99 | return OkStatus(); |
| 100 | } |
| 101 | |
| 102 | template <typename T> |
| 103 | Status Texture2D::ReadData(CLCommandQueue* queue, |
nothing calls this directly
no test coverage detected