| /* | |
| * Copyright (C) 2026 The Android Open Source Project | |
| * | |
| * 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. | |
| */ | |
| #ifndef ANDROID_VULKAN_LAYERS_DISCOVERED_LAYER_LIBRARIES_H | |
| #define ANDROID_VULKAN_LAYERS_DISCOVERED_LAYER_LIBRARIES_H | |
| #include <memory> | |
| #include <string> | |
| #include <vector> | |
| #include "DiscoveredLayerLibrary.h" | |
| namespace vulkan { | |
| namespace layers { | |
| class LayerEnvironment; | |
| // This class encapsulates all layer library files that the loader discovers, | |
| // according to the Android layer mechanism specification. Library discovery | |
| // happens the first time a process starts to use one of the early Vulkan | |
| // functions. There are 3 types of libraries: | |
| // | |
| // 1) Explicit layer libraries, delievered in the application's APK | |
| // 2) Implicit layer libraries, not delievered in the application's APK | |
| // 3) System layer libraries, delievered by a platform vertical (e.g. handhelds, | |
| // XR, TV), an SoC vendor, or a device OEM manufacturer | |
| class DiscoveredLayerLibraries { | |
| public: | |
| DiscoveredLayerLibraries(const LayerEnvironment& env) : env_(env) {} | |
| void DiscoverLibraries(); | |
| const std::vector<std::shared_ptr<DiscoveredLayerLibrary>>& | |
| GetExplicitLibraries() const { | |
| return explicit_libs_; | |
| } | |
| const std::vector<std::shared_ptr<DiscoveredLayerLibrary>>& | |
| GetImplicitLibraries() const { | |
| return implicit_libs_; | |
| } | |
| const std::vector<std::shared_ptr<DiscoveredLayerLibrary>>& | |
| GetSystemLibraries() const { | |
| return system_libs_; | |
| } | |
| private: | |
| void DiscoverExplicitLibraries(); | |
| void DiscoverImplicitLibraries(); | |
| void DiscoverSystemLibraries(); | |
| void DiscoverLibrariesInPathList( | |
| const std::string& paths_str, | |
| std::vector<std::shared_ptr<DiscoveredLayerLibrary>>& list, | |
| LayerType type); | |
| void AddLibraryIfValid( | |
| const std::string& directory, | |
| const std::string& filename, | |
| std::vector<std::shared_ptr<DiscoveredLayerLibrary>>& list, | |
| LayerType type, | |
| const std::string& layer_name = "", | |
| int order = 0); | |
| const LayerEnvironment& env_; | |
| std::vector<std::shared_ptr<DiscoveredLayerLibrary>> explicit_libs_; | |
| std::vector<std::shared_ptr<DiscoveredLayerLibrary>> implicit_libs_; | |
| std::vector<std::shared_ptr<DiscoveredLayerLibrary>> system_libs_; | |
| }; | |
| } // namespace layers | |
| } // namespace vulkan | |
| #endif // ANDROID_VULKAN_LAYERS_DISCOVERED_LAYER_LIBRARIES_H |