• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright (c) 2023 LunarG Inc.
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 #pragma once
16 
17 #include <cstdio>
18 #include <memory>
19 #include <queue>
20 #include <unordered_map>
21 #include <unordered_set>
22 #include <vector>
23 
24 #include "source/opt/pass.h"
25 
26 namespace spvtools {
27 namespace opt {
28 
29 // See optimizer.hpp for documentation.
30 class SwitchDescriptorSetPass : public Pass {
31  public:
SwitchDescriptorSetPass(uint32_t ds_from,uint32_t ds_to)32   SwitchDescriptorSetPass(uint32_t ds_from, uint32_t ds_to)
33       : ds_from_(ds_from), ds_to_(ds_to) {}
34 
name()35   const char* name() const override { return "switch-descriptorset"; }
36 
37   Status Process() override;
38 
GetPreservedAnalyses()39   IRContext::Analysis GetPreservedAnalyses() override {
40     // this pass preserves everything except decorations
41     uint32_t mask = ((IRContext::kAnalysisEnd << 1) - 1);
42     mask &= ~static_cast<uint32_t>(IRContext::kAnalysisDecorations);
43     return static_cast<IRContext::Analysis>(mask);
44   }
45 
46  private:
47   uint32_t ds_from_;
48   uint32_t ds_to_;
49 };
50 
51 }  // namespace opt
52 }  // namespace spvtools
53