1 // 2 // Copyright 2020 The ANGLE Project Authors. All rights reserved. 3 // Use of this source code is governed by a BSD-style license that can be 4 // found in the LICENSE file. 5 // 6 // vulkan_icd.h : Helper for creating vulkan instances & selecting physical device. 7 8 #ifndef COMMON_VULKAN_VULKAN_ICD_H_ 9 #define COMMON_VULKAN_VULKAN_ICD_H_ 10 11 #include <string> 12 13 #include "common/Optional.h" 14 #include "common/angleutils.h" 15 #include "libANGLE/renderer/vulkan/vk_headers.h" 16 17 namespace angle 18 { 19 20 namespace vk 21 { 22 23 enum class ICD 24 { 25 Default, 26 Mock, 27 SwiftShader, 28 }; 29 30 class ScopedVkLoaderEnvironment : angle::NonCopyable 31 { 32 public: 33 ScopedVkLoaderEnvironment(bool enableValidationLayers, vk::ICD icd); 34 ~ScopedVkLoaderEnvironment(); 35 canEnableValidationLayers()36 bool canEnableValidationLayers() const { return mEnableValidationLayers; } getEnabledICD()37 vk::ICD getEnabledICD() const { return mICD; } 38 39 private: 40 bool setICDEnvironment(const char *icd); 41 42 bool mEnableValidationLayers; 43 vk::ICD mICD; 44 bool mChangedCWD; 45 Optional<std::string> mPreviousCWD; 46 bool mChangedICDEnv; 47 Optional<std::string> mPreviousICDEnv; 48 }; 49 50 void ChoosePhysicalDevice(const std::vector<VkPhysicalDevice> &physicalDevices, 51 vk::ICD preferredICD, 52 VkPhysicalDevice *physicalDeviceOut, 53 VkPhysicalDeviceProperties *physicalDevicePropertiesOut); 54 55 } // namespace vk 56 57 } // namespace angle 58 59 #endif // COMMON_VULKAN_VULKAN_ICD_H_ 60