analyze_live_input_pass.cpp 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. // Copyright (c) 2022 The Khronos Group Inc.
  2. // Copyright (c) 2022 LunarG Inc.
  3. //
  4. // Licensed under the Apache License, Version 2.0 (the "License");
  5. // you may not use this file except in compliance with the License.
  6. // You may obtain a copy of the License at
  7. //
  8. // http://www.apache.org/licenses/LICENSE-2.0
  9. //
  10. // Unless required by applicable law or agreed to in writing, software
  11. // distributed under the License is distributed on an "AS IS" BASIS,
  12. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. // See the License for the specific language governing permissions and
  14. // limitations under the License.
  15. #include "source/opt/analyze_live_input_pass.h"
  16. #include "source/opt/ir_context.h"
  17. namespace spvtools {
  18. namespace opt {
  19. Pass::Status AnalyzeLiveInputPass::Process() {
  20. // Current functionality assumes shader capability
  21. if (!context()->get_feature_mgr()->HasCapability(spv::Capability::Shader))
  22. return Status::SuccessWithoutChange;
  23. Pass::Status status = DoLiveInputAnalysis();
  24. return status;
  25. }
  26. Pass::Status AnalyzeLiveInputPass::DoLiveInputAnalysis() {
  27. // Current functionality only supports frag, tesc, tese or geom shaders.
  28. // Report failure for any other stage.
  29. auto stage = context()->GetStage();
  30. if (stage != spv::ExecutionModel::Fragment &&
  31. stage != spv::ExecutionModel::TessellationControl &&
  32. stage != spv::ExecutionModel::TessellationEvaluation &&
  33. stage != spv::ExecutionModel::Geometry)
  34. return Status::Failure;
  35. context()->get_liveness_mgr()->GetLiveness(live_locs_, live_builtins_);
  36. return Status::SuccessWithoutChange;
  37. }
  38. } // namespace opt
  39. } // namespace spvtools