• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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_AST_INTERPOLATE_DECORATION_H_
16 #define SRC_AST_INTERPOLATE_DECORATION_H_
17 
18 #include <ostream>
19 #include <string>
20 
21 #include "src/ast/decoration.h"
22 
23 namespace tint {
24 namespace ast {
25 
26 /// The interpolation type.
27 enum class InterpolationType { kPerspective, kLinear, kFlat };
28 
29 /// The interpolation sampling.
30 enum class InterpolationSampling { kNone = -1, kCenter, kCentroid, kSample };
31 
32 /// An interpolate decoration
33 class InterpolateDecoration
34     : public Castable<InterpolateDecoration, Decoration> {
35  public:
36   /// Create an interpolate decoration.
37   /// @param pid the identifier of the program that owns this node
38   /// @param src the source of this node
39   /// @param type the interpolation type
40   /// @param sampling the interpolation sampling
41   InterpolateDecoration(ProgramID pid,
42                         const Source& src,
43                         InterpolationType type,
44                         InterpolationSampling sampling);
45   ~InterpolateDecoration() override;
46 
47   /// @returns the WGSL name for the decoration
48   std::string Name() const override;
49 
50   /// Clones this node and all transitive child nodes using the `CloneContext`
51   /// `ctx`.
52   /// @param ctx the clone context
53   /// @return the newly cloned node
54   const InterpolateDecoration* Clone(CloneContext* ctx) const override;
55 
56   /// The interpolation type
57   const InterpolationType type;
58 
59   /// The interpolation sampling
60   const InterpolationSampling sampling;
61 };
62 
63 /// @param out the std::ostream to write to
64 /// @param type the interpolation type
65 /// @return the std::ostream so calls can be chained
66 std::ostream& operator<<(std::ostream& out, InterpolationType type);
67 
68 /// @param out the std::ostream to write to
69 /// @param sampling the interpolation sampling
70 /// @return the std::ostream so calls can be chained
71 std::ostream& operator<<(std::ostream& out, InterpolationSampling sampling);
72 
73 }  // namespace ast
74 }  // namespace tint
75 
76 #endif  // SRC_AST_INTERPOLATE_DECORATION_H_
77