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 16 #include "source/opt/analyze_live_input_pass.h" 17 18 #include "source/opt/ir_context.h" 19 20 namespace spvtools { 21 namespace opt { 22 Process()23Pass::Status AnalyzeLiveInputPass::Process() { 24 // Current functionality assumes shader capability 25 if (!context()->get_feature_mgr()->HasCapability(spv::Capability::Shader)) 26 return Status::SuccessWithoutChange; 27 Pass::Status status = DoLiveInputAnalysis(); 28 return status; 29 } 30 DoLiveInputAnalysis()31Pass::Status AnalyzeLiveInputPass::DoLiveInputAnalysis() { 32 // Current functionality only supports frag, tesc, tese or geom shaders. 33 // Report failure for any other stage. 34 auto stage = context()->GetStage(); 35 if (stage != spv::ExecutionModel::Fragment && 36 stage != spv::ExecutionModel::TessellationControl && 37 stage != spv::ExecutionModel::TessellationEvaluation && 38 stage != spv::ExecutionModel::Geometry) 39 return Status::Failure; 40 context()->get_liveness_mgr()->GetLiveness(live_locs_, live_builtins_); 41 return Status::SuccessWithoutChange; 42 } 43 44 } // namespace opt 45 } // namespace spvtools 46