// Copyright (c) 2018 Google LLC. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. #include <algorithm> #include <vector> #include "source/spirv_constant.h" #include "source/spirv_target_env.h" #include "source/val/function.h" #include "source/val/instruction.h" #include "source/val/validate.h" #include "source/val/validation_state.h" namespace spvtools { namespace val { namespace { // Limit the number of checked locations to 4096. Multiplied by 4 to represent // all the components. This limit is set to be well beyond practical use cases. const uint32_t kMaxLocations = …; // Returns true if \c inst is an input or output variable. bool is_interface_variable(const Instruction* inst, bool is_spv_1_4) { … } // Checks that \c var is listed as an interface in all the entry points that use // it. spv_result_t check_interface_variable(ValidationState_t& _, const Instruction* var) { … } // This function assumes a base location has been determined already. As such // any further location decorations are invalid. // TODO: if this code turns out to be slow, there is an opportunity to cache // the result for a given type id. spv_result_t NumConsumedLocations(ValidationState_t& _, const Instruction* type, uint32_t* num_locations) { … } // Returns the number of components consumed by types that support a component // decoration. uint32_t NumConsumedComponents(ValidationState_t& _, const Instruction* type) { … } // Populates |locations| (and/or |output_index1_locations|) with the use // location and component coordinates for |variable|. Indices are calculated as // 4 * location + component. spv_result_t GetLocationsForVariable( ValidationState_t& _, const Instruction* entry_point, const Instruction* variable, std::unordered_set<uint32_t>* locations, std::unordered_set<uint32_t>* output_index1_locations) { … } spv_result_t ValidateLocations(ValidationState_t& _, const Instruction* entry_point) { … } spv_result_t ValidateStorageClass(ValidationState_t& _, const Instruction* entry_point) { … } } // namespace spv_result_t ValidateInterfaces(ValidationState_t& _) { … } } // namespace val } // namespace spvtools