switch_descriptorset_pass.h 1.5 KB

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