Lots of code and warning cleanup. OGL/D3D: Moved to a shared config class in VideoCommon. This lets VideoCommon code read the config without ugly hacks. Fixed various config race conditions by keeping a copy (g_ActiveConfig) of the g_Config struct which is updated once per frame.

git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@4256 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
hrydgard
2009-09-13 08:21:35 +00:00
parent 52ea8a0fd1
commit 700f2ff694
44 changed files with 613 additions and 856 deletions

View File

@ -119,9 +119,9 @@ void SetColorMask(const BPCmd &bp)
void CopyEFB(const BPCmd &bp, const EFBRectangle &rc, const u32 &address, const bool &fromZBuffer, const bool &isIntensityFmt, const u32 &copyfmt, const int &scaleByHalf)
{
// bpmem.zcontrol.pixel_format to PIXELFMT_Z24 is when the game wants to copy from ZBuffer (Zbuffer uses 24-bit Format)
if (!g_Config.bEFBCopyDisable)
if (!g_ActiveConfig.bEFBCopyDisable)
{
if (g_Config.bCopyEFBToRAM) // To RAM
if (g_ActiveConfig.bCopyEFBToRAM) // To RAM
TextureConverter::EncodeToRam(address, fromZBuffer, isIntensityFmt, copyfmt, scaleByHalf, rc);
else // To OGL Texture
TextureMngr::CopyRenderTargetToTexture(address, fromZBuffer, isIntensityFmt, copyfmt, scaleByHalf, rc);
@ -160,9 +160,9 @@ bool GetConfig(const int &type)
case CONFIG_ISWII:
return g_VideoInitialize.bWii;
case CONFIG_DISABLEFOG:
return g_Config.bDisableFog;
return g_ActiveConfig.bDisableFog;
case CONFIG_SHOWEFBREGIONS:
return g_Config.bShowEFBCopyRegions;
return g_ActiveConfig.bShowEFBCopyRegions;
default:
PanicAlert("GetConfig Error: Unknown Config Type!");
return false;

View File

@ -1,182 +0,0 @@
// Copyright (C) 2003 Dolphin Project.
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, version 2.0.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License 2.0 for more details.
// A copy of the GPL 2.0 should have been included with the program.
// If not, see http://www.gnu.org/licenses/
// Official SVN repository and contact information can be found at
// http://code.google.com/p/dolphin-emu/
#include "Globals.h"
#include "Common.h"
#include "IniFile.h"
#include "Config.h"
#include "../../../Core/Core/Src/ConfigManager.h" // FIXME
Config g_Config;
Config::Config()
{
bRunning = false;
}
void Config::Load()
{
std::string temp;
IniFile iniFile;
iniFile.Load(FULL_CONFIG_DIR "gfx_opengl.ini");
// get resolution
iniFile.Get("Hardware", "WindowedRes", &temp, "640x480");
strncpy(iInternalRes, temp.c_str(), 16);
iniFile.Get("Hardware", "FullscreenRes", &temp, "640x480");
strncpy(iFSResolution, temp.c_str(), 16);
iniFile.Get("Hardware", "Fullscreen", &bFullscreen, 0); // Hardware
iniFile.Get("Hardware", "VSync", &bVSync, 0); // Hardware
iniFile.Get("Hardware", "RenderToMainframe", &RenderToMainframe, false);
iniFile.Get("Settings", "StretchToFit", &bNativeResolution, true);
iniFile.Get("Settings", "2xResolution", &b2xResolution, false);
iniFile.Get("Settings", "wideScreenHack", &bWidescreenHack, false);
iniFile.Get("Settings", "KeepAR_4_3", &bKeepAR43, false);
iniFile.Get("Settings", "KeepAR_16_9", &bKeepAR169, false);
iniFile.Get("Settings", "Crop", &bCrop, false);
iniFile.Get("Settings", "HideCursor", &bHideCursor, false);
iniFile.Get("Settings", "UseXFB", &bUseXFB, 0);
iniFile.Get("Settings", "AutoScale", &bAutoScale, true);
iniFile.Get("Settings", "SafeTextureCache", &bSafeTextureCache, false); // Settings
iniFile.Get("Settings", "ShowFPS", &bShowFPS, false); // Settings
iniFile.Get("Settings", "OverlayStats", &bOverlayStats, false);
iniFile.Get("Settings", "OverlayProjStats", &bOverlayProjStats, false);
iniFile.Get("Settings", "ShowEFBCopyRegions", &bShowEFBCopyRegions, false);
iniFile.Get("Settings", "DLOptimize", &iCompileDLsLevel, 0);
iniFile.Get("Settings", "DumpTextures", &bDumpTextures, 0);
iniFile.Get("Settings", "HiresTextures", &bHiresTextures, 0);
iniFile.Get("Settings", "DumpEFBTarget", &bDumpEFBTarget, 0);
iniFile.Get("Settings", "DumpFrames", &bDumpFrames, 0);
iniFile.Get("Settings", "FreeLook", &bFreeLook, 0);
iniFile.Get("Settings", "ShowShaderErrors", &bShowShaderErrors, 0);
iniFile.Get("Settings", "MSAA", &iMultisampleMode, 0);
iniFile.Get("Settings", "DstAlphaPass", &bDstAlphaPass, false);
iniFile.Get("Settings", "TexFmtOverlayEnable", &bTexFmtOverlayEnable, 0);
iniFile.Get("Settings", "TexFmtOverlayCenter", &bTexFmtOverlayCenter, 0);
iniFile.Get("Settings", "WireFrame", &bWireFrame, 0);
iniFile.Get("Settings", "DisableLighting", &bDisableLighting, 0);
iniFile.Get("Settings", "DisableTexturing", &bDisableTexturing, 0);
iniFile.Get("Settings", "DisableFog", &bDisableFog, 0);
iniFile.Get("Enhancements", "ForceFiltering", &bForceFiltering, 0);
iniFile.Get("Enhancements", "MaxAnisotropy", &iMaxAnisotropy, 3); // NOTE - this is x in (1 << x)
iniFile.Get("Enhancements", "PostProcessingShader", &sPostProcessingShader, "");
iniFile.Get("Hacks", "EFBCopyDisable", &bEFBCopyDisable, 0);
iniFile.Get("Hacks", "EFBCopyDisableHotKey", &bEFBCopyDisableHotKey, 0);
iniFile.Get("Hacks", "EFBToTextureEnable", &bCopyEFBToRAM, 0);
iniFile.Get("Hacks", "ProjectionHack", &iPhackvalue, 0);
// Load common settings
iniFile.Load(CONFIG_FILE);
bool bTmp;
iniFile.Get("Interface", "UsePanicHandlers", &bTmp, true);
SetEnableAlert(bTmp);
}
void Config::GameIniLoad()
{
IniFile *iniFile = ((struct SConfig *)globals->config)->m_LocalCoreStartupParameter.gameIni;
if (! iniFile)
return;
if (iniFile->Exists("Video", "ForceFiltering"))
iniFile->Get("Video", "ForceFiltering", &bForceFiltering, 0);
if (iniFile->Exists("Video", "MaxAnisotropy"))
iniFile->Get("Video", "MaxAnisotropy", &iMaxAnisotropy, 3); // NOTE - this is x in (1 << x)
if (iniFile->Exists("Video", "EFBCopyDisable"))
iniFile->Get("Video", "EFBCopyDisable", &bEFBCopyDisable, 0);
if (iniFile->Exists("Video", "EFBCopyDisableHotKey"))
iniFile->Get("Video", "EFBCopyDisableHotKey", &bEFBCopyDisableHotKey, 0);
if (iniFile->Exists("Video", "EFBToRAMEnable"))
iniFile->Get("Video", "EFBToRAMEnable", &bCopyEFBToRAM, 0);
if (iniFile->Exists("Video", "SafeTextureCache"))
iniFile->Get("Video", "SafeTextureCache", &bSafeTextureCache, false);
if (iniFile->Exists("Video", "MSAA"))
iniFile->Get("Video", "MSAA", &iMultisampleMode, 0);
if (iniFile->Exists("Video", "DstAlphaPass"))
iniFile->Get("Video", "DstAlphaPass", &bDstAlphaPass, false);
if (iniFile->Exists("Video", "UseXFB"))
iniFile->Get("Video", "UseXFB", &bUseXFB, 0);
if (iniFile->Exists("Video", "ProjectionHack"))
iniFile->Get("Video", "ProjectionHack", &iPhackvalue, 0);
}
void Config::Save()
{
IniFile iniFile;
iniFile.Load(FULL_CONFIG_DIR "gfx_opengl.ini");
iniFile.Set("Hardware", "WindowedRes", iInternalRes);
iniFile.Set("Hardware", "FullscreenRes", iFSResolution);
iniFile.Set("Hardware", "Fullscreen", bFullscreen);
iniFile.Set("Hardware", "VSync", bVSync);
iniFile.Set("Hardware", "RenderToMainframe", RenderToMainframe);
iniFile.Set("Settings", "StretchToFit", bNativeResolution);
iniFile.Set("Settings", "2xResolution", b2xResolution);
iniFile.Set("Settings", "KeepAR_4_3", bKeepAR43);
iniFile.Set("Settings", "KeepAR_16_9", bKeepAR169);
iniFile.Set("Settings", "Crop", bCrop);
iniFile.Set("Settings", "wideScreenHack", bWidescreenHack);
iniFile.Set("Settings", "HideCursor", bHideCursor);
iniFile.Set("Settings", "UseXFB", bUseXFB);
iniFile.Set("Settings", "AutoScale", bAutoScale);
iniFile.Set("Settings", "SafeTextureCache", bSafeTextureCache);
iniFile.Set("Settings", "ShowFPS", bShowFPS);
iniFile.Set("Settings", "OverlayStats", bOverlayStats);
iniFile.Set("Settings", "OverlayProjStats", bOverlayProjStats);
iniFile.Set("Settings", "DLOptimize", iCompileDLsLevel);
iniFile.Set("Settings", "Show", iCompileDLsLevel);
iniFile.Set("Settings", "DumpTextures", bDumpTextures);
iniFile.Set("Settings", "HiresTextures", bHiresTextures);
iniFile.Set("Settings", "DumpEFBTarget", bDumpEFBTarget);
iniFile.Set("Settings", "DumpFrames", bDumpFrames);
iniFile.Set("Settings", "FreeLook", bFreeLook);
iniFile.Set("Settings", "ShowEFBCopyRegions", bShowEFBCopyRegions);
iniFile.Set("Settings", "ShowShaderErrors", bShowShaderErrors);
iniFile.Set("Settings", "MSAA", iMultisampleMode);
iniFile.Set("Settings", "TexFmtOverlayEnable", bTexFmtOverlayEnable);
iniFile.Set("Settings", "TexFmtOverlayCenter", bTexFmtOverlayCenter);
iniFile.Set("Settings", "Wireframe", bWireFrame);
iniFile.Set("Settings", "DisableLighting", bDisableLighting);
iniFile.Set("Settings", "DisableTexturing", bDisableTexturing);
iniFile.Set("Settings", "DstAlphaPass", bDstAlphaPass);
iniFile.Set("Settings", "DisableFog", bDisableFog);
iniFile.Set("Enhancements", "ForceFiltering", bForceFiltering);
iniFile.Set("Enhancements", "MaxAnisotropy", iMaxAnisotropy);
iniFile.Set("Enhancements", "PostProcessingShader", sPostProcessingShader);
iniFile.Set("Hacks", "EFBCopyDisable", bEFBCopyDisable);
iniFile.Set("Hacks", "EFBCopyDisableHotKey", bEFBCopyDisableHotKey);
iniFile.Set("Hacks", "EFBToTextureEnable", bCopyEFBToRAM);
iniFile.Set("Hacks", "ProjectionHack", iPhackvalue);
iniFile.Save(FULL_CONFIG_DIR "gfx_opengl.ini");
}

View File

@ -1,120 +0,0 @@
// Copyright (C) 2003 Dolphin Project.
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, version 2.0.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License 2.0 for more details.
// A copy of the GPL 2.0 should have been included with the program.
// If not, see http://www.gnu.org/licenses/
// Official SVN repository and contact information can be found at
// http://code.google.com/p/dolphin-emu/
#ifndef _PLUGIN_VIDEOOGL_CONFIG_H_
#define _PLUGIN_VIDEOOGL_CONFIG_H_
#include "Common.h"
#include <string>
// Log in two categories, and save three other options in the same byte
#define CONF_LOG 1
#define CONF_PRIMLOG 2
#define CONF_SAVETEXTURES 4
#define CONF_SAVETARGETS 8
#define CONF_SAVESHADERS 16
enum MultisampleMode {
MULTISAMPLE_OFF,
MULTISAMPLE_2X,
MULTISAMPLE_4X,
MULTISAMPLE_8X,
MULTISAMPLE_CSAA_8X,
MULTISAMPLE_CSAA_8XQ,
MULTISAMPLE_CSAA_16X,
MULTISAMPLE_CSAA_16XQ,
};
// NEVER inherit from this class.
struct Config
{
Config();
void Load();
void GameIniLoad();
void Save();
void UpdateProjectionHack();
// General
bool bFullscreen;
bool bHideCursor;
bool RenderToMainframe;
bool bVSync;
// Resolution control
char iFSResolution[16];
char iInternalRes[16];
bool bNativeResolution, b2xResolution, bRunning; // Should possibly be augmented with 2x, 4x native.
bool bWidescreenHack;
bool bKeepAR43, bKeepAR169, bCrop; // Aspect ratio controls.
bool bUseXFB;
bool bAutoScale; // Removes annoying borders without using XFB. Doesn't always work perfectly.
// Enhancements
int iMultisampleMode;
bool bForceFiltering;
int iMaxAnisotropy;
std::string sPostProcessingShader;
// Information
bool bShowFPS;
bool bOverlayStats;
bool bOverlayProjStats;
bool bTexFmtOverlayEnable;
bool bTexFmtOverlayCenter;
bool bShowEFBCopyRegions;
// Render
bool bWireFrame;
bool bDisableLighting;
bool bDisableTexturing;
bool bDstAlphaPass;
bool bDisableFog;
// Utility
bool bDumpTextures;
bool bHiresTextures;
bool bDumpEFBTarget;
bool bDumpFrames;
bool bFreeLook;
// Hacks
bool bEFBCopyDisable;
bool bEFBCopyDisableHotKey;
bool bHack;
bool bCopyEFBToRAM;
bool bSafeTextureCache;
int iPhackvalue;
bool bPhackvalue1, bPhackvalue2;
float fhackvalue1, fhackvalue2;
bool bProjHack1;
int iLog; // CONF_ bits
int iSaveTargetId;
//currently unused:
int iCompileDLsLevel;
bool bShowShaderErrors;
private:
DISALLOW_COPY_AND_ASSIGN(Config);
};
extern Config g_Config;
#endif // _PLUGIN_VIDEOOGL_CONFIG_H_

View File

@ -19,7 +19,7 @@
#include "IniFile.h"
#include "Debugger.h"
#include "../Config.h"
#include "Config.h"
#include "../Globals.h"
extern int g_Preset;

View File

@ -188,7 +188,7 @@ void FramebufferManager::Shutdown()
void FramebufferManager::CopyToXFB(u32 xfbAddr, u32 fbWidth, u32 fbHeight, const EFBRectangle& sourceRc)
{
if (g_Config.bUseXFB)
if (g_ActiveConfig.bUseXFB)
copyToRealXFB(xfbAddr, fbWidth, fbHeight, sourceRc);
else
copyToVirtualXFB(xfbAddr, fbWidth, fbHeight, sourceRc);
@ -196,7 +196,7 @@ void FramebufferManager::CopyToXFB(u32 xfbAddr, u32 fbWidth, u32 fbHeight, const
const XFBSource* FramebufferManager::GetXFBSource(u32 xfbAddr, u32 fbWidth, u32 fbHeight)
{
if (g_Config.bUseXFB)
if (g_ActiveConfig.bUseXFB)
return getRealXFBSource(xfbAddr, fbWidth, fbHeight);
else
return getVirtualXFBSource(xfbAddr, fbWidth, fbHeight);

View File

@ -129,9 +129,9 @@ bool OpenGL_Create(SVideoInitialize &_VideoInitialize, int _iwidth, int _iheight
int _twidth, _theight;
if (g_Config.bFullscreen)
{
if (strlen(g_Config.iFSResolution) > 1)
if (strlen(g_Config.cFSResolution) > 1)
{
sscanf(g_Config.iFSResolution, "%dx%d", &_twidth, &_theight);
sscanf(g_Config.cFSResolution, "%dx%d", &_twidth, &_theight);
}
else // No full screen reso set, fall back to default reso
{
@ -141,9 +141,9 @@ bool OpenGL_Create(SVideoInitialize &_VideoInitialize, int _iwidth, int _iheight
}
else // Going Windowed
{
if (strlen(g_Config.iInternalRes) > 1)
if (strlen(g_Config.cInternalRes) > 1)
{
sscanf(g_Config.iInternalRes, "%dx%d", &_twidth, &_theight);
sscanf(g_Config.cInternalRes, "%dx%d", &_twidth, &_theight);
}
else // No Window resolution set, fall back to default
{

View File

@ -24,7 +24,7 @@
#include "ConfigDlg.h"
#include "../Globals.h"
#include "../Config.h"
#include "Config.h"
#include "../TextureMngr.h"
#include "VertexShaderManager.h"
#include "../PostProcessing.h"
@ -89,9 +89,6 @@ END_EVENT_TABLE()
GFXConfigDialogOGL::GFXConfigDialogOGL(wxWindow *parent, wxWindowID id, const wxString &title, const wxPoint &position, const wxSize& size, long style)
: wxDialog(parent, id, title, position, size, style)
{
g_Config.Load();
g_Config.GameIniLoad();
g_Config.UpdateProjectionHack();
}
@ -188,9 +185,9 @@ void GFXConfigDialogOGL::CreateGUIControls()
wxStaticText *WM2Text = new wxStaticText(m_PageGeneral, ID_WM2TEXT, wxT("Window mode:"), wxDefaultPosition, wxDefaultSize , 0 );
wxStaticText *FMText = new wxStaticText(m_PageGeneral, ID_FMTEXT, wxT("Separate window:"), wxDefaultPosition, wxDefaultSize , 0 );
m_WindowResolutionCB = new wxComboBox(m_PageGeneral, ID_WINDOWRESOLUTIONCB, arrayStringFor_WindowResolutionCB[0], wxDefaultPosition, wxDefaultSize, arrayStringFor_WindowResolutionCB, wxCB_READONLY, wxDefaultValidator);
m_WindowResolutionCB->SetValue(wxString::FromAscii(g_Config.iInternalRes));
m_WindowResolutionCB->SetValue(wxString::FromAscii(g_Config.cInternalRes));
m_WindowFSResolutionCB = new wxComboBox(m_PageGeneral, ID_WINDOWFSRESOLUTIONCB, arrayStringFor_FullscreenCB[0], wxDefaultPosition, wxDefaultSize, arrayStringFor_FullscreenCB, wxCB_READONLY, wxDefaultValidator);
m_WindowFSResolutionCB->SetValue(wxString::FromAscii(g_Config.iFSResolution));
m_WindowFSResolutionCB->SetValue(wxString::FromAscii(g_Config.cFSResolution));
// Aspect ratio / positioning controls
wxStaticText *KeepARText = new wxStaticText(m_PageGeneral, wxID_ANY, wxT("Keep aspect ratio:"), wxDefaultPosition, wxDefaultSize, 0);
@ -285,7 +282,7 @@ void GFXConfigDialogOGL::CreateGUIControls()
m_MaxAnisotropyCB->Append(wxT("8x"));
m_MaxAnisotropyCB->Append(wxT("16x"));
m_MaxAnisotropyCB->SetSelection(g_Config.iMaxAnisotropy - 1);
m_ForceFiltering = new wxCheckBox(m_PageGeneral, ID_FORCEFILTERING, wxT("Force bi/trilinear filtering"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator);
m_ForceFiltering = new wxCheckBox(m_PageGeneral, ID_FORCEFILTERING, wxT("Force bi/trilinear filter. (Breaks FMV in many Wii games)"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator);
m_ForceFiltering->SetValue(g_Config.bForceFiltering);
wxStaticText *PostShaderText = new wxStaticText(m_PageGeneral, ID_POSTSHADERTEXT, wxT("Post-processing shader:"), wxDefaultPosition, wxDefaultSize, 0);
@ -633,10 +630,10 @@ void GFXConfigDialogOGL::GeneralSettingsChanged(wxCommandEvent& event)
break;
#endif
case ID_WINDOWRESOLUTIONCB:
strcpy(g_Config.iInternalRes, m_WindowResolutionCB->GetValue().mb_str() );
strcpy(g_Config.cInternalRes, m_WindowResolutionCB->GetValue().mb_str() );
break;
case ID_WINDOWFSRESOLUTIONCB:
strcpy(g_Config.iFSResolution, m_WindowFSResolutionCB->GetValue().mb_str() );
strcpy(g_Config.cFSResolution, m_WindowFSResolutionCB->GetValue().mb_str() );
break;
case ID_MAXANISOTROPY:
g_Config.iMaxAnisotropy = m_MaxAnisotropyCB->GetSelection() + 1;
@ -755,7 +752,7 @@ void GFXConfigDialogOGL::AdvancedSettingsChanged(wxCommandEvent& event)
void GFXConfigDialogOGL::CloseWindow()
{
// Save the config to INI
g_Config.Save();
g_Config.Save(FULL_CONFIG_DIR "gfx_opengl.ini");
EndModal(1);
}

View File

@ -263,7 +263,7 @@ void GLVertexFormat::EnableComponents(u32 components)
// tex
for (int i = 0; i < 8; ++i)
{
if (!g_Config.bDisableTexturing)
if (!g_ActiveConfig.bDisableTexturing)
{
if ((components & (VB_HAS_UV0 << i)) != (s_prevcomponents & (VB_HAS_UV0 << i)))
{
@ -283,7 +283,7 @@ void GLVertexFormat::EnableComponents(u32 components)
// Disable Lighting
// TODO - Is this a good spot for this code?
if (g_Config.bDisableLighting)
if (g_ActiveConfig.bDisableLighting)
{
for (int i = 0; i < xfregs.nNumChans; i++)
{

View File

@ -24,7 +24,7 @@
#include <wx/aboutdlg.h>
#include "../Globals.h"
#include "../Config.h"
#include "Config.h"
#include "main.h"
#include "Win32.h"
#include "OnScreenDisplay.h"
@ -269,21 +269,23 @@ void OnKeyDown(WPARAM wParam)
LRESULT CALLBACK WndProc(HWND hWnd, UINT iMsg, WPARAM wParam, LPARAM lParam)
{
HDC hdc;
PAINTSTRUCT ps;
switch( iMsg )
switch (iMsg)
{
case WM_CREATE:
PostMessage(m_hParent, WM_USER, OPENGL_WM_USER_CREATE, (int)m_hParent);
break;
case WM_PAINT:
hdc = BeginPaint( hWnd, &ps );
EndPaint( hWnd, &ps );
{
HDC hdc;
PAINTSTRUCT ps;
hdc = BeginPaint(hWnd, &ps);
EndPaint(hWnd, &ps);
}
return 0;
case WM_SYSKEYDOWN:
switch( LOWORD( wParam ))
switch (LOWORD(wParam))
{
case VK_RETURN:
// Pressing Alt+Enter switch FullScreen/Windowed
@ -298,7 +300,8 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT iMsg, WPARAM wParam, LPARAM lParam)
case WM_KEYDOWN:
// Don't process this as a child window to avoid double events
if (!g_Config.RenderToMainframe) OnKeyDown(wParam);
if (!g_Config.RenderToMainframe)
OnKeyDown(wParam);
break;
/* Post thes mouse events to the main window, it's nessesary becase in difference to the
@ -307,7 +310,7 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT iMsg, WPARAM wParam, LPARAM lParam)
case WM_LBUTTONUP:
case WM_LBUTTONDBLCLK:
PostMessage(GetParentWnd(), iMsg, wParam, lParam);
break;
break;
/* The reason we pick up the WM_MOUSEMOVE is to be able to change this option
during gameplay. The alternative is to load one of the cursors when the plugin
@ -335,7 +338,8 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT iMsg, WPARAM wParam, LPARAM lParam)
else
SetCursor(hCursorBlank);
}
if (wParam == OPENGL_WM_USER_KEYDOWN) OnKeyDown(lParam);
if (wParam == OPENGL_WM_USER_KEYDOWN)
OnKeyDown(lParam);
break;
// This is called when we close the window when we render to a separate window
@ -445,8 +449,8 @@ void ToggleFullscreen(HWND hParent)
g_Config.bFullscreen = false;
RECT rc = {0, 0, w_fs, h_fs};
if (strlen(g_Config.iInternalRes) > 1)
sscanf(g_Config.iInternalRes, "%dx%d", &w_fs, &h_fs);
if (strlen(g_Config.cInternalRes) > 1)
sscanf(g_Config.cInternalRes, "%dx%d", &w_fs, &h_fs);
// FullScreen -> Desktop
ChangeDisplaySettings(NULL, 0);
@ -456,8 +460,8 @@ void ToggleFullscreen(HWND hParent)
ShowCursor(TRUE);
// SetWindowPos to the center of the screen
int X = (rcdesktop.right-rcdesktop.left)/2 - (rc.right-rc.left)/2;
int Y = (rcdesktop.bottom-rcdesktop.top)/2 - (rc.bottom-rc.top)/2;
int X = (rcdesktop.right - rcdesktop.left)/2 - (rc.right - rc.left)/2;
int Y = (rcdesktop.bottom - rcdesktop.top)/2 - (rc.bottom - rc.top)/2;
// Note: we now use the same res for fullscreen and windowed, so we need to check if the window
// is not too big here
@ -478,8 +482,8 @@ void ToggleFullscreen(HWND hParent)
DEVMODE dmScreenSettings;
memset(&dmScreenSettings, 0, sizeof(dmScreenSettings));
if (strlen(g_Config.iFSResolution) > 1)
sscanf(g_Config.iFSResolution, "%dx%d", &w_fs, &h_fs);
if (strlen(g_Config.cFSResolution) > 1)
sscanf(g_Config.cFSResolution, "%dx%d", &w_fs, &h_fs);
// Desktop -> FullScreen
dmScreenSettings.dmSize = sizeof(dmScreenSettings);

View File

@ -199,7 +199,7 @@ FRAGMENTSHADER* PixelShaderCache::GetShader(bool dstAlphaEnable)
dstAlphaEnable);
#if defined(_DEBUG) || defined(DEBUGFAST)
if (g_Config.iLog & CONF_SAVESHADERS && code) {
if (g_ActiveConfig.iLog & CONF_SAVESHADERS && code) {
static int counter = 0;
char szTemp[MAX_PATH];
sprintf(szTemp, "%s/ps_%04i.txt", FULL_DUMP_DIR, counter++);

View File

@ -45,11 +45,11 @@ void ReloadShader()
bool ApplyShader()
{
if (s_currentShader != "User/Shaders/" + g_Config.sPostProcessingShader + ".txt")
if (s_currentShader != "User/Shaders/" + g_ActiveConfig.sPostProcessingShader + ".txt")
{
// Set immediately to prevent endless recompiles on failure.
if (!g_Config.sPostProcessingShader.empty())
s_currentShader = "User/Shaders/" + g_Config.sPostProcessingShader + ".txt";
if (!g_ActiveConfig.sPostProcessingShader.empty())
s_currentShader = "User/Shaders/" + g_ActiveConfig.sPostProcessingShader + ".txt";
else
s_currentShader.clear();

View File

@ -176,10 +176,11 @@ void HandleCgError(CGcontext ctx, CGerror err, void* appdata)
// Init functions
bool Renderer::Init()
{
UpdateActiveConfig();
bool bSuccess = true;
s_blendMode = 0;
s_MSAACoverageSamples = 0;
switch (g_Config.iMultisampleMode)
switch (g_ActiveConfig.iMultisampleMode)
{
case MULTISAMPLE_OFF: s_MSAASamples = 1; break;
case MULTISAMPLE_2X: s_MSAASamples = 2; break;
@ -217,7 +218,7 @@ bool Renderer::Init()
(const char*)glGetString(GL_RENDERER),
(const char*)glGetString(GL_VERSION)).c_str(), 5000);
s_bFullscreen = g_Config.bFullscreen;
s_bFullscreen = g_ActiveConfig.bFullscreen;
glGetIntegerv(GL_MAX_VERTEX_ATTRIBS, &numvertexattribs);
if (numvertexattribs < 11) {
@ -258,12 +259,12 @@ bool Renderer::Init()
// TODO: FILL IN
#elif defined _WIN32
if (WGLEW_EXT_swap_control)
wglSwapIntervalEXT(g_Config.bVSync ? 1 : 0);
wglSwapIntervalEXT(g_ActiveConfig.bVSync ? 1 : 0);
else
ERROR_LOG(VIDEO, "no support for SwapInterval (framerate clamped to monitor refresh rate)Does your video card support OpenGL 2.x?");
#elif defined(HAVE_X11) && HAVE_X11
if (glXSwapIntervalSGI)
glXSwapIntervalSGI(g_Config.bVSync ? 1 : 0);
glXSwapIntervalSGI(g_ActiveConfig.bVSync ? 1 : 0);
else
ERROR_LOG(VIDEO, "no support for SwapInterval (framerate clamped to monitor refresh rate)");
#endif
@ -287,12 +288,12 @@ bool Renderer::Init()
// Decide frambuffer size
int W = (int)OpenGL_GetBackbufferWidth(), H = (int)OpenGL_GetBackbufferHeight();
if (g_Config.bNativeResolution)
if (g_ActiveConfig.bNativeResolution)
{
m_FrameBufferWidth = EFB_WIDTH;
m_FrameBufferHeight = EFB_HEIGHT;
}
else if (g_Config.b2xResolution)
else if (g_ActiveConfig.b2xResolution)
{
m_FrameBufferWidth = 2 * EFB_WIDTH;
m_FrameBufferHeight = 2 * EFB_HEIGHT;
@ -318,7 +319,7 @@ bool Renderer::Init()
m_CustomHeight = (int)OpenGL_GetBackbufferHeight();
// Because of the fixed framebuffer size we need to disable the resolution options while running
g_Config.bRunning = true;
g_ActiveConfig.bRunning = true;
if (GL_REPORT_ERROR() != GL_NO_ERROR)
bSuccess = false;
@ -401,12 +402,14 @@ bool Renderer::Init()
glClientActiveTexture(GL_TEXTURE0);
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
UpdateActiveConfig();
return glGetError() == GL_NO_ERROR && bSuccess;
}
void Renderer::Shutdown(void)
{
g_Config.bRunning = false;
UpdateActiveConfig();
delete s_pfont;
s_pfont = 0;
@ -468,13 +471,13 @@ int Renderer::GetCustomHeight()
// Return the rendering target width and height
int Renderer::GetTargetWidth()
{
return (g_Config.bNativeResolution || g_Config.b2xResolution) ?
(g_Config.bNativeResolution ? EFB_WIDTH : EFB_WIDTH * 2) : m_CustomWidth;
return (g_ActiveConfig.bNativeResolution || g_ActiveConfig.b2xResolution) ?
(g_ActiveConfig.bNativeResolution ? EFB_WIDTH : EFB_WIDTH * 2) : m_CustomWidth;
}
int Renderer::GetTargetHeight()
{
return (g_Config.bNativeResolution || g_Config.b2xResolution) ?
(g_Config.bNativeResolution ? EFB_HEIGHT : EFB_HEIGHT * 2) : m_CustomHeight;
return (g_ActiveConfig.bNativeResolution || g_ActiveConfig.b2xResolution) ?
(g_ActiveConfig.bNativeResolution ? EFB_HEIGHT : EFB_HEIGHT * 2) : m_CustomHeight;
}
float Renderer::GetTargetScaleX()
{
@ -716,69 +719,6 @@ bool Renderer::SetScissorRect()
return false;
}
// Aspect ratio functions
static void ComputeBackbufferRectangle(TargetRectangle *rc)
{
float FloatGLWidth = (float)OpenGL_GetBackbufferWidth();
float FloatGLHeight = (float)OpenGL_GetBackbufferHeight();
float FloatXOffset = 0;
float FloatYOffset = 0;
// The rendering window size
const float WinWidth = FloatGLWidth;
const float WinHeight = FloatGLHeight;
// Handle aspect ratio.
if (g_Config.bKeepAR43 || g_Config.bKeepAR169)
{
// The rendering window aspect ratio as a proportion of the 4:3 or 16:9 ratio
float Ratio = (WinWidth / WinHeight) / (g_Config.bKeepAR43 ? (4.0f / 3.0f) : (16.0f / 9.0f));
// Check if height or width is the limiting factor. If ratio > 1 the picture is to wide and have to limit the width.
if (Ratio > 1)
{
// Scale down and center in the X direction.
FloatGLWidth /= Ratio;
FloatXOffset = (WinWidth - FloatGLWidth) / 2.0f;
}
// The window is too high, we have to limit the height
else
{
// Scale down and center in the Y direction.
FloatGLHeight *= Ratio;
FloatYOffset = FloatYOffset + (WinHeight - FloatGLHeight) / 2.0f;
}
}
// -----------------------------------------------------------------------
// Crop the picture from 4:3 to 5:4 or from 16:9 to 16:10.
// Output: FloatGLWidth, FloatGLHeight, FloatXOffset, FloatYOffset
// ------------------
if ((g_Config.bKeepAR43 || g_Config.bKeepAR169) && g_Config.bCrop)
{
float Ratio = g_Config.bKeepAR43 ? ((4.0 / 3.0) / (5.0 / 4.0)) : (((16.0 / 9.0) / (16.0 / 10.0)));
// The width and height we will add (calculate this before FloatGLWidth and FloatGLHeight is adjusted)
float IncreasedWidth = (Ratio - 1.0) * FloatGLWidth;
float IncreasedHeight = (Ratio - 1.0) * FloatGLHeight;
// The new width and height
FloatGLWidth = FloatGLWidth * Ratio;
FloatGLHeight = FloatGLHeight * Ratio;
// Adjust the X and Y offset
FloatXOffset = FloatXOffset - (IncreasedWidth / 2.0);
FloatYOffset = FloatYOffset - (IncreasedHeight / 2.0);
//NOTICE_LOG(OSREPORT, "Crop Ratio:%1.2f IncreasedHeight:%3.0f YOffset:%3.0f", Ratio, IncreasedHeight, FloatYOffset);
//NOTICE_LOG(OSREPORT, "Crop FloatGLWidth:%1.2f FloatGLHeight:%3.0f", (float)FloatGLWidth, (float)FloatGLHeight);
//NOTICE_LOG(OSREPORT, "");
}
// round(float) = floor(float + 0.5)
int XOffset = floor(FloatXOffset + 0.5);
int YOffset = floor(FloatYOffset + 0.5);
rc->left = XOffset;
rc->top = YOffset + ceil(FloatGLHeight);
rc->right = XOffset + ceil(FloatGLWidth);
rc->bottom = YOffset;
}
void Renderer::ClearScreen(const EFBRectangle& rc, bool colorEnable, bool alphaEnable, bool zEnable, u32 color, u32 z)
{
// Update the view port for clearing the picture
@ -823,7 +763,7 @@ void Renderer::RenderToXFB(u32 xfbAddr, u32 fbWidth, u32 fbHeight, const EFBRect
// XXX: Without the VI, how would we know what kind of field this is? So
// just use progressive.
if (!g_Config.bUseXFB)
if (!g_ActiveConfig.bUseXFB)
{
// TODO: Find better name for this because I don't know if it means what it says.
g_VideoInitialize.pCopiedToXFB(false);
@ -835,7 +775,7 @@ void Renderer::RenderToXFB(u32 xfbAddr, u32 fbWidth, u32 fbHeight, const EFBRect
// This function has the final picture. We adjust the aspect ratio here.
void Renderer::Swap(u32 xfbAddr, FieldType field, u32 fbWidth, u32 fbHeight)
{
if(s_skipSwap)
if (s_skipSwap)
return;
const XFBSource* xfbSource = g_framebufferManager.GetXFBSource(xfbAddr, fbWidth, fbHeight);
@ -851,11 +791,11 @@ void Renderer::Swap(u32 xfbAddr, FieldType field, u32 fbWidth, u32 fbHeight)
ResetAPIState();
TargetRectangle back_rc;
ComputeBackbufferRectangle(&back_rc);
ComputeDrawRectangle(OpenGL_GetBackbufferWidth(), OpenGL_GetBackbufferHeight(), true, &back_rc);
TargetRectangle sourceRc;
if (g_Config.bAutoScale || g_Config.bUseXFB)
if (g_ActiveConfig.bAutoScale || g_ActiveConfig.bUseXFB)
{
sourceRc = xfbSource->sourceRc;
}
@ -867,7 +807,7 @@ void Renderer::Swap(u32 xfbAddr, FieldType field, u32 fbWidth, u32 fbHeight)
sourceRc.bottom = 0;
}
int yOffset = (g_Config.bUseXFB && field == FIELD_LOWER) ? -1 : 0;
int yOffset = (g_ActiveConfig.bUseXFB && field == FIELD_LOWER) ? -1 : 0;
sourceRc.top -= yOffset;
sourceRc.bottom -= yOffset;
@ -929,7 +869,7 @@ void Renderer::Swap(u32 xfbAddr, FieldType field, u32 fbWidth, u32 fbHeight)
TextureMngr::DisableStage(0);
// Wireframe
if (g_Config.bWireFrame)
if (g_ActiveConfig.bWireFrame)
glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
// Save screenshot
@ -955,7 +895,7 @@ void Renderer::Swap(u32 xfbAddr, FieldType field, u32 fbWidth, u32 fbHeight)
// Frame dumps are handled a little differently in Windows
#ifdef _WIN32
if (g_Config.bDumpFrames)
if (g_ActiveConfig.bDumpFrames)
{
if (!s_tempScreenshotFramebuffer)
glGenFramebuffersEXT(1, &s_tempScreenshotFramebuffer);
@ -1009,7 +949,7 @@ void Renderer::Swap(u32 xfbAddr, FieldType field, u32 fbWidth, u32 fbHeight)
s_bLastFrameDumped = false;
}
#else
if (g_Config.bDumpFrames) {
if (g_ActiveConfig.bDumpFrames) {
s_criticalScreenshot.Enter();
char movie_file_name[255];
int w = OpenGL_GetBackbufferWidth();
@ -1056,6 +996,8 @@ void Renderer::Swap(u32 xfbAddr, FieldType field, u32 fbWidth, u32 fbHeight)
GL_REPORT_ERRORD();
g_Config.iSaveTargetId = 0;
UpdateActiveConfig();
// For testing zbuffer targets.
// Renderer::SetZBufferRender();
// SaveTexture("tex.tga", GL_TEXTURE_RECTANGLE_ARB, s_FakeZTarget, GetTargetWidth(), GetTargetHeight());
@ -1152,10 +1094,10 @@ void Renderer::DrawDebugText()
char *p = debugtext_buffer;
p[0] = 0;
if (g_Config.bShowFPS)
if (g_ActiveConfig.bShowFPS)
p+=sprintf(p, "FPS: %d\n", s_fps);
if (g_Config.bShowEFBCopyRegions)
if (g_ActiveConfig.bShowEFBCopyRegions)
{
// Store Line Size
GLfloat lSize;
@ -1200,99 +1142,62 @@ void Renderer::DrawDebugText()
stats.efb_regions.clear();
}
if (g_Config.bOverlayStats)
if (g_ActiveConfig.bOverlayStats)
{
p+=sprintf(p,"textures created: %i\n",stats.numTexturesCreated);
p+=sprintf(p,"textures alive: %i\n",stats.numTexturesAlive);
p+=sprintf(p,"pshaders created: %i\n",stats.numPixelShadersCreated);
p+=sprintf(p,"pshaders alive: %i\n",stats.numPixelShadersAlive);
p+=sprintf(p,"vshaders created: %i\n",stats.numVertexShadersCreated);
p+=sprintf(p,"vshaders alive: %i\n",stats.numVertexShadersAlive);
p+=sprintf(p,"dlists called: %i\n",stats.numDListsCalled);
p+=sprintf(p,"dlists called(f): %i\n",stats.thisFrame.numDListsCalled);
p+=sprintf(p,"dlists alive: %i\n",stats.numDListsAlive);
// not used.
//p+=sprintf(p,"dlists created: %i\n",stats.numDListsCreated);
//p+=sprintf(p,"dlists alive: %i\n",stats.numDListsAlive);
//p+=sprintf(p,"strip joins: %i\n",stats.numJoins);
p+=sprintf(p,"primitives: %i\n",stats.thisFrame.numPrims);
p+=sprintf(p,"primitive joins: %i\n",stats.thisFrame.numPrimitiveJoins);
p+=sprintf(p,"buffer splits: %i\n",stats.thisFrame.numBufferSplits);
p+=sprintf(p,"primitives (DL): %i\n",stats.thisFrame.numDLPrims);
p+=sprintf(p,"XF loads: %i\n",stats.thisFrame.numXFLoads);
p+=sprintf(p,"XF loads (DL): %i\n",stats.thisFrame.numXFLoadsInDL);
p+=sprintf(p,"CP loads: %i\n",stats.thisFrame.numCPLoads);
p+=sprintf(p,"CP loads (DL): %i\n",stats.thisFrame.numCPLoadsInDL);
p+=sprintf(p,"BP loads: %i\n",stats.thisFrame.numBPLoads);
p+=sprintf(p,"BP loads (DL): %i\n",stats.thisFrame.numBPLoadsInDL);
p+=sprintf(p,"vertex loaders: %i\n",stats.numVertexLoaders);
p = Statistics::ToString(p);
}
if (g_Config.bOverlayProjStats)
if (g_ActiveConfig.bOverlayProjStats)
{
p+=sprintf(p,"Projection #: X for Raw 6=0 (X for Raw 6!=0)\n\n");
p+=sprintf(p,"Projection 0: %f (%f) Raw 0: %f\n", stats.gproj_0, stats.g2proj_0, stats.proj_0);
p+=sprintf(p,"Projection 1: %f (%f)\n", stats.gproj_1, stats.g2proj_1);
p+=sprintf(p,"Projection 2: %f (%f) Raw 1: %f\n", stats.gproj_2, stats.g2proj_2, stats.proj_1);
p+=sprintf(p,"Projection 3: %f (%f)\n\n", stats.gproj_3, stats.g2proj_3);
p+=sprintf(p,"Projection 4: %f (%f)\n", stats.gproj_4, stats.g2proj_4);
p+=sprintf(p,"Projection 5: %f (%f) Raw 2: %f\n", stats.gproj_5, stats.g2proj_5, stats.proj_2);
p+=sprintf(p,"Projection 6: %f (%f) Raw 3: %f\n", stats.gproj_6, stats.g2proj_6, stats.proj_3);
p+=sprintf(p,"Projection 7: %f (%f)\n\n", stats.gproj_7, stats.g2proj_7);
p+=sprintf(p,"Projection 8: %f (%f)\n", stats.gproj_8, stats.g2proj_8);
p+=sprintf(p,"Projection 9: %f (%f)\n", stats.gproj_9, stats.g2proj_9);
p+=sprintf(p,"Projection 10: %f (%f) Raw 4: %f\n\n", stats.gproj_10, stats.g2proj_10, stats.proj_4);
p+=sprintf(p,"Projection 11: %f (%f) Raw 5: %f\n\n", stats.gproj_11, stats.g2proj_11, stats.proj_5);
p+=sprintf(p,"Projection 12: %f (%f)\n", stats.gproj_12, stats.g2proj_12);
p+=sprintf(p,"Projection 13: %f (%f)\n", stats.gproj_13, stats.g2proj_13);
p+=sprintf(p,"Projection 14: %f (%f)\n", stats.gproj_14, stats.g2proj_14);
p+=sprintf(p,"Projection 15: %f (%f)\n", stats.gproj_15, stats.g2proj_15);
p = Statistics::ToStringProj(p);
}
// Render a shadow, and then the text.
Renderer::RenderText(debugtext_buffer, 21, 21, 0xDD000000);
Renderer::RenderText(debugtext_buffer, 20, 20, 0xFF00FFFF);
if (p != debugtext_buffer)
{
Renderer::RenderText(debugtext_buffer, 21, 21, 0xDD000000);
Renderer::RenderText(debugtext_buffer, 20, 20, 0xFF00FFFF);
}
// OSD Menu messages
if (OSDChoice > 0 && g_Config.bEFBCopyDisableHotKey)
if (OSDChoice > 0 && g_ActiveConfig.bEFBCopyDisableHotKey)
{
OSDTime = timeGetTime() + 3000;
OSDChoice = -OSDChoice;
}
if ((u32)OSDTime > timeGetTime() && g_Config.bEFBCopyDisableHotKey)
if ((u32)OSDTime > timeGetTime() && g_ActiveConfig.bEFBCopyDisableHotKey)
{
std::string T1 = "", T2 = "";
std::vector<std::string> T0;
int W, H;
sscanf(g_Config.iInternalRes, "%dx%d", &W, &H);
sscanf(g_ActiveConfig.cInternalRes, "%dx%d", &W, &H);
std::string OSDM1 =
g_Config.bNativeResolution || g_Config.b2xResolution ?
(g_Config.bNativeResolution ?
g_ActiveConfig.bNativeResolution || g_ActiveConfig.b2xResolution ?
(g_ActiveConfig.bNativeResolution ?
StringFromFormat("%i x %i (native)", OSDInternalW, OSDInternalH)
: StringFromFormat("%i x %i (2x)", OSDInternalW, OSDInternalH))
: StringFromFormat("%i x %i (custom)", W, H);
std::string OSDM21 =
!(g_Config.bKeepAR43 || g_Config.bKeepAR169) ? "-": (g_Config.bKeepAR43 ? "4:3" : "16:9");
!(g_ActiveConfig.bKeepAR43 || g_ActiveConfig.bKeepAR169) ? "-": (g_ActiveConfig.bKeepAR43 ? "4:3" : "16:9");
std::string OSDM22 =
g_Config.bCrop ? " (crop)" : "";
g_ActiveConfig.bCrop ? " (crop)" : "";
std::string OSDM31 =
g_Config.bCopyEFBToRAM ? "RAM" : "Texture";
g_ActiveConfig.bCopyEFBToRAM ? "RAM" : "Texture";
std::string OSDM32 =
g_Config.bEFBCopyDisable ? "No" : "Yes";
g_ActiveConfig.bEFBCopyDisable ? "No" : "Yes";
// If there is more text than this we will have a collission
if (g_Config.bShowFPS)
if (g_ActiveConfig.bShowFPS)
{ T1 += "\n\n"; T2 += "\n\n"; }
// The rows
T0.push_back(StringFromFormat("3: Internal Resolution: %s\n", OSDM1.c_str()));
T0.push_back(StringFromFormat("4: Lock Aspect Ratio: %s%s\n", OSDM21.c_str(), OSDM22.c_str()));
T0.push_back(StringFromFormat("5: Copy Embedded Framebuffer to %s: %s\n", OSDM31.c_str(), OSDM32.c_str()));
T0.push_back(StringFromFormat("6: Fog: %s\n", g_Config.bDisableFog ? "Disabled" : "Enabled"));
T0.push_back(StringFromFormat("7: Material Lighting: %s\n", g_Config.bDisableLighting ? "Disabled" : "Enabled"));
T0.push_back(StringFromFormat("6: Fog: %s\n", g_ActiveConfig.bDisableFog ? "Disabled" : "Enabled"));
T0.push_back(StringFromFormat("7: Material Lighting: %s\n", g_ActiveConfig.bDisableLighting ? "Disabled" : "Enabled"));
// The latest changed setting in yellow
T1 += (OSDChoice == -1) ? T0.at(0) : "\n";
@ -1347,9 +1252,9 @@ THREAD_RETURN TakeScreenshot(void *pArgs)
float FloatH = (float)threadStruct->H;
// Handle aspect ratio for the final ScrStrct to look exactly like what's on screen.
if (g_Config.bKeepAR43 || g_Config.bKeepAR169)
if (g_ActiveConfig.bKeepAR43 || g_ActiveConfig.bKeepAR169)
{
float Ratio = (FloatW / FloatH) / (g_Config.bKeepAR43 ? (4.0f / 3.0f) : (16.0f / 9.0f));
float Ratio = (FloatW / FloatH) / (g_ActiveConfig.bKeepAR43 ? (4.0f / 3.0f) : (16.0f / 9.0f));
// If ratio > 1 the picture is too wide and we have to limit the width.
if (Ratio > 1)
@ -1438,30 +1343,11 @@ void Renderer::FlipImageData(u8 *data, int w, int h)
}
}
// This function does not have the final picture. Use Renderer::Swap() to adjust the final picture.
// Call schedule: Called from VertexShaderManager
// Called from VertexShaderManager
void UpdateViewport()
{
// ---------
// Logging
// ---------
// reversed gxsetviewport(xorig, yorig, width, height, nearz, farz)
// [0] = width/2
// [1] = height/2
// [2] = 16777215 * (farz - nearz)
// [3] = xorig + width/2 + 342
// [4] = yorig + height/2 + 342
// [5] = 16777215 * farz
/*INFO_LOG(VIDEO, "view: topleft=(%f,%f), wh=(%f,%f), z=(%f,%f)",
rawViewport[3]-rawViewport[0]-342, rawViewport[4]+rawViewport[1]-342,
2 * rawViewport[0], 2 * rawViewport[1],
(rawViewport[5] - rawViewport[2]) / 16777215.0f, rawViewport[5] / 16777215.0f);*/
// --------
int scissorXOff = bpmem.scissorOffset.x * 2; // 342
int scissorYOff = bpmem.scissorOffset.y * 2; // 342
// -------------------------------------
float MValueX = Renderer::GetTargetScaleX();
float MValueY = Renderer::GetTargetScaleY();
@ -1477,30 +1363,4 @@ void UpdateViewport()
// Update the view port
glViewport(GLx, GLy, GLWidth, GLHeight);
glDepthRange(GLNear, GLFar);
// -------------------------------------
// Logging
/*
RECT RcTop, RcParent, RcChild;
HWND Child = EmuWindow::GetWnd();
HWND Parent = GetParent(Child);
HWND Top = GetParent(Parent);
GetWindowRect(Top, &RcTop);
GetWindowRect(Parent, &RcParent);
GetWindowRect(Child, &RcChild);
//Console::ClearScreen();
DEBUG_LOG(CONSOLE, "----------------------------------------------------------------");
DEBUG_LOG(CONSOLE, "Top window: X:%03i Y:%03i Width:%03i Height:%03i", RcTop.left, RcTop.top, RcTop.right - RcTop.left, RcTop.bottom - RcTop.top);
DEBUG_LOG(CONSOLE, "Parent window: X:%03i Y:%03i Width:%03i Height:%03i", RcParent.left, RcParent.top, RcParent.right - RcParent.left, RcParent.bottom - RcParent.top);
DEBUG_LOG(CONSOLE, "Child window: X:%03i Y:%03i Width:%03i Height:%03i", RcChild.left, RcChild.top, RcChild.right - RcChild.left, RcChild.bottom - RcChild.top);
DEBUG_LOG(CONSOLE, "----------------------------------------------------------------");
DEBUG_LOG(CONSOLE, "Res. MValue: X:%f Y:%f XOffs:%f YOffs:%f", OpenGL_GetXmax(), OpenGL_GetYmax(), OpenGL_GetXoff(), OpenGL_GetYoff());
DEBUG_LOG(CONSOLE, "GLViewPort: X:%03i Y:%03i Width:%03i Height:%03i", GLx, GLy, GLWidth, GLHeight);
DEBUG_LOG(CONSOLE, "GLDepthRange: Near:%f Far:%f", GLNear, GLFar);
DEBUG_LOG(CONSOLE, "GLScissor: X:%03i Y:%03i Width:%03i Height:%03i", GLScissorX, GLScissorY, GLScissorW, GLScissorH);
DEBUG_LOG(CONSOLE, "----------------------------------------------------------------");
*/
}

View File

@ -11,7 +11,6 @@ name = "Plugin_VideoOGL"
files = [
'BPFunctions.cpp',
'Config.cpp',
'DLCache.cpp',
'rasterfont.cpp',
'Render.cpp',

View File

@ -116,7 +116,7 @@ FRAGMENTSHADER &GetOrCreateEncodingShader(u32 format)
const char* shader = TextureConversionShader::GenerateEncodingShader(format);
#if defined(_DEBUG) || defined(DEBUGFAST)
if (g_Config.iLog & CONF_SAVESHADERS && shader) {
if (g_ActiveConfig.iLog & CONF_SAVESHADERS && shader) {
static int counter = 0;
char szTemp[MAX_PATH];
sprintf(szTemp, "%s/enc_%04i.txt", FULL_DUMP_DIR, counter++);

View File

@ -112,9 +112,9 @@ void TextureMngr::TCacheEntry::SetTextureParameters(TexMode0 &newmode)
{
// very limited!
glTexParameteri(GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MAG_FILTER,
(newmode.mag_filter || g_Config.bForceFiltering) ? GL_LINEAR : GL_NEAREST);
(newmode.mag_filter || g_ActiveConfig.bForceFiltering) ? GL_LINEAR : GL_NEAREST);
glTexParameteri(GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MIN_FILTER,
(g_Config.bForceFiltering || newmode.min_filter >= 4) ? GL_LINEAR : GL_NEAREST);
(g_ActiveConfig.bForceFiltering || newmode.min_filter >= 4) ? GL_LINEAR : GL_NEAREST);
if (newmode.wrap_s == 2 || newmode.wrap_t == 2)
DEBUG_LOG(VIDEO, "cannot support mirrorred repeat mode");
@ -129,19 +129,19 @@ void TextureMngr::TCacheEntry::SetTextureParameters(TexMode0 &newmode)
if (bHaveMipMaps) {
int filt = newmode.min_filter;
if (g_Config.bForceFiltering && newmode.min_filter < 4)
if (g_ActiveConfig.bForceFiltering && newmode.min_filter < 4)
newmode.min_filter += 4; // take equivalent forced linear
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, c_MinLinearFilter[filt]);
}
else
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER,
(g_Config.bForceFiltering || newmode.min_filter >= 4) ? GL_LINEAR : GL_NEAREST);
(g_ActiveConfig.bForceFiltering || newmode.min_filter >= 4) ? GL_LINEAR : GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, c_WrapSettings[newmode.wrap_s]);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, c_WrapSettings[newmode.wrap_t]);
}
if (g_Config.iMaxAnisotropy >= 1)
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, (float)(1 << g_Config.iMaxAnisotropy));
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, (float)(1 << g_ActiveConfig.iMaxAnisotropy));
}
void TextureMngr::TCacheEntry::Destroy(bool shutdown)
@ -149,7 +149,7 @@ void TextureMngr::TCacheEntry::Destroy(bool shutdown)
if (!texture)
return;
glDeleteTextures(1, &texture);
if (!isRenderTarget && !shutdown && !g_Config.bSafeTextureCache) {
if (!isRenderTarget && !shutdown && !g_ActiveConfig.bSafeTextureCache) {
u32 *ptr = (u32*)g_VideoInitialize.pGetMemoryPointer(addr + hashoffset * 4);
if (ptr && *ptr == hash)
*ptr = oldpixel;
@ -160,7 +160,7 @@ void TextureMngr::TCacheEntry::Destroy(bool shutdown)
void TextureMngr::Init()
{
temp = (u8*)AllocateMemoryPages(TEMP_SIZE);
TexDecoder_SetTexFmtOverlayOptions(g_Config.bTexFmtOverlayEnable, g_Config.bTexFmtOverlayCenter);
TexDecoder_SetTexFmtOverlayOptions(g_ActiveConfig.bTexFmtOverlayEnable, g_ActiveConfig.bTexFmtOverlayCenter);
HiresTextures::Init(((struct SConfig *)globals->config)->m_LocalCoreStartupParameter.GetUniqueID().c_str());
}
@ -268,10 +268,10 @@ TextureMngr::TCacheEntry* TextureMngr::Load(int texstage, u32 address, int width
u32 texID = address;
u32 texHash;
if (g_Config.bSafeTextureCache || g_Config.bHiresTextures || g_Config.bDumpTextures)
if (g_ActiveConfig.bSafeTextureCache || g_ActiveConfig.bHiresTextures || g_ActiveConfig.bDumpTextures)
{
texHash = TexDecoder_GetSafeTextureHash(ptr, expandedWidth, expandedHeight, tex_format, 0); // remove last arg
if (g_Config.bSafeTextureCache)
if (g_ActiveConfig.bSafeTextureCache)
hash_value = texHash;
if ((tex_format == GX_TF_C4) || (tex_format == GX_TF_C8) || (tex_format == GX_TF_C14X2))
{
@ -284,7 +284,7 @@ TextureMngr::TCacheEntry* TextureMngr::Load(int texstage, u32 address, int width
// we must make sure that texture with different tluts get different IDs.
u32 tlutHash = TexDecoder_GetTlutHash(&texMem[tlutaddr], (tex_format == GX_TF_C4) ? 32 : 128);
texHash ^= tlutHash;
if (g_Config.bSafeTextureCache)
if (g_ActiveConfig.bSafeTextureCache)
texID ^= tlutHash;
//DebugLog("addr: %08x | texID: %08x | texHash: %08x", address, texID, hash_value);
}
@ -296,7 +296,7 @@ TextureMngr::TCacheEntry* TextureMngr::Load(int texstage, u32 address, int width
if (iter != textures.end()) {
TCacheEntry &entry = iter->second;
if (!g_Config.bSafeTextureCache)
if (!g_ActiveConfig.bSafeTextureCache)
hash_value = ((u32 *)ptr)[entry.hashoffset];
if (entry.isRenderTarget || ((address == entry.addr) && (hash_value == entry.hash)))
@ -307,7 +307,7 @@ TextureMngr::TCacheEntry* TextureMngr::Load(int texstage, u32 address, int width
glBindTexture(entry.isRectangle ? GL_TEXTURE_RECTANGLE_ARB : GL_TEXTURE_2D, entry.texture);
if (entry.mode.hex != tm0.hex)
entry.SetTextureParameters(tm0);
//DebugLog("%cC addr: %08x | fmt: %i | e.hash: %08x | w:%04i h:%04i", g_Config.bSafeTextureCache ? 'S' : 'U'
//DebugLog("%cC addr: %08x | fmt: %i | e.hash: %08x | w:%04i h:%04i", g_ActiveConfig.bSafeTextureCache ? 'S' : 'U'
// , address, tex_format, entry.hash, width, height);
return &entry;
}
@ -335,7 +335,7 @@ TextureMngr::TCacheEntry* TextureMngr::Load(int texstage, u32 address, int width
TCacheEntry& entry = textures[texID];
PC_TexFormat dfmt = PC_TEX_FMT_NONE;
if (g_Config.bHiresTextures)
if (g_ActiveConfig.bHiresTextures)
{
//Load Custom textures
char texPathTemp[MAX_PATH];
@ -361,14 +361,14 @@ TextureMngr::TCacheEntry* TextureMngr::Load(int texstage, u32 address, int width
//entry.paletteHash = hashseed;
entry.oldpixel = ((u32 *)ptr)[entry.hashoffset];
if (g_Config.bSafeTextureCache)
if (g_ActiveConfig.bSafeTextureCache)
entry.hash = hash_value;
else
{
entry.hash = (u32)(((double)rand() / RAND_MAX) * 0xFFFFFFFF);
((u32 *)ptr)[entry.hashoffset] = entry.hash;
}
//DebugLog("%c addr: %08x | fmt: %i | e.hash: %08x | w:%04i h:%04i", g_Config.bSafeTextureCache ? 'S' : 'U'
//DebugLog("%c addr: %08x | fmt: %i | e.hash: %08x | w:%04i h:%04i", g_ActiveConfig.bSafeTextureCache ? 'S' : 'U'
// , address, tex_format, entry.hash, width, height);
@ -462,7 +462,7 @@ TextureMngr::TCacheEntry* TextureMngr::Load(int texstage, u32 address, int width
entry.fmt = tex_format;
entry.SetTextureParameters(tm0);
if (g_Config.bDumpTextures) // dump texture to file
if (g_ActiveConfig.bDumpTextures) // dump texture to file
{
char szTemp[MAX_PATH];
@ -731,7 +731,7 @@ void TextureMngr::CopyRenderTargetToTexture(u32 address, bool bFromZBuffer, bool
GL_REPORT_ERRORD();
if (g_Config.bDumpEFBTarget)
if (g_ActiveConfig.bDumpEFBTarget)
{
static int count = 0;
SaveTexture(StringFromFormat("%s/efb_frame_%i.tga", FULL_DUMP_TEXTURES_DIR, count++).c_str(), GL_TEXTURE_RECTANGLE_ARB, entry.texture, entry.w, entry.h);

View File

@ -156,7 +156,7 @@ void Flush()
_assert_(s_pCurBufferPointer != s_pBaseBufferPointer);
#if defined(_DEBUG) || defined(DEBUGFAST)
PRIM_LOG("frame%d:\n texgen=%d, numchan=%d, dualtex=%d, ztex=%d, cole=%d, alpe=%d, ze=%d", g_Config.iSaveTargetId, xfregs.numTexGens,
PRIM_LOG("frame%d:\n texgen=%d, numchan=%d, dualtex=%d, ztex=%d, cole=%d, alpe=%d, ze=%d", g_ActiveConfig.iSaveTargetId, xfregs.numTexGens,
xfregs.nNumChans, (int)xfregs.bEnableDualTexTransform, bpmem.ztex2.op,
bpmem.blendmode.colorupdate, bpmem.blendmode.alphaupdate, bpmem.zmode.updateenable);
@ -242,7 +242,7 @@ void Flush()
// texture is hires - pass the scaling size
if (tentry->scaleX != 1.0f || tentry->scaleY != 1.0f)
PixelShaderManager::SetCustomTexScale(i, tentry->scaleX, tentry->scaleY);
if (g_Config.iLog & CONF_SAVETEXTURES)
if (g_ActiveConfig.iLog & CONF_SAVETEXTURES)
{
// save the textures
char strfile[255];
@ -287,7 +287,7 @@ void Flush()
}
// run through vertex groups again to set alpha
if (!g_Config.bDstAlphaPass && bpmem.dstalpha.enable && bpmem.blendmode.alphaupdate)
if (!g_ActiveConfig.bDstAlphaPass && bpmem.dstalpha.enable && bpmem.blendmode.alphaupdate)
{
ps = PixelShaderCache::GetShader(true);
@ -317,22 +317,22 @@ void Flush()
}
#if defined(_DEBUG) || defined(DEBUGFAST)
if (g_Config.iLog & CONF_SAVESHADERS)
if (g_ActiveConfig.iLog & CONF_SAVESHADERS)
{
// save the shaders
char strfile[255];
sprintf(strfile, "%sframes/ps%.3d.txt", FULL_DUMP_DIR, g_Config.iSaveTargetId);
sprintf(strfile, "%sframes/ps%.3d.txt", FULL_DUMP_DIR, g_ActiveConfig.iSaveTargetId);
std::ofstream fps(strfile);
fps << ps->strprog.c_str();
sprintf(strfile, "%sframes/vs%.3d.txt", FULL_DUMP_DIR, g_Config.iSaveTargetId);
sprintf(strfile, "%sframes/vs%.3d.txt", FULL_DUMP_DIR, g_ActiveConfig.iSaveTargetId);
std::ofstream fvs(strfile);
fvs << vs->strprog.c_str();
}
if (g_Config.iLog & CONF_SAVETARGETS)
if (g_ActiveConfig.iLog & CONF_SAVETARGETS)
{
char str[128];
sprintf(str, "%sframes/targ%.3d.tga", FULL_DUMP_DIR, g_Config.iSaveTargetId);
sprintf(str, "%sframes/targ%.3d.tga", FULL_DUMP_DIR, g_ActiveConfig.iSaveTargetId);
Renderer::SaveRenderTarget(str, Renderer::GetTargetWidth(), Renderer::GetTargetHeight());
}
#endif

View File

@ -41,8 +41,7 @@ bool VertexShaderCache::s_displayCompileAlert;
static VERTEXSHADER *pShaderLast = NULL;
static int s_nMaxVertexInstructions;
static float lastVSconstants[C_FOGPARAMS+8][4];
static float GC_ALIGNED16(lastVSconstants[C_FOGPARAMS+8][4]);
void SetVSConstant4f(int const_number, float f1, float f2, float f3, float f4)
{
@ -144,7 +143,7 @@ VERTEXSHADER* VertexShaderCache::GetShader(u32 components)
const char *code = GenerateVertexShader(components, false);
#if defined(_DEBUG) || defined(DEBUGFAST)
if (g_Config.iLog & CONF_SAVESHADERS && code) {
if (g_ActiveConfig.iLog & CONF_SAVESHADERS && code) {
static int counter = 0;
char szTemp[MAX_PATH];
sprintf(szTemp, "%s/vs_%04i.txt", FULL_DUMP_DIR, counter++);

View File

@ -70,6 +70,11 @@ GFXDebuggerOGL *m_DebuggerFrame = NULL;
#endif // HAVE_WX
#include "Config.h"
// Having to include this is TERRIBLY ugly. FIXME x100
#include "Globals.h"
#include "../../../Core/Core/Src/ConfigManager.h" // FIXME
#include "LookUpTables.h"
#include "ImageWrite.h"
#include "Render.h"
@ -280,6 +285,12 @@ void CocaAddResolutions() {
void DllConfig(HWND _hParent)
{
g_Config.Load(FULL_CONFIG_DIR "gfx_opengl.ini");
// UGLY
IniFile *iniFile = ((struct SConfig *)globals->config)->m_LocalCoreStartupParameter.gameIni;
g_Config.GameIniLoad(iniFile);
g_Config.UpdateProjectionHack();
UpdateActiveConfig();
#if defined(HAVE_WX) && HAVE_WX
// Prevent user to show more than 1 config window at same time
if (allowConfigShow) {
@ -314,14 +325,17 @@ void Initialize(void *init)
g_VideoInitialize = *(_pVideoInitialize);
InitXFBConvTables();
g_Config.Load();
g_Config.GameIniLoad();
g_Config.Load(FULL_CONFIG_DIR "gfx_opengl.ini");
// UGLY
IniFile *iniFile = ((struct SConfig *)globals->config)->m_LocalCoreStartupParameter.gameIni;
g_Config.GameIniLoad(iniFile);
#if defined(HAVE_WX) && HAVE_WX
g_Config.UpdateProjectionHack();
//Enable support for PNG screenshots.
wxImage::AddHandler( new wxPNGHandler );
#endif
UpdateActiveConfig();
if (!OpenGL_Create(g_VideoInitialize, 640, 480)) {
g_VideoInitialize.pLog("Renderer::Create failed\n", TRUE);
@ -460,7 +474,7 @@ void VideoFifo_CheckSwapRequest()
{
if (Common::AtomicLoadAcquire(s_swapRequested))
{
if (ForceSwap || g_Config.bUseXFB)
if (ForceSwap || g_ActiveConfig.bUseXFB)
{
Renderer::Swap(s_beginFieldArgs.xfbAddr, s_beginFieldArgs.field, s_beginFieldArgs.fbWidth, s_beginFieldArgs.fbHeight);
g_VideoInitialize.pCopiedToXFB(false);
@ -481,7 +495,7 @@ inline bool addrRangesOverlap(u32 aLower, u32 aUpper, u32 bLower, u32 bUpper)
// Run from the graphics thread (from Fifo.cpp)
void VideoFifo_CheckSwapRequestAt(u32 xfbAddr, u32 fbWidth, u32 fbHeight)
{
if (Common::AtomicLoadAcquire(s_swapRequested) && g_Config.bUseXFB)
if (Common::AtomicLoadAcquire(s_swapRequested) && g_ActiveConfig.bUseXFB)
{
u32 aLower = xfbAddr;
u32 aUpper = xfbAddr + 2 * fbWidth * fbHeight;