build: only enable adrenotools on arm64

This commit is contained in:
Liam 2023-03-16 11:56:51 -04:00 committed by bunnei
parent 515f3deea1
commit 616cf70a80
9 changed files with 33 additions and 15 deletions

View File

@ -106,12 +106,20 @@ endif()
if (YUZU_USE_BUNDLED_VCPKG) if (YUZU_USE_BUNDLED_VCPKG)
if (ANDROID) if (ANDROID)
set(VCPKG_TARGET_TRIPLET "arm64-android")
set(ENV{ANDROID_NDK_HOME} "${ANDROID_NDK}") set(ENV{ANDROID_NDK_HOME} "${ANDROID_NDK}")
list(APPEND VCPKG_MANIFEST_FEATURES "android")
if (CMAKE_ANDROID_ARCH_ABI STREQUAL "arm64-v8a")
set(VCPKG_TARGET_TRIPLET "arm64-android")
# this is to avoid CMake using the host pkg-config to find the host # this is to avoid CMake using the host pkg-config to find the host
# libraries when building for Android targets # libraries when building for Android targets
set(PKG_CONFIG_EXECUTABLE "aarch64-none-linux-android-pkg-config" CACHE FILEPATH "" FORCE) set(PKG_CONFIG_EXECUTABLE "aarch64-none-linux-android-pkg-config" CACHE FILEPATH "" FORCE)
list(APPEND VCPKG_MANIFEST_FEATURES "android") elseif (CMAKE_ANDROID_ARCH_ABI STREQUAL "x86_64")
set(VCPKG_TARGET_TRIPLET "x64-android")
set(PKG_CONFIG_EXECUTABLE "x86_64-none-linux-android-pkg-config" CACHE FILEPATH "" FORCE)
else()
message(FATAL_ERROR "Unsupported Android architecture ${CMAKE_ANDROID_ARCH_ABI}")
endif()
endif() endif()
if (YUZU_TESTS) if (YUZU_TESTS)

View File

@ -149,5 +149,7 @@ add_library(stb stb/stb_dxt.cpp)
target_include_directories(stb PUBLIC ./stb) target_include_directories(stb PUBLIC ./stb)
if (ANDROID) if (ANDROID)
if (ARCHITECTURE_arm64)
add_subdirectory(libadrenotools) add_subdirectory(libadrenotools)
endif()
endif() endif()

View File

@ -10,7 +10,6 @@ plugins {
*/ */
def autoVersion = (int) (((new Date().getTime() / 1000) - 1451606400) / 10) def autoVersion = (int) (((new Date().getTime() / 1000) - 1451606400) / 10)
def buildType def buildType
def abiFilter = "arm64-v8a" //, "x86"
android { android {
namespace 'org.yuzu.yuzu_emu' namespace 'org.yuzu.yuzu_emu'
@ -44,7 +43,7 @@ android {
targetSdkVersion 33 targetSdkVersion 33
versionCode autoVersion versionCode autoVersion
versionName getVersion() versionName getVersion()
ndk.abiFilters abiFilter ndk.abiFilters "arm64-v8a", "x86_64"
} }
signingConfigs { signingConfigs {
@ -115,7 +114,7 @@ android {
"-DYUZU_USE_BUNDLED_VCPKG=ON", "-DYUZU_USE_BUNDLED_VCPKG=ON",
"-DYUZU_USE_BUNDLED_FFMPEG=ON" "-DYUZU_USE_BUNDLED_FFMPEG=ON"
abiFilters abiFilter abiFilters "arm64-v8a", "x86_64"
} }
} }
} }

View File

@ -13,6 +13,9 @@ add_library(yuzu-android SHARED
set_property(TARGET yuzu-android PROPERTY IMPORTED_LOCATION ${FFmpeg_LIBRARY_DIR}) set_property(TARGET yuzu-android PROPERTY IMPORTED_LOCATION ${FFmpeg_LIBRARY_DIR})
target_link_libraries(yuzu-android PRIVATE audio_core common core input_common) target_link_libraries(yuzu-android PRIVATE audio_core common core input_common)
target_link_libraries(yuzu-android PRIVATE android camera2ndk EGL glad inih jnigraphics adrenotools log) target_link_libraries(yuzu-android PRIVATE android camera2ndk EGL glad inih jnigraphics log)
if (ARCHITECTURE_arm64)
target_link_libraries(yuzu-android PRIVATE adrenotools)
endif()
set(CPACK_PACKAGE_EXECUTABLES ${CPACK_PACKAGE_EXECUTABLES} yuzu-android) set(CPACK_PACKAGE_EXECUTABLES ${CPACK_PACKAGE_EXECUTABLES} yuzu-android)

View File

@ -7,7 +7,9 @@
#include <string_view> #include <string_view>
#include <dlfcn.h> #include <dlfcn.h>
#ifdef ARCHITECTURE_arm64
#include <adrenotools/driver.h> #include <adrenotools/driver.h>
#endif
#include <android/api-level.h> #include <android/api-level.h>
#include <android/native_window_jni.h> #include <android/native_window_jni.h>
@ -76,6 +78,7 @@ public:
void InitializeGpuDriver(const std::string& hook_lib_dir, const std::string& custom_driver_dir, void InitializeGpuDriver(const std::string& hook_lib_dir, const std::string& custom_driver_dir,
const std::string& custom_driver_name, const std::string& custom_driver_name,
const std::string& file_redirect_dir) { const std::string& file_redirect_dir) {
#ifdef ARCHITECTURE_arm64
void* handle{}; void* handle{};
const char* file_redirect_dir_{}; const char* file_redirect_dir_{};
int featureFlags{}; int featureFlags{};
@ -101,6 +104,7 @@ public:
} }
m_vulkan_library = std::make_shared<Common::DynamicLibrary>(handle); m_vulkan_library = std::make_shared<Common::DynamicLibrary>(handle);
#endif
} }
bool IsRunning() const { bool IsRunning() const {

View File

@ -346,6 +346,6 @@ if (YUZU_ENABLE_LTO)
set_property(TARGET video_core PROPERTY INTERPROCEDURAL_OPTIMIZATION TRUE) set_property(TARGET video_core PROPERTY INTERPROCEDURAL_OPTIMIZATION TRUE)
endif() endif()
if (ANDROID) if (ANDROID AND ARCHITECTURE_arm64)
target_link_libraries(video_core PRIVATE adrenotools) target_link_libraries(video_core PRIVATE adrenotools)
endif() endif()

View File

@ -1,7 +1,7 @@
// SPDX-FileCopyrightText: Copyright 2022 yuzu Emulator Project // SPDX-FileCopyrightText: Copyright 2022 yuzu Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later // SPDX-License-Identifier: GPL-2.0-or-later
#ifdef ANDROID #if defined(ANDROID) && defined(ARCHITECTURE_arm64)
#include <adrenotools/driver.h> #include <adrenotools/driver.h>
#endif #endif
@ -148,7 +148,7 @@ void TurboMode::Run(std::stop_token stop_token) {
auto cmdbuf = vk::CommandBuffer{cmdbufs[0], m_device.GetDispatchLoader()}; auto cmdbuf = vk::CommandBuffer{cmdbufs[0], m_device.GetDispatchLoader()};
while (!stop_token.stop_requested()) { while (!stop_token.stop_requested()) {
#ifdef ANDROID #if defined(ANDROID) && defined(ARCHITECTURE_arm64)
adrenotools_set_turbo(true); adrenotools_set_turbo(true);
#else #else
// Reset the fence. // Reset the fence.
@ -224,7 +224,7 @@ void TurboMode::Run(std::stop_token stop_token) {
std::chrono::milliseconds{100}; std::chrono::milliseconds{100};
}); });
} }
#ifdef ANDROID #if defined(ANDROID) && defined(ARCHITECTURE_arm64)
adrenotools_set_turbo(false); adrenotools_set_turbo(false);
#endif #endif
} }

View File

@ -18,7 +18,7 @@
#include "video_core/vulkan_common/vulkan_device.h" #include "video_core/vulkan_common/vulkan_device.h"
#include "video_core/vulkan_common/vulkan_wrapper.h" #include "video_core/vulkan_common/vulkan_wrapper.h"
#ifdef ANDROID #if defined(ANDROID) && defined(ARCHITECTURE_arm64)
#include <adrenotools/bcenabler.h> #include <adrenotools/bcenabler.h>
#endif #endif
@ -374,6 +374,7 @@ Device::Device(VkInstance instance_, vk::PhysicalDevice physical_, VkSurfaceKHR
extensions.push_descriptor = false; extensions.push_descriptor = false;
loaded_extensions.erase(VK_KHR_PUSH_DESCRIPTOR_EXTENSION_NAME); loaded_extensions.erase(VK_KHR_PUSH_DESCRIPTOR_EXTENSION_NAME);
#ifdef ARCHITECTURE_arm64
// Patch the driver to enable BCn textures. // Patch the driver to enable BCn textures.
const auto major = (properties.properties.driverVersion >> 24) << 2; const auto major = (properties.properties.driverVersion >> 24) << 2;
const auto minor = (properties.properties.driverVersion >> 12) & 0xFFFU; const auto minor = (properties.properties.driverVersion >> 12) & 0xFFFU;
@ -391,6 +392,7 @@ Device::Device(VkInstance instance_, vk::PhysicalDevice physical_, VkSurfaceKHR
} else { } else {
LOG_WARNING(Render_Vulkan, "Adreno driver can't be patched to enable BCn textures"); LOG_WARNING(Render_Vulkan, "Adreno driver can't be patched to enable BCn textures");
} }
#endif // ARCHITECTURE_arm64
} }
const bool is_arm = driver_id == VK_DRIVER_ID_ARM_PROPRIETARY; const bool is_arm = driver_id == VK_DRIVER_ID_ARM_PROPRIETARY;

View File

@ -13,7 +13,7 @@ namespace Vulkan {
std::shared_ptr<Common::DynamicLibrary> OpenLibrary( std::shared_ptr<Common::DynamicLibrary> OpenLibrary(
[[maybe_unused]] Core::Frontend::GraphicsContext* context) { [[maybe_unused]] Core::Frontend::GraphicsContext* context) {
LOG_DEBUG(Render_Vulkan, "Looking for a Vulkan library"); LOG_DEBUG(Render_Vulkan, "Looking for a Vulkan library");
#ifdef ANDROID #if defined(ANDROID) && defined(ARCHITECTURE_arm64)
// Android manages its Vulkan driver from the frontend. // Android manages its Vulkan driver from the frontend.
return context->GetDriverLibrary(); return context->GetDriverLibrary();
#else #else