diff --git a/Source/Core/Common/Src/Common.h b/Source/Core/Common/Src/Common.h index a79666a683..7618f5329b 100644 --- a/Source/Core/Common/Src/Common.h +++ b/Source/Core/Common/Src/Common.h @@ -151,8 +151,7 @@ private: enum HOST_COMM { // Begin at 10 in case there is already messages with wParam = 0, 1, 2 and so on - WM_USER_PAUSE = 10, - WM_USER_STOP, + WM_USER_STOP = 10, WM_USER_CREATE, WM_USER_SETCURSOR, WM_USER_KEYDOWN, diff --git a/Source/Core/Common/Src/VideoBackendBase.cpp b/Source/Core/Common/Src/VideoBackendBase.cpp index 1fbe0f4a41..1c77ec7c9b 100644 --- a/Source/Core/Common/Src/VideoBackendBase.cpp +++ b/Source/Core/Common/Src/VideoBackendBase.cpp @@ -16,6 +16,7 @@ // http://code.google.com/p/dolphin-emu/ #include "VideoBackendBase.h" +#include "../../VideoCommon/Src/VideoConfig.h" // TODO: ugly #ifdef _WIN32 @@ -73,3 +74,13 @@ void VideoBackend::ActivateBackend(const std::string& name) if (name == (*it)->GetName()) g_video_backend = *it; } + +void VideoBackend::LoadConfig() +{ + g_Config.Load(((File::GetUserPath(D_CONFIG_IDX) + ini_name) + ".ini").c_str()); +} + +void VideoBackend::SaveConfig() +{ + g_Config.Save(((File::GetUserPath(D_CONFIG_IDX) + ini_name) + ".ini").c_str()); +} diff --git a/Source/Core/Common/Src/VideoBackendBase.h b/Source/Core/Common/Src/VideoBackendBase.h index 667a3d3a32..4e2690911f 100644 --- a/Source/Core/Common/Src/VideoBackendBase.h +++ b/Source/Core/Common/Src/VideoBackendBase.h @@ -83,6 +83,10 @@ struct SCPFifoStruct class VideoBackend { public: + const char* const ini_name; + + VideoBackend(const char* _ini_name) : ini_name(_ini_name) {} + virtual ~VideoBackend() {} virtual void EmuStateChange(EMUSTATE_CHANGE) = 0; @@ -127,6 +131,9 @@ public: virtual writeFn16 Video_PEWrite16() = 0; virtual writeFn32 Video_PEWrite32() = 0; + void LoadConfig(); + void SaveConfig(); + static void PopulateList(); static void ClearList(); static void ActivateBackend(const std::string& name); @@ -138,6 +145,9 @@ extern VideoBackend* g_video_backend; // inherited by dx9/dx11/ogl backends class VideoBackendHardware : public VideoBackend { +protected: + VideoBackendHardware(const char* _ini_name) : VideoBackend(_ini_name) {} + void DoState(PointerWrap &p); void RunLoop(bool enable); diff --git a/Source/Core/DolphinWX/Src/ConfigMain.cpp b/Source/Core/DolphinWX/Src/ConfigMain.cpp index 73605f7783..f2c32ad847 100644 --- a/Source/Core/DolphinWX/Src/ConfigMain.cpp +++ b/Source/Core/DolphinWX/Src/ConfigMain.cpp @@ -1377,7 +1377,11 @@ void CConfigMain::OnSelectionChanged(wxCommandEvent& ev) void CConfigMain::OnConfig(wxCommandEvent&) { if (g_video_backend) + { + g_video_backend->LoadConfig(); g_video_backend->ShowConfig(this); + g_video_backend->SaveConfig(); + } } // Search for avaliable resolutions diff --git a/Source/Core/DolphinWX/Src/Frame.cpp b/Source/Core/DolphinWX/Src/Frame.cpp index babd468fcd..9b1472e095 100644 --- a/Source/Core/DolphinWX/Src/Frame.cpp +++ b/Source/Core/DolphinWX/Src/Frame.cpp @@ -127,19 +127,10 @@ CPanel::CPanel( case WM_USER: switch(wParam) { - // Pause - case WM_USER_PAUSE: - main_frame->DoPause(); - break; - - // Stop case WM_USER_STOP: main_frame->DoStop(); break; - case WM_USER_CREATE: - break; - case WM_USER_SETCURSOR: if (SConfig::GetInstance().m_LocalCoreStartupParameter.bHideCursor && main_frame->RendererHasFocus() && Core::GetState() == Core::CORE_RUN) @@ -180,6 +171,7 @@ CPanel::CPanel( } } break; + default: // By default let wxWidgets do what it normally does with this event return wxPanel::MSWWindowProc(nMsg, wParam, lParam); diff --git a/Source/Core/DolphinWX/Src/FrameTools.cpp b/Source/Core/DolphinWX/Src/FrameTools.cpp index 0ed693da50..86436244c4 100644 --- a/Source/Core/DolphinWX/Src/FrameTools.cpp +++ b/Source/Core/DolphinWX/Src/FrameTools.cpp @@ -1161,7 +1161,11 @@ void CFrame::OnConfigMain(wxCommandEvent& WXUNUSED (event)) void CFrame::OnConfigGFX(wxCommandEvent& WXUNUSED (event)) { if (g_video_backend) + { + g_video_backend->LoadConfig(); g_video_backend->ShowConfig(this); + g_video_backend->SaveConfig(); + } } void CFrame::OnConfigDSP(wxCommandEvent& WXUNUSED (event)) diff --git a/Source/Core/DolphinWX/Src/GameListCtrl.cpp b/Source/Core/DolphinWX/Src/GameListCtrl.cpp index 6d4a8d15d3..513c1ed679 100644 --- a/Source/Core/DolphinWX/Src/GameListCtrl.cpp +++ b/Source/Core/DolphinWX/Src/GameListCtrl.cpp @@ -29,6 +29,7 @@ #include "Blob.h" #include "Core.h" #include "ISOProperties.h" +#include "VideoConfigDiag.h" #include "IniFile.h" #include "FileUtil.h" #include "CDUtils.h" @@ -124,6 +125,7 @@ BEGIN_EVENT_TABLE(CGameListCtrl, wxListCtrl) EVT_LIST_COL_BEGIN_DRAG(LIST_CTRL, CGameListCtrl::OnColBeginDrag) EVT_LIST_COL_CLICK(LIST_CTRL, CGameListCtrl::OnColumnClick) EVT_MENU(IDM_PROPERTIES, CGameListCtrl::OnProperties) + EVT_MENU(IDM_GAMEVIDEOCONFIG, CGameListCtrl::OnGameVideoConfig) EVT_MENU(IDM_GAMEWIKI, CGameListCtrl::OnWiki) EVT_MENU(IDM_OPENCONTAININGFOLDER, CGameListCtrl::OnOpenContainingFolder) EVT_MENU(IDM_OPENSAVEFOLDER, CGameListCtrl::OnOpenSaveFolder) @@ -999,6 +1001,7 @@ void CGameListCtrl::OnRightClick(wxMouseEvent& event) { wxMenu* popupMenu = new wxMenu; popupMenu->Append(IDM_PROPERTIES, _("&Properties")); + popupMenu->Append(IDM_GAMEVIDEOCONFIG, _("&Graphics Configuration")); popupMenu->Append(IDM_GAMEWIKI, _("&Wiki")); popupMenu->AppendSeparator(); @@ -1167,6 +1170,31 @@ void CGameListCtrl::OnProperties(wxCommandEvent& WXUNUSED (event)) Update(); } +void CGameListCtrl::OnGameVideoConfig(wxCommandEvent&) +{ + const GameListItem* const iso = GetSelectedISO(); + if (!iso) + return; + + VideoConfig const vc = g_Config; + + g_Config.SetAllUndetermined(); + + // ugly + DiscIO::IVolume* const open_iso = DiscIO::CreateVolumeFromFilename(iso->GetFileName()); + std::string const unique_id = open_iso->GetUniqueID(); + std::string const ini_path = File::GetUserPath(D_GAMECONFIG_IDX) + unique_id + ".ini"; + g_Config.GameIniLoad(ini_path.c_str()); + delete open_iso; + + VideoConfigDiag vcd(this, unique_id, true); + vcd.ShowModal(); + + g_Config.GameIniSave(ini_path.c_str()); + + g_Config = vc; +} + void CGameListCtrl::OnWiki(wxCommandEvent& WXUNUSED (event)) { const GameListItem *iso = GetSelectedISO(); diff --git a/Source/Core/DolphinWX/Src/GameListCtrl.h b/Source/Core/DolphinWX/Src/GameListCtrl.h index 8a9a993140..65c399b818 100644 --- a/Source/Core/DolphinWX/Src/GameListCtrl.h +++ b/Source/Core/DolphinWX/Src/GameListCtrl.h @@ -98,6 +98,7 @@ private: void OnKeyPress(wxListEvent& event); void OnSize(wxSizeEvent& event); void OnProperties(wxCommandEvent& event); + void OnGameVideoConfig(wxCommandEvent&); void OnWiki(wxCommandEvent& event); void OnOpenContainingFolder(wxCommandEvent& event); void OnOpenSaveFolder(wxCommandEvent& event); diff --git a/Source/Core/DolphinWX/Src/Globals.h b/Source/Core/DolphinWX/Src/Globals.h index 72d8d81701..e32bbf0ec1 100644 --- a/Source/Core/DolphinWX/Src/Globals.h +++ b/Source/Core/DolphinWX/Src/Globals.h @@ -92,6 +92,7 @@ enum IDM_RESTART, IDM_CHANGEDISC, IDM_PROPERTIES, + IDM_GAMEVIDEOCONFIG, IDM_GAMEWIKI, IDM_LOAD_WII_MENU, IDM_CONNECT_WIIMOTE1, diff --git a/Source/Core/DolphinWX/Src/VideoConfigDiag.cpp b/Source/Core/DolphinWX/Src/VideoConfigDiag.cpp index d2d3fc1b51..fef9b05a00 100644 --- a/Source/Core/DolphinWX/Src/VideoConfigDiag.cpp +++ b/Source/Core/DolphinWX/Src/VideoConfigDiag.cpp @@ -1,3 +1,4 @@ + #include "VideoConfigDiag.h" #include "FileUtil.h" @@ -13,48 +14,58 @@ #include "Core.h" #include "Host.h" -extern CFrame* main_frame; - #define _connect_macro_(b, f, c, s) (b)->Connect(wxID_ANY, (c), wxCommandEventHandler( f ), (wxObject*)0, (wxEvtHandler*)s) -// template instantiation -template class BoolSetting; -template class BoolSetting; +// hackity hack +static bool g_use_intermediate_state = false; -template <> -SettingCheckBox::BoolSetting(wxWindow* parent, const wxString& label, const wxString& tooltip, bool &setting, bool reverse, long style) - : wxCheckBox(parent, -1, label, wxDefaultPosition, wxDefaultSize, style) +SettingCheckBox::SettingCheckBox(wxWindow* parent, const wxString& label, + const wxString& tooltip, bool &setting, long style) + : wxCheckBox(parent, -1, label, wxDefaultPosition, wxDefaultSize, + style | (g_use_intermediate_state ? (wxCHK_3STATE | wxCHK_ALLOW_3RD_STATE_FOR_USER) : 0)) , m_setting(setting) - , m_reverse(reverse) { SetToolTip(tooltip); - SetValue(m_setting ^ m_reverse); + + if (VideoConfig::IsUndetermined(m_setting)) + Set3StateValue(wxCHK_UNDETERMINED); + else + SetValue(m_setting); + _connect_macro_(this, SettingCheckBox::UpdateValue, wxEVT_COMMAND_CHECKBOX_CLICKED, this); } -template <> -SettingRadioButton::BoolSetting(wxWindow* parent, const wxString& label, const wxString& tooltip, bool &setting, bool reverse, long style) +SettingRadioButton::SettingRadioButton(wxWindow* parent, const wxString& label, + const wxString& tooltip, bool &setting, bool reverse, long style) : wxRadioButton(parent, -1, label, wxDefaultPosition, wxDefaultSize, style) , m_setting(setting) , m_reverse(reverse) { SetToolTip(tooltip); - SetValue(m_setting ^ m_reverse); + + if (!VideoConfig::IsUndetermined(m_setting) && m_setting != m_reverse) + SetValue(true); + _connect_macro_(this, SettingRadioButton::UpdateValue, wxEVT_COMMAND_RADIOBUTTON_SELECTED, this); } -SettingChoice::SettingChoice(wxWindow* parent, int &setting, const wxString& tooltip, int num, const wxString choices[], long style) +SettingChoice::SettingChoice(wxWindow* parent, int &setting, const wxString& tooltip, + int num, const wxString choices[], long style) : wxChoice(parent, -1, wxDefaultPosition, wxDefaultSize, num, choices) , m_setting(setting) { SetToolTip(tooltip); - Select(m_setting); + + if (g_use_intermediate_state) + Insert(wxTRANSLATE("< Default >"), 0); + Select(m_setting + g_use_intermediate_state); + _connect_macro_(this, SettingChoice::UpdateValue, wxEVT_COMMAND_CHOICE_SELECTED, this); } void SettingChoice::UpdateValue(wxCommandEvent& ev) { - m_setting = ev.GetInt(); + m_setting = ev.GetInt() - g_use_intermediate_state; ev.Skip(); } @@ -65,17 +76,6 @@ void VideoConfigDiag::Event_ClickClose(wxCommandEvent&) void VideoConfigDiag::Event_Close(wxCloseEvent& ev) { - if (cur_profile == 0) - { - vconfig.Save((File::GetUserPath(D_CONFIG_IDX) + ininame + ".ini").c_str()); - } - else - { - const GameListItem* item = GameListCtrl->GetISO(GameListCtrl->GetItemData(cur_profile - 1)); - vconfig.GameIniSave((File::GetUserPath(D_CONFIG_IDX) + ininame + ".ini").c_str(), - (File::GetUserPath(D_GAMECONFIG_IDX) + item->GetUniqueID() + ".ini").c_str()); - } - EndModal(wxID_OK); TextureCache::InvalidateDefer(); // For settings like hi-res textures/texture format/etc. @@ -132,43 +132,18 @@ wxString hotkeys_tooltip = wxT(""); wxString ppshader_tooltip = wxT(""); wxString cache_efb_copies_tooltip = wxTRANSLATE("When using EFB to RAM we very often need to decode RAM data to a VRAM texture, which is a very time-consuming task.\nWith this option enabled, we'll skip decoding a texture if it didn't change.\nThis results in a nice speedup, but possibly causes glitches.\nIf you have any problems with this option enabled you should either try increasing the safety of the texture cache or disable this option.\n(NOTE: The safer the texture cache is adjusted the lower the speedup will be; accurate texture cache set to \"safe\" might actually be slower!)"); -VideoConfigDiag::VideoConfigDiag(wxWindow* parent, const std::string &title, const std::string& _ininame) - : wxDialog(parent, -1, - wxString::Format(_("Dolphin %s Graphics Configuration"), - wxGetTranslation(wxString::From8BitData(title.c_str()))), +VideoConfigDiag::VideoConfigDiag(wxWindow* parent, const std::string &title, bool is_game_config) + : wxDialog(parent, -1, wxString::Format(_("Dolphin %s Graphics Configuration"), + wxGetTranslation(wxString::From8BitData(title.c_str()))), wxDefaultPosition, wxDefaultSize) - , choice_adapter(NULL) - , choice_ppshader(NULL) - , ininame(_ininame) - , GameListCtrl(main_frame->GetGameListCtrl()) + //, choice_adapter(NULL) + //, choice_ppshader(NULL) + , vconfig(g_Config) { - // TODO: Make this less hacky - vconfig = g_Config; // take over backend_info - - // If a game from the game list is running, show the game specific config; show the default config otherwise - cur_profile = 0; - if (Core::IsRunning()) - { - // Search which ISO has been started - for (long index = GameListCtrl->GetNextItem(-1); index != -1; index = GameListCtrl->GetNextItem(index)) - { - const GameListItem* item = GameListCtrl->GetISO(GameListCtrl->GetItemData(index)); - if (!item) continue; - if (item->GetUniqueID() == SConfig::GetInstance().m_LocalCoreStartupParameter.m_strUniqueID) - { - cur_profile = index + 1; - break; - } - } - } + g_use_intermediate_state = is_game_config; // Load settings - vconfig.Load((File::GetUserPath(D_CONFIG_IDX) + ininame + ".ini").c_str()); - if (cur_profile != 0) - { - const GameListItem* item = GameListCtrl->GetISO(GameListCtrl->GetItemData(cur_profile - 1)); - vconfig.GameIniLoad((std::string(File::GetUserPath(D_GAMECONFIG_IDX)) + item->GetUniqueID() + ".ini").c_str()); - } + //vconfig.Load((File::GetUserPath(D_CONFIG_IDX) + ininame + ".ini").c_str()); wxNotebook* const notebook = new wxNotebook(this, -1, wxDefaultPosition, wxDefaultSize); @@ -182,28 +157,11 @@ VideoConfigDiag::VideoConfigDiag(wxWindow* parent, const std::string &title, con { wxFlexGridSizer* const szr_basic = new wxFlexGridSizer(2, 5, 5); - // game specific config - szr_basic->Add(new wxStaticText(page_general, -1, _("Configuration profile:")), 1, wxALIGN_CENTER_VERTICAL, 5); - profile_cb = new SettingChoice(page_general, cur_profile, wxGetTranslation(profile_tooltip)); - szr_basic->Add(profile_cb, 1, 0, 0); - - profile_cb->AppendString(_("(Default)")); - for (long index = GameListCtrl->GetNextItem(-1); index != -1; index = GameListCtrl->GetNextItem(index)) - { - const GameListItem* item = GameListCtrl->GetISO(GameListCtrl->GetItemData(index)); - if (!item) continue; - profile_cb->AppendString(wxString(item->GetName(0).c_str(), wxConvUTF8)); - } - - profile_cb->Select(cur_profile); - _connect_macro_(profile_cb, VideoConfigDiag::Event_OnProfileChange, wxEVT_COMMAND_CHOICE_SELECTED, this); - profile_cb->Enable(!Core::IsRunning()); - // adapter // for D3D only if (vconfig.backend_info.Adapters.size()) { szr_basic->Add(new wxStaticText(page_general, -1, _("Adapter:")), 1, wxALIGN_CENTER_VERTICAL, 5); - choice_adapter = new SettingChoice(page_general, vconfig.iAdapter, wxGetTranslation(adapter_tooltip)); + auto const choice_adapter = new SettingChoice(page_general, vconfig.iAdapter, wxGetTranslation(adapter_tooltip)); std::vector::const_iterator it = vconfig.backend_info.Adapters.begin(), @@ -222,7 +180,7 @@ VideoConfigDiag::VideoConfigDiag(wxWindow* parent, const std::string &title, con _("Force 16:9"), _("Force 4:3"), _("Stretch to Window") }; szr_basic->Add(new wxStaticText(page_general, -1, _("Aspect Ratio:")), 1, wxALIGN_CENTER_VERTICAL, 0); - choice_aspect = new SettingChoice(page_general, + auto const choice_aspect = new SettingChoice(page_general, vconfig.iAspectRatio, wxGetTranslation(ar_tooltip), sizeof(ar_choices)/sizeof(*ar_choices), ar_choices); szr_basic->Add(choice_aspect, 1, 0, 0); } @@ -230,9 +188,11 @@ VideoConfigDiag::VideoConfigDiag(wxWindow* parent, const std::string &title, con // widescreen hack { szr_basic->AddStretchSpacer(1); - szr_basic->Add(widescreen_hack = new SettingCheckBox(page_general, _("Widescreen Hack"), wxGetTranslation(ws_hack_tooltip), vconfig.bWidescreenHack), 1, 0, 0); + szr_basic->Add(new SettingCheckBox(page_general, _("Widescreen Hack"), + wxGetTranslation(ws_hack_tooltip), vconfig.bWidescreenHack), 1, 0, 0); szr_basic->AddStretchSpacer(1); - szr_basic->Add(vsync = new SettingCheckBox(page_general, _("V-Sync"), wxGetTranslation(vsync_tooltip), vconfig.bVSync), 1, 0, 0); + szr_basic->Add(new SettingCheckBox(page_general, _("V-Sync"), + wxGetTranslation(vsync_tooltip), vconfig.bVSync), 1, 0, 0); } // enhancements @@ -240,31 +200,36 @@ VideoConfigDiag::VideoConfigDiag(wxWindow* parent, const std::string &title, con szr_enh->Add(new wxStaticText(page_general, -1, _("Anisotropic Filtering:")), 1, wxALIGN_CENTER_VERTICAL, 0); const wxString af_choices[] = {wxT("1x"), wxT("2x"), wxT("4x"), wxT("8x"), wxT("16x")}; - szr_enh->Add(anisotropic_filtering = new SettingChoice(page_general, vconfig.iMaxAnisotropy, wxGetTranslation(af_tooltip), 5, af_choices)); + szr_enh->Add(new SettingChoice(page_general, vconfig.iMaxAnisotropy, + wxGetTranslation(af_tooltip), 5, af_choices)); + if (!vconfig.backend_info.AAModes.empty()) + { + szr_enh->Add(new wxStaticText(page_general, -1, _("Anti-Aliasing:")), 1, wxALIGN_CENTER_VERTICAL, 0); + auto const choice_aamode = new SettingChoice(page_general, vconfig.iMultisampleMode, wxGetTranslation(aa_tooltip)); - text_aamode = new wxStaticText(page_general, -1, _("Anti-Aliasing:")); - szr_enh->Add(text_aamode, 1, wxALIGN_CENTER_VERTICAL, 0); - choice_aamode = new SettingChoice(page_general, vconfig.iMultisampleMode, wxGetTranslation(aa_tooltip)); + std::vector::const_iterator + it = vconfig.backend_info.AAModes.begin(), + itend = vconfig.backend_info.AAModes.end(); + for (; it != itend; ++it) + choice_aamode->AppendString(wxGetTranslation(wxString::FromAscii(it->c_str()))); - std::vector::const_iterator - it = vconfig.backend_info.AAModes.begin(), - itend = vconfig.backend_info.AAModes.end(); - for (; it != itend; ++it) - choice_aamode->AppendString(wxGetTranslation(wxString::FromAscii(it->c_str()))); + choice_aamode->Select(vconfig.iMultisampleMode); + szr_enh->Add(choice_aamode); + } - - choice_aamode->Select(vconfig.iMultisampleMode); - szr_enh->Add(choice_aamode); - - - szr_enh->Add(native_mips = new SettingCheckBox(page_general, _("Load Native Mipmaps"), wxGetTranslation(native_mips_tooltip), vconfig.bUseNativeMips)); - szr_enh->Add(efb_scaled_copy = new SettingCheckBox(page_general, _("EFB Scaled Copy"), wxGetTranslation(scaled_efb_copy_tooltip), vconfig.bCopyEFBScaled)); - szr_enh->Add(pixel_lighting = new SettingCheckBox(page_general, _("Pixel Lighting"), wxGetTranslation(pixel_lighting_tooltip), vconfig.bEnablePixelLighting)); - szr_enh->Add(pixel_depth = new SettingCheckBox(page_general, _("Pixel Depth"), wxGetTranslation(pixel_depth_tooltip), vconfig.bEnablePerPixelDepth)); - szr_enh->Add(force_filtering = new SettingCheckBox(page_general, _("Force Bi/Trilinear Filtering"), wxGetTranslation(force_filtering_tooltip), vconfig.bForceFiltering)); + szr_enh->Add(new SettingCheckBox(page_general, _("Load Native Mipmaps"), + wxGetTranslation(native_mips_tooltip), vconfig.bUseNativeMips)); + szr_enh->Add(new SettingCheckBox(page_general, _("EFB Scaled Copy"), + wxGetTranslation(scaled_efb_copy_tooltip), vconfig.bCopyEFBScaled)); + szr_enh->Add(new SettingCheckBox(page_general, _("Pixel Lighting"), + wxGetTranslation(pixel_lighting_tooltip), vconfig.bEnablePixelLighting)); + szr_enh->Add(new SettingCheckBox(page_general, _("Pixel Depth"), + wxGetTranslation(pixel_depth_tooltip), vconfig.bEnablePerPixelDepth)); + szr_enh->Add(new SettingCheckBox(page_general, _("Force Bi/Trilinear Filtering"), + wxGetTranslation(force_filtering_tooltip), vconfig.bForceFiltering)); - _3d_vision = new SettingCheckBox(page_general, _("3D Vision (Requires Fullscreen)"), wxGetTranslation(_3d_vision_tooltip), vconfig.b3DVision); + auto const _3d_vision = new SettingCheckBox(page_general, _("3D Vision (Requires Fullscreen)"), wxGetTranslation(_3d_vision_tooltip), vconfig.b3DVision); _3d_vision->Show(vconfig.backend_info.bSupports3DVision); szr_enh->Add(_3d_vision); @@ -274,21 +239,24 @@ VideoConfigDiag::VideoConfigDiag(wxWindow* parent, const std::string &title, con const wxString efbscale_choices[] = { _("Fractional"), _("Integral [recommended]"), wxT("1x"), wxT("2x"), wxT("3x"), wxT("0.75x"), wxT("0.5x"), wxT("0.375x") }; - choice_efbscale = new SettingChoice(page_general, + auto const choice_efbscale = new SettingChoice(page_general, vconfig.iEFBScale, wxGetTranslation(internal_res_tooltip), sizeof(efbscale_choices)/sizeof(*efbscale_choices), efbscale_choices); efb_scale_szr->Add(new wxStaticText(page_general, -1, _("Scale:")), 0, wxALIGN_CENTER_VERTICAL, 5); //efb_scale_szr->AddStretchSpacer(1); efb_scale_szr->Add(choice_efbscale, 0, wxBOTTOM | wxLEFT, 5); - emulate_efb_format_changes = new SettingCheckBox(page_general, _("Emulate format changes"), wxGetTranslation(efb_emulate_format_changes_tooltip), vconfig.bEFBEmulateFormatChanges); + auto const emulate_efb_format_changes = new SettingCheckBox(page_general, _("Emulate Format Changes"), + wxGetTranslation(efb_emulate_format_changes_tooltip), vconfig.bEFBEmulateFormatChanges); // EFB copy - efbcopy_enable = new SettingCheckBox(page_general, _("Enable"), wxGetTranslation(efb_copy_tooltip), vconfig.bEFBCopyEnable); - efbcopy_texture = new SettingRadioButton(page_general, _("Texture"), wxGetTranslation(efb_copy_texture_tooltip), vconfig.bCopyEFBToTexture, false, wxRB_GROUP); - efbcopy_ram = new SettingRadioButton(page_general, _("RAM"), wxGetTranslation(efb_copy_ram_tooltip), vconfig.bCopyEFBToTexture, true); - cache_efb_copies = new SettingCheckBox(page_general, _("Enable cache"), wxGetTranslation(cache_efb_copies_tooltip), vconfig.bEFBCopyCacheEnable); + auto const efbcopy_enable = new SettingCheckBox(page_general, _("Enable"), wxGetTranslation(efb_copy_tooltip), vconfig.bEFBCopyEnable); + auto const efbcopy_texture = new SettingRadioButton(page_general, _("Texture"), wxGetTranslation(efb_copy_texture_tooltip), vconfig.bCopyEFBToTexture, false, wxRB_GROUP); + auto const efbcopy_ram = new SettingRadioButton(page_general, _("RAM"), wxGetTranslation(efb_copy_ram_tooltip), vconfig.bCopyEFBToTexture, true); + auto const cache_efb_copies = new SettingCheckBox(page_general, _("Enable Cache"), wxGetTranslation(cache_efb_copies_tooltip), vconfig.bEFBCopyCacheEnable); + wxStaticBoxSizer* const group_efbcopy = new wxStaticBoxSizer(wxHORIZONTAL, page_general, _("Copy")); + group_efbcopy->Add(efbcopy_enable, 0, wxLEFT | wxRIGHT | wxBOTTOM, 5); group_efbcopy->AddStretchSpacer(1); group_efbcopy->Add(efbcopy_texture, 0, wxRIGHT, 5); @@ -297,18 +265,18 @@ VideoConfigDiag::VideoConfigDiag(wxWindow* parent, const std::string &title, con // - safe texture cache - stc_enable = new SettingCheckBox(page_general, _("Enable"), wxGetTranslation(stc_tooltip), vconfig.bSafeTextureCache); + auto const stc_enable = new SettingCheckBox(page_general, _("Enable"), wxGetTranslation(stc_tooltip), vconfig.bSafeTextureCache); - stc_safe = new wxRadioButton(page_general, -1, _("Safe"), + auto const stc_safe = new wxRadioButton(page_general, -1, _("Safe"), wxDefaultPosition, wxDefaultSize, wxRB_GROUP); stc_safe->SetToolTip(wxGetTranslation(stc_speed_tooltip)); _connect_macro_(stc_safe, VideoConfigDiag::Event_StcSafe, wxEVT_COMMAND_RADIOBUTTON_SELECTED, this); - stc_normal = new wxRadioButton(page_general, -1, _("Normal")); + auto const stc_normal = new wxRadioButton(page_general, -1, _("Normal")); stc_normal->SetToolTip(wxGetTranslation(stc_speed_tooltip)); _connect_macro_(stc_normal, VideoConfigDiag::Event_StcNormal, wxEVT_COMMAND_RADIOBUTTON_SELECTED, this); - stc_fast = new wxRadioButton(page_general, -1, _("Fast")); + auto const stc_fast = new wxRadioButton(page_general, -1, _("Fast")); stc_fast->SetToolTip(wxGetTranslation(stc_speed_tooltip)); _connect_macro_(stc_fast, VideoConfigDiag::Event_StcFast, wxEVT_COMMAND_RADIOBUTTON_SELECTED, this); @@ -323,7 +291,8 @@ VideoConfigDiag::VideoConfigDiag(wxWindow* parent, const std::string &title, con wxStaticBoxSizer* const group_efb = new wxStaticBoxSizer(wxVERTICAL, page_general, _("EFB")); szr_general->Add(group_efb, 0, wxEXPAND | wxLEFT | wxRIGHT | wxBOTTOM, 5); group_efb->Add(efb_scale_szr, 0, wxBOTTOM | wxLEFT, 5); - group_efb->Add(efbaccess_enable = new SettingCheckBox(page_general, _("Enable CPU Access"), wxGetTranslation(efb_access_tooltip), vconfig.bEFBAccessEnable), 0, wxBOTTOM | wxLEFT, 5); + group_efb->Add(new SettingCheckBox(page_general, _("Enable CPU Access"), + wxGetTranslation(efb_access_tooltip), vconfig.bEFBAccessEnable), 0, wxBOTTOM | wxLEFT, 5); group_efb->Add(emulate_efb_format_changes, 0, wxBOTTOM | wxLEFT, 5); group_efb->Add(group_efbcopy, 0, wxEXPAND | wxBOTTOM, 5); @@ -345,23 +314,20 @@ VideoConfigDiag::VideoConfigDiag(wxWindow* parent, const std::string &title, con notebook->AddPage(page_advanced, _("Advanced")); wxBoxSizer* const szr_advanced = new wxBoxSizer(wxVERTICAL); - // configuration profiles - { - wxStaticBoxSizer* const group_profile = new wxStaticBoxSizer(wxHORIZONTAL, page_advanced, _("Configuration profile")); - profile_text = new wxStaticText(page_advanced, -1, profile_cb->GetStringSelection()); - szr_advanced->Add(group_profile, 0, wxEXPAND | wxALL, 5); - group_profile->Add(profile_text, 1, wxEXPAND | wxALL, 5); - } - // - rendering { wxGridSizer* const szr_rendering = new wxGridSizer(2, 5, 5); - szr_rendering->Add(wireframe = new SettingCheckBox(page_advanced, _("Enable Wireframe"), wxGetTranslation(wireframe_tooltip), vconfig.bWireFrame)); - szr_rendering->Add(disable_lighting = new SettingCheckBox(page_advanced, _("Disable Lighting"), wxGetTranslation(disable_lighting_tooltip), vconfig.bDisableLighting)); - szr_rendering->Add(disable_textures = new SettingCheckBox(page_advanced, _("Disable Textures"), wxGetTranslation(disable_textures_tooltip), vconfig.bDisableTexturing)); - szr_rendering->Add(disable_fog = new SettingCheckBox(page_advanced, _("Disable Fog"), wxGetTranslation(disable_fog_tooltip), vconfig.bDisableFog)); - szr_rendering->Add(disable_dst_alpha = new SettingCheckBox(page_advanced, _("Disable Dest. Alpha Pass"), wxGetTranslation(disable_alphapass_tooltip), vconfig.bDstAlphaPass)); + szr_rendering->Add(new SettingCheckBox(page_advanced, _("Enable Wireframe"), + wxGetTranslation(wireframe_tooltip), vconfig.bWireFrame)); + szr_rendering->Add(new SettingCheckBox(page_advanced, _("Disable Lighting"), + wxGetTranslation(disable_lighting_tooltip), vconfig.bDisableLighting)); + szr_rendering->Add(new SettingCheckBox(page_advanced, _("Disable Textures"), + wxGetTranslation(disable_textures_tooltip), vconfig.bDisableTexturing)); + szr_rendering->Add(new SettingCheckBox(page_advanced, _("Disable Fog"), + wxGetTranslation(disable_fog_tooltip), vconfig.bDisableFog)); + szr_rendering->Add(new SettingCheckBox(page_advanced, _("Disable Dest. Alpha Pass"), + wxGetTranslation(disable_alphapass_tooltip), vconfig.bDstAlphaPass)); wxStaticBoxSizer* const group_rendering = new wxStaticBoxSizer(wxVERTICAL, page_advanced, _("Rendering")); szr_advanced->Add(group_rendering, 0, wxEXPAND | wxALL, 5); @@ -372,13 +338,20 @@ VideoConfigDiag::VideoConfigDiag(wxWindow* parent, const std::string &title, con { wxGridSizer* const szr_info = new wxGridSizer(2, 5, 5); - szr_info->Add(show_fps = new SettingCheckBox(page_advanced, _("Show FPS"), wxGetTranslation(show_fps_tooltip), vconfig.bShowFPS)); - szr_info->Add(overlay_stats = new SettingCheckBox(page_advanced, _("Various Statistics"), wxGetTranslation(show_stats_tooltip), vconfig.bOverlayStats)); - szr_info->Add(overlay_proj_stats = new SettingCheckBox(page_advanced, _("Projection Stats"), wxGetTranslation(proj_stats_tooltip), vconfig.bOverlayProjStats)); - szr_info->Add(texfmt_overlay = new SettingCheckBox(page_advanced, _("Texture Format"), wxGetTranslation(texfmt_tooltip), vconfig.bTexFmtOverlayEnable)); - szr_info->Add(efb_copy_regions = new SettingCheckBox(page_advanced, _("EFB Copy Regions"), wxGetTranslation(efb_copy_regions_tooltip), vconfig.bShowEFBCopyRegions)); - szr_info->Add(show_shader_errors = new SettingCheckBox(page_advanced, _("Show Shader Errors"), wxT(""), vconfig.bShowShaderErrors)); - szr_info->Add(show_input_display = new SettingCheckBox(page_advanced, _("Show Input Display"), wxGetTranslation(show_input_display_tooltip), vconfig.bShowInputDisplay)); + szr_info->Add(new SettingCheckBox(page_advanced, _("Show FPS"), + wxGetTranslation(show_fps_tooltip), vconfig.bShowFPS)); + szr_info->Add(new SettingCheckBox(page_advanced, _("Various Statistics"), + wxGetTranslation(show_stats_tooltip), vconfig.bOverlayStats)); + szr_info->Add(new SettingCheckBox(page_advanced, _("Projection Stats"), + wxGetTranslation(proj_stats_tooltip), vconfig.bOverlayProjStats)); + szr_info->Add(new SettingCheckBox(page_advanced, _("Texture Format"), + wxGetTranslation(texfmt_tooltip), vconfig.bTexFmtOverlayEnable)); + szr_info->Add(new SettingCheckBox(page_advanced, _("EFB Copy Regions"), + wxGetTranslation(efb_copy_regions_tooltip), vconfig.bShowEFBCopyRegions)); + szr_info->Add(new SettingCheckBox(page_advanced, _("Show Shader Errors"), + wxT(""), vconfig.bShowShaderErrors)); + szr_info->Add(new SettingCheckBox(page_advanced, _("Show Input Display"), + wxGetTranslation(show_input_display_tooltip), vconfig.bShowInputDisplay)); wxStaticBoxSizer* const group_info = new wxStaticBoxSizer(wxVERTICAL, page_advanced, _("Information")); szr_advanced->Add(group_info, 0, wxEXPAND | wxLEFT | wxRIGHT | wxBOTTOM, 5); @@ -387,9 +360,9 @@ VideoConfigDiag::VideoConfigDiag(wxWindow* parent, const std::string &title, con // - XFB { - enable_xfb = new SettingCheckBox(page_advanced, _("Enable"), wxGetTranslation(xfb_tooltip), vconfig.bUseXFB); - virtual_xfb = new SettingRadioButton(page_advanced, _("Virtual"), wxGetTranslation(xfb_tooltip), vconfig.bUseRealXFB, true, wxRB_GROUP); - real_xfb = new SettingRadioButton(page_advanced, _("Real"), wxGetTranslation(xfb_tooltip), vconfig.bUseRealXFB); + auto const enable_xfb = new SettingCheckBox(page_advanced, _("Enable"), wxGetTranslation(xfb_tooltip), vconfig.bUseXFB); + auto const virtual_xfb = new SettingRadioButton(page_advanced, _("Virtual"), wxGetTranslation(xfb_tooltip), vconfig.bUseRealXFB, true, wxRB_GROUP); + auto const real_xfb = new SettingRadioButton(page_advanced, _("Real"), wxGetTranslation(xfb_tooltip), vconfig.bUseRealXFB); wxStaticBoxSizer* const group_xfb = new wxStaticBoxSizer(wxHORIZONTAL, page_advanced, _("XFB")); szr_advanced->Add(group_xfb, 0, wxEXPAND | wxLEFT | wxRIGHT | wxBOTTOM, 5); @@ -397,21 +370,24 @@ VideoConfigDiag::VideoConfigDiag(wxWindow* parent, const std::string &title, con group_xfb->AddStretchSpacer(1); group_xfb->Add(virtual_xfb, 0, wxRIGHT, 5); group_xfb->Add(real_xfb, 0, wxRIGHT, 5); - - } // xfb // - utility { wxGridSizer* const szr_utility = new wxGridSizer(2, 5, 5); - szr_utility->Add(dump_textures = new SettingCheckBox(page_advanced, _("Dump Textures"), wxGetTranslation(dump_textures_tooltip), vconfig.bDumpTextures)); - szr_utility->Add(hires_textures = new SettingCheckBox(page_advanced, _("Load Hi-Res Textures"), wxGetTranslation(load_hires_textures_tooltip), vconfig.bHiresTextures)); - szr_utility->Add(dump_efb = new SettingCheckBox(page_advanced, _("Dump EFB Target"), dump_efb_tooltip, vconfig.bDumpEFBTarget)); - szr_utility->Add(dump_frames = new SettingCheckBox(page_advanced, _("Dump Frames"), dump_frames_tooltip, vconfig.bDumpFrames)); - szr_utility->Add(free_look = new SettingCheckBox(page_advanced, _("Free Look"), free_look_tooltip, vconfig.bFreeLook)); + szr_utility->Add(new SettingCheckBox(page_advanced, _("Dump Textures"), + wxGetTranslation(dump_textures_tooltip), vconfig.bDumpTextures)); + szr_utility->Add(new SettingCheckBox(page_advanced, _("Load Hi-Res Textures"), + wxGetTranslation(load_hires_textures_tooltip), vconfig.bHiresTextures)); + szr_utility->Add(new SettingCheckBox(page_advanced, _("Dump EFB Target"), + dump_efb_tooltip, vconfig.bDumpEFBTarget)); + szr_utility->Add(new SettingCheckBox(page_advanced, _("Dump Frames"), + dump_frames_tooltip, vconfig.bDumpFrames)); + szr_utility->Add(new SettingCheckBox(page_advanced, _("Free Look"), + free_look_tooltip, vconfig.bFreeLook)); #if !defined WIN32 && defined HAVE_LIBAV - szr_utility->Add(frame_dumps_via_ffv1 = new SettingCheckBox(page_advanced, _("Frame dumps use FFV1"), use_ffv1_tooltip, vconfig.bUseFFV1)); + szr_utility->Add(frame_dumps_via_ffv1 = new SettingCheckBox(page_advanced, _("Dump Frames With FFV1"), use_ffv1_tooltip, vconfig.bUseFFV1)); #endif wxStaticBoxSizer* const group_utility = new wxStaticBoxSizer(wxVERTICAL, page_advanced, _("Utility")); @@ -423,18 +399,23 @@ VideoConfigDiag::VideoConfigDiag(wxWindow* parent, const std::string &title, con { wxGridSizer* const szr_misc = new wxGridSizer(2); - szr_misc->Add(crop = new SettingCheckBox(page_advanced, _("Crop"), crop_tooltip, vconfig.bCrop), 0, wxBOTTOM, 5); - szr_misc->Add(opencl = new SettingCheckBox(page_advanced, _("Enable OpenCL"), opencl_tooltip, vconfig.bEnableOpenCL), 0, wxLEFT|wxBOTTOM, 5); - szr_misc->Add(dlcache = new SettingCheckBox(page_advanced, _("Enable Display List Caching"), dlc_tooltip, vconfig.bDlistCachingEnable), 0, wxBOTTOM, 5); - szr_misc->Add(hotkeys = new SettingCheckBox(page_advanced, _("Enable Hotkeys"), hotkeys_tooltip, vconfig.bOSDHotKey), 0, wxLEFT|wxBOTTOM, 5); - szr_misc->Add(ompdecoder = new SettingCheckBox(page_advanced, _("OpenMP Texture Decoder"), omp_tooltip, vconfig.bOMPDecoder), 0, wxBOTTOM, 5); + szr_misc->Add(new SettingCheckBox(page_advanced, _("Crop"), + crop_tooltip, vconfig.bCrop), 0, wxBOTTOM, 5); + szr_misc->Add(new SettingCheckBox(page_advanced, _("Enable OpenCL"), + opencl_tooltip, vconfig.bEnableOpenCL), 0, wxLEFT|wxBOTTOM, 5); + szr_misc->Add(new SettingCheckBox(page_advanced, _("Enable Display List Caching"), + dlc_tooltip, vconfig.bDlistCachingEnable), 0, wxBOTTOM, 5); + szr_misc->Add(new SettingCheckBox(page_advanced, _("Enable Hotkeys"), + hotkeys_tooltip, vconfig.bOSDHotKey), 0, wxLEFT|wxBOTTOM, 5); + szr_misc->Add(new SettingCheckBox(page_advanced, _("OpenMP Texture Decoder"), + omp_tooltip, vconfig.bOMPDecoder), 0, wxBOTTOM, 5); // postproc shader if (vconfig.backend_info.PPShaders.size()) { szr_misc->Add(new wxStaticText(page_advanced, -1, _("Post-Processing Shader:")), 1, wxALIGN_CENTER_VERTICAL, 0); - choice_ppshader = new wxChoice(page_advanced, -1, wxDefaultPosition); + auto const choice_ppshader = new wxChoice(page_advanced, -1, wxDefaultPosition); choice_ppshader->SetToolTip(wxGetTranslation(ppshader_tooltip)); choice_ppshader->AppendString(_("(off)")); @@ -474,166 +455,10 @@ VideoConfigDiag::VideoConfigDiag(wxWindow* parent, const std::string &title, con SetSizerAndFit(szr_main); Center(); SetFocus(); - - SetUIValuesFromConfig(); - Connect(wxID_ANY, wxEVT_UPDATE_UI, wxUpdateUIEventHandler(VideoConfigDiag::OnUpdateUI), NULL, this); - UpdateWindowUI(); -} - -void VideoConfigDiag::Event_OnProfileChange(wxCommandEvent& ev) -{ - // Save settings of current profile - if (cur_profile == 0) - { - vconfig.Save((File::GetUserPath(D_CONFIG_IDX) + ininame + ".ini").c_str()); - } - else - { - const GameListItem* item = GameListCtrl->GetISO(GameListCtrl->GetItemData(cur_profile - 1)); - vconfig.GameIniSave((File::GetUserPath(D_CONFIG_IDX) + ininame + ".ini").c_str(), - (std::string(File::GetUserPath(D_GAMECONFIG_IDX)) + item->GetUniqueID() + ".ini").c_str()); - } - - // Enable new profile - cur_profile = ev.GetInt(); - - // Reset settings - vconfig.Load((File::GetUserPath(D_CONFIG_IDX) + ininame + ".ini").c_str()); - - // Load game-specific settings - if (cur_profile != 0) - { - const GameListItem* item = GameListCtrl->GetISO(GameListCtrl->GetItemData(cur_profile - 1)); - vconfig.GameIniLoad((std::string(File::GetUserPath(D_GAMECONFIG_IDX)) + item->GetUniqueID() + ".ini").c_str()); - } - - // Update our UI elements with the new config - SetUIValuesFromConfig(); - UpdateWindowUI(); - profile_text->SetLabel(profile_cb->GetStringSelection()); - - ev.Skip(); -} - -void VideoConfigDiag::OnUpdateUI(wxUpdateUIEvent& ev) -{ - // Anti-aliasing - choice_aamode->Enable(vconfig.backend_info.AAModes.size() > 1); - text_aamode->Enable(vconfig.backend_info.AAModes.size() > 1); - - // pixel lighting - pixel_lighting->Enable(vconfig.backend_info.bSupportsPixelLighting); - - // 3D vision - _3d_vision->Show(vconfig.backend_info.bSupports3DVision); - - // EFB copy - efbcopy_texture->Enable(vconfig.bEFBCopyEnable); - efbcopy_ram->Enable(vconfig.bEFBCopyEnable); - cache_efb_copies->Enable(vconfig.bEFBCopyEnable && !vconfig.bCopyEFBToTexture); - - // EFB format change emulation - emulate_efb_format_changes->Enable(vconfig.backend_info.bSupportsFormatReinterpretation); - - // ATC - stc_safe->Enable(vconfig.bSafeTextureCache); - stc_normal->Enable(vconfig.bSafeTextureCache); - stc_fast->Enable(vconfig.bSafeTextureCache); - - // XFB - virtual_xfb->Enable(vconfig.bUseXFB); - real_xfb->Enable(vconfig.bUseXFB); - - // If emulation hasn't started, yet, always update g_Config. - // Otherwise only update it if we're editing the currently running game's profile - if (!Core::IsRunning()) - { - g_Config = vconfig; - } - else if (cur_profile != 0) - { - // TODO: Modifying the default profile should update g_Config as well - if (GameListCtrl->GetISO(GameListCtrl->GetItemData(cur_profile - 1))->GetUniqueID() == - SConfig::GetInstance().m_LocalCoreStartupParameter.m_strUniqueID) - g_Config = vconfig; - } - - ev.Skip(); } void VideoConfigDiag::SetUIValuesFromConfig() { - if (choice_adapter) choice_adapter->SetSelection(vconfig.iAdapter); - vconfig.VerifyValidity(); - choice_aspect->SetSelection(vconfig.iAspectRatio); - widescreen_hack->SetValue(vconfig.bWidescreenHack); - vsync->SetValue(vconfig.bVSync); - - anisotropic_filtering->SetSelection(vconfig.iMaxAnisotropy); - choice_aamode->SetSelection(vconfig.iMultisampleMode); - - native_mips->SetValue(vconfig.bUseNativeMips); - efb_scaled_copy->SetValue(vconfig.bCopyEFBScaled); - pixel_lighting->SetValue(vconfig.bEnablePixelLighting); - pixel_depth->SetValue(vconfig.bEnablePerPixelDepth); - force_filtering->SetValue(vconfig.bForceFiltering); - _3d_vision->SetValue(vconfig.b3DVision); - - choice_efbscale->SetSelection(vconfig.iEFBScale); - efbaccess_enable->SetValue(vconfig.bEFBAccessEnable); - emulate_efb_format_changes->SetValue(vconfig.bEFBEmulateFormatChanges); - - efbcopy_enable->SetValue(vconfig.bEFBCopyEnable); - efbcopy_texture->SetValue(vconfig.bCopyEFBToTexture); - efbcopy_ram->SetValue(!vconfig.bCopyEFBToTexture); - cache_efb_copies->SetValue(vconfig.bEFBCopyCacheEnable); - - stc_enable->SetValue(vconfig.bSafeTextureCache); - if (0 == vconfig.iSafeTextureCache_ColorSamples) - stc_safe->SetValue(true); - - if (512 == vconfig.iSafeTextureCache_ColorSamples) - stc_normal->SetValue(true); - - if (128 == vconfig.iSafeTextureCache_ColorSamples) - stc_fast->SetValue(true); - - wireframe->SetValue(vconfig.bWireFrame); - disable_lighting->SetValue(vconfig.bDisableLighting); - disable_textures->SetValue(vconfig.bDisableTexturing); - disable_fog->SetValue(vconfig.bDisableFog); - disable_dst_alpha->SetValue(vconfig.bDstAlphaPass); - - show_fps->SetValue(vconfig.bShowFPS); - overlay_stats->SetValue(vconfig.bOverlayStats); - overlay_proj_stats->SetValue(vconfig.bOverlayProjStats); - texfmt_overlay->SetValue(vconfig.bTexFmtOverlayEnable); - efb_copy_regions->SetValue(vconfig.bShowEFBCopyRegions); - show_shader_errors->SetValue(vconfig.bShowShaderErrors); - show_input_display->SetValue(vconfig.bShowInputDisplay); - - enable_xfb->SetValue(vconfig.bUseXFB); - virtual_xfb->SetValue(!vconfig.bUseRealXFB); - real_xfb->SetValue(vconfig.bUseRealXFB); - - dump_textures->SetValue(vconfig.bDumpTextures); - hires_textures->SetValue(vconfig.bHiresTextures); - dump_efb->SetValue(vconfig.bDumpEFBTarget); - dump_frames->SetValue(vconfig.bDumpFrames); - free_look->SetValue(vconfig.bFreeLook); -#if !defined WIN32 && defined HAVE_LIBAV - frame_dumps_via_ffv1->SetValue(vconfig.bUseFFV1); -#endif - - crop->SetValue(vconfig.bCrop); - opencl->SetValue(vconfig.bEnableOpenCL); - dlcache->SetValue(vconfig.bDlistCachingEnable); - ompdecoder->SetValue(vconfig.bOMPDecoder); - hotkeys->SetValue(vconfig.bOSDHotKey); - - if (choice_ppshader) - { - if (vconfig.sPostProcessingShader.empty()) choice_ppshader->Select(0); - else choice_ppshader->SetStringSelection(wxString::FromAscii(vconfig.sPostProcessingShader.c_str())); - } + //for (auto i = m_settings.begin(), e = m_settings.end(); i != e; ++i) + // (*i)->UpdateUI(); } diff --git a/Source/Core/DolphinWX/Src/VideoConfigDiag.h b/Source/Core/DolphinWX/Src/VideoConfigDiag.h index 3d01af77d8..4d2f858a75 100644 --- a/Source/Core/DolphinWX/Src/VideoConfigDiag.h +++ b/Source/Core/DolphinWX/Src/VideoConfigDiag.h @@ -17,25 +17,40 @@ #include #include -template -class BoolSetting : public W +class SettingCheckBox : public wxCheckBox { public: - BoolSetting(wxWindow* parent, const wxString& label, const wxString& tooltip, bool &setting, bool reverse = false, long style = 0); + SettingCheckBox(wxWindow* parent, const wxString& label, const wxString& tooltip, + bool &setting, long style = 0); + + void UpdateValue(wxCommandEvent& ev) + { + int const val = Get3StateValue(); + *reinterpret_cast(&m_setting) = (u8)val; + ev.Skip(); + } + +private: + bool &m_setting; +}; + +class SettingRadioButton : public wxRadioButton +{ +public: + SettingRadioButton(wxWindow* parent, const wxString& label, const wxString& tooltip, + bool &setting, bool reverse = false, long style = 0); void UpdateValue(wxCommandEvent& ev) { m_setting = (ev.GetInt() != 0) ^ m_reverse; ev.Skip(); } + private: bool &m_setting; const bool m_reverse; }; -typedef BoolSetting SettingCheckBox; -typedef BoolSetting SettingRadioButton; - template class IntegerSetting : public wxSpinCtrl { @@ -47,6 +62,7 @@ public: m_setting = ev.GetInt(); ev.Skip(); } + private: T& m_setting; }; @@ -57,7 +73,9 @@ class SettingChoice : public wxChoice { public: SettingChoice(wxWindow* parent, int &setting, const wxString& tooltip, int num = 0, const wxString choices[] = NULL, long style = 0); + void UpdateValue(wxCommandEvent& ev); + private: int &m_setting; }; @@ -67,9 +85,9 @@ class CGameListCtrl; class VideoConfigDiag : public wxDialog { public: - VideoConfigDiag(wxWindow* parent, const std::string &title, const std::string& ininame); + VideoConfigDiag(wxWindow* parent, const std::string &title, bool is_game_config = false); -protected: +private: void Event_Backend(wxCommandEvent &ev) { ev.Skip(); } // TODO: Query list of supported AA modes void Event_Adapter(wxCommandEvent &ev) { ev.Skip(); } // TODO @@ -90,92 +108,10 @@ protected: void Event_ClickClose(wxCommandEvent&); void Event_Close(wxCloseEvent&); - void Event_OnProfileChange(wxCommandEvent& ev); - - // Enables/disables UI elements depending on current config - if appropriate also updates g_Config - void OnUpdateUI(wxUpdateUIEvent& ev); - // Refresh UI values from current config (used when reloading config) void SetUIValuesFromConfig(); - // Don't mess with keeping two comboboxes in sync, use only one CB instead.. - SettingChoice* profile_cb; // "General" tab - wxStaticText* profile_text; // "Advanced" tab - - wxChoice* choice_adapter; - wxChoice* choice_aspect; - SettingCheckBox* widescreen_hack; - SettingCheckBox* vsync; - - SettingChoice* anisotropic_filtering; - wxStaticText* text_aamode; - SettingChoice* choice_aamode; - - SettingCheckBox* native_mips; - SettingCheckBox* efb_scaled_copy; - SettingCheckBox* pixel_lighting; - SettingCheckBox* pixel_depth; - SettingCheckBox* force_filtering; - SettingCheckBox* _3d_vision; - - wxChoice* choice_efbscale; - SettingCheckBox* efbaccess_enable; - SettingCheckBox* emulate_efb_format_changes; - - SettingCheckBox* efbcopy_enable; - SettingRadioButton* efbcopy_texture; - SettingRadioButton* efbcopy_ram; - SettingCheckBox* cache_efb_copies; - - SettingCheckBox* stc_enable; - wxRadioButton* stc_safe; - wxRadioButton* stc_normal; - wxRadioButton* stc_fast; - - SettingCheckBox* wireframe; - SettingCheckBox* disable_lighting; - SettingCheckBox* disable_textures; - SettingCheckBox* disable_fog; - SettingCheckBox* disable_dst_alpha; - - SettingCheckBox* show_fps; - SettingCheckBox* overlay_stats; - SettingCheckBox* overlay_proj_stats; - SettingCheckBox* texfmt_overlay; - SettingCheckBox* efb_copy_regions; - SettingCheckBox* show_shader_errors; - SettingCheckBox* show_input_display; - - SettingCheckBox* enable_xfb; - SettingRadioButton* virtual_xfb; - SettingRadioButton* real_xfb; - - SettingCheckBox* dump_textures; - SettingCheckBox* hires_textures; - SettingCheckBox* dump_efb; - SettingCheckBox* dump_frames; - SettingCheckBox* free_look; - SettingCheckBox* frame_dumps_via_ffv1; - - SettingCheckBox* crop; - SettingCheckBox* opencl; - SettingCheckBox* dlcache; - SettingCheckBox* hotkeys; - SettingCheckBox* ompdecoder; - wxChoice* choice_ppshader; - - // TODO: Add options for - //vconfig.bTexFmtOverlayCenter - //vconfig.bAnaglyphStereo - //vconfig.iAnaglyphStereoSeparation - //vconfig.iAnaglyphFocalAngle - //vconfig.bShowEFBCopyRegions - //vconfig.iCompileDLsLevel - - VideoConfig vconfig; - std::string ininame; - int cur_profile; - const CGameListCtrl *GameListCtrl; + VideoConfig& vconfig; }; #endif diff --git a/Source/Core/VideoCommon/Src/TextureDecoder.cpp b/Source/Core/VideoCommon/Src/TextureDecoder.cpp index 85872a8b0e..3399d5f429 100644 --- a/Source/Core/VideoCommon/Src/TextureDecoder.cpp +++ b/Source/Core/VideoCommon/Src/TextureDecoder.cpp @@ -685,17 +685,13 @@ PC_TexFormat GetPC_TexFormat(int texformat, int tlutfmt) return PC_TEX_FMT_NONE; } -//switch endianness, unswizzle -//TODO: to save memory, don't blindly convert everything to argb8888 -//also ARGB order needs to be swapped later, to accommodate modern hardware better -//need to add DXT support too -PC_TexFormat TexDecoder_Decode_real(u8 *dst, const u8 *src, int width, int height, int texformat, int tlutaddr, int tlutfmt) +inline void SetOpenMPThreadCount(int width, int height) { #ifdef _OPENMP - //Dont use multithreading in small Textures - if ((width > 127 && height > 127) && g_ActiveConfig.bOMPDecoder) + // Dont use multithreading in small Textures + if (g_ActiveConfig.bOMPDecoder && width > 127 && height > 127) { - //don't span to many threads they will kill the rest of the emu :) + // don't span to many threads they will kill the rest of the emu :) omp_set_num_threads((cpu_info.num_cores + 2) / 3); } else @@ -703,8 +699,19 @@ PC_TexFormat TexDecoder_Decode_real(u8 *dst, const u8 *src, int width, int heigh omp_set_num_threads(1); } #endif - int Wsteps4 = (width + 3) / 4; - int Wsteps8 = (width + 7) / 8; +} + +//switch endianness, unswizzle +//TODO: to save memory, don't blindly convert everything to argb8888 +//also ARGB order needs to be swapped later, to accommodate modern hardware better +//need to add DXT support too +PC_TexFormat TexDecoder_Decode_real(u8 *dst, const u8 *src, int width, int height, int texformat, int tlutaddr, int tlutfmt) +{ + SetOpenMPThreadCount(width, height); + + const int Wsteps4 = (width + 3) / 4; + const int Wsteps8 = (width + 7) / 8; + switch (texformat) { case GX_TF_C4: @@ -967,19 +974,11 @@ PC_TexFormat TexDecoder_Decode_real(u8 *dst, const u8 *src, int width, int heigh PC_TexFormat TexDecoder_Decode_RGBA(u32 * dst, const u8 * src, int width, int height, int texformat, int tlutaddr, int tlutfmt) { -#ifdef _OPENMP - if ((width > 127 && height > 127) && g_ActiveConfig.bOMPDecoder) - { - //don't span to many threads they will kill the rest of the emu :) - omp_set_num_threads((cpu_info.num_cores + 2) / 3); - } - else - { - omp_set_num_threads(1); - } -#endif - int Wsteps4 = (width + 3) / 4; - int Wsteps8 = (width + 7) / 8; + SetOpenMPThreadCount(width, height); + + const int Wsteps4 = (width + 3) / 4; + const int Wsteps8 = (width + 7) / 8; + switch (texformat) { case GX_TF_C4: diff --git a/Source/Core/VideoCommon/Src/VertexLoader.cpp b/Source/Core/VideoCommon/Src/VertexLoader.cpp index 969c3bb2ff..ce9e81219d 100644 --- a/Source/Core/VideoCommon/Src/VertexLoader.cpp +++ b/Source/Core/VideoCommon/Src/VertexLoader.cpp @@ -296,9 +296,14 @@ void VertexLoader::CompileVertexTranslator() // Normals vtx_decl.num_normals = 0; - if (m_VtxDesc.Normal != NOT_PRESENT) { - m_VertexSize += VertexLoader_Normal::GetSize(m_VtxDesc.Normal, m_VtxAttr.NormalFormat, m_VtxAttr.NormalElements, m_VtxAttr.NormalIndex3); - TPipelineFunction pFunc = VertexLoader_Normal::GetFunction(m_VtxDesc.Normal, m_VtxAttr.NormalFormat, m_VtxAttr.NormalElements, m_VtxAttr.NormalIndex3, g_Config.backend_info.bAllowSignedBytes); + if (m_VtxDesc.Normal != NOT_PRESENT) + { + m_VertexSize += VertexLoader_Normal::GetSize(m_VtxDesc.Normal, + m_VtxAttr.NormalFormat, m_VtxAttr.NormalElements, m_VtxAttr.NormalIndex3); + + TPipelineFunction pFunc = VertexLoader_Normal::GetFunction(m_VtxDesc.Normal, + m_VtxAttr.NormalFormat, m_VtxAttr.NormalElements, m_VtxAttr.NormalIndex3); + if (pFunc == 0) { char temp[256]; diff --git a/Source/Core/VideoCommon/Src/VertexLoader_Normal.cpp b/Source/Core/VideoCommon/Src/VertexLoader_Normal.cpp index c49a23031b..830bd3de13 100644 --- a/Source/Core/VideoCommon/Src/VertexLoader_Normal.cpp +++ b/Source/Core/VideoCommon/Src/VertexLoader_Normal.cpp @@ -104,12 +104,14 @@ void VertexLoader_Normal::Init(void) m_Table[NRM_INDEX16][NRM_INDICES3][NRM_NBT3][FORMAT_FLOAT] = Set(6, Normal_Index16_Float3_Indices3); } -unsigned int VertexLoader_Normal::GetSize(unsigned int _type, unsigned int _format, unsigned int _elements, unsigned int _index3) +unsigned int VertexLoader_Normal::GetSize(unsigned int _type, + unsigned int _format, unsigned int _elements, unsigned int _index3) { return m_Table[_type][_index3][_elements][_format].gc_size; } -TPipelineFunction VertexLoader_Normal::GetFunction(unsigned int _type, unsigned int _format, unsigned int _elements, unsigned int _index3, bool allow_signed_bytes) +TPipelineFunction VertexLoader_Normal::GetFunction(unsigned int _type, + unsigned int _format, unsigned int _elements, unsigned int _index3) { TPipelineFunction pFunc = m_Table[_type][_index3][_elements][_format].function; return pFunc; diff --git a/Source/Core/VideoCommon/Src/VertexLoader_Normal.h b/Source/Core/VideoCommon/Src/VertexLoader_Normal.h index b74df88ee7..934cd1ec43 100644 --- a/Source/Core/VideoCommon/Src/VertexLoader_Normal.h +++ b/Source/Core/VideoCommon/Src/VertexLoader_Normal.h @@ -29,10 +29,12 @@ public: static void Init(void); // GetSize - static unsigned int GetSize(unsigned int _type, unsigned int _format, unsigned int _elements, unsigned int _index3); + static unsigned int GetSize(unsigned int _type, unsigned int _format, + unsigned int _elements, unsigned int _index3); // GetFunction - static TPipelineFunction GetFunction(unsigned int _type, unsigned int _format, unsigned int _elements, unsigned int _index3, bool allow_signed_bytes); + static TPipelineFunction GetFunction(unsigned int _type, + unsigned int _format, unsigned int _elements, unsigned int _index3); private: enum ENormalType diff --git a/Source/Core/VideoCommon/Src/VideoConfig.cpp b/Source/Core/VideoCommon/Src/VideoConfig.cpp index 71c90fb986..9e75a59fa9 100644 --- a/Source/Core/VideoCommon/Src/VideoConfig.cpp +++ b/Source/Core/VideoCommon/Src/VideoConfig.cpp @@ -41,7 +41,6 @@ VideoConfig::VideoConfig() // disable all features by default backend_info.APIType = API_NONE; - backend_info.bAllowSignedBytes = false; backend_info.bUseRGBATextures = false; backend_info.bSupports3DVision = false; } @@ -301,86 +300,168 @@ void VideoConfig::Save(const char *ini_file) iniFile.Save(ini_file); } -void VideoConfig::GameIniSave(const char* default_ini, const char* game_ini) +// haxhaxhax +static void SetUndetermined(bool& val) { - // wxWidgets doesn't provide us with a nice way to change 3-state checkboxes into 2-state ones - // This would allow us to make the "default config" dialog layout to be 2-state based, but the - // "game config" layout to be 3-state based (with the 3rd state being "use default") - // Since we can't do that, we instead just save anything which differs from the default config - // TODO: Make this less ugly + // lul, storing a u8 inside a bool + *reinterpret_cast(&val) = 2; +} - VideoConfig defCfg; - defCfg.Load(default_ini); +static void SetUndetermined(int& val) +{ + val = -1; +} - IniFile iniFile; - iniFile.Load(game_ini); +void VideoConfig::SetAllUndetermined() +{ + // video hardware + SetUndetermined(bVSync); + SetUndetermined(iAdapter); - #define SET_IF_DIFFERS(section, key, member) { if ((member) != (defCfg.member)) iniFile.Set((section), (key), (member)); else iniFile.DeleteKey((section), (key)); } + // video settings + SetUndetermined(bWidescreenHack); + SetUndetermined(iAspectRatio); + SetUndetermined(bCrop); + SetUndetermined(bUseXFB); + SetUndetermined(bUseRealXFB); + SetUndetermined(bUseNativeMips); - SET_IF_DIFFERS("Video_Hardware", "VSync", bVSync); - SET_IF_DIFFERS("Video_Settings", "wideScreenHack", bWidescreenHack); - SET_IF_DIFFERS("Video_Settings", "AspectRatio", iAspectRatio); - SET_IF_DIFFERS("Video_Settings", "Crop", bCrop); - SET_IF_DIFFERS("Video_Settings", "UseXFB", bUseXFB); - SET_IF_DIFFERS("Video_Settings", "UseRealXFB", bUseRealXFB); - SET_IF_DIFFERS("Video_Settings", "UseNativeMips", bUseNativeMips); + SetUndetermined(bSafeTextureCache); + SetUndetermined(iSafeTextureCache_ColorSamples); - SET_IF_DIFFERS("Video_Settings", "SafeTextureCache", bSafeTextureCache); - SET_IF_DIFFERS("Video_Settings", "SafeTextureCacheColorSamples", iSafeTextureCache_ColorSamples); + SetUndetermined(bShowFPS); + SetUndetermined(bShowInputDisplay); + SetUndetermined(bOverlayStats); + SetUndetermined(bOverlayProjStats); + SetUndetermined(bShowEFBCopyRegions); + SetUndetermined(iCompileDLsLevel); + SetUndetermined(bDumpTextures); + SetUndetermined(bHiresTextures); + SetUndetermined(bDumpEFBTarget); + SetUndetermined(bDumpFrames); + SetUndetermined(bFreeLook); + SetUndetermined(bUseFFV1); + SetUndetermined(bAnaglyphStereo); + SetUndetermined(iAnaglyphStereoSeparation); + SetUndetermined(iAnaglyphFocalAngle); + SetUndetermined(bEnablePixelLighting); + SetUndetermined(bEnablePerPixelDepth); - SET_IF_DIFFERS("Video_Settings", "ShowFPS", bShowFPS); - SET_IF_DIFFERS("Video_Settings", "ShowInputDisplay", bShowInputDisplay); - SET_IF_DIFFERS("Video_Settings", "OverlayStats", bOverlayStats); - SET_IF_DIFFERS("Video_Settings", "OverlayProjStats", bOverlayProjStats); - SET_IF_DIFFERS("Video_Settings", "ShowEFBCopyRegions", bShowEFBCopyRegions); - SET_IF_DIFFERS("Video_Settings", "DLOptimize", iCompileDLsLevel); - SET_IF_DIFFERS("Video_Settings", "DumpTextures", bDumpTextures); - SET_IF_DIFFERS("Video_Settings", "HiresTextures", bHiresTextures); - SET_IF_DIFFERS("Video_Settings", "DumpEFBTarget", bDumpEFBTarget); - SET_IF_DIFFERS("Video_Settings", "DumpFrames", bDumpFrames); - SET_IF_DIFFERS("Video_Settings", "FreeLook", bFreeLook); - SET_IF_DIFFERS("Video_Settings", "UseFFV1", bUseFFV1); - SET_IF_DIFFERS("Video_Settings", "AnaglyphStereo", bAnaglyphStereo); - SET_IF_DIFFERS("Video_Settings", "AnaglyphStereoSeparation", iAnaglyphStereoSeparation); - SET_IF_DIFFERS("Video_Settings", "AnaglyphFocalAngle", iAnaglyphFocalAngle); - SET_IF_DIFFERS("Video_Settings", "EnablePixelLighting", bEnablePixelLighting); - SET_IF_DIFFERS("Video_Settings", "EnablePerPixelDepth", bEnablePerPixelDepth); + SetUndetermined(bShowShaderErrors); + SetUndetermined(iMultisampleMode); + SetUndetermined(iEFBScale); - SET_IF_DIFFERS("Video_Settings", "ShowShaderErrors", bShowShaderErrors); - SET_IF_DIFFERS("Video_Settings", "MSAA", iMultisampleMode); - SET_IF_DIFFERS("Video_Settings", "EFBScale", iEFBScale); // integral + SetUndetermined(bDstAlphaPass); - SET_IF_DIFFERS("Video_Settings", "DstAlphaPass", bDstAlphaPass); + SetUndetermined(bTexFmtOverlayEnable); + SetUndetermined(bTexFmtOverlayCenter); + SetUndetermined(bWireFrame); + SetUndetermined(bDisableLighting); + SetUndetermined(bDisableTexturing); + SetUndetermined(bDisableFog); - SET_IF_DIFFERS("Video_Settings", "TexFmtOverlayEnable", bTexFmtOverlayEnable); - SET_IF_DIFFERS("Video_Settings", "TexFmtOverlayCenter", bTexFmtOverlayCenter); - SET_IF_DIFFERS("Video_Settings", "WireFrame", bWireFrame); - SET_IF_DIFFERS("Video_Settings", "DisableLighting", bDisableLighting); - SET_IF_DIFFERS("Video_Settings", "DisableTexturing", bDisableTexturing); - SET_IF_DIFFERS("Video_Settings", "DisableFog", bDisableFog); - - SET_IF_DIFFERS("Video_Settings", "EnableOpenCL", bEnableOpenCL); + SetUndetermined(bEnableOpenCL); #ifdef _OPENMP - SET_IF_DIFFERS("Video_Settings", "OMPDecoder", bOMPDecoder); + SetUndetermined(bOMPDecoder); #endif - SET_IF_DIFFERS("Video_Enhancements", "ForceFiltering", bForceFiltering); - SET_IF_DIFFERS("Video_Enhancements", "MaxAnisotropy", iMaxAnisotropy); // NOTE - this is x in (1 << x) - SET_IF_DIFFERS("Video_Enhancements", "PostProcessingShader", sPostProcessingShader); - SET_IF_DIFFERS("Video_Enhancements", "Enable3dVision", b3DVision); + // video enhancements + SetUndetermined(bForceFiltering); + SetUndetermined(iMaxAnisotropy); + //SetUndetermined(sPostProcessingShader); + SetUndetermined(b3DVision); - SET_IF_DIFFERS("Video_Hacks", "EFBAccessEnable", bEFBAccessEnable); - SET_IF_DIFFERS("Video_Hacks", "DlistCachingEnable", bDlistCachingEnable); - SET_IF_DIFFERS("Video_Hacks", "EFBCopyEnable", bEFBCopyEnable); - SET_IF_DIFFERS("Video_Hacks", "EFBCopyDisableHotKey", bOSDHotKey); - SET_IF_DIFFERS("Video_Hacks", "EFBToTextureEnable", bCopyEFBToTexture); - SET_IF_DIFFERS("Video_Hacks", "EFBScaledCopy", bCopyEFBScaled); - SET_IF_DIFFERS("Video_Hacks", "EFBCopyCacheEnable", bEFBCopyCacheEnable); - SET_IF_DIFFERS("Video_Hacks", "EFBEmulateFormatChanges", bEFBEmulateFormatChanges); + // video hacks + SetUndetermined(bEFBAccessEnable); + SetUndetermined(bDlistCachingEnable); + SetUndetermined(bEFBCopyEnable); + SetUndetermined(bOSDHotKey); + SetUndetermined(bCopyEFBToTexture); + SetUndetermined(bCopyEFBScaled); + SetUndetermined(bEFBCopyCacheEnable); + SetUndetermined(bEFBEmulateFormatChanges); - SET_IF_DIFFERS("Video_Hardware", "Adapter", iAdapter); + // this doesn't belong here, o well + backend_info = BackendInfo(); +} - iniFile.Save(game_ini); +void VideoConfig::GameIniSave(const char* game_ini) +{ + IniFile ini_file; + ini_file.Load(game_ini); + + // video hardware + IniFile::Section& vid_hardware = *ini_file.GetOrCreateSection("Video_Hardware"); + SetIfDetermined(vid_hardware, "VSync", bVSync); + SetIfDetermined(vid_hardware, "Adapter", iAdapter); + + // video settings + IniFile::Section& vid_settings = *ini_file.GetOrCreateSection("Video_Settings"); + SetIfDetermined(vid_settings, "wideScreenHack", bWidescreenHack); + SetIfDetermined(vid_settings, "AspectRatio", iAspectRatio); + SetIfDetermined(vid_settings, "Crop", bCrop); + SetIfDetermined(vid_settings, "UseXFB", bUseXFB); + SetIfDetermined(vid_settings, "UseRealXFB", bUseRealXFB); + SetIfDetermined(vid_settings, "UseNativeMips", bUseNativeMips); + + SetIfDetermined(vid_settings, "SafeTextureCache", bSafeTextureCache); + SetIfDetermined(vid_settings, "SafeTextureCacheColorSamples", iSafeTextureCache_ColorSamples); + + SetIfDetermined(vid_settings, "ShowFPS", bShowFPS); + SetIfDetermined(vid_settings, "ShowInputDisplay", bShowInputDisplay); + SetIfDetermined(vid_settings, "OverlayStats", bOverlayStats); + SetIfDetermined(vid_settings, "OverlayProjStats", bOverlayProjStats); + SetIfDetermined(vid_settings, "ShowEFBCopyRegions", bShowEFBCopyRegions); + SetIfDetermined(vid_settings, "DLOptimize", iCompileDLsLevel); + SetIfDetermined(vid_settings, "DumpTextures", bDumpTextures); + SetIfDetermined(vid_settings, "HiresTextures", bHiresTextures); + SetIfDetermined(vid_settings, "DumpEFBTarget", bDumpEFBTarget); + SetIfDetermined(vid_settings, "DumpFrames", bDumpFrames); + SetIfDetermined(vid_settings, "FreeLook", bFreeLook); + SetIfDetermined(vid_settings, "UseFFV1", bUseFFV1); + SetIfDetermined(vid_settings, "AnaglyphStereo", bAnaglyphStereo); + SetIfDetermined(vid_settings, "AnaglyphStereoSeparation", iAnaglyphStereoSeparation); + SetIfDetermined(vid_settings, "AnaglyphFocalAngle", iAnaglyphFocalAngle); + SetIfDetermined(vid_settings, "EnablePixelLighting", bEnablePixelLighting); + SetIfDetermined(vid_settings, "EnablePerPixelDepth", bEnablePerPixelDepth); + + SetIfDetermined(vid_settings, "ShowShaderErrors", bShowShaderErrors); + SetIfDetermined(vid_settings, "MSAA", iMultisampleMode); + SetIfDetermined(vid_settings, "EFBScale", iEFBScale); // integral + + SetIfDetermined(vid_settings, "DstAlphaPass", bDstAlphaPass); + + SetIfDetermined(vid_settings, "TexFmtOverlayEnable", bTexFmtOverlayEnable); + SetIfDetermined(vid_settings, "TexFmtOverlayCenter", bTexFmtOverlayCenter); + SetIfDetermined(vid_settings, "WireFrame", bWireFrame); + SetIfDetermined(vid_settings, "DisableLighting", bDisableLighting); + SetIfDetermined(vid_settings, "DisableTexturing", bDisableTexturing); + SetIfDetermined(vid_settings, "DisableFog", bDisableFog); + + SetIfDetermined(vid_settings, "EnableOpenCL", bEnableOpenCL); +#ifdef _OPENMP + SetIfDetermined(vid_settings, "OMPDecoder", bOMPDecoder); +#endif + + // video enhancements + IniFile::Section& vid_enhancements = *ini_file.GetOrCreateSection("Video_Enhancements"); + SetIfDetermined(vid_enhancements, "ForceFiltering", bForceFiltering); + SetIfDetermined(vid_enhancements, "MaxAnisotropy", iMaxAnisotropy); // NOTE - this is x in (1 << x) + //SetIfDetermined(vid_enhancements, "PostProcessingShader", sPostProcessingShader); + SetIfDetermined(vid_enhancements, "Enable3dVision", b3DVision); + + // video hacks + IniFile::Section& vid_hacks = *ini_file.GetOrCreateSection("Video_Hacks"); + SetIfDetermined(vid_hacks, "EFBAccessEnable", bEFBAccessEnable); + SetIfDetermined(vid_hacks, "DlistCachingEnable", bDlistCachingEnable); + SetIfDetermined(vid_hacks, "EFBCopyEnable", bEFBCopyEnable); + SetIfDetermined(vid_hacks, "EFBCopyDisableHotKey", bOSDHotKey); + SetIfDetermined(vid_hacks, "EFBToTextureEnable", bCopyEFBToTexture); + SetIfDetermined(vid_hacks, "EFBScaledCopy", bCopyEFBScaled); + SetIfDetermined(vid_hacks, "EFBCopyCacheEnable", bEFBCopyCacheEnable); + SetIfDetermined(vid_hacks, "EFBEmulateFormatChanges", bEFBEmulateFormatChanges); + + ini_file.Save(game_ini); } diff --git a/Source/Core/VideoCommon/Src/VideoConfig.h b/Source/Core/VideoCommon/Src/VideoConfig.h index 36c8f142cc..b66bc0b0aa 100644 --- a/Source/Core/VideoCommon/Src/VideoConfig.h +++ b/Source/Core/VideoCommon/Src/VideoConfig.h @@ -27,6 +27,7 @@ #include "Common.h" #include "VideoCommon.h" +#include "IniFile.h" #include #include @@ -66,9 +67,12 @@ struct VideoConfig void GameIniLoad(const char *ini_file); void VerifyValidity(); void Save(const char *ini_file); - void GameIniSave(const char* default_ini, const char* game_ini); + void GameIniSave(const char* game_ini); void UpdateProjectionHack(); + // some hacks used for per-game config + void SetAllUndetermined(); + // General bool bVSync; @@ -149,7 +153,7 @@ struct VideoConfig int iAdapter; // Static config per API - struct + struct BackendInfo { API_TYPE APIType; @@ -159,11 +163,33 @@ struct VideoConfig bool bUseRGBATextures; // used for D3D11 in TextureCache bool bSupports3DVision; - bool bAllowSignedBytes; // D3D9 doesn't support signed bytes (?) bool bSupportsDualSourceBlend; // only supported by D3D11 and OpenGL bool bSupportsFormatReinterpretation; bool bSupportsPixelLighting; } backend_info; + + // haxhaxhax + static bool IsUndetermined(const bool& val) + { + // lul, storing a u8 inside a bool + return (*reinterpret_cast(&val) > 1); + } + + static bool IsUndetermined(int val) + { + return (val < 0); + } + +private: + + template + void SetIfDetermined(IniFile::Section& sect, const char* key, const T& value) + { + if (IsUndetermined(value)) + sect.Delete(key); + else + sect.Set(key, value); + } }; extern VideoConfig g_Config; diff --git a/Source/Plugins/Plugin_VideoDX11/Src/VideoBackend.h b/Source/Plugins/Plugin_VideoDX11/Src/VideoBackend.h index 4c6de67ab1..74ff712323 100644 --- a/Source/Plugins/Plugin_VideoDX11/Src/VideoBackend.h +++ b/Source/Plugins/Plugin_VideoDX11/Src/VideoBackend.h @@ -9,6 +9,9 @@ namespace DX11 class VideoBackend : public VideoBackendHardware { +public: + VideoBackend() : VideoBackendHardware("gfx_dx11") {} + bool Initialize(void *&); void Shutdown(); diff --git a/Source/Plugins/Plugin_VideoDX11/Src/main.cpp b/Source/Plugins/Plugin_VideoDX11/Src/main.cpp index 6d9915f2c2..d601338abf 100644 --- a/Source/Plugins/Plugin_VideoDX11/Src/main.cpp +++ b/Source/Plugins/Plugin_VideoDX11/Src/main.cpp @@ -83,7 +83,6 @@ void InitBackendInfo() g_Config.backend_info.APIType = API_D3D11; g_Config.backend_info.bUseRGBATextures = true; // the GX formats barely match any D3D11 formats g_Config.backend_info.bSupports3DVision = false; - g_Config.backend_info.bAllowSignedBytes = true; g_Config.backend_info.bSupportsDualSourceBlend = true; g_Config.backend_info.bSupportsFormatReinterpretation = true; g_Config.backend_info.bSupportsPixelLighting = true; @@ -142,7 +141,7 @@ void VideoBackend::ShowConfig(void *_hParent) // Clear ppshaders string vector g_Config.backend_info.PPShaders.clear(); - VideoConfigDiag diag((wxWindow*)_hParent, _trans("Direct3D11"), "gfx_dx11"); + VideoConfigDiag diag((wxWindow*)_hParent, _trans("Direct3D11")); diag.ShowModal(); g_Config.backend_info.Adapters.clear(); @@ -157,7 +156,7 @@ bool VideoBackend::Initialize(void *&window_handle) frameCount = 0; - g_Config.Load((File::GetUserPath(D_CONFIG_IDX) + "gfx_dx11.ini").c_str()); + LoadConfig(); g_Config.GameIniLoad(SConfig::GetInstance().m_LocalCoreStartupParameter.m_strGameIni.c_str()); UpdateProjectionHack(g_Config.iPhackvalue, g_Config.sPhackvalue); UpdateActiveConfig(); diff --git a/Source/Plugins/Plugin_VideoDX9/Src/VideoBackend.h b/Source/Plugins/Plugin_VideoDX9/Src/VideoBackend.h index 77cbd14dae..175d66b089 100644 --- a/Source/Plugins/Plugin_VideoDX9/Src/VideoBackend.h +++ b/Source/Plugins/Plugin_VideoDX9/Src/VideoBackend.h @@ -9,6 +9,9 @@ namespace DX9 class VideoBackend : public VideoBackendHardware { +public: + VideoBackend() : VideoBackendHardware("gfx_dx9") {} + bool Initialize(void *&); void Shutdown(); diff --git a/Source/Plugins/Plugin_VideoDX9/Src/main.cpp b/Source/Plugins/Plugin_VideoDX9/Src/main.cpp index d93022e3b0..db7f70e5a9 100644 --- a/Source/Plugins/Plugin_VideoDX9/Src/main.cpp +++ b/Source/Plugins/Plugin_VideoDX9/Src/main.cpp @@ -89,13 +89,13 @@ std::string VideoBackend::GetName() void InitBackendInfo() { g_Config.backend_info.APIType = API_D3D9; - g_Config.backend_info.bUseRGBATextures = true; + g_Config.backend_info.bUseRGBATextures = false; g_Config.backend_info.bSupports3DVision = true; - g_Config.backend_info.bAllowSignedBytes = false; g_Config.backend_info.bSupportsDualSourceBlend = false; g_Config.backend_info.bSupportsFormatReinterpretation = true; - int shaderModel = ((DX9::D3D::GetCaps().PixelShaderVersion >> 8) & 0xFF); - int maxConstants = (shaderModel < 3) ? 32 : ((shaderModel < 4) ? 224 : 65536); + + const int shaderModel = ((DX9::D3D::GetCaps().PixelShaderVersion >> 8) & 0xFF); + const int maxConstants = (shaderModel < 3) ? 32 : ((shaderModel < 4) ? 224 : 65536); g_Config.backend_info.bSupportsPixelLighting = C_PLIGHTS + 40 <= maxConstants && C_PMATERIALS + 4 <= maxConstants; } @@ -123,7 +123,7 @@ void VideoBackend::ShowConfig(void* parent) // Clear ppshaders string vector g_Config.backend_info.PPShaders.clear(); - VideoConfigDiag diag((wxWindow*)parent, _trans("Direct3D9"), "gfx_dx9"); + VideoConfigDiag diag((wxWindow*)parent, _trans("Direct3D9")); diag.ShowModal(); g_Config.backend_info.Adapters.clear(); @@ -137,7 +137,7 @@ bool VideoBackend::Initialize(void *&window_handle) frameCount = 0; - g_Config.Load((File::GetUserPath(D_CONFIG_IDX) + "gfx_dx9.ini").c_str()); + LoadConfig(); g_Config.GameIniLoad(SConfig::GetInstance().m_LocalCoreStartupParameter.m_strGameIni.c_str()); UpdateProjectionHack(g_Config.iPhackvalue, g_Config.sPhackvalue); // DX9 projection hack could be disabled by commenting out this line UpdateActiveConfig(); diff --git a/Source/Plugins/Plugin_VideoOGL/Src/VideoBackend.h b/Source/Plugins/Plugin_VideoOGL/Src/VideoBackend.h index 4c7414794d..e65bc19aa4 100644 --- a/Source/Plugins/Plugin_VideoOGL/Src/VideoBackend.h +++ b/Source/Plugins/Plugin_VideoOGL/Src/VideoBackend.h @@ -9,6 +9,9 @@ namespace OGL class VideoBackend : public VideoBackendHardware { +public: + VideoBackend() : VideoBackendHardware("gfx_opengl") {} + bool Initialize(void *&); void Shutdown(); diff --git a/Source/Plugins/Plugin_VideoOGL/Src/main.cpp b/Source/Plugins/Plugin_VideoOGL/Src/main.cpp index 7e44f615f1..e156d2229c 100644 --- a/Source/Plugins/Plugin_VideoOGL/Src/main.cpp +++ b/Source/Plugins/Plugin_VideoOGL/Src/main.cpp @@ -132,7 +132,6 @@ void InitBackendInfo() g_Config.backend_info.APIType = API_OPENGL; g_Config.backend_info.bUseRGBATextures = false; g_Config.backend_info.bSupports3DVision = false; - g_Config.backend_info.bAllowSignedBytes = true; g_Config.backend_info.bSupportsDualSourceBlend = false; // supported, but broken g_Config.backend_info.bSupportsFormatReinterpretation = false; g_Config.backend_info.bSupportsPixelLighting = true; @@ -150,7 +149,7 @@ void VideoBackend::ShowConfig(void *_hParent) // pp shaders GetShaders(g_Config.backend_info.PPShaders); - VideoConfigDiag diag((wxWindow*)_hParent, "OpenGL", "gfx_opengl"); + VideoConfigDiag diag((wxWindow*)_hParent, "OpenGL"); diag.ShowModal(); #endif } @@ -161,7 +160,7 @@ bool VideoBackend::Initialize(void *&window_handle) frameCount = 0; - g_Config.Load((File::GetUserPath(D_CONFIG_IDX) + "gfx_opengl.ini").c_str()); + LoadConfig(); g_Config.GameIniLoad(SConfig::GetInstance().m_LocalCoreStartupParameter.m_strGameIni.c_str()); g_Config.UpdateProjectionHack(); diff --git a/Source/Plugins/Plugin_VideoSoftware/Src/SWVertexLoader.cpp b/Source/Plugins/Plugin_VideoSoftware/Src/SWVertexLoader.cpp index f147efd79c..0e2cc7f99f 100644 --- a/Source/Plugins/Plugin_VideoSoftware/Src/SWVertexLoader.cpp +++ b/Source/Plugins/Plugin_VideoSoftware/Src/SWVertexLoader.cpp @@ -168,8 +168,12 @@ void SWVertexLoader::SetFormat(u8 attributeIndex, u8 primitiveType) // Normals if (g_VtxDesc.Normal != NOT_PRESENT) { - m_VertexSize += VertexLoader_Normal::GetSize(g_VtxDesc.Normal, m_CurrentVat->g0.NormalFormat, m_CurrentVat->g0.NormalElements, m_CurrentVat->g0.NormalIndex3); - m_normalLoader = VertexLoader_Normal::GetFunction(g_VtxDesc.Normal, m_CurrentVat->g0.NormalFormat, m_CurrentVat->g0.NormalElements, m_CurrentVat->g0.NormalIndex3, true); + m_VertexSize += VertexLoader_Normal::GetSize(g_VtxDesc.Normal, + m_CurrentVat->g0.NormalFormat, m_CurrentVat->g0.NormalElements, m_CurrentVat->g0.NormalIndex3); + + m_normalLoader = VertexLoader_Normal::GetFunction(g_VtxDesc.Normal, + m_CurrentVat->g0.NormalFormat, m_CurrentVat->g0.NormalElements, m_CurrentVat->g0.NormalIndex3); + if (m_normalLoader == 0) { ERROR_LOG(VIDEO, "VertexLoader_Normal::GetFunction returned zero!"); diff --git a/Source/Plugins/Plugin_VideoSoftware/Src/SWmain.cpp b/Source/Plugins/Plugin_VideoSoftware/Src/SWmain.cpp index 7b0fb4e5da..08ce0cec63 100644 --- a/Source/Plugins/Plugin_VideoSoftware/Src/SWmain.cpp +++ b/Source/Plugins/Plugin_VideoSoftware/Src/SWmain.cpp @@ -67,7 +67,7 @@ void VideoSoftware::ShowConfig(void *_hParent) bool VideoSoftware::Initialize(void *&window_handle) { - g_SWVideoConfig.Load((File::GetUserPath(D_CONFIG_IDX) + "gfx_software.ini").c_str()); + LoadConfig(); if (!OpenGL_Create(window_handle)) { diff --git a/Source/Plugins/Plugin_VideoSoftware/Src/VideoBackend.h b/Source/Plugins/Plugin_VideoSoftware/Src/VideoBackend.h index 08b4c155ad..f7643fc507 100644 --- a/Source/Plugins/Plugin_VideoSoftware/Src/VideoBackend.h +++ b/Source/Plugins/Plugin_VideoSoftware/Src/VideoBackend.h @@ -9,6 +9,9 @@ namespace SW class VideoSoftware : public VideoBackend { +public: + VideoSoftware() : VideoBackend("gfx_software") {} + bool Initialize(void *&); void Shutdown();