Browse Source
vulkan_common: Move dynamic library load to a separate file
vulkan_common: Move dynamic library load to a separate file
Allows us to initialize a Vulkan dynamic library from different backends without duplicating code.nce_cpp
4 changed files with 59 additions and 31 deletions
-
2src/video_core/CMakeLists.txt
-
39src/video_core/renderer_vulkan/renderer_vulkan.cpp
-
36src/video_core/vulkan_common/vulkan_library.cpp
-
13src/video_core/vulkan_common/vulkan_library.h
@ -0,0 +1,36 @@ |
|||
// Copyright 2020 yuzu Emulator Project
|
|||
// Licensed under GPLv2 or any later version
|
|||
// Refer to the license.txt file included.
|
|||
|
|||
#include <cstdlib>
|
|||
#include <string>
|
|||
|
|||
#include "common/dynamic_library.h"
|
|||
#include "common/file_util.h"
|
|||
#include "video_core/vulkan_common/vulkan_library.h"
|
|||
|
|||
namespace Vulkan { |
|||
|
|||
Common::DynamicLibrary OpenLibrary() { |
|||
Common::DynamicLibrary library; |
|||
#ifdef __APPLE__
|
|||
// Check if a path to a specific Vulkan library has been specified.
|
|||
char* const libvulkan_env = std::getenv("LIBVULKAN_PATH"); |
|||
if (!libvulkan_env || !library.Open(libvulkan_env)) { |
|||
// Use the libvulkan.dylib from the application bundle.
|
|||
const std::string filename = |
|||
Common::FS::GetBundleDirectory() + "/Contents/Frameworks/libvulkan.dylib"; |
|||
library.Open(filename.c_str()); |
|||
} |
|||
#else
|
|||
std::string filename = Common::DynamicLibrary::GetVersionedFilename("vulkan", 1); |
|||
if (!library.Open(filename.c_str())) { |
|||
// Android devices may not have libvulkan.so.1, only libvulkan.so.
|
|||
filename = Common::DynamicLibrary::GetVersionedFilename("vulkan"); |
|||
void(library.Open(filename.c_str())); |
|||
} |
|||
#endif
|
|||
return library; |
|||
} |
|||
|
|||
} // namespace Vulkan
|
|||
@ -0,0 +1,13 @@ |
|||
// Copyright 2020 yuzu Emulator Project |
|||
// Licensed under GPLv2 or any later version |
|||
// Refer to the license.txt file included. |
|||
|
|||
#pragma once |
|||
|
|||
#include "common/dynamic_library.h" |
|||
|
|||
namespace Vulkan { |
|||
|
|||
Common::DynamicLibrary OpenLibrary(); |
|||
|
|||
} // namespace Vulkan |
|||
Write
Preview
Loading…
Cancel
Save
Reference in new issue