1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
|
// Copyright 2017 Dolphin Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later
#include "DolphinQt/Config/Graphics/SoftwareRendererWidget.h"
#include <QComboBox>
#include <QGridLayout>
#include <QGroupBox>
#include <QLabel>
#include <QSpinBox>
#include <QVBoxLayout>
#include "Core/Config/GraphicsSettings.h"
#include "Core/Config/MainSettings.h"
#include "Core/ConfigManager.h"
#include "Core/Core.h"
#include "DolphinQt/Config/Graphics/GraphicsBool.h"
#include "DolphinQt/Config/Graphics/GraphicsWindow.h"
#include "DolphinQt/Config/ToolTipControls/ToolTipComboBox.h"
#include "DolphinQt/Settings.h"
#include "UICommon/VideoUtils.h"
#include "VideoCommon/VideoBackendBase.h"
#include "VideoCommon/VideoConfig.h"
SoftwareRendererWidget::SoftwareRendererWidget(GraphicsWindow* parent)
{
CreateWidgets();
LoadSettings();
ConnectWidgets();
AddDescriptions();
emit BackendChanged(QString::fromStdString(Config::Get(Config::MAIN_GFX_BACKEND)));
connect(parent, &GraphicsWindow::BackendChanged, [this] { LoadSettings(); });
connect(&Settings::Instance(), &Settings::EmulationStateChanged, this,
[=](Core::State state) { OnEmulationStateChanged(state != Core::State::Uninitialized); });
OnEmulationStateChanged(Core::GetState() != Core::State::Uninitialized);
}
void SoftwareRendererWidget::CreateWidgets()
{
auto* main_layout = new QVBoxLayout;
auto* rendering_box = new QGroupBox(tr("Rendering"));
auto* rendering_layout = new QGridLayout();
m_backend_combo = new ToolTipComboBox();
rendering_box->setLayout(rendering_layout);
rendering_layout->addWidget(new QLabel(tr("Backend:")), 1, 1);
rendering_layout->addWidget(m_backend_combo, 1, 2);
for (const auto& backend : VideoBackendBase::GetAvailableBackends())
m_backend_combo->addItem(tr(backend->GetDisplayName().c_str()));
auto* overlay_box = new QGroupBox(tr("Overlay Information"));
auto* overlay_layout = new QGridLayout();
overlay_box->setLayout(overlay_layout);
m_show_statistics = new GraphicsBool(tr("Show Statistics"), Config::GFX_OVERLAY_STATS);
overlay_layout->addWidget(m_show_statistics);
auto* utility_box = new QGroupBox(tr("Utility"));
auto* utility_layout = new QGridLayout();
m_dump_textures = new GraphicsBool(tr("Dump Textures"), Config::GFX_DUMP_TEXTURES);
m_dump_objects = new GraphicsBool(tr("Dump Objects"), Config::GFX_SW_DUMP_OBJECTS);
utility_box->setLayout(utility_layout);
utility_layout->addWidget(m_dump_textures, 1, 1);
utility_layout->addWidget(m_dump_objects, 1, 2);
auto* debug_box = new QGroupBox(tr("Debug Only"));
auto* debug_layout = new QGridLayout();
m_dump_tev_stages = new GraphicsBool(tr("Dump TEV Stages"), Config::GFX_SW_DUMP_TEV_STAGES);
m_dump_tev_fetches =
new GraphicsBool(tr("Dump Texture Fetches"), Config::GFX_SW_DUMP_TEV_TEX_FETCHES);
debug_layout->addWidget(m_dump_tev_stages, 1, 1);
debug_layout->addWidget(m_dump_tev_fetches, 1, 2);
debug_box->setLayout(debug_layout);
#ifdef _DEBUG
utility_layout->addWidget(debug_box, 2, 1, 1, 2);
#endif
auto* object_range_box = new QGroupBox(tr("Drawn Object Range"));
auto* object_range_layout = new QGridLayout();
m_object_range_min = new QSpinBox();
m_object_range_max = new QSpinBox();
for (auto* spin : {m_object_range_min, m_object_range_max})
{
spin->setMinimum(0);
spin->setMaximum(100000);
}
object_range_box->setLayout(object_range_layout);
object_range_layout->addWidget(m_object_range_min, 1, 1);
object_range_layout->addWidget(m_object_range_max, 1, 2);
main_layout->addWidget(rendering_box);
main_layout->addWidget(overlay_box);
main_layout->addWidget(utility_box);
main_layout->addWidget(object_range_box);
main_layout->addStretch();
setLayout(main_layout);
}
void SoftwareRendererWidget::ConnectWidgets()
{
connect(m_backend_combo, qOverload<int>(&QComboBox::currentIndexChanged),
[this](int) { SaveSettings(); });
connect(m_object_range_min, qOverload<int>(&QSpinBox::valueChanged),
[this](int) { SaveSettings(); });
connect(m_object_range_max, qOverload<int>(&QSpinBox::valueChanged),
[this](int) { SaveSettings(); });
}
void SoftwareRendererWidget::LoadSettings()
{
for (const auto& backend : VideoBackendBase::GetAvailableBackends())
{
if (backend->GetName() == Config::Get(Config::MAIN_GFX_BACKEND))
{
m_backend_combo->setCurrentIndex(
m_backend_combo->findText(tr(backend->GetDisplayName().c_str())));
}
}
m_object_range_min->setValue(Config::Get(Config::GFX_SW_DRAW_START));
m_object_range_max->setValue(Config::Get(Config::GFX_SW_DRAW_END));
}
void SoftwareRendererWidget::SaveSettings()
{
for (const auto& backend : VideoBackendBase::GetAvailableBackends())
{
if (tr(backend->GetDisplayName().c_str()) == m_backend_combo->currentText())
{
const auto backend_name = backend->GetName();
if (backend_name != Config::Get(Config::MAIN_GFX_BACKEND))
emit BackendChanged(QString::fromStdString(backend_name));
break;
}
}
Config::SetBaseOrCurrent(Config::GFX_SW_DRAW_START, m_object_range_min->value());
Config::SetBaseOrCurrent(Config::GFX_SW_DRAW_END, m_object_range_max->value());
}
void SoftwareRendererWidget::AddDescriptions()
{
static const char TR_BACKEND_DESCRIPTION[] = QT_TR_NOOP(
"Selects what graphics API to use internally.<br>The software renderer is extremely "
"slow and only useful for debugging, so you'll want to use either Direct3D or "
"OpenGL. Different games and different GPUs will behave differently on each "
"backend, so for the best emulation experience it's recommended to try both and "
"choose the one that's less problematic.<br><br><dolphin_emphasis>If unsure, select "
"OpenGL.</dolphin_emphasis>");
static const char TR_SHOW_STATISTICS_DESCRIPTION[] =
QT_TR_NOOP("Show various rendering statistics.<br><br><dolphin_emphasis>If unsure, leave "
"this unchecked.</dolphin_emphasis>");
static const char TR_DUMP_TEXTURES_DESCRIPTION[] =
QT_TR_NOOP("Dump decoded game textures to "
"User/Dump/Textures/<game_id>/.<br><br><dolphin_emphasis>If unsure, leave "
"this unchecked.</dolphin_emphasis>");
static const char TR_DUMP_OBJECTS_DESCRIPTION[] =
QT_TR_NOOP("Dump objects to User/Dump/Objects/.<br><br><dolphin_emphasis>If unsure, leave "
"this unchecked.</dolphin_emphasis>");
static const char TR_DUMP_TEV_STAGES_DESCRIPTION[] =
QT_TR_NOOP("Dump TEV Stages to User/Dump/Objects/.<br><br><dolphin_emphasis>If unsure, leave "
"this unchecked.</dolphin_emphasis>");
static const char TR_DUMP_TEV_FETCHES_DESCRIPTION[] = QT_TR_NOOP(
"Dump Texture Fetches to User/Dump/Objects/.<br><br><dolphin_emphasis>If unsure, leave "
"this unchecked.</dolphin_emphasis>");
m_backend_combo->SetTitle(tr("Backend"));
m_backend_combo->SetDescription(tr(TR_BACKEND_DESCRIPTION));
m_show_statistics->SetDescription(tr(TR_SHOW_STATISTICS_DESCRIPTION));
m_dump_textures->SetDescription(tr(TR_DUMP_TEXTURES_DESCRIPTION));
m_dump_objects->SetDescription(tr(TR_DUMP_OBJECTS_DESCRIPTION));
m_dump_tev_stages->SetDescription(tr(TR_DUMP_TEV_STAGES_DESCRIPTION));
m_dump_tev_fetches->SetDescription(tr(TR_DUMP_TEV_FETCHES_DESCRIPTION));
}
void SoftwareRendererWidget::OnEmulationStateChanged(bool running)
{
m_backend_combo->setEnabled(!running);
}
|