• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2020 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_SEM_SAMPLER_TYPE_H_
16 #define SRC_SEM_SAMPLER_TYPE_H_
17 
18 #include <string>
19 
20 #include "src/ast/sampler.h"
21 #include "src/sem/type.h"
22 
23 namespace tint {
24 namespace sem {
25 
26 /// A sampler type.
27 class Sampler : public Castable<Sampler, Type> {
28  public:
29   /// Constructor
30   /// @param kind the kind of sampler
31   explicit Sampler(ast::SamplerKind kind);
32   /// Move constructor
33   Sampler(Sampler&&);
34   ~Sampler() override;
35 
36   /// @returns the sampler type
kind()37   ast::SamplerKind kind() const { return kind_; }
38 
39   /// @returns true if this is a comparison sampler
IsComparison()40   bool IsComparison() const {
41     return kind_ == ast::SamplerKind::kComparisonSampler;
42   }
43 
44   /// @returns the name for this type
45   std::string type_name() const override;
46 
47   /// @param symbols the program's symbol table
48   /// @returns the name for this type that closely resembles how it would be
49   /// declared in WGSL.
50   std::string FriendlyName(const SymbolTable& symbols) const override;
51 
52  private:
53   ast::SamplerKind const kind_;
54 };
55 
56 }  // namespace sem
57 }  // namespace tint
58 
59 #endif  // SRC_SEM_SAMPLER_TYPE_H_
60