Qt: GPU settings tab

This commit is contained in:
Connor McLaughlin 2020-01-03 17:51:58 +10:00
parent fbf5e7f0e3
commit d88fc20434
11 changed files with 217 additions and 18 deletions

View file

@ -36,6 +36,7 @@
</ItemGroup>
<ItemGroup>
<ClCompile Include="consolesettingswidget.cpp" />
<ClCompile Include="gpusettingswidget.cpp" />
<ClCompile Include="qtdisplaywindow.cpp" />
<ClCompile Include="gamelistsettingswidget.cpp" />
<ClCompile Include="gamelistwidget.cpp" />
@ -51,6 +52,7 @@
<ItemGroup>
<QtMoc Include="portsettingswidget.h" />
<QtMoc Include="qtdisplaywindow.h" />
<QtMoc Include="gpusettingswidget.h" />
<ClInclude Include="settingwidgetbinder.h" />
<QtMoc Include="consolesettingswidget.h" />
<QtMoc Include="gamelistsettingswidget.h" />
@ -102,6 +104,7 @@
<ClCompile Include="$(IntDir)moc_consolesettingswidget.cpp" />
<ClCompile Include="$(IntDir)moc_gamelistsettingswidget.cpp" />
<ClCompile Include="$(IntDir)moc_gamelistwidget.cpp" />
<ClCompile Include="$(IntDir)moc_gpusettingswidget.cpp" />
<ClCompile Include="$(IntDir)moc_mainwindow.cpp" />
<ClCompile Include="$(IntDir)moc_opengldisplaywindow.cpp" />
<ClCompile Include="$(IntDir)moc_portsettingswidget.cpp" />
@ -113,6 +116,11 @@
<ItemGroup>
<Natvis Include="qt5.natvis" />
</ItemGroup>
<ItemGroup>
<QtUi Include="gpusettingswidget.ui">
<FileType>Document</FileType>
</QtUi>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{28F14272-0EC4-41BB-849F-182ADB81AF70}</ProjectGuid>
<Keyword>Win32Proj</Keyword>

View file

@ -22,12 +22,14 @@
<ClCompile Include="portsettingswidget.cpp" />
<ClCompile Include="$(IntDir)moc_portsettingswidget.cpp" />
<ClCompile Include="qtdisplaywindow.cpp" />
<ClCompile Include="$(IntDir)moc_qtdisplaywindow.cpp" />
<ClCompile Include="gpusettingswidget.cpp" />
<ClCompile Include="$(IntDir)moc_gpusettingswidget.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="qtsettingsinterface.h" />
<ClInclude Include="qtutils.h" />
<ClInclude Include="settingwidgetbinder.h" />
<ClInclude Include="qtdisplaywindow.h" />
</ItemGroup>
<ItemGroup>
<Filter Include="resources">
@ -46,12 +48,15 @@
<QtMoc Include="qthostinterface.h" />
<QtMoc Include="settingsdialog.h" />
<QtMoc Include="portsettingswidget.h" />
<QtMoc Include="qtdisplaywindow.h" />
<QtMoc Include="gpusettingswidget.h" />
</ItemGroup>
<ItemGroup>
<QtUi Include="consolesettingswidget.ui" />
<QtUi Include="gamelistsettingswidget.ui" />
<QtUi Include="mainwindow.ui" />
<QtUi Include="settingsdialog.ui" />
<QtUi Include="gpusettingswidget.ui" />
</ItemGroup>
<ItemGroup>
<Natvis Include="qt5.natvis" />

View file

@ -0,0 +1,35 @@
#include "gpusettingswidget.h"
#include "core/gpu.h"
#include "core/settings.h"
#include "settingwidgetbinder.h"
GPUSettingsWidget::GPUSettingsWidget(QtHostInterface* host_interface, QWidget* parent /* = nullptr */)
: QWidget(parent), m_host_interface(host_interface)
{
m_ui.setupUi(this);
setupAdditionalUi();
SettingWidgetBinder::BindWidgetToSetting(m_host_interface, m_ui.renderer, &Settings::gpu_renderer);
SettingWidgetBinder::BindWidgetToSetting(m_host_interface, m_ui.fullscreen, &Settings::display_fullscreen);
SettingWidgetBinder::BindWidgetToSetting(m_host_interface, m_ui.displayLinearFiltering,
&Settings::display_linear_filtering);
SettingWidgetBinder::BindWidgetToSetting(m_host_interface, m_ui.vsync, &Settings::video_sync_enabled);
SettingWidgetBinder::BindWidgetToSetting(m_host_interface, m_ui.resolutionScale, &Settings::gpu_resolution_scale);
SettingWidgetBinder::BindWidgetToSetting(m_host_interface, m_ui.trueColor, &Settings::gpu_true_color);
SettingWidgetBinder::BindWidgetToSetting(m_host_interface, m_ui.linearTextureFiltering,
&Settings::gpu_texture_filtering);
SettingWidgetBinder::BindWidgetToSetting(m_host_interface, m_ui.forceProgressiveScan,
&Settings::gpu_force_progressive_scan);
}
GPUSettingsWidget::~GPUSettingsWidget() = default;
void GPUSettingsWidget::setupAdditionalUi()
{
for (u32 i = 0; i < static_cast<u32>(GPURenderer::Count); i++)
m_ui.renderer->addItem(QString::fromLocal8Bit(Settings::GetRendererDisplayName(static_cast<GPURenderer>(i))));
m_ui.resolutionScale->addItem(tr("Automatic based on window size"));
for (u32 i = 1; i <= 16; i++)
m_ui.resolutionScale->addItem(tr("%1x (%2x%3)").arg(i).arg(GPU::VRAM_WIDTH * i).arg(GPU::VRAM_HEIGHT * i));
}

View file

@ -0,0 +1,23 @@
#pragma once
#include <QtWidgets/QWidget>
#include "ui_gpusettingswidget.h"
class QtHostInterface;
class GPUSettingsWidget : public QWidget
{
Q_OBJECT
public:
GPUSettingsWidget(QtHostInterface* host_interface, QWidget* parent = nullptr);
~GPUSettingsWidget();
private:
void setupAdditionalUi();
Ui::GPUSettingsWidget m_ui;
QtHostInterface* m_host_interface;
};

View file

@ -0,0 +1,126 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>GPUSettingsWidget</class>
<widget class="QWidget" name="GPUSettingsWidget">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>1350</width>
<height>788</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<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="QGroupBox" name="groupBox">
<property name="title">
<string>Basic</string>
</property>
<layout class="QFormLayout" name="formLayout_3">
<item row="0" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>Renderer:</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QComboBox" name="renderer"/>
</item>
<item row="1" column="0" colspan="2">
<widget class="QCheckBox" name="fullscreen">
<property name="text">
<string>Fullscreen</string>
</property>
</widget>
</item>
<item row="3" column="0" colspan="2">
<widget class="QCheckBox" name="displayLinearFiltering">
<property name="text">
<string>Linear Upscaling</string>
</property>
</widget>
</item>
<item row="2" column="0" colspan="2">
<widget class="QCheckBox" name="vsync">
<property name="text">
<string>VSync</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBox_2">
<property name="title">
<string>Enhancements</string>
</property>
<layout class="QFormLayout" name="formLayout_2">
<item row="0" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>Resolution Scale:</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QComboBox" name="resolutionScale"/>
</item>
<item row="1" column="0" colspan="2">
<widget class="QCheckBox" name="trueColor">
<property name="text">
<string>True Color Rendering (24-bit, disables dithering)</string>
</property>
</widget>
</item>
<item row="2" column="0" colspan="2">
<widget class="QCheckBox" name="linearTextureFiltering">
<property name="text">
<string>Bilinear Texture Filtering</string>
</property>
</widget>
</item>
<item row="3" column="0" colspan="2">
<widget class="QCheckBox" name="forceProgressiveScan">
<property name="text">
<string>Force Progressive Scan</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>

View file

@ -161,7 +161,6 @@ void MainWindow::connectSignals()
[this]() { doSettings(SettingsDialog::Category::GameListSettings); });
connect(m_ui.actionPortSettings, &QAction::triggered,
[this]() { doSettings(SettingsDialog::Category::PortSettings); });
connect(m_ui.actionCPUSettings, &QAction::triggered, [this]() { doSettings(SettingsDialog::Category::CPUSettings); });
connect(m_ui.actionGPUSettings, &QAction::triggered, [this]() { doSettings(SettingsDialog::Category::GPUSettings); });
connect(m_ui.actionAudioSettings, &QAction::triggered,
[this]() { doSettings(SettingsDialog::Category::AudioSettings); });

View file

@ -75,7 +75,6 @@
<addaction name="actionConsoleSettings"/>
<addaction name="actionGameListSettings"/>
<addaction name="actionPortSettings"/>
<addaction name="actionCPUSettings"/>
<addaction name="actionGPUSettings"/>
<addaction name="actionAudioSettings"/>
<addaction name="separator"/>

View file

@ -1,6 +1,7 @@
#include "settingsdialog.h"
#include "consolesettingswidget.h"
#include "gamelistsettingswidget.h"
#include "gpusettingswidget.h"
#include "portsettingswidget.h"
#include "qthostinterface.h"
#include <QtWidgets/QTextEdit>
@ -13,16 +14,14 @@ SettingsDialog::SettingsDialog(QtHostInterface* host_interface, QWidget* parent
m_console_settings = new ConsoleSettingsWidget(host_interface, m_ui.settingsContainer);
m_game_list_settings = new GameListSettingsWidget(host_interface, m_ui.settingsContainer);
m_port_settings = new PortSettingsWidget(host_interface, m_ui.settingsContainer);
m_cpu_settings = new QWidget(m_ui.settingsContainer);
m_gpu_settings = new QWidget(m_ui.settingsContainer);
m_gpu_settings = new GPUSettingsWidget(host_interface, m_ui.settingsContainer);
m_audio_settings = new QWidget(m_ui.settingsContainer);
m_ui.settingsContainer->insertWidget(0, m_console_settings);
m_ui.settingsContainer->insertWidget(1, m_game_list_settings);
m_ui.settingsContainer->insertWidget(2, m_port_settings);
m_ui.settingsContainer->insertWidget(3, m_cpu_settings);
m_ui.settingsContainer->insertWidget(4, m_gpu_settings);
m_ui.settingsContainer->insertWidget(5, m_audio_settings);
m_ui.settingsContainer->insertWidget(3, m_gpu_settings);
m_ui.settingsContainer->insertWidget(4, m_audio_settings);
m_ui.settingsCategory->setCurrentRow(0);
m_ui.settingsContainer->setCurrentIndex(0);

View file

@ -17,7 +17,6 @@ public:
ConsoleSettings,
GameListSettings,
PortSettings,
CPUSettings,
GPUSettings,
AudioSettings,
Count

View file

@ -67,15 +67,6 @@
<normaloff>:/icons/input-gaming.png</normaloff>:/icons/input-gaming.png</iconset>
</property>
</item>
<item>
<property name="text">
<string>CPU Settings</string>
</property>
<property name="icon">
<iconset resource="icons.qrc">
<normaloff>:/icons/applications-other.png</normaloff>:/icons/applications-other.png</iconset>
</property>
</item>
<item>
<property name="text">
<string>GPU Settings</string>

View file

@ -136,4 +136,19 @@ void BindWidgetToSetting(QtHostInterface* hi, WidgetType* widget, DataType Setti
});
}
template<typename WidgetType, typename DataType>
void BindWidgetToSetting(QtHostInterface* hi, WidgetType* widget, DataType Settings::*settings_ptr,
std::enable_if_t<std::is_integral_v<DataType>, int>* v = nullptr)
{
using Accessor = SettingAccessor<WidgetType>;
Accessor::setIntValue(widget, static_cast<int>(hi->GetCoreSettings().*settings_ptr));
Accessor::connectValueChanged(widget, [hi, widget, settings_ptr](int) {
const int value = Accessor::getIntValue(widget);
(hi->GetCoreSettings().*settings_ptr) = static_cast<DataType>(value);
hi->updateQSettings();
});
}
} // namespace SettingWidgetBinder