vulkan_library.cpp 1.2 KB

123456789101112131415161718192021222324252627282930313233343536
  1. // Copyright 2020 yuzu Emulator Project
  2. // Licensed under GPLv2 or any later version
  3. // Refer to the license.txt file included.
  4. #include <cstdlib>
  5. #include <string>
  6. #include "common/dynamic_library.h"
  7. #include "common/file_util.h"
  8. #include "video_core/vulkan_common/vulkan_library.h"
  9. namespace Vulkan {
  10. Common::DynamicLibrary OpenLibrary() {
  11. Common::DynamicLibrary library;
  12. #ifdef __APPLE__
  13. // Check if a path to a specific Vulkan library has been specified.
  14. char* const libvulkan_env = std::getenv("LIBVULKAN_PATH");
  15. if (!libvulkan_env || !library.Open(libvulkan_env)) {
  16. // Use the libvulkan.dylib from the application bundle.
  17. const std::string filename =
  18. Common::FS::GetBundleDirectory() + "/Contents/Frameworks/libvulkan.dylib";
  19. void(library.Open(filename.c_str()));
  20. }
  21. #else
  22. std::string filename = Common::DynamicLibrary::GetVersionedFilename("vulkan", 1);
  23. if (!library.Open(filename.c_str())) {
  24. // Android devices may not have libvulkan.so.1, only libvulkan.so.
  25. filename = Common::DynamicLibrary::GetVersionedFilename("vulkan");
  26. void(library.Open(filename.c_str()));
  27. }
  28. #endif
  29. return library;
  30. }
  31. } // namespace Vulkan