blob: ce56e147c597a173cdf1c3c2765e8be70a5b02e7 [file] [log] [blame]
Antonio Maioranod733fdb2021-12-13 15:55:11 +00001// 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_LOCALIZE_STRUCT_ARRAY_ASSIGNMENT_H_
16#define SRC_TRANSFORM_LOCALIZE_STRUCT_ARRAY_ASSIGNMENT_H_
17
18#include "src/transform/transform.h"
19
20namespace tint {
21namespace transform {
22
23/// This transforms replaces assignment to dynamically-indexed fixed-size arrays
24/// in structs on shader-local variables with code that copies the arrays to a
25/// temporary local variable, assigns to the local variable, and copies the
26/// array back. This is to work around FXC's compilation failure for these cases
27/// (see crbug.com/tint/1206).
28class LocalizeStructArrayAssignment
29 : public Castable<LocalizeStructArrayAssignment, Transform> {
30 public:
31 /// Constructor
32 LocalizeStructArrayAssignment();
33
34 /// Destructor
35 ~LocalizeStructArrayAssignment() override;
36
37 protected:
38 /// Runs the transform using the CloneContext built for transforming a
39 /// program. Run() is responsible for calling Clone() on the CloneContext.
40 /// @param ctx the CloneContext primed with the input program and
41 /// ProgramBuilder
42 /// @param inputs optional extra transform-specific input data
43 /// @param outputs optional extra transform-specific output data
44 void Run(CloneContext& ctx, const DataMap& inputs, DataMap& outputs) override;
45
46 private:
47 class State;
48};
49
50} // namespace transform
51} // namespace tint
52
53#endif // SRC_TRANSFORM_LOCALIZE_STRUCT_ARRAY_ASSIGNMENT_H_