Ryan Harrison | dbc13af | 2022-02-21 15:19:07 +0000 | [diff] [blame] | 1 | // Copyright 2021 The Tint Authors. |
| 2 | // |
| 3 | // Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | // you may not use this file except in compliance with the License. |
| 5 | // You may obtain a copy of the License at |
| 6 | // |
| 7 | // http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | // |
| 9 | // Unless required by applicable law or agreed to in writing, software |
| 10 | // distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | // See the License for the specific language governing permissions and |
| 13 | // limitations under the License. |
| 14 | |
| 15 | #ifndef SRC_TINT_WRITER_ARRAY_LENGTH_FROM_UNIFORM_OPTIONS_H_ |
| 16 | #define SRC_TINT_WRITER_ARRAY_LENGTH_FROM_UNIFORM_OPTIONS_H_ |
| 17 | |
| 18 | #include <unordered_map> |
| 19 | |
dan sinclair | eebbdef | 2023-03-08 02:48:42 +0000 | [diff] [blame] | 20 | #include "src/tint/writer/binding_point.h" |
Ryan Harrison | dbc13af | 2022-02-21 15:19:07 +0000 | [diff] [blame] | 21 | |
dan sinclair | 67e79fe | 2022-04-07 14:43:05 +0000 | [diff] [blame] | 22 | namespace tint::writer { |
Ryan Harrison | dbc13af | 2022-02-21 15:19:07 +0000 | [diff] [blame] | 23 | |
| 24 | /// Options used to specify a mapping of binding points to indices into a UBO |
| 25 | /// from which to load buffer sizes. |
| 26 | struct ArrayLengthFromUniformOptions { |
dan sinclair | 41e4d9a | 2022-05-01 14:40:55 +0000 | [diff] [blame] | 27 | /// Constructor |
| 28 | ArrayLengthFromUniformOptions(); |
| 29 | /// Destructor |
| 30 | ~ArrayLengthFromUniformOptions(); |
| 31 | /// Copy constructor |
| 32 | ArrayLengthFromUniformOptions(const ArrayLengthFromUniformOptions&); |
| 33 | /// Copy assignment |
| 34 | /// @returns this ArrayLengthFromUniformOptions |
| 35 | ArrayLengthFromUniformOptions& operator=(const ArrayLengthFromUniformOptions&); |
| 36 | /// Move constructor |
| 37 | ArrayLengthFromUniformOptions(ArrayLengthFromUniformOptions&&); |
Ryan Harrison | dbc13af | 2022-02-21 15:19:07 +0000 | [diff] [blame] | 38 | |
dan sinclair | 41e4d9a | 2022-05-01 14:40:55 +0000 | [diff] [blame] | 39 | /// The binding point to use to generate a uniform buffer from which to read |
| 40 | /// buffer sizes. |
dan sinclair | eebbdef | 2023-03-08 02:48:42 +0000 | [diff] [blame] | 41 | BindingPoint ubo_binding; |
dan sinclair | 41e4d9a | 2022-05-01 14:40:55 +0000 | [diff] [blame] | 42 | /// The mapping from storage buffer binding points to the index into the |
| 43 | /// uniform buffer where the length of the buffer is stored. |
dan sinclair | eebbdef | 2023-03-08 02:48:42 +0000 | [diff] [blame] | 44 | std::unordered_map<BindingPoint, uint32_t> bindpoint_to_size_index; |
Ryan Harrison | dbc13af | 2022-02-21 15:19:07 +0000 | [diff] [blame] | 45 | |
Ben Clayton | 648bd7b | 2022-09-02 11:40:19 +0000 | [diff] [blame] | 46 | /// Reflect the fields of this class so that it can be used by tint::ForeachField() |
| 47 | TINT_REFLECT(ubo_binding, bindpoint_to_size_index); |
Ryan Harrison | dbc13af | 2022-02-21 15:19:07 +0000 | [diff] [blame] | 48 | }; |
| 49 | |
dan sinclair | 67e79fe | 2022-04-07 14:43:05 +0000 | [diff] [blame] | 50 | } // namespace tint::writer |
Ryan Harrison | dbc13af | 2022-02-21 15:19:07 +0000 | [diff] [blame] | 51 | |
| 52 | #endif // SRC_TINT_WRITER_ARRAY_LENGTH_FROM_UNIFORM_OPTIONS_H_ |