• 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_TRANSFORM_EXTERNAL_TEXTURE_TRANSFORM_H_
16 #define SRC_TRANSFORM_EXTERNAL_TEXTURE_TRANSFORM_H_
17 
18 #include <utility>
19 
20 #include "src/transform/transform.h"
21 
22 namespace tint {
23 namespace transform {
24 
25 /// Because an external texture is comprised of 1-3 texture views we can simply
26 /// transform external textures into the appropriate number of sampled textures.
27 /// This allows us to share SPIR-V/HLSL writer paths for sampled textures
28 /// instead of adding dedicated writer paths for external textures.
29 /// ExternalTextureTransform performs this transformation.
30 class ExternalTextureTransform
31     : public Castable<ExternalTextureTransform, Transform> {
32  public:
33   /// Constructor
34   ExternalTextureTransform();
35   /// Destructor
36   ~ExternalTextureTransform() override;
37 
38  protected:
39   /// Runs the transform using the CloneContext built for transforming a
40   /// program. Run() is responsible for calling Clone() on the CloneContext.
41   /// @param ctx the CloneContext primed with the input program and
42   /// ProgramBuilder
43   /// @param inputs optional extra transform-specific input data
44   /// @param outputs optional extra transform-specific output data
45   void Run(CloneContext& ctx, const DataMap& inputs, DataMap& outputs) override;
46 };
47 
48 }  // namespace transform
49 }  // namespace tint
50 
51 #endif  // SRC_TRANSFORM_EXTERNAL_TEXTURE_TRANSFORM_H_
52