1
0
Fork 0
forked from suyu/suyu

Settings: Add resolution scaling to settings.

This commit is contained in:
Fernando Sahmkow 2021-07-18 20:33:20 +02:00
parent 22f4b290b6
commit 37ef9c9130
6 changed files with 155 additions and 5 deletions

View file

@ -106,6 +106,57 @@ float Volume() {
return values.volume.GetValue() / 100.0f; return values.volume.GetValue() / 100.0f;
} }
void UpdateRescalingInfo() {
auto setup = values.resolution_setup.GetValue();
auto& info = values.resolution_info;
switch (setup) {
case ResolutionSetup::Res1_2X: {
info.up_scale = 1;
info.down_shift = 1;
break;
}
case ResolutionSetup::Res3_4X: {
info.up_scale = 3;
info.down_shift = 2;
break;
}
case ResolutionSetup::Res1X: {
info.up_scale = 1;
info.down_shift = 0;
break;
}
case ResolutionSetup::Res3_2X: {
info.up_scale = 3;
info.down_shift = 1;
break;
}
case ResolutionSetup::Res2X: {
info.up_scale = 2;
info.down_shift = 0;
break;
}
case ResolutionSetup::Res3X: {
info.up_scale = 3;
info.down_shift = 0;
break;
}
case ResolutionSetup::Res4X: {
info.up_scale = 4;
info.down_shift = 0;
break;
}
default: {
UNREACHABLE();
info.up_scale = 1;
info.down_shift = 0;
}
}
info.up_factor = static_cast<f32>(info.up_scale) / (1U << info.down_shift);
info.down_factor = static_cast<f32>(1U << info.down_shift) / info.up_scale;
info.size_up = info.up_scale * info.up_scale;
info.size_shift = info.down_shift * 2;
}
void RestoreGlobalState(bool is_powered_on) { void RestoreGlobalState(bool is_powered_on) {
// If a game is running, DO NOT restore the global settings state // If a game is running, DO NOT restore the global settings state
if (is_powered_on) { if (is_powered_on) {

View file

@ -56,16 +56,19 @@ enum class ResolutionSetup : u32 {
Res1_2X = 0, Res1_2X = 0,
Res3_4X = 1, Res3_4X = 1,
Res1X = 2, Res1X = 2,
Res3_2K = 3, Res3_2X = 3,
Res2X = 4, Res2X = 4,
Res3X = 5, Res3X = 5,
Res4X = 6,
}; };
struct ResolutionScalingInfo { struct ResolutionScalingInfo {
u32 up_scale{2}; u32 up_scale{1};
u32 down_shift{0}; u32 down_shift{0};
f32 up_factor{2.0f}; f32 up_factor{1.0f};
f32 down_factor{0.5f}; f32 down_factor{1.0f};
u32 size_up{1};
u32 size_shift{0};
}; };
/** The BasicSetting class is a simple resource manager. It defines a label and default value /** The BasicSetting class is a simple resource manager. It defines a label and default value
@ -613,6 +616,8 @@ std::string GetTimeZoneString();
void LogSettings(); void LogSettings();
void UpdateRescalingInfo();
// Restore the global state of all applicable settings in the Values struct // Restore the global state of all applicable settings in the Values struct
void RestoreGlobalState(bool is_powered_on); void RestoreGlobalState(bool is_powered_on);

View file

@ -824,6 +824,7 @@ void Config::ReadRendererValues() {
ReadGlobalSetting(Settings::values.vulkan_device); ReadGlobalSetting(Settings::values.vulkan_device);
ReadGlobalSetting(Settings::values.fullscreen_mode); ReadGlobalSetting(Settings::values.fullscreen_mode);
ReadGlobalSetting(Settings::values.aspect_ratio); ReadGlobalSetting(Settings::values.aspect_ratio);
ReadGlobalSetting(Settings::values.resolution_setup);
ReadGlobalSetting(Settings::values.max_anisotropy); ReadGlobalSetting(Settings::values.max_anisotropy);
ReadGlobalSetting(Settings::values.use_speed_limit); ReadGlobalSetting(Settings::values.use_speed_limit);
ReadGlobalSetting(Settings::values.speed_limit); ReadGlobalSetting(Settings::values.speed_limit);
@ -1364,6 +1365,10 @@ void Config::SaveRendererValues() {
static_cast<u32>(Settings::values.fullscreen_mode.GetDefault()), static_cast<u32>(Settings::values.fullscreen_mode.GetDefault()),
Settings::values.fullscreen_mode.UsingGlobal()); Settings::values.fullscreen_mode.UsingGlobal());
WriteGlobalSetting(Settings::values.aspect_ratio); WriteGlobalSetting(Settings::values.aspect_ratio);
WriteSetting(QString::fromStdString(Settings::values.resolution_setup.GetLabel()),
static_cast<u32>(Settings::values.resolution_setup.GetValue(global)),
static_cast<u32>(Settings::values.resolution_setup.GetDefault()),
Settings::values.resolution_setup.UsingGlobal());
WriteGlobalSetting(Settings::values.max_anisotropy); WriteGlobalSetting(Settings::values.max_anisotropy);
WriteGlobalSetting(Settings::values.use_speed_limit); WriteGlobalSetting(Settings::values.use_speed_limit);
WriteGlobalSetting(Settings::values.speed_limit); WriteGlobalSetting(Settings::values.speed_limit);

View file

@ -189,5 +189,6 @@ Q_DECLARE_METATYPE(Settings::CPUAccuracy);
Q_DECLARE_METATYPE(Settings::GPUAccuracy); Q_DECLARE_METATYPE(Settings::GPUAccuracy);
Q_DECLARE_METATYPE(Settings::FullscreenMode); Q_DECLARE_METATYPE(Settings::FullscreenMode);
Q_DECLARE_METATYPE(Settings::NvdecEmulation); Q_DECLARE_METATYPE(Settings::NvdecEmulation);
Q_DECLARE_METATYPE(Settings::ResolutionSetup);
Q_DECLARE_METATYPE(Settings::RendererBackend); Q_DECLARE_METATYPE(Settings::RendererBackend);
Q_DECLARE_METATYPE(Settings::ShaderBackend); Q_DECLARE_METATYPE(Settings::ShaderBackend);

View file

@ -102,6 +102,8 @@ void ConfigureGraphics::SetConfiguration() {
ui->nvdec_emulation->setCurrentIndex( ui->nvdec_emulation->setCurrentIndex(
static_cast<int>(Settings::values.nvdec_emulation.GetValue())); static_cast<int>(Settings::values.nvdec_emulation.GetValue()));
ui->aspect_ratio_combobox->setCurrentIndex(Settings::values.aspect_ratio.GetValue()); ui->aspect_ratio_combobox->setCurrentIndex(Settings::values.aspect_ratio.GetValue());
ui->resolution_combobox->setCurrentIndex(
static_cast<int>(Settings::values.resolution_setup.GetValue()));
} else { } else {
ConfigurationShared::SetPerGameSetting(ui->api, &Settings::values.renderer_backend); ConfigurationShared::SetPerGameSetting(ui->api, &Settings::values.renderer_backend);
ConfigurationShared::SetHighlight(ui->api_widget, ConfigurationShared::SetHighlight(ui->api_widget,
@ -122,6 +124,11 @@ void ConfigureGraphics::SetConfiguration() {
ConfigurationShared::SetHighlight(ui->ar_label, ConfigurationShared::SetHighlight(ui->ar_label,
!Settings::values.aspect_ratio.UsingGlobal()); !Settings::values.aspect_ratio.UsingGlobal());
ConfigurationShared::SetPerGameSetting(ui->resolution_combobox,
&Settings::values.resolution_setup);
ConfigurationShared::SetHighlight(ui->resolution_label,
!Settings::values.resolution_setup.UsingGlobal());
ui->bg_combobox->setCurrentIndex(Settings::values.bg_red.UsingGlobal() ? 0 : 1); ui->bg_combobox->setCurrentIndex(Settings::values.bg_red.UsingGlobal() ? 0 : 1);
ui->bg_button->setEnabled(!Settings::values.bg_red.UsingGlobal()); ui->bg_button->setEnabled(!Settings::values.bg_red.UsingGlobal());
ConfigurationShared::SetHighlight(ui->bg_layout, !Settings::values.bg_red.UsingGlobal()); ConfigurationShared::SetHighlight(ui->bg_layout, !Settings::values.bg_red.UsingGlobal());
@ -133,11 +140,14 @@ void ConfigureGraphics::SetConfiguration() {
} }
void ConfigureGraphics::ApplyConfiguration() { void ConfigureGraphics::ApplyConfiguration() {
const auto resolution_setup = static_cast<Settings::ResolutionSetup>(
ui->resolution_combobox->currentIndex() -
((Settings::IsConfiguringGlobal()) ? 0 : ConfigurationShared::USE_GLOBAL_OFFSET));
ConfigurationShared::ApplyPerGameSetting(&Settings::values.fullscreen_mode, ConfigurationShared::ApplyPerGameSetting(&Settings::values.fullscreen_mode,
ui->fullscreen_mode_combobox); ui->fullscreen_mode_combobox);
ConfigurationShared::ApplyPerGameSetting(&Settings::values.aspect_ratio, ConfigurationShared::ApplyPerGameSetting(&Settings::values.aspect_ratio,
ui->aspect_ratio_combobox); ui->aspect_ratio_combobox);
ConfigurationShared::ApplyPerGameSetting(&Settings::values.use_disk_shader_cache, ConfigurationShared::ApplyPerGameSetting(&Settings::values.use_disk_shader_cache,
ui->use_disk_shader_cache, use_disk_shader_cache); ui->use_disk_shader_cache, use_disk_shader_cache);
ConfigurationShared::ApplyPerGameSetting(&Settings::values.use_asynchronous_gpu_emulation, ConfigurationShared::ApplyPerGameSetting(&Settings::values.use_asynchronous_gpu_emulation,
@ -165,7 +175,16 @@ void ConfigureGraphics::ApplyConfiguration() {
Settings::values.bg_green.SetValue(static_cast<u8>(bg_color.green())); Settings::values.bg_green.SetValue(static_cast<u8>(bg_color.green()));
Settings::values.bg_blue.SetValue(static_cast<u8>(bg_color.blue())); Settings::values.bg_blue.SetValue(static_cast<u8>(bg_color.blue()));
} }
if (Settings::values.resolution_setup.UsingGlobal()) {
Settings::values.resolution_setup.SetValue(resolution_setup);
}
} else { } else {
if (ui->resolution_combobox->currentIndex() == ConfigurationShared::USE_GLOBAL_INDEX) {
Settings::values.resolution_setup.SetGlobal(true);
} else {
Settings::values.resolution_setup.SetGlobal(false);
Settings::values.resolution_setup.SetValue(resolution_setup);
}
if (ui->api->currentIndex() == ConfigurationShared::USE_GLOBAL_INDEX) { if (ui->api->currentIndex() == ConfigurationShared::USE_GLOBAL_INDEX) {
Settings::values.renderer_backend.SetGlobal(true); Settings::values.renderer_backend.SetGlobal(true);
Settings::values.shader_backend.SetGlobal(true); Settings::values.shader_backend.SetGlobal(true);
@ -207,6 +226,7 @@ void ConfigureGraphics::ApplyConfiguration() {
Settings::values.bg_blue.SetValue(static_cast<u8>(bg_color.blue())); Settings::values.bg_blue.SetValue(static_cast<u8>(bg_color.blue()));
} }
} }
Settings::UpdateRescalingInfo();
} }
void ConfigureGraphics::changeEvent(QEvent* event) { void ConfigureGraphics::changeEvent(QEvent* event) {
@ -312,6 +332,7 @@ void ConfigureGraphics::SetupPerGameUI() {
ui->device->setEnabled(Settings::values.renderer_backend.UsingGlobal()); ui->device->setEnabled(Settings::values.renderer_backend.UsingGlobal());
ui->fullscreen_mode_combobox->setEnabled(Settings::values.fullscreen_mode.UsingGlobal()); ui->fullscreen_mode_combobox->setEnabled(Settings::values.fullscreen_mode.UsingGlobal());
ui->aspect_ratio_combobox->setEnabled(Settings::values.aspect_ratio.UsingGlobal()); ui->aspect_ratio_combobox->setEnabled(Settings::values.aspect_ratio.UsingGlobal());
ui->resolution_combobox->setEnabled(Settings::values.resolution_setup.UsingGlobal());
ui->use_asynchronous_gpu_emulation->setEnabled( ui->use_asynchronous_gpu_emulation->setEnabled(
Settings::values.use_asynchronous_gpu_emulation.UsingGlobal()); Settings::values.use_asynchronous_gpu_emulation.UsingGlobal());
ui->nvdec_emulation->setEnabled(Settings::values.nvdec_emulation.UsingGlobal()); ui->nvdec_emulation->setEnabled(Settings::values.nvdec_emulation.UsingGlobal());
@ -340,6 +361,9 @@ void ConfigureGraphics::SetupPerGameUI() {
ConfigurationShared::SetColoredComboBox( ConfigurationShared::SetColoredComboBox(
ui->fullscreen_mode_combobox, ui->fullscreen_mode_label, ui->fullscreen_mode_combobox, ui->fullscreen_mode_label,
static_cast<int>(Settings::values.fullscreen_mode.GetValue(true))); static_cast<int>(Settings::values.fullscreen_mode.GetValue(true)));
ConfigurationShared::SetColoredComboBox(
ui->resolution_combobox, ui->resolution_label,
static_cast<int>(Settings::values.resolution_setup.GetValue(true)));
ConfigurationShared::InsertGlobalItem( ConfigurationShared::InsertGlobalItem(
ui->api, static_cast<int>(Settings::values.renderer_backend.GetValue(true))); ui->api, static_cast<int>(Settings::values.renderer_backend.GetValue(true)));
ConfigurationShared::InsertGlobalItem( ConfigurationShared::InsertGlobalItem(

View file

@ -309,6 +309,70 @@
</layout> </layout>
</widget> </widget>
</item> </item>
<item>
<widget class="QWidget" name="resolution_layout" native="true">
<layout class="QHBoxLayout" name="horizontalLayout_5">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QLabel" name="resolution_label">
<property name="text">
<string>Resolution:</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="resolution_combobox">
<item>
<property name="text">
<string>0.5X (360p/540p)</string>
</property>
</item>
<item>
<property name="text">
<string>0.75X (540p/810p)</string>
</property>
</item>
<item>
<property name="text">
<string>1X (720p/1080p)</string>
</property>
</item>
<item>
<property name="text">
<string>1.5X (1080p/1620p)</string>
</property>
</item>
<item>
<property name="text">
<string>2X (1440p/2160[4K]p)</string>
</property>
</item>
<item>
<property name="text">
<string>3X (2160p[4K]/3240p[6K])</string>
</property>
</item>
<item>
<property name="text">
<string>4X (2880p/4320p[8K])</string>
</property>
</item>
</widget>
</item>
</layout>
</widget>
</item>
<item> <item>
<widget class="QWidget" name="bg_layout" native="true"> <widget class="QWidget" name="bg_layout" native="true">
<property name="sizePolicy"> <property name="sizePolicy">