blob: b8b304aa34870fdb5afb92ec16586c18ea77c0bb [file] [log] [blame]
Ryan Harrisondbc13af2022-02-21 15:19:07 +00001// 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 sinclaireebbdef2023-03-08 02:48:42 +000020#include "src/tint/writer/binding_point.h"
Ryan Harrisondbc13af2022-02-21 15:19:07 +000021
dan sinclair67e79fe2022-04-07 14:43:05 +000022namespace tint::writer {
Ryan Harrisondbc13af2022-02-21 15:19:07 +000023
24/// Options used to specify a mapping of binding points to indices into a UBO
25/// from which to load buffer sizes.
26struct ArrayLengthFromUniformOptions {
dan sinclair41e4d9a2022-05-01 14:40:55 +000027 /// 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 Harrisondbc13af2022-02-21 15:19:07 +000038
dan sinclair41e4d9a2022-05-01 14:40:55 +000039 /// The binding point to use to generate a uniform buffer from which to read
40 /// buffer sizes.
dan sinclaireebbdef2023-03-08 02:48:42 +000041 BindingPoint ubo_binding;
dan sinclair41e4d9a2022-05-01 14:40:55 +000042 /// The mapping from storage buffer binding points to the index into the
43 /// uniform buffer where the length of the buffer is stored.
dan sinclaireebbdef2023-03-08 02:48:42 +000044 std::unordered_map<BindingPoint, uint32_t> bindpoint_to_size_index;
Ryan Harrisondbc13af2022-02-21 15:19:07 +000045
Ben Clayton648bd7b2022-09-02 11:40:19 +000046 /// 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 Harrisondbc13af2022-02-21 15:19:07 +000048};
49
dan sinclair67e79fe2022-04-07 14:43:05 +000050} // namespace tint::writer
Ryan Harrisondbc13af2022-02-21 15:19:07 +000051
52#endif // SRC_TINT_WRITER_ARRAY_LENGTH_FROM_UNIFORM_OPTIONS_H_