From df189c3ea3aa7d17a5a69ecd8497a64c6aefec43 Mon Sep 17 00:00:00 2001 From: Anthony Serna Date: Mon, 14 Sep 2015 18:49:48 -0700 Subject: [PATCH] Improved D3D and OGL AA option UI Removed Quality Levels from D3D AA options Dropdown text now shows whether you're applying MSAA or SSAA Added a description for SSAA Moved SSAA checkbox Cleaned up AA in backends slightly. Supported modes is now a list of ints. --- Source/Core/DolphinWX/VideoConfigDiag.cpp | 46 ++++++++++++++++++----- Source/Core/DolphinWX/VideoConfigDiag.h | 2 + Source/Core/VideoBackends/D3D/D3DBase.cpp | 12 +++--- Source/Core/VideoBackends/D3D/main.cpp | 10 +---- Source/Core/VideoBackends/OGL/main.cpp | 6 +-- Source/Core/VideoCommon/VideoConfig.h | 2 +- 6 files changed, 50 insertions(+), 28 deletions(-) diff --git a/Source/Core/DolphinWX/VideoConfigDiag.cpp b/Source/Core/DolphinWX/VideoConfigDiag.cpp index 9c02a6689e..f24305db61 100644 --- a/Source/Core/DolphinWX/VideoConfigDiag.cpp +++ b/Source/Core/DolphinWX/VideoConfigDiag.cpp @@ -106,6 +106,7 @@ static wxString ws_hack_desc = wxTRANSLATE("Forces the game to output graphics f static wxString vsync_desc = wxTRANSLATE("Wait for vertical blanks in order to reduce tearing.\nDecreases performance if emulation speed is below 100%.\n\nIf unsure, leave this unchecked."); static wxString af_desc = wxTRANSLATE("Enable anisotropic filtering.\nEnhances visual quality of textures that are at oblique viewing angles.\nMight cause issues in a small number of games.\nOn Direct3D, setting this above 1x will also have the same effect as enabling \"Force Texture Filtering\".\n\nIf unsure, select 1x."); static wxString aa_desc = wxTRANSLATE("Reduces the amount of aliasing caused by rasterizing 3D graphics.\nThis smooths out jagged edges on objects.\nHeavily increases GPU load and sometimes causes graphical issues.\n\nIf unsure, select None."); +static wxString ssaa_desc = wxTRANSLATE("Reduces the amount of aliasing caused by enabling supersampling anti-aliasing. This is significantly heavier on GPU load than MSAA, but will provide a much better image quality as well as applying AA to lighting and shader effects.\n\nIf unsure, leave unchecked."); static wxString scaled_efb_copy_desc = wxTRANSLATE("Greatly increases quality of textures generated using render-to-texture effects.\nRaising the internal resolution will improve the effect of this setting.\nSlightly increases GPU load and causes relatively few graphical issues.\n\nIf unsure, leave this checked."); static wxString pixel_lighting_desc = wxTRANSLATE("Calculates lighting of 3D objects per-pixel rather than per-vertex, smoothing out the appearance of lit polygons and making individual triangles less noticeable.\nRarely causes slowdowns or graphical issues.\n\nIf unsure, leave this unchecked."); static wxString fast_depth_calc_desc = wxTRANSLATE("Use a less accurate algorithm to calculate depth values.\nCauses issues in a few games, but can give a decent speedup depending on the game and/or your GPU.\n\nIf unsure, leave this checked."); @@ -365,17 +366,24 @@ VideoConfigDiag::VideoConfigDiag(wxWindow* parent, const std::string &title, con // AA { + + wxFlexGridSizer* const aa_sizer = new wxFlexGridSizer(3, 1, 1); + text_aamode = new wxStaticText(page_enh, wxID_ANY, _("Anti-Aliasing:")); choice_aamode = CreateChoice(page_enh, vconfig.iMultisampleMode, wxGetTranslation(aa_desc)); - for (const std::string& mode : vconfig.backend_info.AAModes) - { - choice_aamode->AppendString(wxGetTranslation(StrToWxStr(mode))); - } + RefreshAAList(); - choice_aamode->Select(vconfig.iMultisampleMode); szr_enh->Add(text_aamode, 1, wxALIGN_CENTER_VERTICAL, 0); - szr_enh->Add(choice_aamode); + aa_sizer->Add(choice_aamode); + + ssaa_checkbox = CreateCheckBox(page_enh, _("SSAA"), wxGetTranslation(ssaa_desc), vconfig.bSSAA); + ssaa_checkbox->Bind(wxEVT_CHECKBOX, &VideoConfigDiag::OnSSAAClick, this); + + aa_sizer->AddSpacer(10); + aa_sizer->Add(ssaa_checkbox, 0, wxTOP, 3); + szr_enh->Add(aa_sizer); + } // AF @@ -413,13 +421,9 @@ VideoConfigDiag::VideoConfigDiag(wxWindow* parent, const std::string &title, con szr_enh->Add(CreateCheckBox(page_enh, _("Scaled EFB Copy"), wxGetTranslation(scaled_efb_copy_desc), vconfig.bCopyEFBScaled)); szr_enh->Add(CreateCheckBox(page_enh, _("Per-Pixel Lighting"), wxGetTranslation(pixel_lighting_desc), vconfig.bEnablePixelLighting)); szr_enh->Add(CreateCheckBox(page_enh, _("Force Texture Filtering"), wxGetTranslation(force_filtering_desc), vconfig.bForceFiltering)); - szr_enh->Add(CreateCheckBox(page_enh, _("Widescreen Hack"), wxGetTranslation(ws_hack_desc), vconfig.bWidescreenHack)); szr_enh->Add(CreateCheckBox(page_enh, _("Disable Fog"), wxGetTranslation(disable_fog_desc), vconfig.bDisableFog)); - ssaa_checkbox = CreateCheckBox(page_enh, _("SSAA"), wxGetTranslation(aa_desc), vconfig.bSSAA); - szr_enh->Add(ssaa_checkbox); - wxStaticBoxSizer* const group_enh = new wxStaticBoxSizer(wxVERTICAL, page_enh, _("Enhancements")); group_enh->Add(szr_enh, 1, wxEXPAND | wxLEFT | wxRIGHT | wxBOTTOM, 5); szr_enh_main->Add(group_enh, 0, wxEXPAND | wxALL, 5); @@ -748,3 +752,25 @@ void VideoConfigDiag::PopulatePostProcessingShaders() postprocessing_shader.LoadShader(vconfig.sPostProcessingShader); button_config_pp->Enable(postprocessing_shader.HasOptions()); } + +void VideoConfigDiag::OnSSAAClick(wxCommandEvent& event) +{ + // Check the checkbox status and not the config option because config hasn't changed yet. + vconfig.bSSAA = ssaa_checkbox->IsChecked(); + RefreshAAList(); +} + +void VideoConfigDiag::RefreshAAList() +{ + choice_aamode->Clear(); + const std::string& suffix = vconfig.bSSAA ? "x SSAA" : "x MSAA"; + + for (int mode : vconfig.backend_info.AAModes) + { + if (mode == 1) + choice_aamode->AppendString(_("None")); + else + choice_aamode->AppendString(std::to_string(mode) + suffix); + } + choice_aamode->SetSelection(vconfig.iMultisampleMode); +} diff --git a/Source/Core/DolphinWX/VideoConfigDiag.h b/Source/Core/DolphinWX/VideoConfigDiag.h index 5971027f27..455e88a921 100644 --- a/Source/Core/DolphinWX/VideoConfigDiag.h +++ b/Source/Core/DolphinWX/VideoConfigDiag.h @@ -245,6 +245,8 @@ protected: void Evt_LeaveControl(wxMouseEvent& ev); void CreateDescriptionArea(wxPanel* const page, wxBoxSizer* const sizer); void PopulatePostProcessingShaders(); + void OnSSAAClick(wxCommandEvent& event); + void RefreshAAList(); wxChoice* choice_backend; wxChoice* choice_adapter; diff --git a/Source/Core/VideoBackends/D3D/D3DBase.cpp b/Source/Core/VideoBackends/D3D/D3DBase.cpp index 8439f95ef6..07d5888ee6 100644 --- a/Source/Core/VideoBackends/D3D/D3DBase.cpp +++ b/Source/Core/VideoBackends/D3D/D3DBase.cpp @@ -178,13 +178,13 @@ std::vector EnumAAModes(IDXGIAdapter* adapter) { UINT quality_levels = 0; _device->CheckMultisampleQualityLevels(DXGI_FORMAT_R8G8B8A8_UNORM, samples, &quality_levels); + + DXGI_SAMPLE_DESC desc; + desc.Count = samples; + desc.Quality = 0; + if (quality_levels > 0) - { - DXGI_SAMPLE_DESC desc; - desc.Count = samples; - for (desc.Quality = 0; desc.Quality < quality_levels; ++desc.Quality) - _aa_modes.push_back(desc); - } + _aa_modes.push_back(desc); } _context->Release(); _device->Release(); diff --git a/Source/Core/VideoBackends/D3D/main.cpp b/Source/Core/VideoBackends/D3D/main.cpp index 66d23116fd..98ed5e60ea 100644 --- a/Source/Core/VideoBackends/D3D/main.cpp +++ b/Source/Core/VideoBackends/D3D/main.cpp @@ -106,16 +106,10 @@ void InitBackendInfo() { std::string samples; std::vector modes = DX11::D3D::EnumAAModes(ad); + // First iteration will be 1. This equals no AA. for (unsigned int i = 0; i < modes.size(); ++i) { - if (i == 0) - samples = _trans("None"); - else if (modes[i].Quality) - samples = StringFromFormat(_trans("%d samples (quality level %d)"), modes[i].Count, modes[i].Quality); - else - samples = StringFromFormat(_trans("%d samples"), modes[i].Count); - - g_Config.backend_info.AAModes.push_back(samples); + g_Config.backend_info.AAModes.push_back(modes[i].Count); } bool shader_model_5_supported = (DX11::D3D::GetFeatureLevel(ad) >= D3D_FEATURE_LEVEL_11_0); diff --git a/Source/Core/VideoBackends/OGL/main.cpp b/Source/Core/VideoBackends/OGL/main.cpp index 1b4ae331b6..a706e27533 100644 --- a/Source/Core/VideoBackends/OGL/main.cpp +++ b/Source/Core/VideoBackends/OGL/main.cpp @@ -121,9 +121,9 @@ static void InitBackendInfo() g_Config.backend_info.Adapters.clear(); - // aamodes - const char* caamodes[] = {_trans("None"), "2x MSAA", "4x MSAA", "8x MSAA"}; - g_Config.backend_info.AAModes.assign(caamodes, caamodes + sizeof(caamodes)/sizeof(*caamodes)); + // aamodes - 1 is to stay consistent with D3D (means no AA) + const int aamodes[] = { 1, 2, 4, 8 }; + g_Config.backend_info.AAModes.assign(aamodes, aamodes + sizeof(aamodes)/sizeof(*aamodes)); // pp shaders g_Config.backend_info.PPShaders = GetShaders(""); diff --git a/Source/Core/VideoCommon/VideoConfig.h b/Source/Core/VideoCommon/VideoConfig.h index 489929f5fd..f6b4f9e7f0 100644 --- a/Source/Core/VideoCommon/VideoConfig.h +++ b/Source/Core/VideoCommon/VideoConfig.h @@ -144,7 +144,7 @@ struct VideoConfig final API_TYPE APIType; std::vector Adapters; // for D3D - std::vector AAModes; + std::vector AAModes; std::vector PPShaders; // post-processing shaders std::vector AnaglyphShaders; // anaglyph shaders