Skip to content

Commit

Permalink
Implement to ui
Browse files Browse the repository at this point in the history
  • Loading branch information
Gamer64ytb committed Jul 31, 2024
1 parent 22c4f1c commit 8bbac3e
Show file tree
Hide file tree
Showing 12 changed files with 44 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ enum class BooleanSetting(
) : AbstractBooleanSetting {
EXPAND_TO_CUTOUT_AREA("expand_to_cutout_area", Settings.SECTION_LAYOUT, false),
SPIRV_SHADER_GEN("spirv_shader_gen", Settings.SECTION_RENDERER, true),
USE_SAMPLE_SHADING("use_sample_shading", Settings.SECTION_RENDERER, false),
ASYNC_SHADERS("async_shader_compilation", Settings.SECTION_RENDERER, false),
ADRENO_GPU_BOOST("adreno_gpu_boost", Settings.SECTION_RENDERER, false),
PLUGIN_LOADER("plugin_loader", Settings.SECTION_SYSTEM, false),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -738,6 +738,15 @@ class SettingsFragmentPresenter(private val fragmentView: SettingsFragmentView)
BooleanSetting.SPIRV_SHADER_GEN.defaultValue,
)
)
add(
SwitchSetting(
BooleanSetting.USE_SAMPLE_SHADING,
R.string.use_sample_shading,
R.string.use_sample_shading_description,
BooleanSetting.USE_SAMPLE_SHADING.key,
BooleanSetting.USE_SAMPLE_SHADING.defaultValue,
)
)
add(
SwitchSetting(
BooleanSetting.ASYNC_SHADERS,
Expand Down
4 changes: 4 additions & 0 deletions src/android/app/src/main/jni/default_ini.h
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,10 @@ async_shader_compilation =
# 0: GLSL, 1: SPIR-V (default)
spirv_shader_gen =
# Enables a vulkan extension that may improve the rendering quality. (Vulkan only)
# 0 (default): Off, 1: On
use_sample_shading =
# Whether to use hardware shaders to emulate 3DS shaders
# 0: Software, 1 (default): Hardware
use_hw_shader =
Expand Down
2 changes: 2 additions & 0 deletions src/android/app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,8 @@
<string name="graphics_api">Graphics API</string>
<string name="spirv_shader_gen">Enable SPIR-V shader generation</string>
<string name="spirv_shader_gen_description">Emits the fragment shader used to emulate PICA using SPIR-V instead of GLSL</string>
<string name="use_sample_shading">Enable Sample Shading</string>
<string name="use_sample_shading_description">Enables a vulkan extension that may improve the rendering quality, at the cost of some performance.</string>
<string name="async_shaders">Enable asynchronous shader compilation</string>
<string name="async_shaders_description">Compiles shaders in the background to reduce stuttering during gameplay. When enabled expect temporary graphical glitches</string>
<string name="renderer_debug">Debug Renderer</string>
Expand Down
2 changes: 2 additions & 0 deletions src/common/settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ void LogSettings() {
log_setting("Renderer_AsyncShaders", values.async_shader_compilation.GetValue());
log_setting("Renderer_AsyncPresentation", values.async_presentation.GetValue());
log_setting("Renderer_SpirvShaderGen", values.spirv_shader_gen.GetValue());
log_setting("Renderer_UseSampleShading", values.use_sample_shading.GetValue());
log_setting("Renderer_Debug", values.renderer_debug.GetValue());
log_setting("Renderer_UseHwShader", values.use_hw_shader.GetValue());
log_setting("Renderer_ShadersAccurateMul", values.shaders_accurate_mul.GetValue());
Expand Down Expand Up @@ -202,6 +203,7 @@ void RestoreGlobalState(bool is_powered_on) {
values.graphics_api.SetGlobal(true);
values.physical_device.SetGlobal(true);
values.spirv_shader_gen.SetGlobal(true);
values.use_sample_shading.SetGlobal(true);
values.async_shader_compilation.SetGlobal(true);
values.async_presentation.SetGlobal(true);
values.use_hw_shader.SetGlobal(true);
Expand Down
2 changes: 1 addition & 1 deletion src/common/settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -471,7 +471,7 @@ struct Values {
Setting<bool> renderer_debug{false, "renderer_debug"};
Setting<bool> dump_command_buffers{false, "dump_command_buffers"};
SwitchableSetting<bool> spirv_shader_gen{true, "spirv_shader_gen"};
SwitchableSetting<bool> use_sample_shading{true, "use_sample_shading"};
SwitchableSetting<bool> use_sample_shading{false, "use_sample_shading"};
SwitchableSetting<bool> async_shader_compilation{false, "async_shader_compilation"};
SwitchableSetting<bool> async_presentation{true, "async_presentation"};
SwitchableSetting<bool> use_hw_shader{true, "use_hw_shader"};
Expand Down
1 change: 1 addition & 0 deletions src/mandarine/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ void Config::ReadValues() {
ReadSetting("Renderer", Settings::values.graphics_api);
ReadSetting("Renderer", Settings::values.physical_device);
ReadSetting("Renderer", Settings::values.spirv_shader_gen);
ReadSetting("Renderer", Settings::values.use_sample_shading);
ReadSetting("Renderer", Settings::values.async_shader_compilation);
ReadSetting("Renderer", Settings::values.async_presentation);
ReadSetting("Renderer", Settings::values.use_gles);
Expand Down
4 changes: 4 additions & 0 deletions src/mandarine/default_ini.h
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,10 @@ priority_boost_starved_threads =
# 0: Software, 1: OpenGL (default), 2: Vulkan
graphics_api =
# Enables a vulkan extension that may improve the rendering quality. (Vulkan only)
# 0 (default): Off, 1: On
use_sample_shading =
# Whether to render using GLES or OpenGL
# 0 (default): OpenGL, 1: GLES
use_gles =
Expand Down
2 changes: 2 additions & 0 deletions src/mandarine_qt/configuration/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -668,6 +668,7 @@ void Config::ReadRendererValues() {
ReadGlobalSetting(Settings::values.graphics_api);
ReadGlobalSetting(Settings::values.physical_device);
ReadGlobalSetting(Settings::values.spirv_shader_gen);
ReadGlobalSetting(Settings::values.use_sample_shading);
ReadGlobalSetting(Settings::values.async_shader_compilation);
ReadGlobalSetting(Settings::values.async_presentation);
ReadGlobalSetting(Settings::values.use_hw_shader);
Expand Down Expand Up @@ -1198,6 +1199,7 @@ void Config::SaveRendererValues() {
WriteGlobalSetting(Settings::values.graphics_api);
WriteGlobalSetting(Settings::values.physical_device);
WriteGlobalSetting(Settings::values.spirv_shader_gen);
WriteGlobalSetting(Settings::values.use_sample_shading);
WriteGlobalSetting(Settings::values.async_shader_compilation);
WriteGlobalSetting(Settings::values.async_presentation);
WriteGlobalSetting(Settings::values.use_hw_shader);
Expand Down
7 changes: 7 additions & 0 deletions src/mandarine_qt/configuration/configure_graphics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ ConfigureGraphics::ConfigureGraphics(QString gl_renderer, std::span<const QStrin

ui->physical_device_combo->setVisible(false);
ui->spirv_shader_gen->setVisible(false);
ui->sample_shading->setVisible(false);
} else {
for (const QString& name : physical_devices) {
ui->physical_device_combo->addItem(name);
Expand Down Expand Up @@ -142,6 +143,7 @@ void ConfigureGraphics::SetConfiguration() {
ui->toggle_disk_shader_cache->setChecked(Settings::values.use_disk_shader_cache.GetValue());
ui->toggle_vsync_new->setChecked(Settings::values.use_vsync_new.GetValue());
ui->spirv_shader_gen->setChecked(Settings::values.spirv_shader_gen.GetValue());
ui->sample_shading->setChecked(Settings::values.use_sample_shading.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(
Expand All @@ -167,6 +169,8 @@ void ConfigureGraphics::ApplyConfiguration() {
ui->toggle_async_present, async_presentation);
ConfigurationShared::ApplyPerGameSetting(&Settings::values.spirv_shader_gen,
ui->spirv_shader_gen, spirv_shader_gen);
ConfigurationShared::ApplyPerGameSetting(&Settings::values.use_sample_shading,
ui->sample_shading, sample_shading);
ConfigurationShared::ApplyPerGameSetting(&Settings::values.use_hw_shader, ui->toggle_hw_shader,
use_hw_shader);
ConfigurationShared::ApplyPerGameSetting(&Settings::values.shaders_accurate_mul,
Expand Down Expand Up @@ -261,6 +265,8 @@ 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->sample_shading, Settings::values.use_sample_shading,
sample_shading);
ConfigurationShared::SetColoredTristate(ui->toggle_force_hw_vertex_shaders,
Settings::values.force_hw_vertex_shaders,
force_hw_vertex_shaders);
Expand Down Expand Up @@ -292,5 +298,6 @@ void ConfigureGraphics::SetPhysicalDeviceComboVisibility(int index) {

ui->physical_device_group->setVisible(effective_api == Settings::GraphicsAPI::Vulkan);
ui->spirv_shader_gen->setVisible(effective_api == Settings::GraphicsAPI::Vulkan);
ui->sample_shading->setVisible(effective_api == Settings::GraphicsAPI::Vulkan);
ui->opengl_renderer_group->setVisible(effective_api == Settings::GraphicsAPI::OpenGL);
}
1 change: 1 addition & 0 deletions src/mandarine_qt/configuration/configure_graphics.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ class ConfigureGraphics : public QWidget {
ConfigurationShared::CheckState async_shader_compilation;
ConfigurationShared::CheckState async_presentation;
ConfigurationShared::CheckState spirv_shader_gen;
ConfigurationShared::CheckState sample_shading;
ConfigurationShared::CheckState force_hw_vertex_shaders;
ConfigurationShared::CheckState disable_surface_texture_copy;
ConfigurationShared::CheckState disable_flush_cpu_write;
Expand Down
10 changes: 10 additions & 0 deletions src/mandarine_qt/configuration/configure_graphics.ui
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,16 @@
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="sample_shading">
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Enables a vulkan extension that may improve the rendering quality, at the cost of some performance.&lt;/p&gt;&lt;p&gt;Requires a relatively powerful GPU for better performance.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="text">
<string>Enable Sample Shading</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
Expand Down

0 comments on commit 8bbac3e

Please sign in to comment.