From e5074c90ad5bdd94e24cd339ea09c83a1006d1c2 Mon Sep 17 00:00:00 2001 From: crueter Date: Fri, 11 Jul 2025 10:05:01 +0200 Subject: [PATCH 1/3] [android] Fix charging indicator and dynamic state setting (#36) Co-authored-by: Pavel Barabanov Reviewed-on: https://git.eden-emu.dev/eden-emu/eden/pulls/36 --- .../features/settings/model/view/SingleChoiceSetting.kt | 9 ++++++++- .../org/yuzu/yuzu_emu/fragments/EmulationFragment.kt | 8 +++++++- src/android/app/src/main/res/values/strings.xml | 6 +++--- src/common/settings.h | 4 ++-- 4 files changed, 20 insertions(+), 7 deletions(-) diff --git a/src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/model/view/SingleChoiceSetting.kt b/src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/model/view/SingleChoiceSetting.kt index 624bc2445c..aea72946f7 100644 --- a/src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/model/view/SingleChoiceSetting.kt +++ b/src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/model/view/SingleChoiceSetting.kt @@ -5,6 +5,7 @@ package org.yuzu.yuzu_emu.features.settings.model.view import androidx.annotation.ArrayRes import androidx.annotation.StringRes +import org.yuzu.yuzu_emu.features.settings.model.AbstractByteSetting import org.yuzu.yuzu_emu.features.settings.model.AbstractIntSetting import org.yuzu.yuzu_emu.features.settings.model.AbstractSetting @@ -24,8 +25,14 @@ class SingleChoiceSetting( fun getSelectedValue(needsGlobal: Boolean = false) = when (setting) { is AbstractIntSetting -> setting.getInt(needsGlobal) + is AbstractByteSetting -> setting.getByte(needsGlobal).toInt() else -> -1 } - fun setSelectedValue(value: Int) = (setting as AbstractIntSetting).setInt(value) + fun setSelectedValue(value: Int) = + when (setting) { + is AbstractIntSetting -> setting.setInt(value) + is AbstractByteSetting -> setting.setByte(value.toByte()) + else -> -1 + } } diff --git a/src/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/EmulationFragment.kt b/src/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/EmulationFragment.kt index 05c14e278d..6cce31a4eb 100644 --- a/src/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/EmulationFragment.kt +++ b/src/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/EmulationFragment.kt @@ -643,13 +643,19 @@ class EmulationFragment : Fragment(), SurfaceHolder.Callback { val battery: BatteryManager = requireContext().getSystemService(Context.BATTERY_SERVICE) as BatteryManager + val batteryIntent = requireContext().registerReceiver(null, + IntentFilter(Intent.ACTION_BATTERY_CHANGED)) val capacity = battery.getIntProperty(BATTERY_PROPERTY_CAPACITY) val nowUAmps = battery.getIntProperty(BATTERY_PROPERTY_CURRENT_NOW) sb.append(String.format("%.1fA (%d%%)", nowUAmps / 1000000.0, capacity)) - if (battery.isCharging || nowUAmps > 0.0) { + val status = batteryIntent?.getIntExtra(BatteryManager.EXTRA_STATUS, -1) + val isCharging = status == BatteryManager.BATTERY_STATUS_CHARGING || + status == BatteryManager.BATTERY_STATUS_FULL + + if (isCharging) { sb.append(" ${getString(R.string.charging)}") } } diff --git a/src/android/app/src/main/res/values/strings.xml b/src/android/app/src/main/res/values/strings.xml index ac9141863c..602be31027 100644 --- a/src/android/app/src/main/res/values/strings.xml +++ b/src/android/app/src/main/res/values/strings.xml @@ -74,7 +74,7 @@ GPU Extensions Extended Dynamic State - Enables Vulkan features to improve performance, rendering, and save resources on pipeline creation while maintaining lower CPU/GPU usage. These extensions may increase device temperature, and GPUs belonging to the older A6XX line may not react properly. Set to 0 to use Legacy emulated formats. + Enables Vulkan features to improve performance, rendering, and save resources on pipeline creation while maintaining lower CPU/GPU usage. These extensions may increase device temperature, and GPUs belonging to the older A6XX line may not react properly. Disable to emulate scaled formats. Disabled Provoking Vertex Improves lighting and vertex handling in certain games. Only supported on Vulkan 1.0+ GPUs. @@ -95,11 +95,11 @@ Uninstalling firmware Firmware uninstalled successfully - Miscellaneous + CPU and Memory Synchronize Core Speed Synchronize the core tick speed to the maximum speed percentage to improve performance without altering the game\'s actual speed. Enable LRU Cache - Enable or disable the Least Recently Used (LRU) cache, increasing performance by saving CPU process usage. Some games have issue with it, notably TotK 1.2.1, so disable if the game doesn\'t boot or crashes randomly. + Enable or disable the Least Recently Used (LRU) cache, increasing performance by saving CPU process usage. Some games have issues with it, notably TotK 1.2.1, so disable if the game doesn\'t boot or crashes randomly. Fast CPU Time Forces the emulated CPU to run at a higher clock, reducing certain FPS limiters. This option is hacky and may cause issues, and weaker CPUs may see reduced performance. Custom CPU Ticks diff --git a/src/common/settings.h b/src/common/settings.h index 0cadd22459..551e66c57e 100644 --- a/src/common/settings.h +++ b/src/common/settings.h @@ -331,7 +331,7 @@ struct Values { SwitchableSetting use_disk_shader_cache{linkage, true, "use_disk_shader_cache", Category::Renderer}; SwitchableSetting optimize_spirv_output{linkage, - SpirvOptimizeMode::OnLoad, + SpirvOptimizeMode::Never, SpirvOptimizeMode::Never, SpirvOptimizeMode::Always, "optimize_spirv_output", @@ -477,7 +477,7 @@ struct Values { SwitchableSetting use_asynchronous_shaders{linkage, false, "use_asynchronous_shaders", Category::RendererAdvanced}; SwitchableSetting use_fast_gpu_time{linkage, - false, + true, "use_fast_gpu_time", Category::RendererAdvanced, Specialization::Paired, From 7f48f4efb6edc3b16f3fe7800dd055d79fc382b3 Mon Sep 17 00:00:00 2001 From: SDK-Chan Date: Fri, 11 Jul 2025 10:05:17 +0200 Subject: [PATCH 2/3] Add native FreeBSD building functionality (#35) This commit enables native building on FreeBSD through Cmake + ninja. Reviewed-on: https://git.eden-emu.dev/eden-emu/eden/pulls/35 Reviewed-by: crueter Co-authored-by: SDK-Chan Co-committed-by: SDK-Chan --- CMakeLists.txt | 65 ++++++++++++++++++++++----- externals/renderdoc/renderdoc_app.h | 2 + src/core/CMakeLists.txt | 2 +- src/video_core/host1x/ffmpeg/ffmpeg.h | 6 +++ 4 files changed, 63 insertions(+), 12 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 4836ef811e..1efa94e45a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -17,6 +17,10 @@ if (MSVC) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W3 /WX-") endif() +if (${CMAKE_SYSTEM_NAME} STREQUAL "FreeBSD") + set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -L/usr/local/lib") +endif() + # Check if SDL2::SDL2 target exists; if not, create an alias if (TARGET SDL2::SDL2-static) add_library(SDL2::SDL2 ALIAS SDL2::SDL2-static) @@ -27,8 +31,12 @@ endif() # Set bundled sdl2/qt as dependent options. option(ENABLE_SDL2 "Enable the SDL2 frontend" ON) CMAKE_DEPENDENT_OPTION(YUZU_USE_BUNDLED_SDL2 "Download bundled SDL2 binaries" ON "ENABLE_SDL2;MSVC" OFF) -# On Linux system SDL2 is likely to be lacking HIDAPI support which have drawbacks but is needed for SDL motion -CMAKE_DEPENDENT_OPTION(YUZU_USE_EXTERNAL_SDL2 "Compile external SDL2" ON "ENABLE_SDL2;NOT MSVC" OFF) +if (${CMAKE_SYSTEM_NAME} STREQUAL "FreeBSD") + # On Linux system SDL2 is likely to be lacking HIDAPI support which have drawbacks but is needed for SDL motion + CMAKE_DEPENDENT_OPTION(YUZU_USE_EXTERNAL_SDL2 "Compile external SDL2" OFF "ENABLE_SDL2;NOT MSVC" OFF) +else() + CMAKE_DEPENDENT_OPTION(YUZU_USE_EXTERNAL_SDL2 "Compile external SDL2" ON "ENABLE_SDL2;NOT MSVC" OFF) +endif() cmake_dependent_option(ENABLE_LIBUSB "Enable the use of LibUSB" ON "NOT ANDROID" OFF) @@ -43,13 +51,29 @@ CMAKE_DEPENDENT_OPTION(YUZU_USE_BUNDLED_QT "Download bundled Qt binaries" "${MSV option(ENABLE_WEB_SERVICE "Enable web services (telemetry, etc.)" ON) -option(YUZU_USE_BUNDLED_FFMPEG "Download/Build bundled FFmpeg" "ON") +if (${CMAKE_SYSTEM_NAME} STREQUAL "FreeBSD") + option(YUZU_USE_BUNDLED_FFMPEG "Download/Build bundled FFmpeg" OFF) +else() + option(YUZU_USE_BUNDLED_FFMPEG "Download/Build bundled FFmpeg" ON) +endif() -option(YUZU_USE_EXTERNAL_VULKAN_HEADERS "Use Vulkan-Headers from externals" ON) +if (${CMAKE_SYSTEM_NAME} STREQUAL "FreeBSD") + option(YUZU_USE_EXTERNAL_VULKAN_HEADERS "Use Vulkan-Headers from externals" OFF) +else() + option(YUZU_USE_EXTERNAL_VULKAN_HEADERS "Use Vulkan-Headers from externals" ON) +endif() -option(YUZU_USE_EXTERNAL_VULKAN_UTILITY_LIBRARIES "Use Vulkan-Utility-Libraries from externals" ON) +if (${CMAKE_SYSTEM_NAME} STREQUAL "FreeBSD") + option(YUZU_USE_EXTERNAL_VULKAN_UTILITY_LIBRARIES "Use Vulkan-Utility-Libraries from externals" OFF) +else() + option(YUZU_USE_EXTERNAL_VULKAN_UTILITY_LIBRARIES "Use Vulkan-Utility-Libraries from externals" ON) +endif() -option(YUZU_USE_EXTERNAL_VULKAN_SPIRV_TOOLS "Use SPIRV-Tools from externals" ON) +if (${CMAKE_SYSTEM_NAME} STREQUAL "FreeBSD") + option(YUZU_USE_EXTERNAL_VULKAN_SPIRV_TOOLS "Use SPIRV-Tools from externals" OFF) +else() + option(YUZU_USE_EXTERNAL_VULKAN_SPIRV_TOOLS "Use SPIRV-Tools from externals" ON) +endif() option(YUZU_USE_QT_MULTIMEDIA "Use QtMultimedia for Camera" OFF) @@ -61,7 +85,11 @@ option(USE_DISCORD_PRESENCE "Enables Discord Rich Presence" OFF) option(YUZU_TESTS "Compile tests" "${BUILD_TESTING}") -option(YUZU_USE_PRECOMPILED_HEADERS "Use precompiled headers" ON) +if (${CMAKE_SYSTEM_NAME} STREQUAL "FreeBSD") + option(YUZU_USE_PRECOMPILED_HEADERS "Use precompiled headers" OFF) +else() + option(YUZU_USE_PRECOMPILED_HEADERS "Use precompiled headers" ON) +endif() option(YUZU_DOWNLOAD_ANDROID_VVL "Download validation layer binary for android" ON) @@ -75,7 +103,11 @@ CMAKE_DEPENDENT_OPTION(YUZU_CRASH_DUMPS "Compile crash dump (Minidump) support" option(YUZU_USE_BUNDLED_VCPKG "Use vcpkg for yuzu dependencies" "${MSVC}") -option(YUZU_CHECK_SUBMODULES "Check if submodules are present" ON) +if (${CMAKE_SYSTEM_NAME} STREQUAL "FreeBSD") + option(YUZU_CHECK_SUBMODULES "Check if submodules are present" OFF) +else() + option(YUZU_CHECK_SUBMODULES "Check if submodules are present" ON) +endif() option(YUZU_ENABLE_LTO "Enable link-time optimization" OFF) @@ -337,7 +369,11 @@ if (NOT YUZU_USE_EXTERNAL_VULKAN_SPIRV_TOOLS) endif() if (ENABLE_LIBUSB) - find_package(libusb 1.0.24 MODULE) + if (${CMAKE_SYSTEM_NAME} STREQUAL "FreeBSD") + find_package(libusb MODULE) + else() + find_package(libusb 1.0.24 MODULE) + endif() endif() if (ARCHITECTURE_x86 OR ARCHITECTURE_x86_64) @@ -429,7 +465,13 @@ if (ENABLE_QT) list(APPEND CMAKE_PREFIX_PATH "${Qt6_DIR}") endif() - find_package(Qt6 REQUIRED COMPONENTS Widgets Multimedia Concurrent) + # QT6 Multimedia pulls in unneeded audio systems (ALSA, Pulseaudio) for FreeBSD + # ALSA is the default sound system on Linux, but FreeBSD uses OSS which works well enough + if (${CMAKE_SYSTEM_NAME} STREQUAL "FreeBSD") + find_package(Qt6 REQUIRED COMPONENTS Widgets Concurrent) + else() + find_package(Qt6 REQUIRED COMPONENTS Widgets Multimedia Concurrent) + endif() if (UNIX AND NOT APPLE) find_package(Qt6 REQUIRED COMPONENTS DBus) @@ -485,7 +527,8 @@ if (UNIX AND NOT APPLE AND NOT ANDROID) endif() if (NOT YUZU_USE_BUNDLED_FFMPEG) # Use system installed FFmpeg - find_package(FFmpeg 4.3 REQUIRED QUIET COMPONENTS ${FFmpeg_COMPONENTS}) + #find_package(FFmpeg 4.3 REQUIRED QUIET COMPONENTS ${FFmpeg_COMPONENTS}) + find_package(FFmpeg REQUIRED QUIET COMPONENTS ${FFmpeg_COMPONENTS}) endif() if(ENABLE_QT) diff --git a/externals/renderdoc/renderdoc_app.h b/externals/renderdoc/renderdoc_app.h index 0f4a1f98b3..84ff62b5db 100644 --- a/externals/renderdoc/renderdoc_app.h +++ b/externals/renderdoc/renderdoc_app.h @@ -42,6 +42,8 @@ #define RENDERDOC_CC #elif defined(__APPLE__) #define RENDERDOC_CC +#elif defined(__FreeBSD__) +#define RENDERDOC_CC #else #error "Unknown platform" #endif diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt index 187e6a2b4a..d830cc381d 100644 --- a/src/core/CMakeLists.txt +++ b/src/core/CMakeLists.txt @@ -1150,7 +1150,7 @@ add_library(core STATIC tools/renderdoc.h ) -if (UNIX AND NOT APPLE AND NOT ANDROID) +if (${CMAKE_SYSTEM_NAME} STREQUAL "Linux") # find_package(libiw REQUIRED) target_link_libraries(core PRIVATE iw) endif() diff --git a/src/video_core/host1x/ffmpeg/ffmpeg.h b/src/video_core/host1x/ffmpeg/ffmpeg.h index 63e230f1c9..6200fa691d 100644 --- a/src/video_core/host1x/ffmpeg/ffmpeg.h +++ b/src/video_core/host1x/ffmpeg/ffmpeg.h @@ -25,7 +25,13 @@ extern "C" { #include #include #include + +// Works quite fine, and omits the hacky ffmpeg building for now... +#if defined(__FreeBSD__) +#include +#else #include +#endif #if defined(__GNUC__) || defined(__clang__) #pragma GCC diagnostic pop From 3df06da02cf5e86147aa5c8af661313985c4f8ca Mon Sep 17 00:00:00 2001 From: CamilleLaVey Date: Fri, 11 Jul 2025 19:57:21 +0200 Subject: [PATCH 3/3] revert Align and bias memory stronger revert [ir] Align and bias memory stronger Signed-off-by: Aleksandr Popovich Reviewed-on: https://git.eden-emu.dev/eden-emu/eden/pulls/229 Co-authored-by: Aleksandr Popovich Co-committed-by: Aleksandr Popovich Reverted as showed up issues with buffers on games that weren't expected, it's going to be refined and implemented again with better params. --- .../global_memory_to_storage_buffer_pass.cpp | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/src/shader_recompiler/ir_opt/global_memory_to_storage_buffer_pass.cpp b/src/shader_recompiler/ir_opt/global_memory_to_storage_buffer_pass.cpp index 902cd698ad..2d4feca02c 100644 --- a/src/shader_recompiler/ir_opt/global_memory_to_storage_buffer_pass.cpp +++ b/src/shader_recompiler/ir_opt/global_memory_to_storage_buffer_pass.cpp @@ -1,6 +1,3 @@ -// SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project -// SPDX-License-Identifier: GPL-3.0-or-later - // SPDX-FileCopyrightText: Copyright 2021 yuzu Emulator Project // SPDX-License-Identifier: GPL-2.0-or-later @@ -354,7 +351,7 @@ std::optional Track(const IR::Value& value, const Bias* bias) .index = index.U32(), .offset = offset.U32(), }; - const u32 alignment{bias ? bias->alignment : 16U}; + const u32 alignment{bias ? bias->alignment : 8U}; if (!Common::IsAligned(storage_buffer.offset, alignment)) { // The SSBO pointer has to be aligned return std::nullopt; @@ -375,9 +372,9 @@ void CollectStorageBuffers(IR::Block& block, IR::Inst& inst, StorageInfo& info) // avoid getting false positives static constexpr Bias nvn_bias{ .index = 0, - .offset_begin = 0x110, - .offset_end = 0x800, - .alignment = 32, + .offset_begin = 0x100, + .offset_end = 0x700, + .alignment = 16, }; // Track the low address of the instruction const std::optional low_addr_info{TrackLowAddress(&inst)}; @@ -429,10 +426,7 @@ IR::U32 StorageOffset(IR::Block& block, IR::Inst& inst, StorageBufferAddr buffer // Align the offset base to match the host alignment requirements low_cbuf = ir.BitwiseAnd(low_cbuf, ir.Imm32(~(alignment - 1U))); - - // It aligns the memory strongly - IR::U32 res = ir.ISub(offset, low_cbuf); - return res; + return ir.ISub(offset, low_cbuf); } /// Replace a global memory load instruction with its storage buffer equivalent