| 1 | // Copyright 2017 Dolphin Emulator Project |
| 2 | // SPDX-License-Identifier: GPL-2.0-or-later |
| 3 | |
| 4 | #include "DolphinQt/Config/Graphics/EnhancementsWidget.h" |
| 5 | |
| 6 | #include <utility> |
| 7 | |
| 8 | #include <QGridLayout> |
| 9 | #include <QGroupBox> |
| 10 | #include <QLabel> |
| 11 | #include <QPushButton> |
| 12 | #include <QVBoxLayout> |
| 13 | |
| 14 | #include "Common/CommonTypes.h" |
| 15 | |
| 16 | #include "Core/Config/GraphicsSettings.h" |
| 17 | |
| 18 | #include "DolphinQt/Config/ConfigControls/ConfigBool.h" |
| 19 | #include "DolphinQt/Config/ConfigControls/ConfigChoice.h" |
| 20 | #include "DolphinQt/Config/ConfigControls/ConfigFloatSlider.h" |
| 21 | #include "DolphinQt/Config/GameConfigWidget.h" |
| 22 | #include "DolphinQt/Config/Graphics/ColorCorrectionConfigWindow.h" |
| 23 | #include "DolphinQt/Config/Graphics/GraphicsPane.h" |
| 24 | #include "DolphinQt/Config/Graphics/PostProcessingConfigWindow.h" |
| 25 | #include "DolphinQt/Config/ToolTipControls/ToolTipPushButton.h" |
| 26 | #include "DolphinQt/QtUtils/NonDefaultQPushButton.h" |
| 27 | |
| 28 | #include "VideoCommon/PostProcessing.h" |
| 29 | #include "VideoCommon/VideoBackendBase.h" |
| 30 | #include "VideoCommon/VideoCommon.h" |
| 31 | #include "VideoCommon/VideoConfig.h" |
| 32 | |
| 33 | EnhancementsWidget::EnhancementsWidget(GraphicsPane* gfx_pane) |
| 34 | : m_game_layer{gfx_pane->GetConfigLayer()} |
| 35 | { |
| 36 | CreateWidgets(); |
| 37 | LoadPostProcessingShaders(); |
| 38 | ConnectWidgets(); |
| 39 | AddDescriptions(); |
| 40 | |
| 41 | // BackendChanged is called by parent on window creation. |
| 42 | connect(gfx_pane, &GraphicsPane::BackendChanged, this, &EnhancementsWidget::OnBackendChanged); |
| 43 | connect(gfx_pane, &GraphicsPane::UseFastTextureSamplingChanged, this, [this] { |
| 44 | m_texture_filtering_combo->setEnabled( |
| 45 | Get(m_game_layer, Config::GFX_HACK_FAST_TEXTURE_SAMPLING)); |
| 46 | }); |
| 47 | connect(m_arbitrary_mipmap_detection, &QCheckBox::toggled, gfx_pane, |
| 48 | [gfx_pane] { emit gfx_pane->UpdateGPUTextureDecoding(); }); |
| 49 | } |
| 50 | |
| 51 | constexpr int ANISO_1x = std::to_underlying(AnisotropicFilteringMode::Force1x); |
| 52 | constexpr int ANISO_2X = std::to_underlying(AnisotropicFilteringMode::Force2x); |
| 53 | constexpr int ANISO_4X = std::to_underlying(AnisotropicFilteringMode::Force4x); |
| 54 | constexpr int ANISO_8X = std::to_underlying(AnisotropicFilteringMode::Force8x); |
| 55 | constexpr int ANISO_16X = std::to_underlying(AnisotropicFilteringMode::Force16x); |
| 56 | constexpr int FILTERING_DEFAULT = std::to_underlying(TextureFilteringMode::Default); |
| 57 | constexpr int FILTERING_NEAREST = std::to_underlying(TextureFilteringMode::Nearest); |
| 58 | constexpr int FILTERING_LINEAR = std::to_underlying(TextureFilteringMode::Linear); |
| 59 | |
| 60 | void EnhancementsWidget::CreateWidgets() |
| 61 | { |
| 62 | auto* main_layout = new QVBoxLayout; |
| 63 | |
| 64 | // Enhancements |
| 65 | auto* enhancements_box = new QGroupBox(tr("Enhancements")); |
| 66 | auto* enhancements_layout = new QGridLayout(); |
| 67 | enhancements_box->setLayout(enhancements_layout); |
| 68 | |
| 69 | QStringList resolution_options{tr("Auto (Multiple of 640x528)"), tr("Native (640x528)")}; |
| 70 | // From 2x up. |
| 71 | // To calculate the suggested internal resolution scale for each common output resolution, |
| 72 | // we find the minimum multiplier that results in an equal or greater resolution than the |
| 73 | // output one, on both width and height. |
| 74 | // Note that often games don't render to the full resolution, but have some black bars |
| 75 | // on the edges; this is not accounted for in the calculations. |
| 76 | const QStringList resolution_extra_options{ |
| 77 | tr("720p"), tr("1080p"), tr("1440p"), QStringLiteral(""), |
| 78 | tr("4K"), QStringLiteral(""), tr("5K"), QStringLiteral(""), |
| 79 | QStringLiteral(""), QStringLiteral(""), tr("8K")}; |
| 80 | const int visible_resolution_option_count = static_cast<int>(resolution_options.size()) + |
| 81 | static_cast<int>(resolution_extra_options.size()); |
| 82 | |
| 83 | // If the current scale is greater than the max scale in the ini, add sufficient options so that |
| 84 | // when the settings are saved we don't lose the user-modified value from the ini. |
| 85 | const int max_efb_scale = std::max(Get(m_game_layer, Config::GFX_EFB_SCALE), |
| 86 | Get(m_game_layer, Config::GFX_MAX_EFB_SCALE)); |
| 87 | for (int scale = static_cast<int>(resolution_options.size()); scale <= max_efb_scale; scale++) |
| 88 | { |
| 89 | const QString scale_text = QString::number(scale); |
| 90 | const QString width_text = QString::number(static_cast<int>(EFB_WIDTH) * scale); |
| 91 | const QString height_text = QString::number(static_cast<int>(EFB_HEIGHT) * scale); |
| 92 | const int extra_index = resolution_options.size() - 2; |
| 93 | const QString extra_text = resolution_extra_options.size() > extra_index ? |
| 94 | resolution_extra_options[extra_index] : |
| 95 | QStringLiteral(""); |
| 96 | if (extra_text.isEmpty()) |
| 97 | { |
| 98 | resolution_options.append(tr("%1x Native (%2x%3)").arg(scale_text, width_text, height_text)); |
| 99 | } |
| 100 | else |
| 101 | { |
| 102 | resolution_options.append( |
| 103 | tr("%1x Native (%2x%3) for %4").arg(scale_text, width_text, height_text, extra_text)); |
| 104 | } |
| 105 | } |
| 106 | |
| 107 | m_ir_combo = new ConfigChoice(resolution_options, Config::GFX_EFB_SCALE, m_game_layer); |
| 108 | m_ir_combo->setMaxVisibleItems(visible_resolution_option_count); |
| 109 | |
| 110 | m_antialiasing_combo = new ConfigComplexChoice(Config::GFX_MSAA, Config::GFX_SSAA, m_game_layer); |
| 111 | m_antialiasing_combo->Add(tr("None"), (u32)1, false); |
| 112 | |
| 113 | m_texture_filtering_combo = |
| 114 | new ConfigComplexChoice(Config::GFX_ENHANCE_MAX_ANISOTROPY, |
| 115 | Config::GFX_ENHANCE_FORCE_TEXTURE_FILTERING, m_game_layer); |
| 116 | |
| 117 | m_texture_filtering_combo->Add(tr("Default"), Config::DefaultState{}, FILTERING_DEFAULT); |
| 118 | m_texture_filtering_combo->Add(tr("1x Anisotropic"), ANISO_1x, FILTERING_DEFAULT); |
| 119 | m_texture_filtering_combo->Add(tr("2x Anisotropic"), ANISO_2X, FILTERING_DEFAULT); |
| 120 | m_texture_filtering_combo->Add(tr("4x Anisotropic"), ANISO_4X, FILTERING_DEFAULT); |
| 121 | m_texture_filtering_combo->Add(tr("8x Anisotropic"), ANISO_8X, FILTERING_DEFAULT); |
| 122 | m_texture_filtering_combo->Add(tr("16x Anisotropic"), ANISO_16X, FILTERING_DEFAULT); |
| 123 | m_texture_filtering_combo->Add(tr("Force Nearest and 1x Anisotropic "), ANISO_1x, |
| 124 | FILTERING_NEAREST); |
| 125 | m_texture_filtering_combo->Add(tr("Force Linear and 1x Anisotropic"), ANISO_1x, FILTERING_LINEAR); |
| 126 | m_texture_filtering_combo->Add(tr("Force Linear and 2x Anisotropic"), ANISO_2X, FILTERING_LINEAR); |
| 127 | m_texture_filtering_combo->Add(tr("Force Linear and 4x Anisotropic"), ANISO_4X, FILTERING_LINEAR); |
| 128 | m_texture_filtering_combo->Add(tr("Force Linear and 8x Anisotropic"), ANISO_8X, FILTERING_LINEAR); |
| 129 | m_texture_filtering_combo->Add(tr("Force Linear and 16x Anisotropic"), ANISO_16X, |
| 130 | FILTERING_LINEAR); |
| 131 | m_texture_filtering_combo->Refresh(); |
| 132 | m_texture_filtering_combo->setEnabled(Get(m_game_layer, Config::GFX_HACK_FAST_TEXTURE_SAMPLING)); |
| 133 | |
| 134 | m_output_resampling_combo = new ConfigChoice( |
| 135 | {tr("Default"), tr("Bilinear"), tr("Bicubic: B-Spline"), tr("Bicubic: Mitchell-Netravali"), |
| 136 | tr("Bicubic: Catmull-Rom"), tr("Sharp Bilinear"), tr("Area Sampling")}, |
| 137 | Config::GFX_ENHANCE_OUTPUT_RESAMPLING, m_game_layer); |
| 138 | |
| 139 | m_configure_color_correction = new ToolTipPushButton(tr("Configure")); |
| 140 | |
| 141 | // The post-processing effect "(off)" has the config value "", so we need to use the constructor |
| 142 | // that sets ConfigStringChoice's m_text_is_data to false. m_post_processing_effect is cleared in |
| 143 | // LoadPostProcessingShaders so it's pointless to fill it with real data here. |
| 144 | const std::vector<std::pair<QString, QString>> separate_data_and_text; |
| 145 | m_post_processing_effect = |
| 146 | new ConfigStringChoice(separate_data_and_text, Config::GFX_ENHANCE_POST_SHADER, m_game_layer); |
| 147 | m_configure_post_processing_effect = new NonDefaultQPushButton(tr("Configure")); |
| 148 | m_configure_post_processing_effect->setDisabled(true); |
| 149 | |
| 150 | m_scaled_efb_copy = |
| 151 | new ConfigBool(tr("Scaled EFB Copy"), Config::GFX_HACK_COPY_EFB_SCALED, m_game_layer); |
| 152 | m_per_pixel_lighting = |
| 153 | new ConfigBool(tr("Per-Pixel Lighting"), Config::GFX_ENABLE_PIXEL_LIGHTING, m_game_layer); |
| 154 | |
| 155 | m_widescreen_hack = |
| 156 | new ConfigBool(tr("Widescreen Hack"), Config::GFX_WIDESCREEN_HACK, m_game_layer); |
| 157 | m_disable_fog = new ConfigBool(tr("Disable Fog"), Config::GFX_DISABLE_FOG, m_game_layer); |
| 158 | m_force_24bit_color = |
| 159 | new ConfigBool(tr("Force 24-Bit Color"), Config::GFX_ENHANCE_FORCE_TRUE_COLOR, m_game_layer); |
| 160 | m_disable_copy_filter = new ConfigBool(tr("Disable Copy Filter"), |
| 161 | Config::GFX_ENHANCE_DISABLE_COPY_FILTER, m_game_layer); |
| 162 | m_arbitrary_mipmap_detection = |
| 163 | new ConfigBool(tr("Arbitrary Mipmap Detection"), |
| 164 | Config::GFX_ENHANCE_ARBITRARY_MIPMAP_DETECTION, m_game_layer); |
| 165 | m_hdr = new ConfigBool(tr("HDR Post-Processing"), Config::GFX_ENHANCE_HDR_OUTPUT, m_game_layer); |
| 166 | |
| 167 | int row = 0; |
| 168 | enhancements_layout->addWidget(new QLabel(tr("Internal Resolution:")), row, 0); |
| 169 | enhancements_layout->addWidget(m_ir_combo, row, 1, 1, -1); |
| 170 | ++row; |
| 171 | |
| 172 | enhancements_layout->addWidget(new QLabel(tr("Anti-Aliasing:")), row, 0); |
| 173 | enhancements_layout->addWidget(m_antialiasing_combo, row, 1, 1, -1); |
| 174 | ++row; |
| 175 | |
| 176 | enhancements_layout->addWidget(new QLabel(tr("Texture Filtering:")), row, 0); |
| 177 | enhancements_layout->addWidget(m_texture_filtering_combo, row, 1, 1, -1); |
| 178 | ++row; |
| 179 | |
| 180 | enhancements_layout->addWidget(new QLabel(tr("Output Resampling:")), row, 0); |
| 181 | enhancements_layout->addWidget(m_output_resampling_combo, row, 1, 1, -1); |
| 182 | ++row; |
| 183 | |
| 184 | enhancements_layout->addWidget(new QLabel(tr("Color Correction:")), row, 0); |
| 185 | enhancements_layout->addWidget(m_configure_color_correction, row, 1, 1, -1); |
| 186 | ++row; |
| 187 | |
| 188 | enhancements_layout->addWidget(new QLabel(tr("Post-Processing Effect:")), row, 0); |
| 189 | enhancements_layout->addWidget(m_post_processing_effect, row, 1); |
| 190 | enhancements_layout->addWidget(m_configure_post_processing_effect, row, 2); |
| 191 | ++row; |
| 192 | |
| 193 | enhancements_layout->addWidget(m_scaled_efb_copy, row, 0); |
| 194 | enhancements_layout->addWidget(m_per_pixel_lighting, row, 1, 1, -1); |
| 195 | ++row; |
| 196 | |
| 197 | enhancements_layout->addWidget(m_widescreen_hack, row, 0); |
| 198 | enhancements_layout->addWidget(m_force_24bit_color, row, 1, 1, -1); |
| 199 | ++row; |
| 200 | |
| 201 | enhancements_layout->addWidget(m_disable_fog, row, 0); |
| 202 | enhancements_layout->addWidget(m_arbitrary_mipmap_detection, row, 1, 1, -1); |
| 203 | ++row; |
| 204 | |
| 205 | enhancements_layout->addWidget(m_disable_copy_filter, row, 0); |
| 206 | enhancements_layout->addWidget(m_hdr, row, 1, 1, -1); |
| 207 | ++row; |
| 208 | |
| 209 | // Stereoscopy |
| 210 | auto* stereoscopy_box = new QGroupBox(tr("Stereoscopy")); |
| 211 | auto* stereoscopy_layout = new QGridLayout(); |
| 212 | stereoscopy_box->setLayout(stereoscopy_layout); |
| 213 | |
| 214 | m_3d_mode = new ConfigChoice({tr("Off"), tr("Side-by-Side"), tr("Top-and-Bottom"), tr("Anaglyph"), |
| 215 | tr("HDMI 3D"), tr("Passive")}, |
| 216 | Config::GFX_STEREO_MODE, m_game_layer); |
| 217 | m_3d_depth = new ConfigFloatSlider(0, Config::GFX_STEREO_DEPTH_MAXIMUM, Config::GFX_STEREO_DEPTH, |
| 218 | 1.0f, m_game_layer); |
| 219 | m_3d_convergence = new ConfigFloatSlider(0, Config::GFX_STEREO_CONVERGENCE_MAXIMUM, |
| 220 | Config::GFX_STEREO_CONVERGENCE, 0.01f, m_game_layer); |
| 221 | m_3d_depth_value = new QLabel(); |
| 222 | m_3d_convergence_value = new QLabel(); |
| 223 | |
| 224 | m_3d_swap_eyes = new ConfigBool(tr("Swap Eyes"), Config::GFX_STEREO_SWAP_EYES, m_game_layer); |
| 225 | |
| 226 | m_3d_per_eye_resolution = new ConfigBool( |
| 227 | tr("Use Full Resolution Per Eye"), Config::GFX_STEREO_PER_EYE_RESOLUTION_FULL, m_game_layer); |
| 228 | |
| 229 | stereoscopy_layout->addWidget(new QLabel(tr("Stereoscopic 3D Mode:")), 0, 0); |
| 230 | stereoscopy_layout->addWidget(m_3d_mode, 0, 1); |
| 231 | stereoscopy_layout->addWidget(new ConfigFloatLabel(tr("Depth:"), m_3d_depth), 1, 0); |
| 232 | stereoscopy_layout->addWidget(m_3d_depth, 1, 1); |
| 233 | stereoscopy_layout->addWidget(m_3d_depth_value, 1, 2); |
| 234 | stereoscopy_layout->addWidget(new ConfigFloatLabel(tr("Convergence:"), m_3d_convergence), 2, 0); |
| 235 | stereoscopy_layout->addWidget(m_3d_convergence, 2, 1); |
| 236 | stereoscopy_layout->addWidget(m_3d_convergence_value, 2, 2); |
| 237 | stereoscopy_layout->addWidget(m_3d_swap_eyes, 3, 0); |
| 238 | stereoscopy_layout->addWidget(m_3d_per_eye_resolution, 4, 0); |
| 239 | |
| 240 | m_3d_depth_value->setText(QString::asprintf("%.0f", m_3d_depth->GetValue())); |
| 241 | m_3d_convergence_value->setText(QString::asprintf("%.2f", m_3d_convergence->GetValue())); |
| 242 | |
| 243 | auto current_stereo_mode = Get(m_game_layer, Config::GFX_STEREO_MODE); |
| 244 | if (current_stereo_mode != StereoMode::SideBySide && |
| 245 | current_stereo_mode != StereoMode::TopAndBottom) |
| 246 | { |
| 247 | m_3d_per_eye_resolution->hide(); |
| 248 | } |
| 249 | |
| 250 | main_layout->addWidget(enhancements_box); |
| 251 | main_layout->addWidget(stereoscopy_box); |
| 252 | main_layout->addStretch(); |
| 253 | |
| 254 | setLayout(main_layout); |
| 255 | } |
| 256 | |
| 257 | void EnhancementsWidget::ConnectWidgets() |
| 258 | { |
| 259 | connect(m_3d_mode, &QComboBox::currentIndexChanged, this, [this] { |
| 260 | auto current_stereo_mode = Get(m_game_layer, Config::GFX_STEREO_MODE); |
| 261 | LoadPostProcessingShaders(); |
| 262 | |
| 263 | if (current_stereo_mode == StereoMode::SideBySide || |
| 264 | current_stereo_mode == StereoMode::TopAndBottom) |
| 265 | { |
| 266 | m_3d_per_eye_resolution->show(); |
| 267 | } |
| 268 | else |
| 269 | { |
| 270 | m_3d_per_eye_resolution->hide(); |
| 271 | } |
| 272 | }); |
| 273 | |
| 274 | connect(m_post_processing_effect, &QComboBox::currentIndexChanged, this, |
| 275 | &EnhancementsWidget::ShaderChanged); |
| 276 | |
| 277 | connect(m_configure_color_correction, &QPushButton::clicked, this, |
| 278 | &EnhancementsWidget::ConfigureColorCorrection); |
| 279 | connect(m_configure_post_processing_effect, &QPushButton::clicked, this, |
| 280 | &EnhancementsWidget::ConfigurePostProcessingShader); |
| 281 | |
| 282 | connect(m_3d_depth, &ConfigFloatSlider::valueChanged, this, |
| 283 | [this] { m_3d_depth_value->setText(QString::asprintf("%.0f", m_3d_depth->GetValue())); }); |
| 284 | connect(m_3d_convergence, &ConfigFloatSlider::valueChanged, this, [this] { |
| 285 | m_3d_convergence_value->setText(QString::asprintf("%.2f", m_3d_convergence->GetValue())); |
| 286 | }); |
| 287 | } |
| 288 | |
| 289 | void EnhancementsWidget::LoadPostProcessingShaders() |
| 290 | { |
| 291 | auto stereo_mode = Get(m_game_layer, Config::GFX_STEREO_MODE); |
| 292 | |
| 293 | const QSignalBlocker blocker(m_post_processing_effect); |
| 294 | m_post_processing_effect->clear(); |
| 295 | |
| 296 | // Get shader list |
| 297 | std::vector<std::string> shaders = VideoCommon::PostProcessing::GetShaderList(); |
| 298 | |
| 299 | if (stereo_mode == StereoMode::Anaglyph) |
| 300 | shaders = VideoCommon::PostProcessing::GetAnaglyphShaderList(); |
| 301 | else if (stereo_mode == StereoMode::Passive) |
| 302 | shaders = VideoCommon::PostProcessing::GetPassiveShaderList(); |
| 303 | |
| 304 | // Populate widget |
| 305 | if (stereo_mode != StereoMode::Anaglyph && stereo_mode != StereoMode::Passive) |
| 306 | m_post_processing_effect->addItem(tr("(off)"), QStringLiteral("")); |
| 307 | |
| 308 | auto selected_shader = Get(m_game_layer, Config::GFX_ENHANCE_POST_SHADER); |
| 309 | |
| 310 | bool found = false; |
| 311 | |
| 312 | for (const auto& shader : shaders) |
| 313 | { |
| 314 | const QString name = QString::fromStdString(shader); |
| 315 | m_post_processing_effect->addItem(name, name); |
| 316 | if (selected_shader == shader) |
| 317 | { |
| 318 | m_post_processing_effect->setCurrentIndex(m_post_processing_effect->count() - 1); |
| 319 | found = true; |
| 320 | } |
| 321 | } |
| 322 | |
| 323 | // Force a shader for StereoModes that require it. |
| 324 | if (!found) |
| 325 | { |
| 326 | if (stereo_mode == StereoMode::Anaglyph) |
| 327 | selected_shader = "dubois"; |
| 328 | else if (stereo_mode == StereoMode::Passive) |
| 329 | selected_shader = "horizontal"; |
| 330 | else |
| 331 | selected_shader = ""; |
| 332 | |
| 333 | const int index = |
| 334 | std::max(0, m_post_processing_effect->findData(QString::fromStdString(selected_shader))); |
| 335 | m_post_processing_effect->setCurrentIndex(index); |
| 336 | |
| 337 | // Save forced shader, but avoid forcing an option into a game ini layer. |
| 338 | if (m_game_layer == nullptr && |
| 339 | Get(m_game_layer, Config::GFX_ENHANCE_POST_SHADER) != selected_shader) |
| 340 | Config::SetBaseOrCurrent(Config::GFX_ENHANCE_POST_SHADER, selected_shader); |
| 341 | } |
| 342 | |
| 343 | m_post_processing_effect->Load(); |
| 344 | ShaderChanged(); |
| 345 | } |
| 346 | |
| 347 | void EnhancementsWidget::OnBackendChanged() |
| 348 | { |
| 349 | m_output_resampling_combo->setEnabled(g_backend_info.bSupportsPostProcessing); |
| 350 | m_configure_color_correction->setEnabled(g_backend_info.bSupportsPostProcessing); |
| 351 | m_hdr->setEnabled(g_backend_info.bSupportsHDROutput); |
| 352 | |
| 353 | // Stereoscopy |
| 354 | const bool supports_stereoscopy = g_backend_info.bSupportsGeometryShaders; |
| 355 | m_3d_mode->setEnabled(supports_stereoscopy); |
| 356 | m_3d_convergence->setEnabled(supports_stereoscopy); |
| 357 | m_3d_depth->setEnabled(supports_stereoscopy); |
| 358 | m_3d_swap_eyes->setEnabled(supports_stereoscopy); |
| 359 | |
| 360 | // PostProcessing |
| 361 | const bool supports_postprocessing = g_backend_info.bSupportsPostProcessing; |
| 362 | if (!supports_postprocessing) |
| 363 | { |
| 364 | m_configure_post_processing_effect->setEnabled(false); |
| 365 | m_post_processing_effect->setEnabled(false); |
| 366 | m_post_processing_effect->setToolTip( |
| 367 | tr("%1 doesn't support this feature.").arg(tr(g_video_backend->GetDisplayName().c_str()))); |
| 368 | } |
| 369 | else if (!m_post_processing_effect->isEnabled() && supports_postprocessing) |
| 370 | { |
| 371 | m_configure_post_processing_effect->setEnabled(true); |
| 372 | m_post_processing_effect->setEnabled(true); |
| 373 | m_post_processing_effect->setToolTip(QString{}); |
| 374 | LoadPostProcessingShaders(); |
| 375 | } |
| 376 | |
| 377 | UpdateAntialiasingOptions(); |
| 378 | } |
| 379 | |
| 380 | void EnhancementsWidget::ShaderChanged() |
| 381 | { |
| 382 | auto shader = Get(m_game_layer, Config::GFX_ENHANCE_POST_SHADER); |
| 383 | |
| 384 | if (shader == "(off)" || shader == "") |
| 385 | { |
| 386 | shader = ""; |
| 387 | |
| 388 | // Setting a shader to null in a game ini could be confusing, as it won't be bolded. Remove it |
| 389 | // instead. |
| 390 | if (m_game_layer != nullptr) |
| 391 | m_game_layer->DeleteKey(Config::GFX_ENHANCE_POST_SHADER.GetLocation()); |
| 392 | else |
| 393 | Config::SetBaseOrCurrent(Config::GFX_ENHANCE_POST_SHADER, shader); |
| 394 | } |
| 395 | |
| 396 | if (shader != "" && m_post_processing_effect->isEnabled()) |
| 397 | { |
| 398 | VideoCommon::PostProcessingConfiguration pp_shader; |
| 399 | pp_shader.LoadShader(shader); |
| 400 | m_configure_post_processing_effect->setEnabled(pp_shader.HasOptions()); |
| 401 | } |
| 402 | else |
| 403 | { |
| 404 | m_configure_post_processing_effect->setEnabled(false); |
| 405 | } |
| 406 | } |
| 407 | |
| 408 | void EnhancementsWidget::UpdateAntialiasingOptions() |
| 409 | { |
| 410 | const QSignalBlocker blocker(m_antialiasing_combo); |
| 411 | |
| 412 | m_antialiasing_combo->Reset(); |
| 413 | m_antialiasing_combo->Add(tr("None"), (u32)1, false); |
| 414 | |
| 415 | const std::vector<u32>& aa_modes = g_backend_info.AAModes; |
| 416 | for (const u32 aa_mode : aa_modes) |
| 417 | { |
| 418 | if (aa_mode > 1) |
| 419 | m_antialiasing_combo->Add(tr("%1x MSAA").arg(aa_mode), aa_mode, false); |
| 420 | } |
| 421 | |
| 422 | if (g_backend_info.bSupportsSSAA) |
| 423 | { |
| 424 | for (const u32 aa_mode : aa_modes) |
| 425 | { |
| 426 | if (aa_mode > 1) |
| 427 | m_antialiasing_combo->Add(tr("%1x SSAA").arg(aa_mode), aa_mode, true); |
| 428 | } |
| 429 | } |
| 430 | |
| 431 | m_antialiasing_combo->Refresh(); |
| 432 | |
| 433 | // Backend info can't be populated in the local game settings window. Only enable local game AA |
| 434 | // edits when the backend info is correct - global and local have the same backend. |
| 435 | const bool good_info = |
| 436 | m_game_layer == nullptr || !m_game_layer->Exists(Config::MAIN_GFX_BACKEND.GetLocation()) || |
| 437 | Config::Get(Config::MAIN_GFX_BACKEND) == m_game_layer->Get(Config::MAIN_GFX_BACKEND); |
| 438 | |
| 439 | m_antialiasing_combo->setEnabled(m_antialiasing_combo->count() > 1 && good_info); |
| 440 | } |
| 441 | |
| 442 | void EnhancementsWidget::AddDescriptions() |
| 443 | { |
| 444 | static const char TR_INTERNAL_RESOLUTION_DESCRIPTION[] = |
| 445 | QT_TR_NOOP("Controls the rendering resolution.<br><br>A high resolution greatly improves " |
| 446 | "visual quality, but also greatly increases GPU load and can cause issues in " |
| 447 | "certain games. Generally speaking, the lower the internal resolution, the " |
| 448 | "better performance will be.<br><br><dolphin_emphasis>If unsure, " |
| 449 | "select Native.</dolphin_emphasis>"); |
| 450 | static const char TR_ANTIALIAS_DESCRIPTION[] = QT_TR_NOOP( |
| 451 | "Reduces the amount of aliasing caused by rasterizing 3D graphics, resulting " |
| 452 | "in smoother edges on objects. Increases GPU load and sometimes causes graphical " |
| 453 | "issues.<br><br>SSAA is significantly more demanding than MSAA, but provides top quality " |
| 454 | "geometry anti-aliasing and also applies anti-aliasing to lighting, shader " |
| 455 | "effects, and textures.<br><br><dolphin_emphasis>If unsure, select " |
| 456 | "None.</dolphin_emphasis>"); |
| 457 | static const char TR_FORCE_TEXTURE_FILTERING_DESCRIPTION[] = QT_TR_NOOP( |
| 458 | "Adjust the texture filtering. Anisotropic filtering enhances the visual quality of textures " |
| 459 | "that are at oblique viewing angles. Force Nearest and Force Linear override the texture " |
| 460 | "scaling filter selected by the game.<br><br>Any option except 'Default' will alter the look " |
| 461 | "of the game's textures and might cause issues in a small number of games.<br><br>This " |
| 462 | "setting is disabled when Manual Texture Sampling is enabled.<br><br>" |
| 463 | "<dolphin_emphasis>If unsure, select 'Default'.</dolphin_emphasis>"); |
| 464 | static const char TR_OUTPUT_RESAMPLING_DESCRIPTION[] = |
| 465 | QT_TR_NOOP("Affects how the game output is scaled to the window resolution." |
| 466 | "<br>The performance mostly depends on the number of samples each method uses." |
| 467 | "<br>Compared to SSAA, resampling is useful in case the output window" |
| 468 | "<br>resolution isn't a multiplier of the native emulation resolution." |
| 469 | |
| 470 | "<br><br><b>Default</b> - [fastest]" |
| 471 | "<br>Internal GPU bilinear sampler which is not gamma corrected." |
| 472 | "<br>This setting might be ignored if gamma correction is forced on." |
| 473 | |
| 474 | "<br><br><b>Bilinear</b> - [4 samples]" |
| 475 | "<br>Gamma corrected linear interpolation between pixels." |
| 476 | |
| 477 | "<br><br><b>Bicubic</b> - [16 samples]" |
| 478 | "<br>Gamma corrected cubic interpolation between pixels." |
| 479 | "<br>Good when rescaling between close resolutions, e.g. 1080p and 1440p." |
| 480 | "<br>Comes in various flavors:" |
| 481 | "<br><b>B-Spline</b>: Blurry, but avoids all lobing artifacts" |
| 482 | "<br><b>Mitchell-Netravali</b>: Good middle ground between blurry and lobing" |
| 483 | "<br><b>Catmull-Rom</b>: Sharper, but can cause lobing artifacts" |
| 484 | |
| 485 | "<br><br><b>Sharp Bilinear</b> - [1-4 samples]" |
| 486 | "<br>Similar to \"Nearest Neighbor\", it maintains a sharp look," |
| 487 | "<br>but also does some blending to avoid shimmering." |
| 488 | "<br>Works best with 2D games at low resolutions." |
| 489 | |
| 490 | "<br><br><b>Area Sampling</b> - [up to 324 samples]" |
| 491 | "<br>Weighs pixels by the percentage of area they occupy. Gamma corrected." |
| 492 | "<br>Best for downscaling by more than 2x." |
| 493 | |
| 494 | "<br><br><dolphin_emphasis>If unsure, select 'Default'.</dolphin_emphasis>"); |
| 495 | static const char TR_COLOR_CORRECTION_DESCRIPTION[] = |
| 496 | QT_TR_NOOP("A group of features to make the colors more accurate, matching the color space " |
| 497 | "Wii and GC games were meant for."); |
| 498 | static const char TR_POSTPROCESSING_DESCRIPTION[] = |
| 499 | QT_TR_NOOP("Applies a post-processing effect after rendering a frame.<br><br " |
| 500 | "/><dolphin_emphasis>If unsure, select (off).</dolphin_emphasis>"); |
| 501 | static const char TR_SCALED_EFB_COPY_DESCRIPTION[] = |
| 502 | QT_TR_NOOP("Greatly increases the quality of textures generated using render-to-texture " |
| 503 | "effects.<br><br>Slightly increases GPU load and causes relatively few graphical " |
| 504 | "issues. Raising the internal resolution will improve the effect of this setting. " |
| 505 | "<br><br><dolphin_emphasis>If unsure, leave this checked.</dolphin_emphasis>"); |
| 506 | static const char TR_PER_PIXEL_LIGHTING_DESCRIPTION[] = QT_TR_NOOP( |
| 507 | "Calculates lighting of 3D objects per-pixel rather than per-vertex, smoothing out the " |
| 508 | "appearance of lit polygons and making individual triangles less noticeable.<br><br " |
| 509 | "/>Rarely " |
| 510 | "causes slowdowns or graphical issues.<br><br><dolphin_emphasis>If unsure, leave " |
| 511 | "this unchecked.</dolphin_emphasis>"); |
| 512 | static const char TR_WIDESCREEN_HACK_DESCRIPTION[] = QT_TR_NOOP( |
| 513 | "Forces the game to output graphics at any aspect ratio by expanding the view frustum " |
| 514 | "without stretching the image.<br>This is a hack, and its results will vary widely game " |
| 515 | "to game (it often causes the UI to stretch).<br>" |
| 516 | "Game-specific AR/Gecko-code aspect ratio patches are preferable over this if available." |
| 517 | "<br><br><dolphin_emphasis>If unsure, leave this unchecked.</dolphin_emphasis>"); |
| 518 | static const char TR_REMOVE_FOG_DESCRIPTION[] = |
| 519 | QT_TR_NOOP("Makes distant objects more visible by removing fog, thus increasing the overall " |
| 520 | "detail.<br><br>Disabling fog will break some games which rely on proper fog " |
| 521 | "emulation.<br><br><dolphin_emphasis>If unsure, leave this " |
| 522 | "unchecked.</dolphin_emphasis>"); |
| 523 | static const char TR_3D_MODE_DESCRIPTION[] = QT_TR_NOOP( |
| 524 | "Selects the stereoscopic 3D mode. Stereoscopy allows a better feeling " |
| 525 | "of depth if the necessary hardware is present. Heavily decreases " |
| 526 | "emulation speed and sometimes causes issues.<br><br>Side-by-Side and Top-and-Bottom are " |
| 527 | "used by most 3D TVs.<br>Anaglyph is used for Red-Cyan colored glasses.<br>HDMI 3D is " |
| 528 | "used when the monitor supports 3D display resolutions.<br>Passive is another type of 3D " |
| 529 | "used by some TVs.<br><br><dolphin_emphasis>If unsure, select Off.</dolphin_emphasis>"); |
| 530 | static const char TR_3D_DEPTH_DESCRIPTION[] = QT_TR_NOOP( |
| 531 | "Controls the separation distance between the virtual cameras.<br><br>A higher " |
| 532 | "value creates a stronger feeling of depth while a lower value is more comfortable."); |
| 533 | static const char TR_3D_CONVERGENCE_DESCRIPTION[] = QT_TR_NOOP( |
| 534 | "Controls the distance of the convergence plane. This is the distance at which " |
| 535 | "virtual objects will appear to be in front of the screen.<br><br>A higher value creates " |
| 536 | "stronger out-of-screen effects while a lower value is more comfortable."); |
| 537 | static const char TR_3D_SWAP_EYES_DESCRIPTION[] = QT_TR_NOOP( |
| 538 | "Swaps the left and right eye. Most useful in side-by-side stereoscopy " |
| 539 | "mode.<br><br><dolphin_emphasis>If unsure, leave this unchecked.</dolphin_emphasis>"); |
| 540 | static const char TR_3D_PER_EYE_RESOLUTION_DESCRIPTION[] = |
| 541 | QT_TR_NOOP("Whether each eye gets full or half image resolution when using side-by-side " |
| 542 | "or above-and-below 3D." |
| 543 | "<br><br><dolphin_emphasis>If unsure, leave this unchecked.</dolphin_emphasis>"); |
| 544 | static const char TR_FORCE_24BIT_DESCRIPTION[] = QT_TR_NOOP( |
| 545 | "Forces the game to render the RGB color channels in 24-bit, thereby increasing " |
| 546 | "quality by reducing color banding.<br><br>Has no impact on performance and causes " |
| 547 | "few graphical issues.<br><br><dolphin_emphasis>If unsure, leave this " |
| 548 | "checked.</dolphin_emphasis>"); |
| 549 | static const char TR_DISABLE_COPY_FILTER_DESCRIPTION[] = QT_TR_NOOP( |
| 550 | "Disables the blending of adjacent rows when copying the EFB. This is known in " |
| 551 | "some games as \"deflickering\" or \"smoothing\".<br><br>Disabling the filter has no " |
| 552 | "effect on performance, but may result in a sharper image. Causes few " |
| 553 | "graphical issues.<br><br><dolphin_emphasis>If unsure, leave this " |
| 554 | "checked.</dolphin_emphasis>"); |
| 555 | static const char TR_ARBITRARY_MIPMAP_DETECTION_DESCRIPTION[] = QT_TR_NOOP( |
| 556 | "Enables detection of arbitrary mipmaps, which some games use for special distance-based " |
| 557 | "effects.<br><br>May have false positives that result in blurry textures at increased " |
| 558 | "internal " |
| 559 | "resolution, such as in games that use very low resolution mipmaps. Disabling this can also " |
| 560 | "reduce stutter in games that frequently load new textures.<br><br>If this setting is " |
| 561 | "enabled, GPU Texture Decoding will be disabled.<br><br><dolphin_emphasis>If " |
| 562 | "unsure, leave this unchecked.</dolphin_emphasis>"); |
| 563 | static const char TR_HDR_DESCRIPTION[] = QT_TR_NOOP( |
| 564 | "Enables scRGB HDR output (if supported by your graphics backend and monitor)." |
| 565 | " Fullscreen might be required." |
| 566 | "<br><br>This gives post process shaders more room for accuracy, allows \"AutoHDR\" " |
| 567 | "post-process shaders to work, and allows to fully display the PAL and NTSC-J color spaces." |
| 568 | "<br><br>Note that games still render in SDR internally." |
| 569 | "<br><br><dolphin_emphasis>If unsure, leave this unchecked.</dolphin_emphasis>"); |
| 570 | |
| 571 | m_ir_combo->SetTitle(tr("Internal Resolution")); |
| 572 | m_ir_combo->SetDescription(tr(TR_INTERNAL_RESOLUTION_DESCRIPTION)); |
| 573 | |
| 574 | m_antialiasing_combo->SetTitle(tr("Anti-Aliasing")); |
| 575 | m_antialiasing_combo->SetDescription(tr(TR_ANTIALIAS_DESCRIPTION)); |
| 576 | |
| 577 | m_texture_filtering_combo->SetTitle(tr("Texture Filtering")); |
| 578 | m_texture_filtering_combo->SetDescription(tr(TR_FORCE_TEXTURE_FILTERING_DESCRIPTION)); |
| 579 | |
| 580 | m_output_resampling_combo->SetTitle(tr("Output Resampling")); |
| 581 | m_output_resampling_combo->SetDescription(tr(TR_OUTPUT_RESAMPLING_DESCRIPTION)); |
| 582 | |
| 583 | m_configure_color_correction->SetTitle(tr("Color Correction")); |
| 584 | m_configure_color_correction->SetDescription(tr(TR_COLOR_CORRECTION_DESCRIPTION)); |
| 585 | |
| 586 | m_post_processing_effect->SetTitle(tr("Post-Processing Effect")); |
| 587 | m_post_processing_effect->SetDescription(tr(TR_POSTPROCESSING_DESCRIPTION)); |
| 588 | |
| 589 | m_scaled_efb_copy->SetDescription(tr(TR_SCALED_EFB_COPY_DESCRIPTION)); |
| 590 | |
| 591 | m_per_pixel_lighting->SetDescription(tr(TR_PER_PIXEL_LIGHTING_DESCRIPTION)); |
| 592 | |
| 593 | m_widescreen_hack->SetDescription(tr(TR_WIDESCREEN_HACK_DESCRIPTION)); |
| 594 | |
| 595 | m_disable_fog->SetDescription(tr(TR_REMOVE_FOG_DESCRIPTION)); |
| 596 | |
| 597 | m_force_24bit_color->SetDescription(tr(TR_FORCE_24BIT_DESCRIPTION)); |
| 598 | |
| 599 | m_disable_copy_filter->SetDescription(tr(TR_DISABLE_COPY_FILTER_DESCRIPTION)); |
| 600 | |
| 601 | m_arbitrary_mipmap_detection->SetDescription(tr(TR_ARBITRARY_MIPMAP_DETECTION_DESCRIPTION)); |
| 602 | |
| 603 | m_hdr->SetDescription(tr(TR_HDR_DESCRIPTION)); |
| 604 | |
| 605 | m_3d_mode->SetTitle(tr("Stereoscopic 3D Mode")); |
| 606 | m_3d_mode->SetDescription(tr(TR_3D_MODE_DESCRIPTION)); |
| 607 | |
| 608 | m_3d_depth->SetTitle(tr("Depth")); |
| 609 | m_3d_depth->SetDescription(tr(TR_3D_DEPTH_DESCRIPTION)); |
| 610 | |
| 611 | m_3d_convergence->SetTitle(tr("Convergence")); |
| 612 | m_3d_convergence->SetDescription(tr(TR_3D_CONVERGENCE_DESCRIPTION)); |
| 613 | |
| 614 | m_3d_per_eye_resolution->SetDescription(tr(TR_3D_PER_EYE_RESOLUTION_DESCRIPTION)); |
| 615 | |
| 616 | m_3d_swap_eyes->SetDescription(tr(TR_3D_SWAP_EYES_DESCRIPTION)); |
| 617 | } |
| 618 | |
| 619 | void EnhancementsWidget::ConfigureColorCorrection() |
| 620 | { |
| 621 | ColorCorrectionConfigWindow dialog(this); |
| 622 | dialog.exec(); |
| 623 | } |
| 624 | |
| 625 | void EnhancementsWidget::ConfigurePostProcessingShader() |
| 626 | { |
| 627 | const std::string shader = Get(m_game_layer, Config::GFX_ENHANCE_POST_SHADER); |
| 628 | PostProcessingConfigWindow dialog(this, shader); |
| 629 | dialog.exec(); |
| 630 | } |