diff options
| author | 2020-12-24 21:24:34 -0300 | |
|---|---|---|
| committer | 2020-12-31 02:02:48 -0300 | |
| commit | d93742142243dea1355012b9f0ce7f5ac8a2dc02 (patch) | |
| tree | 67538ec18461b8d0f2e125fb7b797b89b8189db8 /src/video_core/vulkan_common | |
| parent | Merge pull request #5263 from lioncash/uninit (diff) | |
| download | yuzu-d93742142243dea1355012b9f0ce7f5ac8a2dc02.tar.gz yuzu-d93742142243dea1355012b9f0ce7f5ac8a2dc02.tar.xz yuzu-d93742142243dea1355012b9f0ce7f5ac8a2dc02.zip | |
vulkan_common: Move dynamic library load to a separate file
Allows us to initialize a Vulkan dynamic library from different backends
without duplicating code.
Diffstat (limited to 'src/video_core/vulkan_common')
| -rw-r--r-- | src/video_core/vulkan_common/vulkan_library.cpp | 36 | ||||
| -rw-r--r-- | src/video_core/vulkan_common/vulkan_library.h | 13 |
2 files changed, 49 insertions, 0 deletions
diff --git a/src/video_core/vulkan_common/vulkan_library.cpp b/src/video_core/vulkan_common/vulkan_library.cpp new file mode 100644 index 000000000..27c958221 --- /dev/null +++ b/src/video_core/vulkan_common/vulkan_library.cpp | |||
| @@ -0,0 +1,36 @@ | |||
| 1 | // Copyright 2020 yuzu Emulator Project | ||
| 2 | // Licensed under GPLv2 or any later version | ||
| 3 | // Refer to the license.txt file included. | ||
| 4 | |||
| 5 | #include <cstdlib> | ||
| 6 | #include <string> | ||
| 7 | |||
| 8 | #include "common/dynamic_library.h" | ||
| 9 | #include "common/file_util.h" | ||
| 10 | #include "video_core/vulkan_common/vulkan_library.h" | ||
| 11 | |||
| 12 | namespace Vulkan { | ||
| 13 | |||
| 14 | Common::DynamicLibrary OpenLibrary() { | ||
| 15 | Common::DynamicLibrary library; | ||
| 16 | #ifdef __APPLE__ | ||
| 17 | // Check if a path to a specific Vulkan library has been specified. | ||
| 18 | char* const libvulkan_env = std::getenv("LIBVULKAN_PATH"); | ||
| 19 | if (!libvulkan_env || !library.Open(libvulkan_env)) { | ||
| 20 | // Use the libvulkan.dylib from the application bundle. | ||
| 21 | const std::string filename = | ||
| 22 | Common::FS::GetBundleDirectory() + "/Contents/Frameworks/libvulkan.dylib"; | ||
| 23 | library.Open(filename.c_str()); | ||
| 24 | } | ||
| 25 | #else | ||
| 26 | std::string filename = Common::DynamicLibrary::GetVersionedFilename("vulkan", 1); | ||
| 27 | if (!library.Open(filename.c_str())) { | ||
| 28 | // Android devices may not have libvulkan.so.1, only libvulkan.so. | ||
| 29 | filename = Common::DynamicLibrary::GetVersionedFilename("vulkan"); | ||
| 30 | void(library.Open(filename.c_str())); | ||
| 31 | } | ||
| 32 | #endif | ||
| 33 | return library; | ||
| 34 | } | ||
| 35 | |||
| 36 | } // namespace Vulkan | ||
diff --git a/src/video_core/vulkan_common/vulkan_library.h b/src/video_core/vulkan_common/vulkan_library.h new file mode 100644 index 000000000..8b28b0e17 --- /dev/null +++ b/src/video_core/vulkan_common/vulkan_library.h | |||
| @@ -0,0 +1,13 @@ | |||
| 1 | // Copyright 2020 yuzu Emulator Project | ||
| 2 | // Licensed under GPLv2 or any later version | ||
| 3 | // Refer to the license.txt file included. | ||
| 4 | |||
| 5 | #pragma once | ||
| 6 | |||
| 7 | #include "common/dynamic_library.h" | ||
| 8 | |||
| 9 | namespace Vulkan { | ||
| 10 | |||
| 11 | Common::DynamicLibrary OpenLibrary(); | ||
| 12 | |||
| 13 | } // namespace Vulkan | ||