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_DECOMPOSE_STRIDED_MATRIX_H_ 16 #define SRC_TRANSFORM_DECOMPOSE_STRIDED_MATRIX_H_ 17 18 #include "src/transform/transform.h" 19 20 namespace tint { 21 namespace transform { 22 23 /// DecomposeStridedMatrix transforms replaces matrix members of storage or 24 /// uniform buffer structures, that have a [[stride]] decoration, into an array 25 /// of N column vectors. 26 /// This transform is used by the SPIR-V reader to handle the SPIR-V 27 /// MatrixStride decoration. 28 class DecomposeStridedMatrix 29 : public Castable<DecomposeStridedMatrix, Transform> { 30 public: 31 /// Constructor 32 DecomposeStridedMatrix(); 33 34 /// Destructor 35 ~DecomposeStridedMatrix() override; 36 37 /// @param program the program to inspect 38 /// @returns true if this transform should be run for the given program 39 static bool ShouldRun(const Program* program); 40 41 protected: 42 /// Runs the transform using the CloneContext built for transforming a 43 /// program. Run() is responsible for calling Clone() on the CloneContext. 44 /// @param ctx the CloneContext primed with the input program and 45 /// ProgramBuilder 46 /// @param inputs optional extra transform-specific input data 47 /// @param outputs optional extra transform-specific output data 48 void Run(CloneContext& ctx, const DataMap& inputs, DataMap& outputs) override; 49 }; 50 51 } // namespace transform 52 } // namespace tint 53 54 #endif // SRC_TRANSFORM_DECOMPOSE_STRIDED_MATRIX_H_ 55