diff --git a/.gitmodules b/.gitmodules
index 4ae9400cff..09ed6b807a 100644
--- a/.gitmodules
+++ b/.gitmodules
@@ -54,3 +54,6 @@
[submodule "Externals/rcheevos/rcheevos"]
path = Externals/rcheevos/rcheevos
url = https://github.com/RetroAchievements/rcheevos.git
+[submodule "Externals/libadrenotools"]
+ path = Externals/libadrenotools
+ url = https://github.com/bylaws/libadrenotools.git
diff --git a/CMakeLists.txt b/CMakeLists.txt
index dcb7f1b94a..c837ddd9c9 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -728,6 +728,11 @@ if(ENABLE_VULKAN)
if(APPLE AND USE_BUNDLED_MOLTENVK)
add_subdirectory(Externals/MoltenVK)
endif()
+
+
+ if (ANDROID AND _M_ARM_64)
+ add_subdirectory(Externals/libadrenotools)
+ endif()
endif()
if(NOT WIN32 OR (NOT (CMAKE_SYSTEM_PROCESSOR STREQUAL "aarch64")))
diff --git a/Externals/libadrenotools b/Externals/libadrenotools
new file mode 160000
index 0000000000..f4ce3c9618
--- /dev/null
+++ b/Externals/libadrenotools
@@ -0,0 +1 @@
+Subproject commit f4ce3c9618e7ecfcdd238b17dad9a0b888f5de90
diff --git a/Source/Android/app/build.gradle b/Source/Android/app/build.gradle
index 36ed3baf02..3ad867b2a6 100644
--- a/Source/Android/app/build.gradle
+++ b/Source/Android/app/build.gradle
@@ -1,6 +1,7 @@
plugins {
id 'com.android.application'
id 'org.jetbrains.kotlin.android'
+ id 'org.jetbrains.kotlin.plugin.serialization' version "1.7.20"
}
task copyProfile (type: Copy) {
@@ -110,6 +111,7 @@ android {
externalNativeBuild {
cmake {
path "../../../CMakeLists.txt"
+ version "3.22.1+"
}
}
namespace 'org.dolphinemu.dolphinemu'
@@ -122,7 +124,7 @@ android {
abiFilters "arm64-v8a", "x86_64" //, "armeabi-v7a", "x86"
// Remove the line below if you want to build the C++ unit tests
- targets "main"
+ //targets "main", "hook_impl", "main_hook", "gsl_alloc_hook", "file_redirect_hook"
}
}
}
@@ -160,6 +162,9 @@ dependencies {
// For loading game covers from disk and GameTDB
implementation 'io.coil-kt:coil:2.2.2'
+ // For loading custom GPU drivers
+ implementation "org.jetbrains.kotlinx:kotlinx-serialization-json:1.3.3"
+
implementation 'com.nononsenseapps:filepicker:4.2.1'
}
diff --git a/Source/Android/app/src/main/AndroidManifest.xml b/Source/Android/app/src/main/AndroidManifest.xml
index f470bafee7..db35188e6e 100644
--- a/Source/Android/app/src/main/AndroidManifest.xml
+++ b/Source/Android/app/src/main/AndroidManifest.xml
@@ -41,7 +41,8 @@
android:supportsRtl="true"
android:isGame="true"
android:banner="@drawable/banner_tv"
- android:hasFragileUserData="true">
+ android:hasFragileUserData="true"
+ android:extractNativeLibs="true">
@@ -82,6 +83,13 @@
android:theme="@style/Theme.Dolphin.Main"
android:label="@string/settings"/>
+
+
GitHub
Support
\u00A9 2003–2015+ Dolphin Team. \u201cGameCube\u201d and \u201cWii\u201d are trademarks of Nintendo. Dolphin is not affiliated with Nintendo in any way.
+ System driver
+ The GPU driver that is part of the OS.
+
+
+ GPU driver
+ Installing the GPU driver…
+ GPU driver installed successfully
+ Failed to unzip the provided driver package
+ The supplied driver package is invalid due to missing metadata
+ The supplied driver package contains invalid metadata, it may be corrupted
+ Your device doesn\'t meet the minimum Android version requirements for the supplied driver
+ The supplied driver package is already installled
Emulated USB Devices
diff --git a/Source/Android/jni/CMakeLists.txt b/Source/Android/jni/CMakeLists.txt
index bc48ec26db..7218c64924 100644
--- a/Source/Android/jni/CMakeLists.txt
+++ b/Source/Android/jni/CMakeLists.txt
@@ -30,6 +30,7 @@ add_library(main SHARED
RiivolutionPatches.cpp
SkylanderConfig.cpp
WiiUtils.cpp
+ GpuDriver.cpp
)
target_link_libraries(main
@@ -50,6 +51,12 @@ PRIVATE
"-Wl,--no-whole-archive"
)
+target_include_directories(main
+PRIVATE
+ ${CMAKE_SOURCE_DIR}/Externals/libadrenotools/include
+ ${CMAKE_SOURCE_DIR}/Externals/VulkanMemoryAllocator/include
+)
+
file(MAKE_DIRECTORY ${CMAKE_SOURCE_DIR}/Source/Android/app/src/main/assets/)
file(REMOVE_RECURSE ${CMAKE_SOURCE_DIR}/Source/Android/app/src/main/assets/Sys/)
file(COPY ${CMAKE_SOURCE_DIR}/Data/Sys DESTINATION ${CMAKE_SOURCE_DIR}/Source/Android/app/src/main/assets/)
diff --git a/Source/Android/jni/GpuDriver.cpp b/Source/Android/jni/GpuDriver.cpp
new file mode 100644
index 0000000000..0631ce81cb
--- /dev/null
+++ b/Source/Android/jni/GpuDriver.cpp
@@ -0,0 +1,147 @@
+// Copyright 2023 Dolphin Emulator Project
+// SPDX-License-Identifier: GPL-2.0-or-later
+
+// Based on: Skyline Emulator Project
+// SPDX-License-Identifier: MPL-2.0
+// Copyright © 2022 Skyline Team and Contributors (https://github.com/skyline-emu/)
+
+#include
+
+#include "Common/IniFile.h"
+#include "jni/AndroidCommon/AndroidCommon.h"
+#include "jni/AndroidCommon/IDCache.h"
+
+#include
+#include
+#include
+#include
+#include "adrenotools/driver.h"
+
+#include "VideoBackends/Vulkan/VulkanContext.h"
+#include "VideoBackends/Vulkan/VulkanLoader.h"
+
+extern "C" {
+
+#if defined(_M_ARM_64)
+
+JNIEXPORT jobjectArray JNICALL
+Java_org_dolphinemu_dolphinemu_utils_GpuDriverHelper_00024Companion_getSystemDriverInfo(JNIEnv* env,
+ jobject)
+{
+ if (!Vulkan::LoadVulkanLibrary(true))
+ {
+ return nullptr;
+ }
+
+ u32 vk_api_version = 0;
+ VkInstance instance = Vulkan::VulkanContext::CreateVulkanInstance(WindowSystemType::Headless,
+ false, false, &vk_api_version);
+ if (!instance)
+ {
+ return nullptr;
+ }
+
+ if (!Vulkan::LoadVulkanInstanceFunctions(instance))
+ {
+ vkDestroyInstance(instance, nullptr);
+ return nullptr;
+ }
+
+ Vulkan::VulkanContext::GPUList gpu_list = Vulkan::VulkanContext::EnumerateGPUs(instance);
+
+ if (gpu_list.empty())
+ {
+ vkDestroyInstance(instance, nullptr);
+ Vulkan::UnloadVulkanLibrary();
+ return nullptr;
+ }
+
+ VkPhysicalDeviceProperties properties;
+ vkGetPhysicalDeviceProperties(gpu_list.front(), &properties);
+
+ std::string driverId;
+ if (vkGetPhysicalDeviceProperties2 && vk_api_version >= VK_VERSION_1_1)
+ {
+ VkPhysicalDeviceDriverProperties driverProperties;
+ driverProperties.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DRIVER_PROPERTIES;
+ driverProperties.pNext = nullptr;
+ VkPhysicalDeviceProperties2 properties2;
+ properties2.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PROPERTIES_2;
+ properties2.pNext = &driverProperties;
+ vkGetPhysicalDeviceProperties2(gpu_list.front(), &properties2);
+ driverId = fmt::format("{}", driverProperties.driverID);
+ }
+ else
+ {
+ driverId = "Unknown";
+ }
+
+ std::string driverVersion =
+ fmt::format("{}.{}.{}", VK_API_VERSION_MAJOR(properties.driverVersion),
+ VK_API_VERSION_MINOR(properties.driverVersion),
+ VK_API_VERSION_PATCH(properties.driverVersion));
+
+ vkDestroyInstance(instance, nullptr);
+ Vulkan::UnloadVulkanLibrary();
+
+ auto array = env->NewObjectArray(2, env->FindClass("java/lang/String"), nullptr);
+ env->SetObjectArrayElement(array, 0, ToJString(env, driverId));
+ env->SetObjectArrayElement(array, 1, ToJString(env, driverVersion));
+ return array;
+}
+
+JNIEXPORT jboolean JNICALL
+Java_org_dolphinemu_dolphinemu_utils_GpuDriverHelper_00024Companion_supportsCustomDriverLoading(
+ JNIEnv* env, jobject instance)
+{
+ // If the KGSL device exists custom drivers can be loaded using adrenotools
+ return Vulkan::SupportsCustomDriver();
+}
+
+JNIEXPORT jboolean JNICALL
+Java_org_dolphinemu_dolphinemu_utils_GpuDriverHelper_00024Companion_supportsForceMaxGpuClocks(
+ JNIEnv* env, jobject instance)
+{
+ // If the KGSL device exists adrenotools can be used to set GPU turbo mode
+ return Vulkan::SupportsCustomDriver();
+}
+
+JNIEXPORT void JNICALL
+Java_org_dolphinemu_dolphinemu_utils_GpuDriverHelper_00024Companion_forceMaxGpuClocks(
+ JNIEnv* env, jobject instance, jboolean enable)
+{
+ adrenotools_set_turbo(enable);
+}
+
+#else
+
+JNIEXPORT jobjectArray JNICALL
+Java_org_dolphinemu_dolphinemu_utils_GpuDriverHelper_00024Companion_getSystemDriverInfo(
+ JNIEnv* env, jobject instance)
+{
+ auto array = env->NewObjectArray(0, env->FindClass("java/lang/String"), nullptr);
+ return array;
+}
+
+JNIEXPORT jboolean JNICALL
+Java_org_dolphinemu_dolphinemu_utils_GpuDriverHelper_00024Companion_supportsCustomDriverLoading(
+ JNIEnv* env, jobject instance)
+{
+ return false;
+}
+
+JNIEXPORT jboolean JNICALL
+Java_org_dolphinemu_dolphinemu_utils_GpuDriverHelper_00024Companion_supportsForceMaxGpuClocks(
+ JNIEnv* env, jobject instance)
+{
+ return false;
+}
+
+JNIEXPORT void JNICALL
+Java_org_dolphinemu_dolphinemu_utils_GpuDriverHelper_00024Companion_forceMaxGpuClocks(
+ JNIEnv* env, jobject instance, jboolean enable)
+{
+}
+
+#endif
+}
diff --git a/Source/Android/jni/MainAndroid.cpp b/Source/Android/jni/MainAndroid.cpp
index 30f0f5995e..d73c9f3d75 100644
--- a/Source/Android/jni/MainAndroid.cpp
+++ b/Source/Android/jni/MainAndroid.cpp
@@ -371,6 +371,15 @@ JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_utils_DirectoryInitializat
File::SetSysDirectory(path);
}
+JNIEXPORT void JNICALL
+Java_org_dolphinemu_dolphinemu_utils_DirectoryInitialization_SetGpuDriverDirectories(
+ JNIEnv* env, jclass, jstring jPath, jstring jLibPath)
+{
+ const std::string path = GetJString(env, jPath);
+ const std::string lib_path = GetJString(env, jLibPath);
+ File::SetGpuDriverDirectories(path, lib_path);
+}
+
JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_SetUserDirectory(
JNIEnv* env, jclass, jstring jDirectory)
{
diff --git a/Source/Core/Common/CommonPaths.h b/Source/Core/Common/CommonPaths.h
index b22033a5cd..44ada6dd19 100644
--- a/Source/Core/Common/CommonPaths.h
+++ b/Source/Core/Common/CommonPaths.h
@@ -163,3 +163,10 @@
// Subdirs in Config
#define GRAPHICSMOD_CONFIG_DIR "GraphicMods"
+
+// GPU drivers
+#define GPU_DRIVERS "GpuDrivers"
+#define GPU_DRIVERS_EXTRACTED "Extracted"
+#define GPU_DRIVERS_TMP "Tmp"
+#define GPU_DRIVERS_HOOK "Hook"
+#define GPU_DRIVERS_FILE_REDIRECT "FileRedirect"
diff --git a/Source/Core/Common/DynamicLibrary.cpp b/Source/Core/Common/DynamicLibrary.cpp
index 039b0a034c..7871198dda 100644
--- a/Source/Core/Common/DynamicLibrary.cpp
+++ b/Source/Core/Common/DynamicLibrary.cpp
@@ -24,11 +24,22 @@ DynamicLibrary::DynamicLibrary(const char* filename)
Open(filename);
}
+DynamicLibrary::DynamicLibrary(void* handle)
+{
+ m_handle = handle;
+}
+
DynamicLibrary::~DynamicLibrary()
{
Close();
}
+DynamicLibrary& DynamicLibrary::operator=(void* handle)
+{
+ m_handle = handle;
+ return *this;
+}
+
std::string DynamicLibrary::GetUnprefixedFilename(const char* filename)
{
#if defined(_WIN32)
diff --git a/Source/Core/Common/DynamicLibrary.h b/Source/Core/Common/DynamicLibrary.h
index edfcde8ff3..29cafbafb2 100644
--- a/Source/Core/Common/DynamicLibrary.h
+++ b/Source/Core/Common/DynamicLibrary.h
@@ -21,6 +21,8 @@ public:
// Automatically loads the specified library. Call IsOpen() to check validity before use.
DynamicLibrary(const char* filename);
+ DynamicLibrary(void* handle);
+
// Closes the library.
~DynamicLibrary();
@@ -30,6 +32,8 @@ public:
DynamicLibrary& operator=(const DynamicLibrary&) = delete;
DynamicLibrary& operator=(DynamicLibrary&&) = delete;
+ DynamicLibrary& operator=(void*);
+
// Returns the specified library name with the platform-specific suffix added.
static std::string GetUnprefixedFilename(const char* filename);
diff --git a/Source/Core/Common/FileUtil.cpp b/Source/Core/Common/FileUtil.cpp
index 9a494ab2e0..f5842c14f9 100644
--- a/Source/Core/Common/FileUtil.cpp
+++ b/Source/Core/Common/FileUtil.cpp
@@ -66,6 +66,8 @@ namespace File
{
#ifdef ANDROID
static std::string s_android_sys_directory;
+static std::string s_android_driver_directory;
+static std::string s_android_lib_directory;
#endif
#ifdef __APPLE__
@@ -796,6 +798,34 @@ void SetSysDirectory(const std::string& path)
s_android_sys_directory);
s_android_sys_directory = path;
}
+
+void SetGpuDriverDirectories(const std::string& path, const std::string& lib_path)
+{
+ INFO_LOG_FMT(COMMON, "Setting Driver directory to {} and library path to {}", path, lib_path);
+ ASSERT_MSG(COMMON, s_android_driver_directory.empty(), "Driver directory already set to {}",
+ s_android_driver_directory);
+ ASSERT_MSG(COMMON, s_android_lib_directory.empty(), "Library directory already set to {}",
+ s_android_lib_directory);
+ s_android_driver_directory = path;
+ s_android_lib_directory = lib_path;
+}
+
+const std::string GetGpuDriverDirectory(unsigned int dir_index)
+{
+ switch (dir_index)
+ {
+ case D_GPU_DRIVERS_EXTRACTED:
+ return s_android_driver_directory + DIR_SEP GPU_DRIVERS_EXTRACTED DIR_SEP;
+ case D_GPU_DRIVERS_TMP:
+ return s_android_driver_directory + DIR_SEP GPU_DRIVERS_TMP DIR_SEP;
+ case D_GPU_DRIVERS_HOOKS:
+ return s_android_lib_directory;
+ case D_GPU_DRIVERS_FILE_REDIRECT:
+ return s_android_driver_directory + DIR_SEP GPU_DRIVERS_FILE_REDIRECT DIR_SEP;
+ }
+ return "";
+}
+
#endif
static std::string s_user_paths[NUM_PATH_INDICES];
diff --git a/Source/Core/Common/FileUtil.h b/Source/Core/Common/FileUtil.h
index 2a2e112039..8d5f312d65 100644
--- a/Source/Core/Common/FileUtil.h
+++ b/Source/Core/Common/FileUtil.h
@@ -67,6 +67,10 @@ enum
D_GBAUSER_IDX,
D_GBASAVES_IDX,
D_WIISDCARDSYNCFOLDER_IDX,
+ D_GPU_DRIVERS_EXTRACTED,
+ D_GPU_DRIVERS_TMP,
+ D_GPU_DRIVERS_HOOKS,
+ D_GPU_DRIVERS_FILE_REDIRECT,
FIRST_FILE_USER_PATH_IDX,
F_DOLPHINCONFIG_IDX = FIRST_FILE_USER_PATH_IDX,
F_GCPADCONFIG_IDX,
@@ -228,6 +232,8 @@ const std::string& GetSysDirectory();
#ifdef ANDROID
void SetSysDirectory(const std::string& path);
+void SetGpuDriverDirectories(const std::string& path, const std::string& lib_path);
+const std::string GetGpuDriverDirectory(unsigned int dir_index);
#endif
#ifdef __APPLE__
diff --git a/Source/Core/Core/Config/GraphicsSettings.cpp b/Source/Core/Core/Config/GraphicsSettings.cpp
index ff621b48c2..f4c16b286c 100644
--- a/Source/Core/Core/Config/GraphicsSettings.cpp
+++ b/Source/Core/Core/Config/GraphicsSettings.cpp
@@ -111,6 +111,8 @@ const Info GFX_PREFER_GLES{{System::GFX, "Settings", "PreferGLES"}, false}
const Info GFX_MODS_ENABLE{{System::GFX, "Settings", "EnableMods"}, false};
+const Info GFX_DRIVER_LIB_NAME{{System::GFX, "Settings", "DriverLibName"}, ""};
+
// Graphics.Enhancements
const Info GFX_ENHANCE_FORCE_TEXTURE_FILTERING{
@@ -171,4 +173,5 @@ const Info GFX_HACK_NO_MIPMAPPING{{System::GFX, "Hacks", "NoMipmapping"},
// Graphics.GameSpecific
const Info GFX_PERF_QUERIES_ENABLE{{System::GFX, "GameSpecific", "PerfQueriesEnable"}, false};
+
} // namespace Config
diff --git a/Source/Core/Core/Config/GraphicsSettings.h b/Source/Core/Core/Config/GraphicsSettings.h
index ce10005da9..f45d0c4811 100644
--- a/Source/Core/Core/Config/GraphicsSettings.h
+++ b/Source/Core/Core/Config/GraphicsSettings.h
@@ -148,4 +148,8 @@ extern const Info GFX_HACK_NO_MIPMAPPING;
extern const Info GFX_PERF_QUERIES_ENABLE;
+// Android custom GPU drivers
+
+extern const Info GFX_DRIVER_LIB_NAME;
+
} // namespace Config
diff --git a/Source/Core/VideoBackends/Vulkan/CMakeLists.txt b/Source/Core/VideoBackends/Vulkan/CMakeLists.txt
index 7abf9a038b..ec9e1b51cb 100644
--- a/Source/Core/VideoBackends/Vulkan/CMakeLists.txt
+++ b/Source/Core/VideoBackends/Vulkan/CMakeLists.txt
@@ -48,11 +48,19 @@ PRIVATE
xxhash
)
+if (ANDROID AND _M_ARM_64)
+ target_link_libraries(videovulkan
+ PRIVATE
+ adrenotools
+ )
+endif()
+
# Only include the Vulkan headers when building the Vulkan backend
target_include_directories(videovulkan
PRIVATE
${CMAKE_SOURCE_DIR}/Externals/Vulkan/Include
${CMAKE_SOURCE_DIR}/Externals/VulkanMemoryAllocator/include
+ ${CMAKE_SOURCE_DIR}/Externals/libadrenotools/include
)
if(MSVC)
diff --git a/Source/Core/VideoBackends/Vulkan/VulkanContext.cpp b/Source/Core/VideoBackends/Vulkan/VulkanContext.cpp
index 5b5f2ffaee..ed4d749878 100644
--- a/Source/Core/VideoBackends/Vulkan/VulkanContext.cpp
+++ b/Source/Core/VideoBackends/Vulkan/VulkanContext.cpp
@@ -143,7 +143,18 @@ VkInstance VulkanContext::CreateVulkanInstance(WindowSystemType wstype, bool ena
{
// The device itself may not support 1.1, so we check that before using any 1.1 functionality.
app_info.apiVersion = VK_MAKE_VERSION(1, 1, 0);
+ WARN_LOG_FMT(HOST_GPU, "Using Vulkan 1.1, supported: {}.{}",
+ VK_VERSION_MAJOR(supported_api_version),
+ VK_VERSION_MINOR(supported_api_version));
}
+ else
+ {
+ WARN_LOG_FMT(HOST_GPU, "Using Vulkan 1.0");
+ }
+ }
+ else
+ {
+ WARN_LOG_FMT(HOST_GPU, "Using Vulkan 1.0");
}
*out_vk_api_version = app_info.apiVersion;
diff --git a/Source/Core/VideoBackends/Vulkan/VulkanLoader.cpp b/Source/Core/VideoBackends/Vulkan/VulkanLoader.cpp
index 9b62244dfd..34c531fc2f 100644
--- a/Source/Core/VideoBackends/Vulkan/VulkanLoader.cpp
+++ b/Source/Core/VideoBackends/Vulkan/VulkanLoader.cpp
@@ -8,11 +8,18 @@
#include
#include
+#if defined(ANDROID)
+#include
+#include
+#endif
+
#include "Common/CommonFuncs.h"
#include "Common/DynamicLibrary.h"
#include "Common/FileUtil.h"
#include "Common/StringUtil.h"
+#include "VideoCommon/VideoConfig.h"
+
#define VULKAN_MODULE_ENTRY_POINT(name, required) PFN_##name name;
#define VULKAN_INSTANCE_ENTRY_POINT(name, required) PFN_##name name;
#define VULKAN_DEVICE_ENTRY_POINT(name, required) PFN_##name name;
@@ -36,9 +43,9 @@ static void ResetVulkanLibraryFunctionPointers()
static Common::DynamicLibrary s_vulkan_module;
-static bool OpenVulkanLibrary()
+static bool OpenVulkanLibrary(bool force_system_library)
{
-#ifdef __APPLE__
+#if defined(__APPLE__)
// Check if a path to a specific Vulkan library has been specified.
char* libvulkan_env = getenv("LIBVULKAN_PATH");
if (libvulkan_env && s_vulkan_module.Open(libvulkan_env))
@@ -48,6 +55,35 @@ static bool OpenVulkanLibrary()
std::string filename = File::GetBundleDirectory() + "/Contents/Frameworks/libMoltenVK.dylib";
return s_vulkan_module.Open(filename.c_str());
#else
+
+#if defined(ANDROID) && _M_ARM_64
+ const std::string& driver_lib_name = g_Config.customDriverLibraryName;
+
+ if (!force_system_library && !driver_lib_name.empty() && SupportsCustomDriver())
+ {
+ std::string tmp_dir = File::GetGpuDriverDirectory(D_GPU_DRIVERS_TMP);
+ std::string hook_dir = File::GetGpuDriverDirectory(D_GPU_DRIVERS_HOOKS);
+ std::string file_redirect_dir = File::GetGpuDriverDirectory(D_GPU_DRIVERS_FILE_REDIRECT);
+ std::string driver_dir = File::GetGpuDriverDirectory(D_GPU_DRIVERS_EXTRACTED);
+ INFO_LOG_FMT(HOST_GPU, "Loading driver: {}", driver_lib_name);
+
+ s_vulkan_module = adrenotools_open_libvulkan(
+ RTLD_NOW, ADRENOTOOLS_DRIVER_FILE_REDIRECT | ADRENOTOOLS_DRIVER_CUSTOM, tmp_dir.c_str(),
+ hook_dir.c_str(), driver_dir.c_str(), driver_lib_name.c_str(), file_redirect_dir.c_str(),
+ nullptr);
+ if (s_vulkan_module.IsOpen())
+ {
+ INFO_LOG_FMT(HOST_GPU, "Successfully loaded driver: {}", driver_lib_name);
+ return true;
+ }
+ else
+ {
+ WARN_LOG_FMT(HOST_GPU, "Loading driver {} failed.", driver_lib_name);
+ }
+ }
+#endif
+
+ WARN_LOG_FMT(HOST_GPU, "Loading system driver");
std::string filename = Common::DynamicLibrary::GetVersionedFilename("vulkan", 1);
if (s_vulkan_module.Open(filename.c_str()))
return true;
@@ -58,9 +94,9 @@ static bool OpenVulkanLibrary()
#endif
}
-bool LoadVulkanLibrary()
+bool LoadVulkanLibrary(bool force_system_library)
{
- if (!s_vulkan_module.IsOpen() && !OpenVulkanLibrary())
+ if (!s_vulkan_module.IsOpen() && !OpenVulkanLibrary(force_system_library))
return false;
#define VULKAN_MODULE_ENTRY_POINT(name, required) \
@@ -91,7 +127,7 @@ bool LoadVulkanInstanceFunctions(VkInstance instance)
*func_ptr = vkGetInstanceProcAddr(instance, name);
if (!(*func_ptr) && is_required)
{
- ERROR_LOG_FMT(VIDEO, "Vulkan: Failed to load required instance function {}", name);
+ ERROR_LOG_FMT(HOST_GPU, "Vulkan: Failed to load required instance function {}", name);
required_functions_missing = true;
}
};
@@ -111,7 +147,7 @@ bool LoadVulkanDeviceFunctions(VkDevice device)
*func_ptr = vkGetDeviceProcAddr(device, name);
if (!(*func_ptr) && is_required)
{
- ERROR_LOG_FMT(VIDEO, "Vulkan: Failed to load required device function {}", name);
+ ERROR_LOG_FMT(HOST_GPU, "Vulkan: Failed to load required device function {}", name);
required_functions_missing = true;
}
};
@@ -212,4 +248,18 @@ void LogVulkanResult(Common::Log::LogLevel level, const char* func_name, VkResul
static_cast(res), VkResultToString(res));
}
+#ifdef ANDROID
+static bool CheckKgslPresent()
+{
+ constexpr auto KgslPath{"/dev/kgsl-3d0"};
+
+ return access(KgslPath, F_OK) == 0;
+}
+
+bool SupportsCustomDriver()
+{
+ return android_get_device_api_level() >= 28 && CheckKgslPresent();
+}
+#endif
+
} // namespace Vulkan
diff --git a/Source/Core/VideoBackends/Vulkan/VulkanLoader.h b/Source/Core/VideoBackends/Vulkan/VulkanLoader.h
index 652b512dd4..d1a426d952 100644
--- a/Source/Core/VideoBackends/Vulkan/VulkanLoader.h
+++ b/Source/Core/VideoBackends/Vulkan/VulkanLoader.h
@@ -23,6 +23,10 @@
#include "vulkan/vulkan.h"
+#ifdef ANDROID
+#include
+#endif
+
// Currently, exclusive fullscreen is only supported on Windows.
#if defined(WIN32)
#define SUPPORTS_VULKAN_EXCLUSIVE_FULLSCREEN 1
@@ -78,11 +82,15 @@
namespace Vulkan
{
-bool LoadVulkanLibrary();
+bool LoadVulkanLibrary(bool force_system_library = false);
bool LoadVulkanInstanceFunctions(VkInstance instance);
bool LoadVulkanDeviceFunctions(VkDevice device);
void UnloadVulkanLibrary();
+#ifdef ANDROID
+bool SupportsCustomDriver();
+#endif
+
const char* VkResultToString(VkResult res);
void LogVulkanResult(Common::Log::LogLevel level, const char* func_name, VkResult res,
const char* msg);
diff --git a/Source/Core/VideoCommon/VideoConfig.cpp b/Source/Core/VideoCommon/VideoConfig.cpp
index 38ee680bf3..9284c8171f 100644
--- a/Source/Core/VideoCommon/VideoConfig.cpp
+++ b/Source/Core/VideoCommon/VideoConfig.cpp
@@ -172,6 +172,8 @@ void VideoConfig::Refresh()
bPerfQueriesEnable = Config::Get(Config::GFX_PERF_QUERIES_ENABLE);
bGraphicMods = Config::Get(Config::GFX_MODS_ENABLE);
+
+ customDriverLibraryName = Config::Get(Config::GFX_DRIVER_LIB_NAME);
}
void VideoConfig::VerifyValidity()
diff --git a/Source/Core/VideoCommon/VideoConfig.h b/Source/Core/VideoCommon/VideoConfig.h
index a479276e6c..33f2a06ebe 100644
--- a/Source/Core/VideoCommon/VideoConfig.h
+++ b/Source/Core/VideoCommon/VideoConfig.h
@@ -214,6 +214,9 @@ struct VideoConfig final
int iShaderCompilerThreads = 0;
int iShaderPrecompilerThreads = 0;
+ // Loading custom drivers on Android
+ std::string customDriverLibraryName;
+
// Static config per API
// TODO: Move this out of VideoConfig
struct