VERY experimental Nintendo Switch 2 emulator
C++
FRAME_SKIPPING and FRAME_INTERPOLATION only android and delete "enable"
Pavel Barabanovbe2e838f0d3f
diff --git a/src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/model/BooleanSetting.kt b/src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/model/BooleanSetting.ktindex 4d5208c4c7..38c5f1e73d 100644--- a/src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/model/BooleanSetting.kt+++ b/src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/model/BooleanSetting.kt@@ -28,8 +28,8 @@ enum class BooleanSetting(override val key: String) : AbstractBooleanSetting {SHOW_INPUT_OVERLAY("show_input_overlay"),TOUCHSCREEN("touchscreen"),SHOW_THERMAL_OVERLAY("show_thermal_overlay"),- ENABLE_FRAME_INTERPOLATION("enable_frame_interpolation"),- ENABLE_FRAME_SKIPPING("enable_frame_skipping");+ FRAME_INTERPOLATION("frame_interpolation"),+ FRAME_SKIPPING("frame_skipping");external fun isFrameSkippingEnabled(): Booleanexternal fun isFrameInterpolationEnabled(): Booleandiff --git a/src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/model/view/SettingsItem.kt b/src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/model/view/SettingsItem.ktindex 0868da00a5..6bc6be0031 100644--- a/src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/model/view/SettingsItem.kt+++ b/src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/model/view/SettingsItem.kt@@ -173,37 +173,37 @@ abstract class SettingsItem(override fun reset() = BooleanSetting.USE_DOCKED_MODE.reset()}val enableInterpolationSetting = object : AbstractBooleanSetting {- override val key = BooleanSetting.ENABLE_FRAME_INTERPOLATION.key+ override val key = BooleanSetting.FRAME_INTERPOLATION.keyoverride fun getBoolean(needsGlobal: Boolean): Boolean =- BooleanSetting.ENABLE_FRAME_INTERPOLATION.getBoolean(needsGlobal)+ BooleanSetting.FRAME_INTERPOLATION.getBoolean(needsGlobal)override fun setBoolean(value: Boolean) =- BooleanSetting.ENABLE_FRAME_INTERPOLATION.setBoolean(value)+ BooleanSetting.FRAME_INTERPOLATION.setBoolean(value)- override val defaultValue = BooleanSetting.ENABLE_FRAME_INTERPOLATION.defaultValue+ override val defaultValue = BooleanSetting.FRAME_INTERPOLATION.defaultValueoverride fun getValueAsString(needsGlobal: Boolean): String =- BooleanSetting.ENABLE_FRAME_INTERPOLATION.getValueAsString(needsGlobal)+ BooleanSetting.FRAME_INTERPOLATION.getValueAsString(needsGlobal)- override fun reset() = BooleanSetting.ENABLE_FRAME_INTERPOLATION.reset()+ override fun reset() = BooleanSetting.FRAME_INTERPOLATION.reset()}val enableFrameSkippingSetting = object : AbstractBooleanSetting {- override val key = BooleanSetting.ENABLE_FRAME_SKIPPING.key+ override val key = BooleanSetting.FRAME_SKIPPING.keyoverride fun getBoolean(needsGlobal: Boolean): Boolean =- BooleanSetting.ENABLE_FRAME_SKIPPING.getBoolean(needsGlobal)+ BooleanSetting.FRAME_SKIPPING.getBoolean(needsGlobal)override fun setBoolean(value: Boolean) =- BooleanSetting.ENABLE_FRAME_SKIPPING.setBoolean(value)+ BooleanSetting.FRAME_SKIPPING.setBoolean(value)- override val defaultValue = BooleanSetting.ENABLE_FRAME_SKIPPING.defaultValue+ override val defaultValue = BooleanSetting.FRAME_SKIPPING.defaultValueoverride fun getValueAsString(needsGlobal: Boolean): String =- BooleanSetting.ENABLE_FRAME_SKIPPING.getValueAsString(needsGlobal)+ BooleanSetting.FRAME_SKIPPING.getValueAsString(needsGlobal)- override fun reset() = BooleanSetting.ENABLE_FRAME_SKIPPING.reset()+ override fun reset() = BooleanSetting.FRAME_SKIPPING.reset()}val syncCoreSpeedSetting = object : AbstractBooleanSetting {@@ -227,17 +227,17 @@ abstract class SettingsItem(put(SwitchSetting(- BooleanSetting.ENABLE_FRAME_INTERPOLATION,- titleId = R.string.enable_frame_interpolation,- descriptionId = R.string.enable_frame_interpolation_description+ BooleanSetting.FRAME_INTERPOLATION,+ titleId = R.string.frame_interpolation,+ descriptionId = R.string.frame_interpolation_description))put(SwitchSetting(- BooleanSetting.ENABLE_FRAME_SKIPPING,- titleId = R.string.enable_frame_skipping,- descriptionId = R.string.enable_frame_skipping_description+ BooleanSetting.FRAME_SKIPPING,+ titleId = R.string.frame_skipping,+ descriptionId = R.string.frame_skipping_description))diff --git a/src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/ui/SettingsFragmentPresenter.kt b/src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/ui/SettingsFragmentPresenter.ktindex fe31b4054e..33a1c4f5d2 100644--- a/src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/ui/SettingsFragmentPresenter.kt+++ b/src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/ui/SettingsFragmentPresenter.kt@@ -170,8 +170,8 @@ class SettingsFragmentPresenter(private fun addGraphicsSettings(sl: ArrayList<SettingsItem>) {sl.apply {- add(BooleanSetting.ENABLE_FRAME_INTERPOLATION.key)- add(BooleanSetting.ENABLE_FRAME_SKIPPING.key)+ add(BooleanSetting.FRAME_INTERPOLATION.key)+ add(BooleanSetting.FRAME_SKIPPING.key)add(IntSetting.RENDERER_ACCURACY.key)add(IntSetting.RENDERER_RESOLUTION.key)add(IntSetting.RENDERER_VSYNC.key)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.ktindex e316d96a2a..a264f5d995 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@@ -535,7 +535,7 @@ class EmulationFragment : Fragment(), SurfaceHolder.Callback {val usedMegs = (mi.totalMem - mi.availMem) / 1048576L // Convert bytes to megabytesval actualFps = perfStats[FPS]- val enableFrameInterpolation = BooleanSetting.ENABLE_FRAME_INTERPOLATION.getBoolean()+ val enableFrameInterpolation = BooleanSetting.FRAME_INTERPOLATION.getBoolean()val generatedFpsText = if (enableFrameInterpolation) {val generatedFps = actualFps * 2String.format("(Generated: %.1f)", generatedFps)diff --git a/src/android/app/src/main/res/values/strings.xml b/src/android/app/src/main/res/values/strings.xmlindex 263acda9fa..20eed3cb34 100644--- a/src/android/app/src/main/res/values/strings.xml+++ b/src/android/app/src/main/res/values/strings.xml@@ -234,10 +234,10 @@<string name="set_custom_rtc">Set custom RTC</string><!-- Graphics settings strings -->- <string name="enable_frame_skipping">Enable Frame Skipping</string>- <string name="enable_frame_skipping_description">Toggle frame skipping to improve performance by reducing the number of rendered frames.</string>- <string name="enable_frame_interpolation">Enable Frame Interpolation</string>- <string name="enable_frame_interpolation_description">Toggle frame interpolation to improve visual smoothness by generating intermediate frames.</string>+ <string name="frame_skipping">Frame Skipping</string>+ <string name="frame_skipping_description">Toggle frame skipping to improve performance by reducing the number of rendered frames.</string>+ <string name="frame_interpolation">Frame Interpolation</string>+ <string name="frame_interpolation_description">Toggle frame interpolation to improve visual smoothness by generating intermediate frames.</string><string name="renderer_accuracy">Accuracy level</string><string name="renderer_resolution">Resolution (Handheld/Docked)</string><string name="renderer_vsync">VSync mode</string>diff --git a/src/common/settings.h b/src/common/settings.hindex 9eb04897da..46ae6655ae 100644--- a/src/common/settings.h+++ b/src/common/settings.h@@ -273,10 +273,12 @@ struct Values {"shader_backend", Category::Renderer, Specialization::RuntimeList};SwitchableSetting<int> vulkan_device{linkage, 0, "vulkan_device", Category::Renderer,Specialization::RuntimeList};+ #ifdef __ANDROID__SwitchableSetting<bool> enable_frame_interpolation{linkage, true, "enable_frame_interpolation", Category::Renderer,Specialization::RuntimeList};SwitchableSetting<bool> enable_frame_skipping{linkage, true, "enable_frame_skipping", Category::Renderer,Specialization::RuntimeList};+ #endifSwitchableSetting<bool> use_disk_shader_cache{linkage, true, "use_disk_shader_cache",Category::Renderer};SwitchableSetting<bool> use_asynchronous_gpu_emulation{diff --git a/src/video_core/renderer_vulkan/renderer_vulkan.cpp b/src/video_core/renderer_vulkan/renderer_vulkan.cppindex 3ca69de530..6948682ef1 100644--- a/src/video_core/renderer_vulkan/renderer_vulkan.cpp+++ b/src/video_core/renderer_vulkan/renderer_vulkan.cpp@@ -141,8 +141,8 @@ RendererVulkan::~RendererVulkan() {#ifdef __ANDROID__class BooleanSetting {public:- static BooleanSetting ENABLE_FRAME_SKIPPING;- static BooleanSetting ENABLE_FRAME_INTERPOLATION;+ static BooleanSetting FRAME_SKIPPING;+ static BooleanSetting FRAME_INTERPOLATION;explicit BooleanSetting(bool initial_value = false) : value(initial_value) {}[[nodiscard]] bool getBoolean() const {@@ -158,17 +158,17 @@ class BooleanSetting {};// Initialize static members- BooleanSetting BooleanSetting::ENABLE_FRAME_SKIPPING(false);- BooleanSetting BooleanSetting::ENABLE_FRAME_INTERPOLATION(false);+ BooleanSetting BooleanSetting::FRAME_SKIPPING(false);+ BooleanSetting BooleanSetting::FRAME_INTERPOLATION(false);extern "C" JNIEXPORT jboolean JNICALLJava_org_uzuy_uzuy_1emu_features_settings_model_BooleanSetting_isFrameSkippingEnabled(JNIEnv* env, jobject /* this */) {- return static_cast<jboolean>(BooleanSetting::ENABLE_FRAME_SKIPPING.getBoolean());+ return static_cast<jboolean>(BooleanSetting::FRAME_SKIPPING.getBoolean());}extern "C" JNIEXPORT jboolean JNICALLJava_org_uzuy_uzuy_1emu_features_settings_model_BooleanSetting_isFrameInterpolationEnabled(JNIEnv* env, jobject /* this */) {- return static_cast<jboolean>(BooleanSetting::ENABLE_FRAME_INTERPOLATION.getBoolean());+ return static_cast<jboolean>(BooleanSetting::FRAME_INTERPOLATION.getBoolean());}void RendererVulkan::InterpolateFrames(Frame* prev_frame, Frame* interpolated_frame) {@@ -186,8 +186,8 @@ void RendererVulkan::Composite(std::span<const Tegra::FramebufferConfig> framebustatic int target_fps = 60; // Target FPS (30 or 60)int frame_skip_threshold = 1;- bool enable_frame_skipping = BooleanSetting::ENABLE_FRAME_SKIPPING.getBoolean();- bool enable_frame_interpolation = BooleanSetting::ENABLE_FRAME_INTERPOLATION.getBoolean();+ bool frame_skipping = BooleanSetting::FRAME_SKIPPING.getBoolean();+ bool frame_interpolation = BooleanSetting::FRAME_INTERPOLATION.getBoolean();#endifif (framebuffers.empty()) {@@ -195,13 +195,13 @@ void RendererVulkan::Composite(std::span<const Tegra::FramebufferConfig> framebu}#ifdef __ANDROID__- if (enable_frame_skipping) {+ if (frame_skipping) {frame_skip_threshold = (target_fps == 30) ? 2 : 2;}frame_counter++;if (frame_counter % frame_skip_threshold != 0) {- if (enable_frame_interpolation && previous_frame) {+ if (frame_interpolation && previous_frame) {Frame* interpolated_frame = present_manager.GetRenderFrame();InterpolateFrames(previous_frame, interpolated_frame);blit_swapchain.DrawToFrame(rasterizer, interpolated_frame, framebuffers,