Skip to content

Commit

Permalink
Android & PC: Implement weihuoya hacks to the UI
Browse files Browse the repository at this point in the history
  • Loading branch information
Gamer64ytb committed Jul 25, 2024
1 parent ead7f00 commit 0ceaa1b
Show file tree
Hide file tree
Showing 12 changed files with 157 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ enum class IntSetting(
TEXTURE_FILTER("texture_filter", 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),
FORCE_HW_VERTEX_SHADERS("force_hw_vertex_shaders", Settings.SECTION_RENDERER, 0),
DISABLE_SURFACE_TEXTURE_COPY("disable_surface_texture_copy", Settings.SECTION_RENDERER, 0),
DISABLE_FLUSH_CPU_WRITE("disable_flush_cpu_write", Settings.SECTION_RENDERER, 0),
USE_ARTIC_BASE_CONTROLLER("use_artic_base_controller", Settings.SECTION_CONTROLS, 0);

override var int: Int = defaultValue
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -761,6 +761,35 @@ class SettingsFragmentPresenter(private val fragmentView: SettingsFragmentView)
)
)

add(HeaderSetting(R.string.tweaks))
add(
SwitchSetting(
IntSetting.FORCE_HW_VERTEX_SHADERS,
R.string.force_hw_vertex_shaders,
R.string.force_hw_vertex_shaders_description,
IntSetting.FORCE_HW_VERTEX_SHADERS.key,
IntSetting.FORCE_HW_VERTEX_SHADERS.defaultValue
)
)
add(
SwitchSetting(
IntSetting.DISABLE_SURFACE_TEXTURE_COPY,
R.string.disable_surface_texture_copy,
R.string.disable_surface_texture_copy_description,
IntSetting.DISABLE_SURFACE_TEXTURE_COPY.key,
IntSetting.DISABLE_SURFACE_TEXTURE_COPY.defaultValue
)
)
add(
SwitchSetting(
IntSetting.DISABLE_FLUSH_CPU_WRITE,
R.string.disable_flush_cpu_write,
R.string.disable_flush_cpu_write_description,
IntSetting.DISABLE_FLUSH_CPU_WRITE.key,
IntSetting.DISABLE_FLUSH_CPU_WRITE.defaultValue
)
)

add(HeaderSetting(R.string.stereoscopy))
add(
SingleChoiceSetting(
Expand Down
3 changes: 3 additions & 0 deletions src/android/app/src/main/jni/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,9 @@ void Config::ReadValues() {
ReadSetting("Renderer", Settings::values.bg_green);
ReadSetting("Renderer", Settings::values.bg_blue);
ReadSetting("Renderer", Settings::values.delay_game_render_thread_us);
ReadSetting("Renderer", Settings::values.force_hw_vertex_shaders);
ReadSetting("Renderer", Settings::values.disable_surface_texture_copy);
ReadSetting("Renderer", Settings::values.disable_flush_cpu_write);

// Layout
Settings::values.layout_option = static_cast<Settings::LayoutOption>(sdl2_config->GetInteger(
Expand Down
12 changes: 12 additions & 0 deletions src/android/app/src/main/jni/default_ini.h
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,18 @@ filter_mode =
# Set to 0 for no delay, only useful in dynamic-fps games to simulate GPU delay.
delay_game_render_thread_us =
# Ignores software vertex shaders from PICA core
# 0: Off, 1 (default): On
force_hw_vertex_shaders =
# Ignores texture copies if src_surface_id is null
# 0: Off, 1 (default): On
disable_surface_texture_copy =
# Ignores CPU write if there is a region to invalidate from rasterizer cache
# 0: Off, 1 (default): On
disable_flush_cpu_write =
[Layout]
# Layout for the screen inside the render window.
# 0 (default): Default Top Bottom Screen, 1: Single Screen Only, 2: Large Screen Small Screen, 3: Side by Side
Expand Down
4 changes: 2 additions & 2 deletions src/android/app/src/main/res/values-es/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,8 @@ Se esperan fallos gráficos temporales cuando ésta esté activado.</string>
<string name="linear_filtering_description">Activa el filtro linear, que hace que los gráficos del juego se vean más suaves.</string>
<string name="texture_filter_name">Filtro de Texturas</string>
<string name="texture_filter_description">Mejora los gráficos visuales de los juegos al aplicar un filtro a las texturas. Los filtros soportados son Anime4K Ultrafast, Bicubic, ScaleForce, y xBRZ freescale.</string>
<string name="delay_render_thread">Retrasa el hilo de dibujado del juego</string>
<string name="delay_render_thread_description">Retrasa el hilo de dibujado del juego cuando envía datos a la GPU. Ayuda con problemas de rendimiento en los (muy pocos) juegos de fps dinámicos.</string>
<string name="hw_shaders">Activar Sombreador de Hardware</string>
<string name="hw_shaders_description">Usa el hardware para emular los sombreadores de 3DS. Cuando se active, el rendimiento mejorará notablemente.</string>
<string name="shaders_accurate_mul">Multiplicación Precisa</string>
Expand Down Expand Up @@ -666,8 +668,6 @@ Se esperan fallos gráficos temporales cuando ésta esté activado.</string>
<string name="artic_base_connect">Conectar con Artic Base</string>
<string name="artic_base_connect_description">Conectar con una consola real que esté ejecutando un servidor Artic Base</string>
<string name="artic_base_enter_address">Introduce la dirección del servidor Artic Base</string>
<string name="delay_render_thread">Retrasa el hilo de dibujado del juego</string>
<string name="delay_render_thread_description">Retrasa el hilo de dibujado del juego cuando envía datos a la GPU. Ayuda con problemas de rendimiento en los (muy pocos) juegos de fps dinámicos.</string>
<string name="miscellaneous">Misceláneo</string>
<string name="use_artic_base_controller">Usar Artic Controller cuando se está conectado a Artic Base Server</string>
<string name="use_artic_base_controller_desc">Usa los controles proporcionados por Artic Base Server cuando esté conectado a él en lugar del dispositivo de entrada configurado.</string>
Expand Down
11 changes: 9 additions & 2 deletions src/android/app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,15 @@
<string name="linear_filtering_description">Enables linear filtering, which causes game visuals to appear smoother.</string>
<string name="texture_filter_name">Texture Filter</string>
<string name="texture_filter_description">Enhances the visuals of games by applying a filter to textures. The supported filters are Anime4K Ultrafast, Bicubic, ScaleForce, and xBRZ freescale.</string>
<string name="delay_render_thread">Delay game render thread</string>
<string name="delay_render_thread_description">Delay the game render thread when it submits data to the GPU. Helps with performance issues in the (very few) dynamic-fps games.</string>
<string name="tweaks">Tweaks</string>
<string name="force_hw_vertex_shaders">Force Hardware Vertex Shaders</string>
<string name="force_hw_vertex_shaders_description">Ignores software vertex shaders from PICA core. Enable this may lead a small performance boost, but may cause graphical bugs as well.</string>
<string name="disable_surface_texture_copy">Disable Surface Texture Copy</string>
<string name="disable_surface_texture_copy_description">Ignores texture copies if src_surface_id is null. Enable this may lead a small performance boost, but may cause graphical bugs as well.</string>
<string name="disable_flush_cpu_write">Disable Flush CPU Write</string>
<string name="disable_flush_cpu_write_description">Ignores CPU write if there is a region to invalidate from rasterizer cache. Enable this may lead a small performance boost, but may cause graphical bugs as well.</string>
<string name="hw_shaders">Enable Hardware Shader</string>
<string name="hw_shaders_description">Uses hardware to emulate 3DS shaders. When enabled, game performance will be significantly improved.</string>
<string name="shaders_accurate_mul">Accurate Multiplication</string>
Expand Down Expand Up @@ -694,8 +703,6 @@
<string name="artic_base_connect_description">Connect to a real console that is running an Artic Base server</string>
<string name="artic_base_connect">Connect to Artic Base</string>
<string name="artic_base_enter_address">Enter Artic Base server address</string>
<string name="delay_render_thread">Delay game render thread</string>
<string name="delay_render_thread_description">Delay the game render thread when it submits data to the GPU. Helps with performance issues in the (very few) dynamic-fps games.</string>

<!-- Quickload&Save-->
<string name="emulation_quicksave_slot">Quicksave</string>
Expand Down
3 changes: 3 additions & 0 deletions src/citra/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,9 @@ void Config::ReadValues() {
ReadSetting("Renderer", Settings::values.texture_filter);
ReadSetting("Renderer", Settings::values.texture_sampling);
ReadSetting("Renderer", Settings::values.delay_game_render_thread_us);
ReadSetting("Renderer", Settings::values.force_hw_vertex_shaders);
ReadSetting("Renderer", Settings::values.disable_surface_texture_copy);
ReadSetting("Renderer", Settings::values.disable_flush_cpu_write);

ReadSetting("Renderer", Settings::values.mono_render_option);
ReadSetting("Renderer", Settings::values.render_3d);
Expand Down
16 changes: 16 additions & 0 deletions src/citra/default_ini.h
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,22 @@ resolution_factor =
# 0: None, 1: Anime4K, 2: Bicubic, 3: Nearest Neighbor, 4: ScaleForce, 5: xBRZ
texture_filter =
# Delays the game render thread by the specified amount of microseconds
# Set to 0 for no delay, only useful in dynamic-fps games to simulate GPU delay.
delay_game_render_thread_us =
# Ignores software vertex shaders from PICA core
# 0: Off, 1 (default): On
force_hw_vertex_shaders =
# Ignores texture copies if src_surface_id is null
# 0: Off, 1 (default): On
disable_surface_texture_copy =
# Ignores CPU write if there is a region to invalidate from rasterizer cache
# 0: Off, 1 (default): On
disable_flush_cpu_write =
# Limits the speed of the game to run no faster than this value as a percentage of target speed.
# Will not have an effect if unthrottled is enabled.
# 5 - 995: Speed limit as a percentage of target game speed. 0 for unthrottled. 100 (default)
Expand Down
8 changes: 8 additions & 0 deletions src/citra_qt/configuration/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -672,6 +672,10 @@ void Config::ReadRendererValues() {

ReadGlobalSetting(Settings::values.delay_game_render_thread_us);

ReadGlobalSetting(Settings::values.force_hw_vertex_shaders);
ReadGlobalSetting(Settings::values.disable_surface_texture_copy);
ReadGlobalSetting(Settings::values.disable_flush_cpu_write);

if (global) {
ReadBasicSetting(Settings::values.use_shader_jit);
}
Expand Down Expand Up @@ -1175,6 +1179,10 @@ void Config::SaveRendererValues() {

WriteGlobalSetting(Settings::values.delay_game_render_thread_us);

WriteGlobalSetting(Settings::values.force_hw_vertex_shaders);
WriteGlobalSetting(Settings::values.disable_surface_texture_copy);
WriteGlobalSetting(Settings::values.disable_flush_cpu_write);

if (global) {
WriteSetting(QStringLiteral("use_shader_jit"), Settings::values.use_shader_jit.GetValue(),
true);
Expand Down
30 changes: 30 additions & 0 deletions src/citra_qt/configuration/configure_graphics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,12 @@ void ConfigureGraphics::SetConfiguration() {
ui->spirv_shader_gen->setChecked(Settings::values.spirv_shader_gen.GetValue());
ui->toggle_async_shaders->setChecked(Settings::values.async_shader_compilation.GetValue());
ui->toggle_async_present->setChecked(Settings::values.async_presentation.GetValue());
ui->toggle_force_hw_vertex_shaders->setChecked(
Settings::values.force_hw_vertex_shaders.GetValue());
ui->toggle_disable_surface_texture_copy->setChecked(
Settings::values.disable_surface_texture_copy.GetValue());
ui->toggle_disable_flush_cpu_write->setChecked(
Settings::values.disable_flush_cpu_write.GetValue());

if (Settings::IsConfiguringGlobal()) {
ui->toggle_shader_jit->setChecked(Settings::values.use_shader_jit.GetValue());
Expand Down Expand Up @@ -171,6 +177,15 @@ void ConfigureGraphics::ApplyConfiguration() {
ui->toggle_disk_shader_cache, use_disk_shader_cache);
ConfigurationShared::ApplyPerGameSetting(&Settings::values.use_vsync_new, ui->toggle_vsync_new,
use_vsync_new);
ConfigurationShared::ApplyPerGameSetting(&Settings::values.force_hw_vertex_shaders,
ui->toggle_force_hw_vertex_shaders,
force_hw_vertex_shaders);
ConfigurationShared::ApplyPerGameSetting(&Settings::values.disable_surface_texture_copy,
ui->toggle_disable_surface_texture_copy,
disable_surface_texture_copy);
ConfigurationShared::ApplyPerGameSetting(&Settings::values.disable_flush_cpu_write,
ui->toggle_disable_flush_cpu_write,
disable_flush_cpu_write);
ConfigurationShared::ApplyPerGameSetting(
&Settings::values.delay_game_render_thread_us, ui->delay_render_combo,
[this](s32) { return ui->delay_render_slider->value(); });
Expand All @@ -196,6 +211,12 @@ void ConfigureGraphics::SetupPerGameUI() {
Settings::values.use_vsync_new.UsingGlobal());
ui->toggle_async_shaders->setEnabled(
Settings::values.async_shader_compilation.UsingGlobal());
ui->toggle_force_hw_vertex_shaders->setEnabled(
Settings::values.force_hw_vertex_shaders.UsingGlobal());
ui->toggle_disable_surface_texture_copy->setEnabled(
Settings::values.disable_surface_texture_copy.UsingGlobal());
ui->toggle_disable_flush_cpu_write->setEnabled(
Settings::values.disable_flush_cpu_write.UsingGlobal());
ui->widget_texture_sampling->setEnabled(Settings::values.texture_sampling.UsingGlobal());
ui->toggle_async_present->setEnabled(Settings::values.async_presentation.UsingGlobal());
ui->graphics_api_combo->setEnabled(Settings::values.graphics_api.UsingGlobal());
Expand Down Expand Up @@ -240,6 +261,15 @@ void ConfigureGraphics::SetupPerGameUI() {
ui->toggle_async_present, Settings::values.async_presentation, async_presentation);
ConfigurationShared::SetColoredTristate(ui->spirv_shader_gen, Settings::values.spirv_shader_gen,
spirv_shader_gen);
ConfigurationShared::SetColoredTristate(ui->toggle_force_hw_vertex_shaders,
Settings::values.force_hw_vertex_shaders,
force_hw_vertex_shaders);
ConfigurationShared::SetColoredTristate(ui->toggle_disable_surface_texture_copy,
Settings::values.disable_surface_texture_copy,
disable_surface_texture_copy);
ConfigurationShared::SetColoredTristate(ui->toggle_disable_flush_cpu_write,
Settings::values.disable_flush_cpu_write,
disable_flush_cpu_write);
}

void ConfigureGraphics::SetPhysicalDeviceComboVisibility(int index) {
Expand Down
3 changes: 3 additions & 0 deletions src/citra_qt/configuration/configure_graphics.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ class ConfigureGraphics : public QWidget {
ConfigurationShared::CheckState async_shader_compilation;
ConfigurationShared::CheckState async_presentation;
ConfigurationShared::CheckState spirv_shader_gen;
ConfigurationShared::CheckState force_hw_vertex_shaders;
ConfigurationShared::CheckState disable_surface_texture_copy;
ConfigurationShared::CheckState disable_flush_cpu_write;
std::unique_ptr<Ui::ConfigureGraphics> ui;
QColor bg_color;
};
39 changes: 39 additions & 0 deletions src/citra_qt/configuration/configure_graphics.ui
Original file line number Diff line number Diff line change
Expand Up @@ -387,6 +387,45 @@
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBox">
<property name="title">
<string>Tweaks</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_4">
<item>
<widget class="QCheckBox" name="toggle_force_hw_vertex_shaders">
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Ignores software vertex shaders from PICA core. Enable this may lead a small performance boost, but may cause graphical bugs as well.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="text">
<string>Force Hardware Vertex Shaders</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="toggle_disable_surface_texture_copy">
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Ignores texture copies if src_surface_id is null. Enable this may lead a small performance boost, but may cause graphical bugs as well.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="text">
<string>Disable Surface Texture Copy</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="toggle_disable_flush_cpu_write">
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Ignores CPU write if there is a region to invalidate from rasterizer cache. Enable this may lead a small performance boost, but may cause graphical bugs as well.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="text">
<string>Disable Flush CPU Write</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
Expand Down

0 comments on commit 0ceaa1b

Please sign in to comment.