diff --git a/src/android/app/src/main/java/io/github/lime3ds/android/NativeLibrary.kt b/src/android/app/src/main/java/io/github/lime3ds/android/NativeLibrary.kt index a606de913..7d91c09fd 100644 --- a/src/android/app/src/main/java/io/github/lime3ds/android/NativeLibrary.kt +++ b/src/android/app/src/main/java/io/github/lime3ds/android/NativeLibrary.kt @@ -172,6 +172,8 @@ object NativeLibrary { fileRedirectDir: String? ) + external fun enableAdrenoTurboMode(enable: Boolean) + external fun areKeysAvailable(): Boolean external fun getHomeMenuPath(region: Int): String diff --git a/src/android/app/src/main/java/io/github/lime3ds/android/activities/EmulationActivity.kt b/src/android/app/src/main/java/io/github/lime3ds/android/activities/EmulationActivity.kt index b5d8ec940..f72d80033 100644 --- a/src/android/app/src/main/java/io/github/lime3ds/android/activities/EmulationActivity.kt +++ b/src/android/app/src/main/java/io/github/lime3ds/android/activities/EmulationActivity.kt @@ -33,6 +33,7 @@ import io.github.lime3ds.android.contracts.OpenFileResultContract import io.github.lime3ds.android.databinding.ActivityEmulationBinding import io.github.lime3ds.android.display.ScreenAdjustmentUtil import io.github.lime3ds.android.features.hotkeys.HotkeyUtility +import io.github.lime3ds.android.features.settings.model.BooleanSetting import io.github.lime3ds.android.features.settings.model.SettingsViewModel import io.github.lime3ds.android.features.settings.model.view.InputBindingSetting import io.github.lime3ds.android.fragments.EmulationFragment @@ -73,6 +74,8 @@ class EmulationActivity : AppCompatActivity() { super.onCreate(savedInstanceState) + NativeLibrary.enableAdrenoTurboMode(BooleanSetting.ADRENO_GPU_BOOST.boolean) + binding = ActivityEmulationBinding.inflate(layoutInflater) screenAdjustmentUtil = ScreenAdjustmentUtil(windowManager, settingsViewModel.settings) hotkeyUtility = HotkeyUtility(screenAdjustmentUtil) @@ -129,6 +132,7 @@ class EmulationActivity : AppCompatActivity() { } override fun onDestroy() { + NativeLibrary.enableAdrenoTurboMode(false) EmulationLifecycleUtil.clear() isEmulationRunning = false instance = null diff --git a/src/android/app/src/main/java/io/github/lime3ds/android/features/settings/model/BooleanSetting.kt b/src/android/app/src/main/java/io/github/lime3ds/android/features/settings/model/BooleanSetting.kt index 7e3114c77..ecdd19267 100644 --- a/src/android/app/src/main/java/io/github/lime3ds/android/features/settings/model/BooleanSetting.kt +++ b/src/android/app/src/main/java/io/github/lime3ds/android/features/settings/model/BooleanSetting.kt @@ -13,7 +13,8 @@ enum class BooleanSetting( ASYNC_SHADERS("async_shader_compilation", Settings.SECTION_RENDERER, false), PLUGIN_LOADER("plugin_loader", Settings.SECTION_SYSTEM, false), ALLOW_PLUGIN_LOADER("allow_plugin_loader", Settings.SECTION_SYSTEM, true), - SWAP_SCREEN("swap_screen", Settings.SECTION_LAYOUT, false); + SWAP_SCREEN("swap_screen", Settings.SECTION_LAYOUT, false), + ADRENO_GPU_BOOST("adreno_gpu_boost", Settings.SECTION_RENDERER, false); override var boolean: Boolean = defaultValue @@ -33,7 +34,8 @@ enum class BooleanSetting( companion object { private val NOT_RUNTIME_EDITABLE = listOf( PLUGIN_LOADER, - ALLOW_PLUGIN_LOADER + ALLOW_PLUGIN_LOADER, + ADRENO_GPU_BOOST ) fun from(key: String): BooleanSetting? = diff --git a/src/android/app/src/main/java/io/github/lime3ds/android/features/settings/ui/SettingsAdapter.kt b/src/android/app/src/main/java/io/github/lime3ds/android/features/settings/ui/SettingsAdapter.kt index 1f80bf408..6806991a8 100644 --- a/src/android/app/src/main/java/io/github/lime3ds/android/features/settings/ui/SettingsAdapter.kt +++ b/src/android/app/src/main/java/io/github/lime3ds/android/features/settings/ui/SettingsAdapter.kt @@ -450,7 +450,7 @@ class SettingsAdapter( R.string.setting_not_editable_description ).show((fragmentView as SettingsFragment).childFragmentManager, MessageDialogFragment.TAG) } - + fun onClickRegenerateConsoleId() { MaterialAlertDialogBuilder(context) .setTitle(R.string.regenerate_console_id) diff --git a/src/android/app/src/main/java/io/github/lime3ds/android/features/settings/ui/SettingsFragmentPresenter.kt b/src/android/app/src/main/java/io/github/lime3ds/android/features/settings/ui/SettingsFragmentPresenter.kt index b35dc1ebb..9049d4dd6 100644 --- a/src/android/app/src/main/java/io/github/lime3ds/android/features/settings/ui/SettingsFragmentPresenter.kt +++ b/src/android/app/src/main/java/io/github/lime3ds/android/features/settings/ui/SettingsFragmentPresenter.kt @@ -38,6 +38,7 @@ import io.github.lime3ds.android.features.settings.model.view.SwitchSetting import io.github.lime3ds.android.features.settings.utils.SettingsFile import io.github.lime3ds.android.fragments.ResetSettingsDialogFragment import io.github.lime3ds.android.utils.BirthdayMonth +import io.github.lime3ds.android.utils.GpuDriverHelper import io.github.lime3ds.android.utils.Log import io.github.lime3ds.android.utils.SystemSaveGame import io.github.lime3ds.android.utils.ThemeUtil @@ -724,6 +725,17 @@ class SettingsFragmentPresenter(private val fragmentView: SettingsFragmentView) IntSetting.SHADERS_ACCURATE_MUL.defaultValue ) ) + if (GpuDriverHelper.supportsCustomDriverLoading()) { + add( + SwitchSetting( + BooleanSetting.ADRENO_GPU_BOOST, + R.string.adreno_gpu_boost, + R.string.adreno_gpu_boost_description, + BooleanSetting.ADRENO_GPU_BOOST.key, + BooleanSetting.ADRENO_GPU_BOOST.defaultValue + ) + ) + } add( SwitchSetting( IntSetting.DISK_SHADER_CACHE, diff --git a/src/android/app/src/main/java/io/github/lime3ds/android/features/settings/ui/viewholder/SwitchSettingViewHolder.kt b/src/android/app/src/main/java/io/github/lime3ds/android/features/settings/ui/viewholder/SwitchSettingViewHolder.kt index e4d099beb..c3fc38a71 100644 --- a/src/android/app/src/main/java/io/github/lime3ds/android/features/settings/ui/viewholder/SwitchSettingViewHolder.kt +++ b/src/android/app/src/main/java/io/github/lime3ds/android/features/settings/ui/viewholder/SwitchSettingViewHolder.kt @@ -34,13 +34,10 @@ class SwitchSettingViewHolder(val binding: ListItemSettingSwitchBinding, adapter } binding.switchWidget.isEnabled = setting.isEditable - if (setting.isEditable) { - binding.textSettingName.alpha = 1f - binding.textSettingDescription.alpha = 1f - } else { - binding.textSettingName.alpha = 0.5f - binding.textSettingDescription.alpha = 0.5f - } + + val textAlpha = if (setting.isEditable) 1f else 0.5f + binding.textSettingName.alpha = textAlpha + binding.textSettingDescription.alpha = textAlpha } override fun onClick(clicked: View) { diff --git a/src/android/app/src/main/jni/native.cpp b/src/android/app/src/main/jni/native.cpp index 54c0a2d2a..471be3d7c 100644 --- a/src/android/app/src/main/jni/native.cpp +++ b/src/android/app/src/main/jni/native.cpp @@ -257,6 +257,12 @@ static Core::System::ResultStatus RunCitra(const std::string& filepath) { return Core::System::ResultStatus::Success; } +void EnableAdrenoTurboMode(bool enable) { +#if defined(ENABLE_VULKAN) && CITRA_ARCH(arm64) + adrenotools_set_turbo(enable); +#endif +} + void InitializeGpuDriver(const std::string& hook_lib_dir, const std::string& custom_driver_dir, const std::string& custom_driver_name, const std::string& file_redirect_dir) { @@ -334,6 +340,12 @@ void JNICALL Java_io_github_lime3ds_android_NativeLibrary_initializeGpuDriver( GetJString(env, custom_driver_name), GetJString(env, file_redirect_dir)); } +void JNICALL Java_io_github_lime3ds_android_NativeLibrary_enableAdrenoTurboMode(JNIEnv* env, + jobject obj, + jboolean enable) { + EnableAdrenoTurboMode(enable); +} + void Java_io_github_lime3ds_android_NativeLibrary_notifyOrientationChange( [[maybe_unused]] JNIEnv* env, [[maybe_unused]] jobject obj, jint layout_option, jint rotation) { Settings::values.layout_option = static_cast(layout_option); diff --git a/src/android/app/src/main/res/values/strings.xml b/src/android/app/src/main/res/values/strings.xml index fa4b77a92..f7d3596d4 100644 --- a/src/android/app/src/main/res/values/strings.xml +++ b/src/android/app/src/main/res/values/strings.xml @@ -263,6 +263,8 @@ Shader JIT Disk Shader Cache Reduce stuttering by storing and loading generated shaders to disk. It cannot be used without Enabling Hardware Shader. + Adreno GPU Boost (Experimental) + Increases graphics throughput on supported devices, improving performance. Use of this setting can increase power usage and temperature. May cause stability issues on certain devices. Utility Dump Textures Textures are dumped to dump/textures/[Title ID]/.