[android] make YUZU_LEGACY a compile def; add legacy as a build flavor
All checks were successful
eden-license / license-header (pull_request) Successful in 21s

Signed-off-by: crueter <crueter@eden-emu.dev>
This commit is contained in:
crueter 2025-10-02 23:31:44 -04:00
parent 15b4d6fca9
commit 351c8fe478
Signed by: crueter
GPG key ID: 425ACD2D4830EBC6
9 changed files with 76 additions and 43 deletions

View file

@ -212,6 +212,8 @@ endif()
# TODO(crueter): CI this? # TODO(crueter): CI this?
option(YUZU_DOWNLOAD_ANDROID_VVL "Download validation layer binary for android" ON) option(YUZU_DOWNLOAD_ANDROID_VVL "Download validation layer binary for android" ON)
option(YUZU_LEGACY "Apply patches that improve compatibility with older GPUs (e.g. Snapdragon 865) at the cost of performance" OFF)
cmake_dependent_option(YUZU_ROOM "Enable dedicated room functionality" ON "NOT ANDROID" OFF) cmake_dependent_option(YUZU_ROOM "Enable dedicated room functionality" ON "NOT ANDROID" OFF)
cmake_dependent_option(YUZU_ROOM_STANDALONE "Enable standalone room executable" ON "YUZU_ROOM" OFF) cmake_dependent_option(YUZU_ROOM_STANDALONE "Enable standalone room executable" ON "YUZU_ROOM" OFF)
@ -309,6 +311,11 @@ if (UNIX)
add_compile_definitions(YUZU_UNIX=1) add_compile_definitions(YUZU_UNIX=1)
endif() endif()
if (YUZU_LEGACY)
message(WARNING "Making legacy build. Performance may suffer.")
add_compile_definitions(YUZU_LEGACY)
endif()
if (ARCHITECTURE_arm64 AND (ANDROID OR PLATFORM_LINUX)) if (ARCHITECTURE_arm64 AND (ANDROID OR PLATFORM_LINUX))
set(HAS_NCE 1) set(HAS_NCE 1)
add_compile_definitions(HAS_NCE=1) add_compile_definitions(HAS_NCE=1)

View file

@ -57,8 +57,8 @@ android {
} }
defaultConfig { defaultConfig {
// TODO If this is ever modified, change application_id in strings.xml applicationId = "dev.eden.eden_emulator"
applicationId = "dev.legacy.eden_emulator"
minSdk = 28 minSdk = 28
targetSdk = 36 targetSdk = 36
versionName = getGitVersion() versionName = getGitVersion()
@ -72,8 +72,30 @@ android {
buildConfigField("String", "GIT_HASH", "\"${getGitHash()}\"") buildConfigField("String", "GIT_HASH", "\"${getGitHash()}\"")
buildConfigField("String", "BRANCH", "\"${getBranch()}\"") buildConfigField("String", "BRANCH", "\"${getBranch()}\"")
externalNativeBuild {
cmake {
arguments.addAll(listOf(
"-DENABLE_QT=0", // Don't use QT
"-DENABLE_SDL2=0", // Don't use SDL
"-DENABLE_WEB_SERVICE=1", // Enable web service
"-DENABLE_OPENSSL=ON",
"-DANDROID_ARM_NEON=true", // cryptopp requires Neon to work
"-DYUZU_USE_CPM=ON",
"-DCPMUTIL_FORCE_BUNDLED=ON",
"-DYUZU_USE_BUNDLED_FFMPEG=ON",
"-DCMAKE_EXPORT_COMPILE_COMMANDS=ON",
"-DBUILD_TESTING=OFF",
"-DYUZU_TESTS=OFF",
"-DDYNARMIC_TESTS=OFF"
))
abiFilters("arm64-v8a")
}
}
} }
val keystoreFile = System.getenv("ANDROID_KEYSTORE_FILE") val keystoreFile = System.getenv("ANDROID_KEYSTORE_FILE")
signingConfigs { signingConfigs {
if (keystoreFile != null) { if (keystoreFile != null) {
@ -94,7 +116,6 @@ android {
// Define build types, which are orthogonal to product flavors. // Define build types, which are orthogonal to product flavors.
buildTypes { buildTypes {
// Signed by release key, allowing for upload to Play Store. // Signed by release key, allowing for upload to Play Store.
release { release {
signingConfig = if (keystoreFile != null) { signingConfig = if (keystoreFile != null) {
@ -103,7 +124,7 @@ android {
signingConfigs.getByName("default") signingConfigs.getByName("default")
} }
resValue("string", "app_name_suffixed", "Eden Legacy") resValue("string", "app_name_suffixed", "Eden")
isMinifyEnabled = true isMinifyEnabled = true
isDebuggable = false isDebuggable = false
proguardFiles( proguardFiles(
@ -150,9 +171,27 @@ android {
create("genshinSpoof") { create("genshinSpoof") {
dimension = "version" dimension = "version"
resValue("string", "app_name_suffixed", "Eden Optimised") resValue("string", "app_name_suffixed", "Eden Optimized")
applicationId = "com.miHoYo.Yuanshen" applicationId = "com.miHoYo.Yuanshen"
} }
create("legacy") {
dimension = "version"
resValue("string", "app_name_suffixed", "Eden Legacy")
applicationId = "dev.legacy.eden_emulator"
externalNativeBuild {
cmake {
arguments.add("-DYUZU_LEGACY=ON")
}
}
sourceSets {
getByName("legacy") {
res.srcDirs("src/main/legacy")
}
}
}
} }
} }
@ -162,29 +201,6 @@ android {
path = file("../../../CMakeLists.txt") path = file("../../../CMakeLists.txt")
} }
} }
defaultConfig {
externalNativeBuild {
cmake {
arguments(
"-DENABLE_QT=0", // Don't use QT
"-DENABLE_SDL2=0", // Don't use SDL
"-DENABLE_WEB_SERVICE=1", // Enable web service
"-DENABLE_OPENSSL=ON",
"-DANDROID_ARM_NEON=true", // cryptopp requires Neon to work
"-DYUZU_USE_CPM=ON",
"-DCPMUTIL_FORCE_BUNDLED=ON",
"-DYUZU_USE_BUNDLED_FFMPEG=ON",
"-DCMAKE_EXPORT_COMPILE_COMMANDS=ON",
"-DBUILD_TESTING=OFF",
"-DYUZU_TESTS=OFF",
"-DDYNARMIC_TESTS=OFF"
)
abiFilters("arm64-v8a")
}
}
}
} }
tasks.register<Delete>("ktlintReset", fun Delete.() { tasks.register<Delete>("ktlintReset", fun Delete.() {

View file

Before

Width:  |  Height:  |  Size: 38 KiB

After

Width:  |  Height:  |  Size: 38 KiB

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 438 KiB

After

Width:  |  Height:  |  Size: 438 KiB

Before After
Before After

View file

@ -26,7 +26,7 @@ BufferCache<P>::BufferCache(Tegra::MaxwellDeviceMemoryManager& device_memory_, R
void(slot_buffers.insert(runtime, NullBufferParams{})); void(slot_buffers.insert(runtime, NullBufferParams{}));
gpu_modified_ranges.Clear(); gpu_modified_ranges.Clear();
inline_buffer_id = NULL_BUFFER_ID; inline_buffer_id = NULL_BUFFER_ID;
#ifdef ANDROID #ifdef YUZU_LEGACY
immediately_free = (Settings::values.vram_usage_mode.GetValue() == Settings::VramUsageMode::Aggressive); immediately_free = (Settings::values.vram_usage_mode.GetValue() == Settings::VramUsageMode::Aggressive);
#endif #endif
if (!runtime.CanReportMemoryUsage()) { if (!runtime.CanReportMemoryUsage()) {
@ -1380,8 +1380,10 @@ void BufferCache<P>::JoinOverlap(BufferId new_buffer_id, BufferId overlap_id,
}); });
new_buffer.MarkUsage(copies[0].dst_offset, copies[0].size); new_buffer.MarkUsage(copies[0].dst_offset, copies[0].size);
runtime.CopyBuffer(new_buffer, overlap, copies, true); runtime.CopyBuffer(new_buffer, overlap, copies, true);
#ifdef YUZU_LEGACY
if (immediately_free) if (immediately_free)
runtime.Finish(); runtime.Finish();
#endif
DeleteBuffer(overlap_id, true); DeleteBuffer(overlap_id, true);
} }
@ -1673,8 +1675,11 @@ void BufferCache<P>::DeleteBuffer(BufferId buffer_id, bool do_not_mark) {
Unregister(buffer_id); Unregister(buffer_id);
#ifdef YUZU_LEGACY
if (!do_not_mark || !immediately_free) if (!do_not_mark || !immediately_free)
#endif
delayed_destruction_ring.Push(std::move(slot_buffers[buffer_id])); delayed_destruction_ring.Push(std::move(slot_buffers[buffer_id]));
slot_buffers.erase(buffer_id); slot_buffers.erase(buffer_id);
if constexpr (HAS_PERSISTENT_UNIFORM_BUFFER_BINDINGS) { if constexpr (HAS_PERSISTENT_UNIFORM_BUFFER_BINDINGS) {

View file

@ -154,7 +154,7 @@ template <class P>
class BufferCache : public VideoCommon::ChannelSetupCaches<BufferCacheChannelInfo> { class BufferCache : public VideoCommon::ChannelSetupCaches<BufferCacheChannelInfo> {
// Page size for caching purposes. // Page size for caching purposes.
// This is unrelated to the CPU page size and it can be changed as it seems optimal. // This is unrelated to the CPU page size and it can be changed as it seems optimal.
#ifdef ANDROID #ifdef YUZU_LEGACY
static constexpr u32 CACHING_PAGEBITS = 12; static constexpr u32 CACHING_PAGEBITS = 12;
#else #else
static constexpr u32 CACHING_PAGEBITS = 16; static constexpr u32 CACHING_PAGEBITS = 16;
@ -172,16 +172,15 @@ class BufferCache : public VideoCommon::ChannelSetupCaches<BufferCacheChannelInf
static constexpr bool SEPARATE_IMAGE_BUFFERS_BINDINGS = P::SEPARATE_IMAGE_BUFFER_BINDINGS; static constexpr bool SEPARATE_IMAGE_BUFFERS_BINDINGS = P::SEPARATE_IMAGE_BUFFER_BINDINGS;
static constexpr bool USE_MEMORY_MAPS_FOR_UPLOADS = P::USE_MEMORY_MAPS_FOR_UPLOADS; static constexpr bool USE_MEMORY_MAPS_FOR_UPLOADS = P::USE_MEMORY_MAPS_FOR_UPLOADS;
#ifdef ANDROID #ifdef YUZU_LEGACY
static constexpr s64 DEFAULT_EXPECTED_MEMORY = 512_MiB;
static constexpr s64 DEFAULT_CRITICAL_MEMORY = 1_GiB;
static constexpr s64 TARGET_THRESHOLD = 3_GiB; static constexpr s64 TARGET_THRESHOLD = 3_GiB;
#else #else
static constexpr s64 DEFAULT_EXPECTED_MEMORY = 512_MiB;
static constexpr s64 DEFAULT_CRITICAL_MEMORY = 1_GiB;
static constexpr s64 TARGET_THRESHOLD = 4_GiB; static constexpr s64 TARGET_THRESHOLD = 4_GiB;
#endif #endif
static constexpr s64 DEFAULT_EXPECTED_MEMORY = 512_MiB;
static constexpr s64 DEFAULT_CRITICAL_MEMORY = 1_GiB;
// Debug Flags. // Debug Flags.
static constexpr bool DISABLE_DOWNLOADS = true; static constexpr bool DISABLE_DOWNLOADS = true;
@ -456,7 +455,7 @@ private:
Tegra::MaxwellDeviceMemoryManager& device_memory; Tegra::MaxwellDeviceMemoryManager& device_memory;
Common::SlotVector<Buffer> slot_buffers; Common::SlotVector<Buffer> slot_buffers;
#ifdef ANDROID #ifdef YUZU_LEGACY
static constexpr size_t TICKS_TO_DESTROY = 6; static constexpr size_t TICKS_TO_DESTROY = 6;
#else #else
static constexpr size_t TICKS_TO_DESTROY = 8; static constexpr size_t TICKS_TO_DESTROY = 8;
@ -493,7 +492,9 @@ private:
u64 minimum_memory = 0; u64 minimum_memory = 0;
u64 critical_memory = 0; u64 critical_memory = 0;
BufferId inline_buffer_id; BufferId inline_buffer_id;
#ifdef YUZU_LEGACY
bool immediately_free = false; bool immediately_free = false;
#endif
std::array<BufferId, ((1ULL << 34) >> CACHING_PAGEBITS)> page_table; std::array<BufferId, ((1ULL << 34) >> CACHING_PAGEBITS)> page_table;
Common::ScratchBuffer<u8> tmp_buffer; Common::ScratchBuffer<u8> tmp_buffer;

View file

@ -21,11 +21,15 @@ Host1x::~Host1x() = default;
void Host1x::StartDevice(s32 fd, ChannelType type, u32 syncpt) { void Host1x::StartDevice(s32 fd, ChannelType type, u32 syncpt) {
switch (type) { switch (type) {
case ChannelType::NvDec: case ChannelType::NvDec:
#ifdef YUZU_LEGACY
std::call_once(nvdec_first_init, []() {std::this_thread::sleep_for(std::chrono::milliseconds{500});}); // HACK: For Astroneer std::call_once(nvdec_first_init, []() {std::this_thread::sleep_for(std::chrono::milliseconds{500});}); // HACK: For Astroneer
#endif
devices[fd] = std::make_unique<Tegra::Host1x::Nvdec>(*this, fd, syncpt, frame_queue); devices[fd] = std::make_unique<Tegra::Host1x::Nvdec>(*this, fd, syncpt, frame_queue);
break; break;
case ChannelType::VIC: case ChannelType::VIC:
#ifdef YUZU_LEGACY
std::call_once(vic_first_init, []() {std::this_thread::sleep_for(std::chrono::milliseconds{500});}); // HACK: For Astroneer std::call_once(vic_first_init, []() {std::this_thread::sleep_for(std::chrono::milliseconds{500});}); // HACK: For Astroneer
#endif
devices[fd] = std::make_unique<Tegra::Host1x::Vic>(*this, fd, syncpt, frame_queue); devices[fd] = std::make_unique<Tegra::Host1x::Vic>(*this, fd, syncpt, frame_queue);
break; break;
default: default:

View file

@ -204,8 +204,10 @@ private:
std::unique_ptr<Common::FlatAllocator<u32, 0, 32>> allocator; std::unique_ptr<Common::FlatAllocator<u32, 0, 32>> allocator;
FrameQueue frame_queue; FrameQueue frame_queue;
std::unordered_map<s32, std::unique_ptr<CDmaPusher>> devices; std::unordered_map<s32, std::unique_ptr<CDmaPusher>> devices;
#ifdef YUZU_LEGACY
std::once_flag nvdec_first_init; std::once_flag nvdec_first_init;
std::once_flag vic_first_init; std::once_flag vic_first_init;
#endif
}; };
} // namespace Tegra::Host1x } // namespace Tegra::Host1x

View file

@ -110,17 +110,15 @@ class TextureCache : public VideoCommon::ChannelSetupCaches<TextureCacheChannelI
static constexpr size_t UNSET_CHANNEL{(std::numeric_limits<size_t>::max)()}; static constexpr size_t UNSET_CHANNEL{(std::numeric_limits<size_t>::max)()};
#ifdef ANDROID #ifdef YUZU_LEGACY
static constexpr s64 TARGET_THRESHOLD = 3_GiB; static constexpr s64 TARGET_THRESHOLD = 3_GiB;
static constexpr s64 DEFAULT_EXPECTED_MEMORY = 1_GiB + 125_MiB; #else
static constexpr s64 DEFAULT_CRITICAL_MEMORY = 1_GiB + 625_MiB;
static constexpr size_t GC_EMERGENCY_COUNTS = 2;
#else
static constexpr s64 TARGET_THRESHOLD = 4_GiB; static constexpr s64 TARGET_THRESHOLD = 4_GiB;
#endif
static constexpr s64 DEFAULT_EXPECTED_MEMORY = 1_GiB + 125_MiB; static constexpr s64 DEFAULT_EXPECTED_MEMORY = 1_GiB + 125_MiB;
static constexpr s64 DEFAULT_CRITICAL_MEMORY = 1_GiB + 625_MiB; static constexpr s64 DEFAULT_CRITICAL_MEMORY = 1_GiB + 625_MiB;
static constexpr size_t GC_EMERGENCY_COUNTS = 2; static constexpr size_t GC_EMERGENCY_COUNTS = 2;
#endif
using Runtime = typename P::Runtime; using Runtime = typename P::Runtime;
using Image = typename P::Image; using Image = typename P::Image;
@ -486,7 +484,7 @@ private:
}; };
Common::LeastRecentlyUsedCache<LRUItemParams> lru_cache; Common::LeastRecentlyUsedCache<LRUItemParams> lru_cache;
#ifdef ANDROID #ifdef YUZU_LEGACY
static constexpr size_t TICKS_TO_DESTROY = 6; static constexpr size_t TICKS_TO_DESTROY = 6;
#else #else
static constexpr size_t TICKS_TO_DESTROY = 8; static constexpr size_t TICKS_TO_DESTROY = 8;