1 // Copyright (c) 2021 The Khronos Group Inc.
2 // Copyright (c) 2021 Valve Corporation
3 // Copyright (c) 2021 LunarG Inc.
4 //
5 // Licensed under the Apache License, Version 2.0 (the "License");
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
8 //
9 //     http://www.apache.org/licenses/LICENSE-2.0
10 //
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an "AS IS" BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
16 
17 #ifndef SOURCE_OPT_INTERP_FIXUP_H
18 #define SOURCE_OPT_INTERP_FIXUP_H
19 
20 #include "source/opt/ir_context.h"
21 #include "source/opt/module.h"
22 #include "source/opt/pass.h"
23 
24 namespace spvtools {
25 namespace opt {
26 
27 // Replaces overloaded internal form for GLSLstd450Interpolate* instructions
28 // with external form. Specifically, removes OpLoad from the first argument
29 // and replaces it with the pointer for the OpLoad. glslang generates the
30 // internal form. This pass is called as part of glslang HLSL legalization.
31 class InterpFixupPass : public Pass {
32  public:
name()33   const char* name() const override { return "interp-fixup"; }
34   Status Process() override;
35 
GetPreservedAnalyses()36   IRContext::Analysis GetPreservedAnalyses() override {
37     return IRContext::kAnalysisInstrToBlockMapping |
38            IRContext::kAnalysisDecorations | IRContext::kAnalysisCombinators |
39            IRContext::kAnalysisCFG | IRContext::kAnalysisDominatorAnalysis |
40            IRContext::kAnalysisLoopAnalysis | IRContext::kAnalysisNameMap |
41            IRContext::kAnalysisScalarEvolution |
42            IRContext::kAnalysisRegisterPressure |
43            IRContext::kAnalysisValueNumberTable |
44            IRContext::kAnalysisStructuredCFG |
45            IRContext::kAnalysisBuiltinVarId |
46            IRContext::kAnalysisIdToFuncMapping | IRContext::kAnalysisTypes |
47            IRContext::kAnalysisDefUse | IRContext::kAnalysisConstants;
48   }
49 };
50 
51 }  // namespace opt
52 }  // namespace spvtools
53 
54 #endif  // SOURCE_OPT_INTERP_FIXUP_H
55