android: Implement Adreno Turbo setting for eligible GPUs (#227)

Co-authored-by: Ishan09811 <156402647+Ishan09811@users.noreply.github.com>
Co-authored-by: Gamer64 <76565986+Gamer64ytb@users.noreply.github.com>
Co-authored-by: OpenSauce04 <opensauce04@gmail.com>
This commit is contained in:
kleidis 2024-06-28 22:13:54 +02:00 committed by OpenSauce04
parent 6a8fa2c402
commit f84503cf8c
7 changed files with 40 additions and 9 deletions

View File

@ -172,6 +172,8 @@ object NativeLibrary {
fileRedirectDir: String?
)
external fun enableAdrenoTurboMode(enable: Boolean)
external fun areKeysAvailable(): Boolean
external fun getHomeMenuPath(region: Int): String

View File

@ -33,6 +33,7 @@ import org.citra.citra_emu.contracts.OpenFileResultContract
import org.citra.citra_emu.databinding.ActivityEmulationBinding
import org.citra.citra_emu.display.ScreenAdjustmentUtil
import org.citra.citra_emu.features.hotkeys.HotkeyUtility
import org.citra.citra_emu.features.settings.model.BooleanSetting
import org.citra.citra_emu.features.settings.model.SettingsViewModel
import org.citra.citra_emu.features.settings.model.view.InputBindingSetting
import org.citra.citra_emu.fragments.EmulationFragment
@ -71,6 +72,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, this)
@ -127,6 +130,7 @@ class EmulationActivity : AppCompatActivity() {
}
override fun onDestroy() {
NativeLibrary.enableAdrenoTurboMode(false)
EmulationLifecycleUtil.clear()
isEmulationRunning = false
instance = null

View File

@ -14,7 +14,8 @@ enum class BooleanSetting(
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),
INSTANT_DEBUG_LOG("instant_debug_log", Settings.SECTION_DEBUG, false);
INSTANT_DEBUG_LOG("instant_debug_log", Settings.SECTION_DEBUG, false),
ADRENO_GPU_BOOST("adreno_gpu_boost", Settings.SECTION_RENDERER, false);
override var boolean: Boolean = defaultValue
@ -35,7 +36,8 @@ enum class BooleanSetting(
private val NOT_RUNTIME_EDITABLE = listOf(
PLUGIN_LOADER,
ALLOW_PLUGIN_LOADER,
ASYNC_SHADERS
ASYNC_SHADERS,
ADRENO_GPU_BOOST
)
fun from(key: String): BooleanSetting? =

View File

@ -38,6 +38,7 @@ import org.citra.citra_emu.features.settings.model.view.SwitchSetting
import org.citra.citra_emu.features.settings.utils.SettingsFile
import org.citra.citra_emu.fragments.ResetSettingsDialogFragment
import org.citra.citra_emu.utils.BirthdayMonth
import org.citra.citra_emu.utils.GpuDriverHelper
import org.citra.citra_emu.utils.Log
import org.citra.citra_emu.utils.SystemSaveGame
import org.citra.citra_emu.utils.ThemeUtil
@ -744,6 +745,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,

View File

@ -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) {

View File

@ -256,6 +256,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) {
@ -335,6 +341,12 @@ void JNICALL Java_org_citra_citra_1emu_NativeLibrary_initializeGpuDriver(
GetJString(env, custom_driver_name), GetJString(env, file_redirect_dir));
}
void JNICALL Java_org_citra_citra_1emu_NativeLibrary_enableAdrenoTurboMode(JNIEnv* env,
jobject obj,
jboolean enable) {
EnableAdrenoTurboMode(enable);
}
void Java_org_citra_citra_1emu_NativeLibrary_notifyOrientationChange([[maybe_unused]] JNIEnv* env,
[[maybe_unused]] jobject obj,
jint layout_option,

View File

@ -267,6 +267,8 @@
<string name="use_shader_jit">Shader JIT</string>
<string name="use_disk_shader_cache">Disk Shader Cache</string>
<string name="use_disk_shader_cache_description">Reduce stuttering by storing and loading generated shaders to disk. It cannot be used without Enabling Hardware Shader.</string>
<string name="adreno_gpu_boost">Adreno GPU Boost (Experimental)</string>
<string name="adreno_gpu_boost_description">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.</string>
<string name="utility">Utility</string>
<string name="dump_textures">Dump Textures</string>
<string name="dump_textures_description">Textures are dumped to dump/textures/[Title ID]/.</string>