From 5897d04917e9d5f116e750bca04ab3ad8029511e Mon Sep 17 00:00:00 2001 From: ramapcsx2 Date: Thu, 5 Mar 2009 20:00:41 +0000 Subject: [PATCH] Experimental commit! Hacked in a way to make GSdx change the renderer on the fly. When you press F11 it will switch to DX9 sowftware rendering. Press it again to get back to the setting you were using before. Notes: -For this change I had to modify a few lines in GSdx. If that's not acceptable we can do more drastic measures and modify the gsdx.ini :p -F11 is currently also used for doing gsstates in debug modes, it will likely be changed. -When in dx10 hardware + fullscreen mode, pressing this key will crash GSdx. Sorry. git-svn-id: http://pcsx2.googlecode.com/svn/trunk@689 96395faa-99c1-11dd-bbfe-3dabce05a288 --- pcsx2/MTGS.cpp | 9 ++++++--- pcsx2/windows/WinSysExec.cpp | 23 +++++++++++++++++++++-- plugins/GSdx/GS.cpp | 12 +++++++++--- 3 files changed, 36 insertions(+), 8 deletions(-) diff --git a/pcsx2/MTGS.cpp b/pcsx2/MTGS.cpp index 5d0c5d6b19..a1fc1b44a7 100644 --- a/pcsx2/MTGS.cpp +++ b/pcsx2/MTGS.cpp @@ -471,7 +471,7 @@ struct PacketTagType u32 command; u32 data[3]; }; - +extern bool renderswitch; int mtgsThreadObject::Callback() { Console::WriteLn("MTGS > Thread Started, Opening GS Plugin..."); @@ -479,8 +479,11 @@ int mtgsThreadObject::Callback() memcpy_aligned( m_gsMem, PS2MEM_GS, sizeof(m_gsMem) ); GSsetBaseMem( m_gsMem ); GSirqCallback( NULL ); - - m_returncode = GSopen((void *)&pDsp, "PCSX2", 1); + + //tells GSdx to go into dx9 sw if "renderswitch" is set. Abusing the isMultiThread int + //for that so we don't need a new callback + if (!renderswitch) m_returncode = GSopen((void *)&pDsp, "PCSX2", 1); + else if (renderswitch) m_returncode = GSopen((void *)&pDsp, "PCSX2", 2); Console::WriteLn( "MTGS > GSopen Finished, return code: 0x%x", params m_returncode ); diff --git a/pcsx2/windows/WinSysExec.cpp b/pcsx2/windows/WinSysExec.cpp index 7d0ddf5ec3..0c966f237e 100644 --- a/pcsx2/windows/WinSysExec.cpp +++ b/pcsx2/windows/WinSysExec.cpp @@ -27,6 +27,7 @@ static bool sinit = false; bool UseGui = true; bool nDisableSC = false; // screensaver +bool renderswitch = 0; // This instance is not modified by command line overrides so @@ -427,7 +428,7 @@ namespace HostGui case VK_F1: case VK_F2: case VK_F3: case VK_F4: case VK_F5: case VK_F6: case VK_F7: case VK_F8: - case VK_F9: case VK_F10: case VK_F11: case VK_F12: + case VK_F9: case VK_F10: case VK_F12: try { ProcessFKeys(ev->key-VK_F1 + 1, shiftkey); @@ -441,7 +442,25 @@ namespace HostGui SysEndExecution(); } break; - + + case VK_F11: //gsdx "on the fly" renderer switching + if (!renderswitch) { + StateRecovery::MakeGsOnly(); + g_EmulationInProgress = false; + ClosePlugins( 1 ); + renderswitch = true; //go to dx9 sw + StateRecovery::Recover(); + HostGui::BeginExecution(); //also sets g_EmulationInProgress to true later + } + else { + StateRecovery::MakeGsOnly(); + g_EmulationInProgress = false; + ClosePlugins( 1 ); + renderswitch = false; //return to default renderer + StateRecovery::Recover(); + HostGui::BeginExecution(); //also sets g_EmulationInProgress to true later + } + break; case VK_TAB: CycleFrameLimit(0); break; diff --git a/plugins/GSdx/GS.cpp b/plugins/GSdx/GS.cpp index 062fbd24c2..996454189a 100644 --- a/plugins/GSdx/GS.cpp +++ b/plugins/GSdx/GS.cpp @@ -154,9 +154,15 @@ static INT32 GSopen(void* dsp, char* title, int mt, int renderer) EXPORT_C_(INT32) GSopen(void* dsp, char* title, int mt) { AFX_MANAGE_STATE(AfxGetStaticModuleState()); - - int renderer = AfxGetApp()->GetProfileInt(_T("Settings"), _T("renderer"), 0); - + int renderer; + + if (mt == 2){ //pcsx2 sent a switch renderer request + renderer = 1; //DX9 sw + mt = 1; + } + else { //normal init + renderer = AfxGetApp()->GetProfileInt(_T("Settings"), _T("renderer"), 0); + } return GSopen(dsp, title, mt, renderer); }