From a8fe1bd5d7f5fffce9137daa3cca8dc6d125c25a Mon Sep 17 00:00:00 2001 From: Reg Tiangha Date: Mon, 7 Oct 2024 06:27:19 -0600 Subject: [PATCH] Android: Add Texture Sampling settings UI --- .../android/features/settings/model/IntSetting.kt | 1 + .../settings/ui/SettingsFragmentPresenter.kt | 13 ++++++++++++- src/android/app/src/main/jni/default_ini.h | 5 +++++ src/android/app/src/main/res/values/arrays.xml | 11 +++++++++++ src/android/app/src/main/res/values/strings.xml | 9 ++++++++- src/lime_qt/configuration/configure_graphics.ui | 2 +- 6 files changed, 38 insertions(+), 3 deletions(-) diff --git a/src/android/app/src/main/java/io/github/lime3ds/android/features/settings/model/IntSetting.kt b/src/android/app/src/main/java/io/github/lime3ds/android/features/settings/model/IntSetting.kt index 25991f002..4be72f12b 100644 --- a/src/android/app/src/main/java/io/github/lime3ds/android/features/settings/model/IntSetting.kt +++ b/src/android/app/src/main/java/io/github/lime3ds/android/features/settings/model/IntSetting.kt @@ -58,6 +58,7 @@ enum class IntSetting( VSYNC("use_vsync_new", Settings.SECTION_RENDERER, 1), DEBUG_RENDERER("renderer_debug", Settings.SECTION_DEBUG, 0), TEXTURE_FILTER("texture_filter", Settings.SECTION_RENDERER, 0), + TEXTURE_SAMPLING("texture_sampling", Settings.SECTION_RENDERER, 0), USE_FRAME_LIMIT("use_frame_limit", Settings.SECTION_RENDERER, 1), DELAY_RENDER_THREAD_US("delay_game_render_thread_us", Settings.SECTION_RENDERER, 0), USE_ARTIC_BASE_CONTROLLER("use_artic_base_controller", Settings.SECTION_CONTROLS, 0); 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 d35e1a2c6..e440d8a37 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 @@ -887,7 +887,18 @@ class SettingsFragmentPresenter(private val fragmentView: SettingsFragmentView) IntSetting.ASYNC_CUSTOM_LOADING.defaultValue ) ) - + add(HeaderSetting(R.string.advanced)) + add( + SingleChoiceSetting( + IntSetting.TEXTURE_SAMPLING, + R.string.texture_sampling_name, + R.string.texture_sampling_description, + R.array.textureSamplingNames, + R.array.textureSamplingValues, + IntSetting.TEXTURE_SAMPLING.key, + IntSetting.TEXTURE_SAMPLING.defaultValue + ) + ) // Disabled until custom texture implementation gets rewrite, current one overloads RAM // and crashes Lime3DS. // add( diff --git a/src/android/app/src/main/jni/default_ini.h b/src/android/app/src/main/jni/default_ini.h index b2741c8df..645f2d9eb 100644 --- a/src/android/app/src/main/jni/default_ini.h +++ b/src/android/app/src/main/jni/default_ini.h @@ -125,6 +125,11 @@ shaders_accurate_mul = # 0: Interpreter (slow), 1 (default): JIT (fast) use_shader_jit = +# Overrides the sampling filter used by games. This can be useful in certain +# cases with poorly behaved games when upscaling. +# 0 (default): Game Controlled, 2: Nearest Neighbor, 3: Linear +texture_sampling = + # Forces VSync on the display thread. Usually doesn't impact performance, but on some drivers it can # so only turn this off if you notice a speed difference. # 0: Off, 1 (default): On diff --git a/src/android/app/src/main/res/values/arrays.xml b/src/android/app/src/main/res/values/arrays.xml index c6baf68a2..c37803d58 100644 --- a/src/android/app/src/main/res/values/arrays.xml +++ b/src/android/app/src/main/res/values/arrays.xml @@ -211,6 +211,17 @@ 5 + + @string/game_controlled + @string/nearest_neighbor + @string/linear + + + 0 + 1 + 2 + + Blue (Default) Cyan diff --git a/src/android/app/src/main/res/values/strings.xml b/src/android/app/src/main/res/values/strings.xml index ddb874645..ae099650a 100644 --- a/src/android/app/src/main/res/values/strings.xml +++ b/src/android/app/src/main/res/values/strings.xml @@ -230,6 +230,9 @@ Enables linear filtering, which causes game visuals to appear smoother. Texture Filter Enhances the visuals of games by applying a filter to textures. The supported filters are Anime4K Ultrafast, Bicubic, ScaleForce, xBRZ freescale, and MMPX. + Advanced" + Texture Sampling + Overrides the sampling filter used by games. This can be useful in certain cases with poorly behaved games when upscaling. If unsure, set this to Game Controlled. Enable Hardware Shader Uses hardware to emulate 3DS shaders. When enabled, game performance will be significantly improved. Accurate Multiplication @@ -577,11 +580,15 @@ Anime4K Bicubic - Nearest Neighbor ScaleForce xBRZ MMPX + + Game Controlled + Nearest Neighbor + Linear + Mono Stereo diff --git a/src/lime_qt/configuration/configure_graphics.ui b/src/lime_qt/configuration/configure_graphics.ui index a052186cd..e5af63969 100644 --- a/src/lime_qt/configuration/configure_graphics.ui +++ b/src/lime_qt/configuration/configure_graphics.ui @@ -258,7 +258,7 @@ - <html><head/><body><p>Overrides the sampling filter used by games. This can be useful in certain cases with poorly behaved games when upscaling. If unsure set this to Game Controlled</p></body></html> + <html><head/><body><p>Overrides the sampling filter used by games. This can be useful in certain cases with poorly behaved games when upscaling. If unsure, set this to Game Controlled.</p></body></html> Texture Sampling