webgpu/dawn/include/tint/external_texture_options.h
 1// Copyright 2023 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 INCLUDE_TINT_EXTERNAL_TEXTURE_OPTIONS_H_
16#define INCLUDE_TINT_EXTERNAL_TEXTURE_OPTIONS_H_
17
18#include <unordered_map>
19
20#include "tint/binding_point.h"
21
22namespace tint {
23
24/// Options used to specify mappings of binding points for external textures.
25struct ExternalTextureOptions {
26    /// This struct identifies the binding groups and locations for new bindings to
27    /// use when transforming a texture_external instance.
28    struct BindingPoints {
29        /// The desired binding location of the texture_2d representing plane #1 when
30        /// a texture_external binding is expanded.
31        BindingPoint plane_1;
32        /// The desired binding location of the ExternalTextureParams uniform when a
33        /// texture_external binding is expanded.
34        BindingPoint params;
35
36        /// Reflect the fields of this class so that it can be used by tint::ForeachField()
37        TINT_REFLECT(plane_1, params);
38    };
39
40    /// BindingsMap is a map where the key is the binding location of a
41    /// texture_external and the value is a struct containing the desired
42    /// locations for new bindings expanded from the texture_external instance.
43    using BindingsMap = std::unordered_map<BindingPoint, BindingPoints>;
44
45    /// A map of new binding points to use.
46    BindingsMap bindings_map;
47
48    /// Reflect the fields of this class so that it can be used by tint::ForeachField()
49    TINT_REFLECT(bindings_map);
50};
51
52}  // namespace tint
53
54#endif  // INCLUDE_TINT_EXTERNAL_TEXTURE_OPTIONS_H_