2013-04-18 03:09:55 +00:00
|
|
|
// Copyright 2013 Dolphin Emulator Project
|
|
|
|
// Licensed under GPLv2
|
|
|
|
// Refer to the license.txt file included.
|
2008-12-08 05:25:12 +00:00
|
|
|
|
2009-09-13 08:21:35 +00:00
|
|
|
#include <cmath>
|
|
|
|
|
2014-09-08 01:06:58 +00:00
|
|
|
#include "Common/CommonTypes.h"
|
2014-02-17 10:18:15 +00:00
|
|
|
#include "Common/FileUtil.h"
|
|
|
|
#include "Common/IniFile.h"
|
2014-07-06 19:33:08 +00:00
|
|
|
#include "Common/StringUtil.h"
|
2014-02-17 10:18:15 +00:00
|
|
|
#include "Core/ConfigManager.h"
|
|
|
|
#include "Core/Core.h"
|
|
|
|
#include "Core/Movie.h"
|
|
|
|
#include "VideoCommon/OnScreenDisplay.h"
|
|
|
|
#include "VideoCommon/VideoCommon.h"
|
2014-02-19 01:27:20 +00:00
|
|
|
#include "VideoCommon/VideoConfig.h"
|
2008-12-08 05:25:12 +00:00
|
|
|
|
2009-09-13 10:18:01 +00:00
|
|
|
VideoConfig g_Config;
|
|
|
|
VideoConfig g_ActiveConfig;
|
2009-09-13 08:21:35 +00:00
|
|
|
|
2010-06-05 01:38:22 +00:00
|
|
|
void UpdateActiveConfig()
|
2009-09-13 08:21:35 +00:00
|
|
|
{
|
2013-05-21 23:20:22 +00:00
|
|
|
if (Movie::IsPlayingInput() && Movie::IsConfigSaved())
|
|
|
|
Movie::SetGraphicsConfig();
|
2009-09-13 08:21:35 +00:00
|
|
|
g_ActiveConfig = g_Config;
|
|
|
|
}
|
2008-12-08 05:25:12 +00:00
|
|
|
|
2009-09-13 10:18:01 +00:00
|
|
|
VideoConfig::VideoConfig()
|
2008-12-08 05:25:12 +00:00
|
|
|
{
|
2009-09-06 15:11:21 +00:00
|
|
|
bRunning = false;
|
2014-06-18 13:04:23 +00:00
|
|
|
bFullscreen = false;
|
2010-11-21 14:47:28 +00:00
|
|
|
|
2010-04-04 22:52:27 +00:00
|
|
|
// Needed for the first frame, I think
|
|
|
|
fAspectRatioHackW = 1;
|
|
|
|
fAspectRatioHackH = 1;
|
2010-11-21 14:47:28 +00:00
|
|
|
|
|
|
|
// disable all features by default
|
|
|
|
backend_info.APIType = API_NONE;
|
2013-02-18 16:14:56 +00:00
|
|
|
backend_info.bUseMinimalMipCount = false;
|
2014-07-19 18:18:03 +00:00
|
|
|
backend_info.bSupportsExclusiveFullscreen = false;
|
2014-11-24 11:01:21 +00:00
|
|
|
|
|
|
|
// Game-specific stereoscopy settings
|
|
|
|
bStereoMonoEFBDepth = false;
|
2014-11-24 11:19:25 +00:00
|
|
|
iStereoSeparationPercent = 100;
|
|
|
|
iStereoConvergencePercent = 100;
|
2008-12-08 05:25:12 +00:00
|
|
|
}
|
|
|
|
|
2014-03-12 19:33:41 +00:00
|
|
|
void VideoConfig::Load(const std::string& ini_file)
|
2008-12-08 05:25:12 +00:00
|
|
|
{
|
2010-06-05 01:38:22 +00:00
|
|
|
IniFile iniFile;
|
2011-04-25 20:06:45 +00:00
|
|
|
iniFile.Load(ini_file);
|
2013-03-20 01:51:12 +00:00
|
|
|
|
2014-06-16 05:12:43 +00:00
|
|
|
IniFile::Section* hardware = iniFile.GetOrCreateSection("Hardware");
|
|
|
|
hardware->Get("VSync", &bVSync, 0);
|
|
|
|
hardware->Get("Adapter", &iAdapter, 0);
|
|
|
|
|
|
|
|
IniFile::Section* settings = iniFile.GetOrCreateSection("Settings");
|
|
|
|
settings->Get("wideScreenHack", &bWidescreenHack, false);
|
|
|
|
settings->Get("AspectRatio", &iAspectRatio, (int)ASPECT_AUTO);
|
|
|
|
settings->Get("Crop", &bCrop, false);
|
|
|
|
settings->Get("UseXFB", &bUseXFB, 0);
|
|
|
|
settings->Get("UseRealXFB", &bUseRealXFB, 0);
|
|
|
|
settings->Get("SafeTextureCacheColorSamples", &iSafeTextureCache_ColorSamples,128);
|
|
|
|
settings->Get("ShowFPS", &bShowFPS, false);
|
2014-07-09 15:03:17 +00:00
|
|
|
settings->Get("LogRenderTimeToFile", &bLogRenderTimeToFile, false);
|
2014-06-16 05:12:43 +00:00
|
|
|
settings->Get("OverlayStats", &bOverlayStats, false);
|
|
|
|
settings->Get("OverlayProjStats", &bOverlayProjStats, false);
|
|
|
|
settings->Get("ShowEFBCopyRegions", &bShowEFBCopyRegions, false);
|
|
|
|
settings->Get("DumpTextures", &bDumpTextures, 0);
|
|
|
|
settings->Get("HiresTextures", &bHiresTextures, 0);
|
|
|
|
settings->Get("DumpEFBTarget", &bDumpEFBTarget, 0);
|
|
|
|
settings->Get("FreeLook", &bFreeLook, 0);
|
|
|
|
settings->Get("UseFFV1", &bUseFFV1, 0);
|
|
|
|
settings->Get("EnablePixelLighting", &bEnablePixelLighting, 0);
|
|
|
|
settings->Get("FastDepthCalc", &bFastDepthCalc, true);
|
|
|
|
settings->Get("MSAA", &iMultisampleMode, 0);
|
|
|
|
settings->Get("EFBScale", &iEFBScale, (int) SCALE_1X); // native
|
|
|
|
settings->Get("DstAlphaPass", &bDstAlphaPass, false);
|
|
|
|
settings->Get("TexFmtOverlayEnable", &bTexFmtOverlayEnable, 0);
|
|
|
|
settings->Get("TexFmtOverlayCenter", &bTexFmtOverlayCenter, 0);
|
|
|
|
settings->Get("WireFrame", &bWireFrame, 0);
|
|
|
|
settings->Get("DisableFog", &bDisableFog, 0);
|
|
|
|
settings->Get("EnableShaderDebugging", &bEnableShaderDebugging, false);
|
2014-07-26 10:43:49 +00:00
|
|
|
settings->Get("BorderlessFullscreen", &bBorderlessFullscreen, false);
|
2014-06-16 05:12:43 +00:00
|
|
|
|
|
|
|
IniFile::Section* enhancements = iniFile.GetOrCreateSection("Enhancements");
|
|
|
|
enhancements->Get("ForceFiltering", &bForceFiltering, 0);
|
|
|
|
enhancements->Get("MaxAnisotropy", &iMaxAnisotropy, 0); // NOTE - this is x in (1 << x)
|
|
|
|
enhancements->Get("PostProcessingShader", &sPostProcessingShader, "");
|
2014-11-10 23:53:03 +00:00
|
|
|
enhancements->Get("StereoMode", &iStereoMode, 0);
|
2014-11-27 14:28:00 +00:00
|
|
|
enhancements->Get("StereoSeparation", &iStereoSeparation, 20);
|
|
|
|
enhancements->Get("StereoConvergence", &iStereoConvergence, 20);
|
2014-11-10 23:53:03 +00:00
|
|
|
enhancements->Get("StereoSwapEyes", &bStereoSwapEyes, false);
|
2014-06-16 05:12:43 +00:00
|
|
|
|
|
|
|
IniFile::Section* hacks = iniFile.GetOrCreateSection("Hacks");
|
|
|
|
hacks->Get("EFBAccessEnable", &bEFBAccessEnable, true);
|
|
|
|
hacks->Get("EFBCopyEnable", &bEFBCopyEnable, true);
|
|
|
|
hacks->Get("EFBToTextureEnable", &bCopyEFBToTexture, true);
|
|
|
|
hacks->Get("EFBScaledCopy", &bCopyEFBScaled, true);
|
|
|
|
hacks->Get("EFBCopyCacheEnable", &bEFBCopyCacheEnable, false);
|
|
|
|
hacks->Get("EFBEmulateFormatChanges", &bEFBEmulateFormatChanges, false);
|
2011-04-25 20:06:45 +00:00
|
|
|
|
2009-06-04 21:21:07 +00:00
|
|
|
// Load common settings
|
2010-02-02 21:56:29 +00:00
|
|
|
iniFile.Load(File::GetUserPath(F_DOLPHINCONFIG_IDX));
|
2014-06-16 05:12:43 +00:00
|
|
|
IniFile::Section* interface = iniFile.GetOrCreateSection("Interface");
|
2009-06-04 21:21:07 +00:00
|
|
|
bool bTmp;
|
2014-06-16 05:12:43 +00:00
|
|
|
interface->Get("UsePanicHandlers", &bTmp, true);
|
2009-06-04 21:21:07 +00:00
|
|
|
SetEnableAlert(bTmp);
|
2013-08-17 21:48:06 +00:00
|
|
|
|
|
|
|
// Shader Debugging causes a huge slowdown and it's easy to forget about it
|
|
|
|
// since it's not exposed in the settings dialog. It's only used by
|
|
|
|
// developers, so displaying an obnoxious message avoids some confusion and
|
|
|
|
// is not too annoying/confusing for users.
|
|
|
|
//
|
|
|
|
// XXX(delroth): This is kind of a bad place to put this, but the current
|
|
|
|
// VideoCommon is a mess and we don't have a central initialization
|
|
|
|
// function to do these kind of checks. Instead, the init code is
|
|
|
|
// triplicated for each video backend.
|
|
|
|
if (bEnableShaderDebugging)
|
|
|
|
OSD::AddMessage("Warning: Shader Debugging is enabled, performance will suffer heavily", 15000);
|
2008-12-08 05:25:12 +00:00
|
|
|
}
|
|
|
|
|
2013-09-23 06:39:14 +00:00
|
|
|
void VideoConfig::GameIniLoad()
|
2009-06-28 16:47:14 +00:00
|
|
|
{
|
2013-09-04 21:21:45 +00:00
|
|
|
bool gfx_override_exists = false;
|
|
|
|
|
|
|
|
// XXX: Again, bad place to put OSD messages at (see delroth's comment above)
|
|
|
|
// XXX: This will add an OSD message for each projection hack value... meh
|
2013-09-07 21:02:49 +00:00
|
|
|
#define CHECK_SETTING(section, key, var) do { \
|
2013-09-04 21:21:45 +00:00
|
|
|
decltype(var) temp = var; \
|
|
|
|
if (iniFile.GetIfExists(section, key, &var) && var != temp) { \
|
2014-07-06 19:33:08 +00:00
|
|
|
std::string msg = StringFromFormat("Note: Option \"%s\" is overridden by game ini.", key); \
|
|
|
|
OSD::AddMessage(msg, 7500); \
|
2013-09-04 21:21:45 +00:00
|
|
|
gfx_override_exists = true; \
|
|
|
|
} \
|
2013-09-07 21:02:49 +00:00
|
|
|
} while (0)
|
2013-09-04 21:21:45 +00:00
|
|
|
|
2013-09-23 06:39:14 +00:00
|
|
|
IniFile iniFile = SConfig::GetInstance().m_LocalCoreStartupParameter.LoadGameIni();
|
2011-02-13 22:36:12 +00:00
|
|
|
|
2013-09-04 21:21:45 +00:00
|
|
|
CHECK_SETTING("Video_Hardware", "VSync", bVSync);
|
|
|
|
|
|
|
|
CHECK_SETTING("Video_Settings", "wideScreenHack", bWidescreenHack);
|
|
|
|
CHECK_SETTING("Video_Settings", "AspectRatio", iAspectRatio);
|
|
|
|
CHECK_SETTING("Video_Settings", "Crop", bCrop);
|
|
|
|
CHECK_SETTING("Video_Settings", "UseXFB", bUseXFB);
|
|
|
|
CHECK_SETTING("Video_Settings", "UseRealXFB", bUseRealXFB);
|
|
|
|
CHECK_SETTING("Video_Settings", "SafeTextureCacheColorSamples", iSafeTextureCache_ColorSamples);
|
|
|
|
CHECK_SETTING("Video_Settings", "HiresTextures", bHiresTextures);
|
|
|
|
CHECK_SETTING("Video_Settings", "EnablePixelLighting", bEnablePixelLighting);
|
|
|
|
CHECK_SETTING("Video_Settings", "FastDepthCalc", bFastDepthCalc);
|
|
|
|
CHECK_SETTING("Video_Settings", "MSAA", iMultisampleMode);
|
2013-04-08 07:05:12 +00:00
|
|
|
int tmp = -9000;
|
2013-09-04 21:21:45 +00:00
|
|
|
CHECK_SETTING("Video_Settings", "EFBScale", tmp); // integral
|
2013-04-08 07:11:45 +00:00
|
|
|
if (tmp != -9000)
|
2013-04-05 21:13:48 +00:00
|
|
|
{
|
2013-04-08 07:11:45 +00:00
|
|
|
if (tmp != SCALE_FORCE_INTEGRAL)
|
2013-04-24 13:21:54 +00:00
|
|
|
{
|
2013-04-08 07:11:45 +00:00
|
|
|
iEFBScale = tmp;
|
2013-04-24 13:21:54 +00:00
|
|
|
}
|
|
|
|
else // Round down to multiple of native IR
|
2013-04-05 21:13:48 +00:00
|
|
|
{
|
2013-04-08 07:11:45 +00:00
|
|
|
switch (iEFBScale)
|
|
|
|
{
|
|
|
|
case SCALE_AUTO:
|
|
|
|
iEFBScale = SCALE_AUTO_INTEGRAL;
|
|
|
|
break;
|
|
|
|
case SCALE_1_5X:
|
|
|
|
iEFBScale = SCALE_1X;
|
|
|
|
break;
|
|
|
|
case SCALE_2_5X:
|
|
|
|
iEFBScale = SCALE_2X;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2013-04-05 21:13:48 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-09-04 21:21:45 +00:00
|
|
|
CHECK_SETTING("Video_Settings", "DstAlphaPass", bDstAlphaPass);
|
|
|
|
CHECK_SETTING("Video_Settings", "DisableFog", bDisableFog);
|
|
|
|
|
|
|
|
CHECK_SETTING("Video_Enhancements", "ForceFiltering", bForceFiltering);
|
|
|
|
CHECK_SETTING("Video_Enhancements", "MaxAnisotropy", iMaxAnisotropy); // NOTE - this is x in (1 << x)
|
|
|
|
CHECK_SETTING("Video_Enhancements", "PostProcessingShader", sPostProcessingShader);
|
2014-11-10 23:53:03 +00:00
|
|
|
CHECK_SETTING("Video_Enhancements", "StereoMode", iStereoMode);
|
|
|
|
CHECK_SETTING("Video_Enhancements", "StereoSeparation", iStereoSeparation);
|
2014-11-24 10:50:35 +00:00
|
|
|
CHECK_SETTING("Video_Enhancements", "StereoConvergence", iStereoConvergence);
|
2014-11-10 23:53:03 +00:00
|
|
|
CHECK_SETTING("Video_Enhancements", "StereoSwapEyes", bStereoSwapEyes);
|
2014-11-24 11:01:21 +00:00
|
|
|
|
|
|
|
CHECK_SETTING("Video_Stereoscopy", "StereoMonoEFBDepth", bStereoMonoEFBDepth);
|
2014-11-24 11:19:25 +00:00
|
|
|
CHECK_SETTING("Video_Stereoscopy", "StereoSeparationPercent", iStereoSeparationPercent);
|
|
|
|
CHECK_SETTING("Video_Stereoscopy", "StereoConvergencePercent", iStereoConvergencePercent);
|
2013-09-04 21:21:45 +00:00
|
|
|
|
|
|
|
CHECK_SETTING("Video_Hacks", "EFBAccessEnable", bEFBAccessEnable);
|
|
|
|
CHECK_SETTING("Video_Hacks", "EFBCopyEnable", bEFBCopyEnable);
|
|
|
|
CHECK_SETTING("Video_Hacks", "EFBToTextureEnable", bCopyEFBToTexture);
|
|
|
|
CHECK_SETTING("Video_Hacks", "EFBScaledCopy", bCopyEFBScaled);
|
|
|
|
CHECK_SETTING("Video_Hacks", "EFBCopyCacheEnable", bEFBCopyCacheEnable);
|
|
|
|
CHECK_SETTING("Video_Hacks", "EFBEmulateFormatChanges", bEFBEmulateFormatChanges);
|
|
|
|
|
2013-09-18 10:27:50 +00:00
|
|
|
CHECK_SETTING("Video", "ProjectionHack", iPhackvalue[0]);
|
2013-09-04 21:21:45 +00:00
|
|
|
CHECK_SETTING("Video", "PH_SZNear", iPhackvalue[1]);
|
|
|
|
CHECK_SETTING("Video", "PH_SZFar", iPhackvalue[2]);
|
|
|
|
CHECK_SETTING("Video", "PH_ZNear", sPhackvalue[0]);
|
|
|
|
CHECK_SETTING("Video", "PH_ZFar", sPhackvalue[1]);
|
|
|
|
CHECK_SETTING("Video", "PerfQueriesEnable", bPerfQueriesEnable);
|
|
|
|
|
|
|
|
if (gfx_override_exists)
|
|
|
|
OSD::AddMessage("Warning: Opening the graphics configuration will reset settings and might cause issues!", 10000);
|
2011-02-13 13:42:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void VideoConfig::VerifyValidity()
|
|
|
|
{
|
|
|
|
// TODO: Check iMaxAnisotropy value
|
2011-04-25 20:06:45 +00:00
|
|
|
if (iAdapter < 0 || iAdapter > ((int)backend_info.Adapters.size() - 1)) iAdapter = 0;
|
2011-02-13 22:36:12 +00:00
|
|
|
if (iMultisampleMode < 0 || iMultisampleMode >= (int)backend_info.AAModes.size()) iMultisampleMode = 0;
|
2014-12-16 23:26:03 +00:00
|
|
|
if (!backend_info.bSupportsGeometryShaders) iStereoMode = 0;
|
2009-03-20 11:51:22 +00:00
|
|
|
}
|
|
|
|
|
2014-03-12 19:33:41 +00:00
|
|
|
void VideoConfig::Save(const std::string& ini_file)
|
2008-12-08 05:25:12 +00:00
|
|
|
{
|
2010-06-05 01:38:22 +00:00
|
|
|
IniFile iniFile;
|
|
|
|
iniFile.Load(ini_file);
|
2014-06-16 05:12:43 +00:00
|
|
|
|
|
|
|
IniFile::Section* hardware = iniFile.GetOrCreateSection("Hardware");
|
|
|
|
hardware->Set("VSync", bVSync);
|
|
|
|
hardware->Set("Adapter", iAdapter);
|
|
|
|
|
|
|
|
IniFile::Section* settings = iniFile.GetOrCreateSection("Settings");
|
|
|
|
settings->Set("AspectRatio", iAspectRatio);
|
|
|
|
settings->Set("Crop", bCrop);
|
|
|
|
settings->Set("wideScreenHack", bWidescreenHack);
|
|
|
|
settings->Set("UseXFB", bUseXFB);
|
|
|
|
settings->Set("UseRealXFB", bUseRealXFB);
|
|
|
|
settings->Set("SafeTextureCacheColorSamples", iSafeTextureCache_ColorSamples);
|
|
|
|
settings->Set("ShowFPS", bShowFPS);
|
2014-07-09 15:03:17 +00:00
|
|
|
settings->Set("LogRenderTimeToFile", bLogRenderTimeToFile);
|
2014-06-16 05:12:43 +00:00
|
|
|
settings->Set("OverlayStats", bOverlayStats);
|
|
|
|
settings->Set("OverlayProjStats", bOverlayProjStats);
|
|
|
|
settings->Set("DumpTextures", bDumpTextures);
|
|
|
|
settings->Set("HiresTextures", bHiresTextures);
|
|
|
|
settings->Set("DumpEFBTarget", bDumpEFBTarget);
|
|
|
|
settings->Set("FreeLook", bFreeLook);
|
|
|
|
settings->Set("UseFFV1", bUseFFV1);
|
|
|
|
settings->Set("EnablePixelLighting", bEnablePixelLighting);
|
|
|
|
settings->Set("FastDepthCalc", bFastDepthCalc);
|
|
|
|
settings->Set("ShowEFBCopyRegions", bShowEFBCopyRegions);
|
|
|
|
settings->Set("MSAA", iMultisampleMode);
|
|
|
|
settings->Set("EFBScale", iEFBScale);
|
|
|
|
settings->Set("TexFmtOverlayEnable", bTexFmtOverlayEnable);
|
|
|
|
settings->Set("TexFmtOverlayCenter", bTexFmtOverlayCenter);
|
|
|
|
settings->Set("Wireframe", bWireFrame);
|
|
|
|
settings->Set("DstAlphaPass", bDstAlphaPass);
|
|
|
|
settings->Set("DisableFog", bDisableFog);
|
|
|
|
settings->Set("EnableShaderDebugging", bEnableShaderDebugging);
|
2014-07-26 10:43:49 +00:00
|
|
|
settings->Set("BorderlessFullscreen", bBorderlessFullscreen);
|
2014-06-16 05:12:43 +00:00
|
|
|
|
|
|
|
IniFile::Section* enhancements = iniFile.GetOrCreateSection("Enhancements");
|
|
|
|
enhancements->Set("ForceFiltering", bForceFiltering);
|
|
|
|
enhancements->Set("MaxAnisotropy", iMaxAnisotropy);
|
|
|
|
enhancements->Set("PostProcessingShader", sPostProcessingShader);
|
2014-11-10 23:53:03 +00:00
|
|
|
enhancements->Set("StereoMode", iStereoMode);
|
|
|
|
enhancements->Set("StereoSeparation", iStereoSeparation);
|
2014-11-24 10:50:35 +00:00
|
|
|
enhancements->Set("StereoConvergence", iStereoConvergence);
|
2014-11-10 23:53:03 +00:00
|
|
|
enhancements->Set("StereoSwapEyes", bStereoSwapEyes);
|
2014-06-16 05:12:43 +00:00
|
|
|
|
|
|
|
IniFile::Section* hacks = iniFile.GetOrCreateSection("Hacks");
|
|
|
|
hacks->Set("EFBAccessEnable", bEFBAccessEnable);
|
|
|
|
hacks->Set("EFBCopyEnable", bEFBCopyEnable);
|
|
|
|
hacks->Set("EFBToTextureEnable", bCopyEFBToTexture);
|
|
|
|
hacks->Set("EFBScaledCopy", bCopyEFBScaled);
|
|
|
|
hacks->Set("EFBCopyCacheEnable", bEFBCopyCacheEnable);
|
|
|
|
hacks->Set("EFBEmulateFormatChanges", bEFBEmulateFormatChanges);
|
2013-03-20 01:51:12 +00:00
|
|
|
|
2010-06-05 01:38:22 +00:00
|
|
|
iniFile.Save(ini_file);
|
2009-09-13 08:21:35 +00:00
|
|
|
}
|
|
|
|
|
2013-03-19 00:41:45 +00:00
|
|
|
bool VideoConfig::IsVSync()
|
|
|
|
{
|
2014-04-30 10:50:29 +00:00
|
|
|
return bVSync && !Core::GetIsFramelimiterTempDisabled();
|
2013-03-19 00:41:45 +00:00
|
|
|
}
|