more uninteresting cleanup, fixed a minor race condition when toggling efb copy mode

git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@4261 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
hrydgard
2009-09-13 10:18:01 +00:00
parent 2d93c654f0
commit 73d2b3e968
12 changed files with 30 additions and 56 deletions

View File

@ -348,7 +348,7 @@ THREAD_RETURN EmuThread(void *pArg)
CPluginManager &Plugins = CPluginManager::GetInstance(); CPluginManager &Plugins = CPluginManager::GetInstance();
if (_CoreParameter.bLockThreads) if (_CoreParameter.bLockThreads)
Common::Thread::SetCurrentThreadAffinity(2); // Force to second core Common::Thread::SetCurrentThreadAffinity(2); // Force to second core
INFO_LOG(OSREPORT, "Starting core = %s mode", _CoreParameter.bWii ? "Wii" : "Gamecube"); INFO_LOG(OSREPORT, "Starting core = %s mode", _CoreParameter.bWii ? "Wii" : "Gamecube");
INFO_LOG(OSREPORT, "Dualcore = %s", _CoreParameter.bUseDualCore ? "Yes" : "No"); INFO_LOG(OSREPORT, "Dualcore = %s", _CoreParameter.bUseDualCore ? "Yes" : "No");
@ -485,6 +485,8 @@ THREAD_RETURN EmuThread(void *pArg)
#ifdef _WIN32 #ifdef _WIN32
// the spawned CPU Thread is the... CPU thread but it also does the graphics. // the spawned CPU Thread is the... CPU thread but it also does the graphics.
// the EmuThread is thus an idle thread, which sleeps and wait for the emu to terminate. // the EmuThread is thus an idle thread, which sleeps and wait for the emu to terminate.
// Without this extra thread, the video plugin window hangs in single core mode since
// noone is pumping messages.
cpuThread = new Common::Thread(CpuThread, pArg); cpuThread = new Common::Thread(CpuThread, pArg);
Common::SetCurrentThreadName("Emuthread - Idle"); Common::SetCurrentThreadName("Emuthread - Idle");

View File

@ -23,8 +23,6 @@ namespace
static bool g_ProjHack0; static bool g_ProjHack0;
static ProjectionHack g_ProjHack1; static ProjectionHack g_ProjHack1;
static ProjectionHack g_ProjHack2; static ProjectionHack g_ProjHack2;
static bool g_FreeLook;
static bool g_Widescreen;
} // Namespace } // Namespace
@ -43,16 +41,6 @@ void Projection_SetHack2(ProjectionHack value)
g_ProjHack2 = value; g_ProjHack2 = value;
} }
void Projection_SetFreeLook(bool enabled)
{
g_FreeLook = enabled;
}
void Projection_SetWidescreen(bool enabled)
{
g_Widescreen = enabled;
}
bool Projection_GetHack0() bool Projection_GetHack0()
{ {
return g_ProjHack0; return g_ProjHack0;
@ -68,17 +56,6 @@ ProjectionHack Projection_GetHack2()
return g_ProjHack2; return g_ProjHack2;
} }
bool Projection_GetFreeLook()
{
return g_FreeLook;
}
bool Projection_GetWidescreen()
{
return g_Widescreen;
}
void UpdateProjectionHack(int iPhackvalue) void UpdateProjectionHack(int iPhackvalue)
{ {
bool bProjHack1=0, bPhackvalue1=0, bPhackvalue2=0; bool bProjHack1=0, bPhackvalue1=0, bPhackvalue2=0;

View File

@ -56,13 +56,9 @@ struct ProjectionHack
void Projection_SetHack0(bool value); void Projection_SetHack0(bool value);
void Projection_SetHack1(ProjectionHack value); void Projection_SetHack1(ProjectionHack value);
void Projection_SetHack2(ProjectionHack value); void Projection_SetHack2(ProjectionHack value);
void Projection_SetFreeLook(bool enabled);
void Projection_SetWidescreen(bool enabled);
bool Projection_GetHack0(); bool Projection_GetHack0();
ProjectionHack Projection_GetHack1(); ProjectionHack Projection_GetHack1();
ProjectionHack Projection_GetHack2(); ProjectionHack Projection_GetHack2();
bool Projection_GetFreeLook();
bool Projection_GetWidescreen();
void UpdateProjectionHack(int hackIdx); void UpdateProjectionHack(int hackIdx);

View File

@ -88,4 +88,6 @@ public:
static void Swap(u32 xfbAddr, FieldType field, u32 fbWidth, u32 fbHeight); static void Swap(u32 xfbAddr, FieldType field, u32 fbWidth, u32 fbHeight);
}; };
void UpdateViewport();
#endif // _COMMON_RENDER_H_ #endif // _COMMON_RENDER_H_

View File

@ -16,6 +16,7 @@
// http://code.google.com/p/dolphin-emu/ // http://code.google.com/p/dolphin-emu/
#include "Common.h" #include "Common.h"
#include "VideoConfig.h"
#include "MathUtil.h" #include "MathUtil.h"
#include "Profiler.h" #include "Profiler.h"
@ -216,9 +217,8 @@ void VertexShaderManager::SetConstants()
if (xfregs.rawProjection[6] == 0) if (xfregs.rawProjection[6] == 0)
{ {
bool bWidescreenHack = Projection_GetWidescreen();
// Perspective // Perspective
g_fProjectionMatrix[0] = (bWidescreenHack ? xfregs.rawProjection[0]*0.75f : xfregs.rawProjection[0]); g_fProjectionMatrix[0] = (g_ActiveConfig.bWidescreenHack ? xfregs.rawProjection[0]*0.75f : xfregs.rawProjection[0]);
g_fProjectionMatrix[1] = 0.0f; g_fProjectionMatrix[1] = 0.0f;
g_fProjectionMatrix[2] = xfregs.rawProjection[1]; g_fProjectionMatrix[2] = xfregs.rawProjection[1];
g_fProjectionMatrix[3] = 0.0f; g_fProjectionMatrix[3] = 0.0f;
@ -313,7 +313,7 @@ void VertexShaderManager::SetConstants()
PRIM_LOG("Projection: %f %f %f %f %f %f\n", xfregs.rawProjection[0], xfregs.rawProjection[1], xfregs.rawProjection[2], xfregs.rawProjection[3], xfregs.rawProjection[4], xfregs.rawProjection[5]); PRIM_LOG("Projection: %f %f %f %f %f %f\n", xfregs.rawProjection[0], xfregs.rawProjection[1], xfregs.rawProjection[2], xfregs.rawProjection[3], xfregs.rawProjection[4], xfregs.rawProjection[5]);
if (Projection_GetFreeLook()) if (g_ActiveConfig.bFreeLook)
{ {
Matrix44 mtxA; Matrix44 mtxA;
Matrix44 mtxB; Matrix44 mtxB;

View File

@ -22,20 +22,20 @@
#include "VideoConfig.h" #include "VideoConfig.h"
#include "VideoCommon.h" #include "VideoCommon.h"
Config g_Config; VideoConfig g_Config;
Config g_ActiveConfig; VideoConfig g_ActiveConfig;
void UpdateActiveConfig() void UpdateActiveConfig()
{ {
g_ActiveConfig = g_Config; g_ActiveConfig = g_Config;
} }
Config::Config() VideoConfig::VideoConfig()
{ {
bRunning = false; bRunning = false;
} }
void Config::Load(const char *ini_file) void VideoConfig::Load(const char *ini_file)
{ {
std::string temp; std::string temp;
IniFile iniFile; IniFile iniFile;
@ -105,7 +105,7 @@ void Config::Load(const char *ini_file)
SetEnableAlert(bTmp); SetEnableAlert(bTmp);
} }
void Config::GameIniLoad(const char *ini_file) void VideoConfig::GameIniLoad(const char *ini_file)
{ {
IniFile iniFile; IniFile iniFile;
iniFile.Load(ini_file); iniFile.Load(ini_file);
@ -121,7 +121,7 @@ void Config::GameIniLoad(const char *ini_file)
iniFile.Get("Video", "ProjectionHack", &iPhackvalue, 0); iniFile.Get("Video", "ProjectionHack", &iPhackvalue, 0);
} }
void Config::Save(const char *ini_file) void VideoConfig::Save(const char *ini_file)
{ {
IniFile iniFile; IniFile iniFile;
iniFile.Load(ini_file); iniFile.Load(ini_file);

View File

@ -51,9 +51,9 @@ enum MultisampleMode {
class IniFile; class IniFile;
// NEVER inherit from this class. // NEVER inherit from this class.
struct Config struct VideoConfig
{ {
Config(); VideoConfig();
void Load(const char *ini_file); void Load(const char *ini_file);
void GameIniLoad(const char *ini_file); void GameIniLoad(const char *ini_file);
void Save(const char *ini_file); void Save(const char *ini_file);
@ -128,12 +128,16 @@ struct Config
bool bVsync; bool bVsync;
// With this enabled, the plugin renders directly to the backbuffer. Many features are
// disabled but it might be faster on really old GPUs.
bool bSimpleFB;
// Runtime detection config // Runtime detection config
bool bOldCard; bool bOldCard;
}; };
extern Config g_Config; extern VideoConfig g_Config;
extern Config g_ActiveConfig; extern VideoConfig g_ActiveConfig;
// Called every frame. // Called every frame.
void UpdateActiveConfig(); void UpdateActiveConfig();

View File

@ -65,8 +65,9 @@ bool Renderer::Init()
UpdateActiveConfig(); UpdateActiveConfig();
EmuWindow::SetSize(g_Res[g_ActiveConfig.iWindowedRes][0], g_Res[g_ActiveConfig.iWindowedRes][1]); EmuWindow::SetSize(g_Res[g_ActiveConfig.iWindowedRes][0], g_Res[g_ActiveConfig.iWindowedRes][1]);
int backbuffer_ms_mode = g_ActiveConfig.iMultisampleMode;
D3D::Create(g_ActiveConfig.iAdapter, EmuWindow::GetWnd(), g_ActiveConfig.bFullscreen, D3D::Create(g_ActiveConfig.iAdapter, EmuWindow::GetWnd(), g_ActiveConfig.bFullscreen,
g_ActiveConfig.iFSResolution, g_ActiveConfig.iMultisampleMode); g_ActiveConfig.iFSResolution, backbuffer_ms_mode);
s_targetWidth = D3D::GetDisplayWidth(); s_targetWidth = D3D::GetDisplayWidth();
s_targetHeight = D3D::GetDisplayHeight(); s_targetHeight = D3D::GetDisplayHeight();
@ -92,7 +93,6 @@ bool Renderer::Init()
D3D::dev->SetSamplerState(i, D3DSAMP_MAXANISOTROPY, 16); D3D::dev->SetSamplerState(i, D3DSAMP_MAXANISOTROPY, 16);
D3D::BeginFrame(true, 0, 1.0f); D3D::BeginFrame(true, 0, 1.0f);
VertexManager::BeginFrame();
return true; return true;
} }
@ -308,7 +308,7 @@ void Renderer::SwapBuffers()
// So let's keep it commented out. // So let's keep it commented out.
// D3D::EnableAlphaToCoverage(); // D3D::EnableAlphaToCoverage();
VertexManager::BeginFrame(); UpdateViewport();
if (g_ActiveConfig.bOldCard) if (g_ActiveConfig.bOldCard)
D3D::font.SetRenderStates(); //compatibility with low end cards D3D::font.SetRenderStates(); //compatibility with low end cards

View File

@ -101,10 +101,6 @@ void CreateDeviceObjects()
{ {
} }
void BeginFrame()
{
}
void DestroyDeviceObjects() void DestroyDeviceObjects()
{ {
} }

View File

@ -27,8 +27,6 @@ namespace VertexManager
bool Init(); bool Init();
void Shutdown(); void Shutdown();
void BeginFrame();
void AddVertices(int _primitive, int _numVertices); void AddVertices(int _primitive, int _numVertices);
void Flush(); void Flush();

View File

@ -595,7 +595,6 @@ void GFXConfigDialogOGL::GeneralSettingsChanged(wxCommandEvent& event)
break; break;
case ID_WIDESCREEN_HACK: case ID_WIDESCREEN_HACK:
g_Config.bWidescreenHack = m_WidescreenHack->IsChecked(); g_Config.bWidescreenHack = m_WidescreenHack->IsChecked();
Projection_SetWidescreen(g_Config.bWidescreenHack);
break; break;
case ID_VSYNC: case ID_VSYNC:
g_Config.bVSync = m_VSync->IsChecked(); g_Config.bVSync = m_VSync->IsChecked();
@ -713,7 +712,6 @@ void GFXConfigDialogOGL::AdvancedSettingsChanged(wxCommandEvent& event)
break; break;
case ID_FREELOOK: case ID_FREELOOK:
g_Config.bFreeLook = m_FreeLook->IsChecked(); g_Config.bFreeLook = m_FreeLook->IsChecked();
Projection_SetFreeLook(g_Config.bFreeLook);
break; break;
case ID_TEXTUREPATH: case ID_TEXTUREPATH:
break; break;
@ -731,11 +729,9 @@ void GFXConfigDialogOGL::AdvancedSettingsChanged(wxCommandEvent& event)
g_Config.bHack = m_Hack->IsChecked(); g_Config.bHack = m_Hack->IsChecked();
break; break;
case ID_RADIO_COPYEFBTORAM: case ID_RADIO_COPYEFBTORAM:
TextureMngr::ClearRenderTargets();
g_Config.bCopyEFBToRAM = true; g_Config.bCopyEFBToRAM = true;
break; break;
case ID_RADIO_COPYEFBTOGL: case ID_RADIO_COPYEFBTOGL:
TextureMngr::ClearRenderTargets();
g_Config.bCopyEFBToRAM = false; g_Config.bCopyEFBToRAM = false;
break; break;
case ID_PROJSTATS: case ID_PROJSTATS:
@ -784,7 +780,7 @@ void GFXConfigDialogOGL::UpdateGUI()
} }
void Config::UpdateProjectionHack() void VideoConfig::UpdateProjectionHack()
{ {
::UpdateProjectionHack(g_Config.iPhackvalue); ::UpdateProjectionHack(g_Config.iPhackvalue);
//switch(g_Config.iPhackvalue) //switch(g_Config.iPhackvalue)

View File

@ -979,7 +979,7 @@ void Renderer::Swap(u32 xfbAddr, FieldType field, u32 fbWidth, u32 fbHeight)
free(data); free(data);
s_criticalScreenshot.Leave(); s_criticalScreenshot.Leave();
} else { } else {
if(s_bLastFrameDumped && f_pFrameDump != NULL) { if (s_bLastFrameDumped && f_pFrameDump != NULL) {
fclose(f_pFrameDump); fclose(f_pFrameDump);
f_pFrameDump = NULL; f_pFrameDump = NULL;
} }
@ -996,7 +996,10 @@ void Renderer::Swap(u32 xfbAddr, FieldType field, u32 fbWidth, u32 fbHeight)
GL_REPORT_ERRORD(); GL_REPORT_ERRORD();
g_Config.iSaveTargetId = 0; g_Config.iSaveTargetId = 0;
bool last_copy_efb_to_ram = g_ActiveConfig.bCopyEFBToRAM;
UpdateActiveConfig(); UpdateActiveConfig();
if (last_copy_efb_to_ram != g_ActiveConfig.bCopyEFBToRAM)
TextureMngr::ClearRenderTargets();
// For testing zbuffer targets. // For testing zbuffer targets.
// Renderer::SetZBufferRender(); // Renderer::SetZBufferRender();