diff --git a/Source/Core/Core/Src/Core.cpp b/Source/Core/Core/Src/Core.cpp index 63983dac52..428b50d8e1 100644 --- a/Source/Core/Core/Src/Core.cpp +++ b/Source/Core/Core/Src/Core.cpp @@ -73,9 +73,11 @@ void Callback_VideoLog(const TCHAR* _szMessage, BOOL _bDoBreak); void Callback_VideoCopiedToXFB(); void Callback_DSPLog(const TCHAR* _szMessage); void Callback_DSPInterrupt(); -void Callback_DVDLog(const TCHAR* _szMessage); -void Callback_DVDSetStatusbar(TCHAR* _szMessage); void Callback_PADLog(const TCHAR* _szMessage); + +// For keyboard shortcuts. +void Callback_KeyPress(int key, BOOL shift, BOOL control); + TPeekMessages Callback_PeekMessages = NULL; TUpdateFPSDisplay g_pUpdateFPSDisplay = NULL; @@ -270,6 +272,7 @@ THREAD_RETURN EmuThread(void *pArg) VideoInitialize.pCPFifo = (SCPFifoStruct*)&CommandProcessor::fifo; VideoInitialize.pUpdateInterrupts = &(CommandProcessor::UpdateInterruptsFromVideoPlugin); VideoInitialize.pMemoryBase = Memory::base; + VideoInitialize.pKeyPress = Callback_KeyPress; PluginVideo::Video_Initialize(&VideoInitialize); // Under linux, this is an X11 Display, not an HWND! @@ -414,11 +417,11 @@ EState GetState() } void SaveState() { - State_Save("state.dlp"); + State_Save(0); } void LoadState() { - State_Load("state.dlp"); + State_Load(0); } const SCoreStartupParameter& GetStartupParameter() @@ -517,25 +520,6 @@ void Callback_DSPInterrupt() DSP::GenerateDSPInterruptFromPlugin(DSP::INT_DSP); } -// __________________________________________________________________________________________________ -// Callback_DVDLog -// -void Callback_DVDLog(TCHAR* _szMessage) -{ - LOG(DVDINTERFACE, _szMessage); -} - -// __________________________________________________________________________________________________ -// Callback_DVDSetStatusbar -// -void Callback_DVDSetStatusbar(TCHAR* _szMessage) -{ - //Todo: PostMessage to main window to set the string -// strDVDMessage = _szMessage; -// if (g_CoreStartupParameter.m_StatusUpdate != NULL) -// g_CoreStartupParameter.m_StatusUpdate(); -} - // __________________________________________________________________________________________________ // Callback_PADLog // @@ -544,4 +528,20 @@ void Callback_PADLog(const TCHAR* _szMessage) LOG(SERIALINTERFACE, _szMessage); } + +// Called from ANY thread! +void Callback_KeyPress(int key, BOOL shift, BOOL control) +{ + // 0x70 == VK_F1 + if (key >= 0x70 && key < 0x79) { + // F-key + int slot_number = key - 0x70 + 1; + if (shift) { + State_Save(slot_number); + } else { + State_Load(slot_number); + } + } +} + } // end of namespace Core diff --git a/Source/Core/Core/Src/HW/SerialInterface_Devices.cpp b/Source/Core/Core/Src/HW/SerialInterface_Devices.cpp index 8abead6fb8..d7e1a36d51 100644 --- a/Source/Core/Core/Src/HW/SerialInterface_Devices.cpp +++ b/Source/Core/Core/Src/HW/SerialInterface_Devices.cpp @@ -195,7 +195,8 @@ CSIDevice_GCController::SendCommand(u32 _Cmd) { unsigned int uType = command.Parameter1; // 0 = stop, 1 = rumble, 2 = stop hard unsigned int uStrength = command.Parameter2; - PluginPAD::PAD_Rumble(ISIDevice::m_iDeviceNumber, uType, uStrength); + if (PluginPAD::PAD_Rumble) + PluginPAD::PAD_Rumble(ISIDevice::m_iDeviceNumber, uType, uStrength); } break; diff --git a/Source/Core/Core/Src/State.cpp b/Source/Core/Core/Src/State.cpp index ef811bac8f..31183e9f72 100644 --- a/Source/Core/Core/Src/State.cpp +++ b/Source/Core/Core/Src/State.cpp @@ -37,8 +37,18 @@ static int ev_Load; static std::string cur_filename; +enum { + version = 1 +}; + void DoState(PointerWrap &p) { + u32 cookie = 0xBAADBABE + version; + p.Do(cookie); + if (cookie != 0xBAADBABE + version) { + PanicAlert("Can't load states from other versions."); + return; + } // Begin with video plugin, so that it gets a chance to clear it's caches and writeback modified things to RAM PluginVideo::Video_DoState(p.GetPPtr(), p.GetMode()); PluginDSP::DSP_DoState(p.GetPPtr(), p.GetMode()); @@ -50,7 +60,6 @@ void DoState(PointerWrap &p) void SaveStateCallback(u64 userdata, int cyclesLate) { Jit64::ClearCache(); - u8 *ptr = 0; PointerWrap p(&ptr, PointerWrap::MODE_MEASURE); DoState(p); @@ -65,14 +74,17 @@ void SaveStateCallback(u64 userdata, int cyclesLate) delete [] buffer; - Core::DisplayMessage("Saved State", 2000); + Core::DisplayMessage(StringFromFormat("Saved State to %s", cur_filename.c_str()).c_str(), 2000); } void LoadStateCallback(u64 userdata, int cyclesLate) { - Jit64::ClearCache(); - FILE *f = fopen(cur_filename.c_str(), "rb"); + if (!f) { + Core::DisplayMessage("State not found", 2000); + return; + } + Jit64::ClearCache(); fseek(f, 0, SEEK_END); int sz = ftell(f); fseek(f, 0, SEEK_SET); @@ -87,7 +99,7 @@ void LoadStateCallback(u64 userdata, int cyclesLate) DoState(p); delete [] buffer; - Core::DisplayMessage("Loaded State", 2000); + Core::DisplayMessage(StringFromFormat("Loaded state from %s", cur_filename.c_str()).c_str(), 2000); } void State_Init() @@ -101,18 +113,18 @@ void State_Shutdown() // nothing to do, here for consistency. } -std::string GetStateFilename(int state_number) { +std::string MakeStateFilename(int state_number) { return StringFromFormat("StateSaves/%s.s%02i", Core::GetStartupParameter().GetUniqueID().c_str(), state_number); } -void State_Save(const char *filename) +void State_Save(int slot) { - cur_filename = GetStateFilename(0); + cur_filename = MakeStateFilename(slot); CoreTiming::ScheduleEvent_Threadsafe(0, ev_Save); } -void State_Load(const char *filename) +void State_Load(int slot) { - cur_filename = GetStateFilename(0); + cur_filename = MakeStateFilename(slot); CoreTiming::ScheduleEvent_Threadsafe(0, ev_Load); } diff --git a/Source/Core/Core/Src/State.h b/Source/Core/Core/Src/State.h index e2800ff240..2dc5798c95 100644 --- a/Source/Core/Core/Src/State.h +++ b/Source/Core/Core/Src/State.h @@ -22,7 +22,8 @@ void State_Init(); void State_Shutdown(); // These don't happen instantly - they get scheduled as events. -void State_Save(const char *filename); -void State_Load(const char *filename); +// Slots from 0-99. +void State_Save(int slot); +void State_Load(int slot); #endif diff --git a/Source/Core/DolphinWX/src/Frame.cpp b/Source/Core/DolphinWX/src/Frame.cpp index c9b926c58e..a88a5b0e5c 100644 --- a/Source/Core/DolphinWX/src/Frame.cpp +++ b/Source/Core/DolphinWX/src/Frame.cpp @@ -25,6 +25,7 @@ #include "Common.h" #include "Config.h" #include "Core.h" +#include "State.h" #include "PluginOptions.h" #include "PluginManager.h" #include "MemcardManager.h" @@ -95,8 +96,26 @@ EVT_MENU(IDM_MEMCARD, CFrame::OnMemcard) EVT_MENU(IDM_TOGGLE_FULLSCREEN, CFrame::OnToggleFullscreen) EVT_MENU(IDM_TOGGLE_DUALCORE, CFrame::OnToggleDualCore) EVT_MENU(IDM_TOGGLE_TOOLBAR, CFrame::OnToggleToolbar) -EVT_MENU(IDM_LOADSTATE, CFrame::OnLoadState) -EVT_MENU(IDM_SAVESTATE, CFrame::OnSaveState) +EVT_MENU(IDM_LOADSLOT1, CFrame::OnLoadState) +EVT_MENU(IDM_LOADSLOT2, CFrame::OnLoadState) +EVT_MENU(IDM_LOADSLOT3, CFrame::OnLoadState) +EVT_MENU(IDM_LOADSLOT4, CFrame::OnLoadState) +EVT_MENU(IDM_LOADSLOT5, CFrame::OnLoadState) +EVT_MENU(IDM_LOADSLOT6, CFrame::OnLoadState) +EVT_MENU(IDM_LOADSLOT7, CFrame::OnLoadState) +EVT_MENU(IDM_LOADSLOT8, CFrame::OnLoadState) +EVT_MENU(IDM_LOADSLOT9, CFrame::OnLoadState) +EVT_MENU(IDM_LOADSLOT10, CFrame::OnLoadState) +EVT_MENU(IDM_SAVESLOT1, CFrame::OnSaveState) +EVT_MENU(IDM_SAVESLOT2, CFrame::OnSaveState) +EVT_MENU(IDM_SAVESLOT3, CFrame::OnSaveState) +EVT_MENU(IDM_SAVESLOT4, CFrame::OnSaveState) +EVT_MENU(IDM_SAVESLOT5, CFrame::OnSaveState) +EVT_MENU(IDM_SAVESLOT6, CFrame::OnSaveState) +EVT_MENU(IDM_SAVESLOT7, CFrame::OnSaveState) +EVT_MENU(IDM_SAVESLOT8, CFrame::OnSaveState) +EVT_MENU(IDM_SAVESLOT9, CFrame::OnSaveState) +EVT_MENU(IDM_SAVESLOT10, CFrame::OnSaveState) EVT_HOST_COMMAND(wxID_ANY, CFrame::OnHostMessage) END_EVENT_TABLE() @@ -167,32 +186,32 @@ void CFrame::CreateMenu() // file menu wxMenu* fileMenu = new wxMenu; - fileMenu->Append(wxID_OPEN, _T("&Open...")); + fileMenu->Append(wxID_OPEN, _T("&Open...\tCtrl+O")); fileMenu->Append(wxID_REFRESH, _T("&Refresh")); fileMenu->Append(IDM_BROWSE, _T("&Browse for ISOs...")); fileMenu->AppendSeparator(); - fileMenu->Append(wxID_EXIT, _T("E&xit"), _T("")); + fileMenu->Append(wxID_EXIT, _T("E&xit"), _T("Alt+F4")); m_pMenuBar->Append(fileMenu, _T("&File")); // emulation menu wxMenu* emulationMenu = new wxMenu; - m_pMenuItemPlay = new wxMenuItem(fileMenu, IDM_PLAY, _T("&Play")); - emulationMenu->Append(m_pMenuItemPlay); - m_pMenuItemStop = new wxMenuItem(fileMenu, IDM_STOP, _T("&Stop")); - emulationMenu->Append(m_pMenuItemStop); + m_pMenuItemPlay = emulationMenu->Append(IDM_PLAY, _T("&Play")); + m_pMenuItemStop = emulationMenu->Append(IDM_STOP, _T("&Stop")); emulationMenu->AppendSeparator(); - - m_pMenuItemLoad = new wxMenuItem(fileMenu, IDM_LOADSTATE, _T("&Load State")); - emulationMenu->Append(m_pMenuItemLoad); - m_pMenuItemSave = new wxMenuItem(fileMenu, IDM_SAVESTATE, _T("Sa&ve State")); - emulationMenu->Append(m_pMenuItemSave); + wxMenu *saveMenu = new wxMenu; + wxMenu *loadMenu = new wxMenu; + m_pMenuItemLoad = emulationMenu->AppendSubMenu(saveMenu, _T("&Load State")); + m_pMenuItemSave = emulationMenu->AppendSubMenu(loadMenu, _T("Sa&ve State")); + for (int i = 1; i < 10; i++) { + saveMenu->Append(IDM_LOADSLOT1 + i - 1, wxString::Format(_T("Slot %i F%i"), i, i)); + loadMenu->Append(IDM_SAVESLOT1 + i - 1, wxString::Format(_T("Slot %i Shift+F%i"), i, i)); + } m_pMenuBar->Append(emulationMenu, _T("&Emulation")); // options menu wxMenu* pOptionsMenu = new wxMenu; - m_pPluginOptions = new wxMenuItem(pOptionsMenu, IDM_PLUGIN_OPTIONS, _T("&Select plugins")); - pOptionsMenu->Append(m_pPluginOptions); + m_pPluginOptions = pOptionsMenu->Append(IDM_PLUGIN_OPTIONS, _T("&Select plugins")); pOptionsMenu->AppendSeparator(); pOptionsMenu->Append(IDM_CONFIG_GFX_PLUGIN, _T("&GFX settings")); pOptionsMenu->Append(IDM_CONFIG_DSP_PLUGIN, _T("&DSP settings")); @@ -501,14 +520,18 @@ void CFrame::OnToggleDualCore(wxCommandEvent& WXUNUSED (event)) SConfig::GetInstance().SaveSettings(); } -void CFrame::OnLoadState(wxCommandEvent& WXUNUSED (event)) +void CFrame::OnLoadState(wxCommandEvent& event) { - Core::LoadState(); + int id = event.GetId(); + int slot = id - IDM_LOADSLOT1 + 1; + State_Load(slot); } -void CFrame::OnSaveState(wxCommandEvent& WXUNUSED (event)) +void CFrame::OnSaveState(wxCommandEvent& event) { - Core::SaveState(); + int id = event.GetId(); + int slot = id - IDM_SAVESLOT1 + 1; + State_Save(slot); } void CFrame::OnToggleToolbar(wxCommandEvent& event) diff --git a/Source/Core/DolphinWX/src/Globals.h b/Source/Core/DolphinWX/src/Globals.h index 15625906c9..89ff5a2176 100644 --- a/Source/Core/DolphinWX/src/Globals.h +++ b/Source/Core/DolphinWX/src/Globals.h @@ -22,6 +22,26 @@ enum { IDM_LOADSTATE = 200, IDM_SAVESTATE, + IDM_SAVESLOT1, + IDM_SAVESLOT2, + IDM_SAVESLOT3, + IDM_SAVESLOT4, + IDM_SAVESLOT5, + IDM_SAVESLOT6, + IDM_SAVESLOT7, + IDM_SAVESLOT8, + IDM_SAVESLOT9, + IDM_SAVESLOT10, + IDM_LOADSLOT1, + IDM_LOADSLOT2, + IDM_LOADSLOT3, + IDM_LOADSLOT4, + IDM_LOADSLOT5, + IDM_LOADSLOT6, + IDM_LOADSLOT7, + IDM_LOADSLOT8, + IDM_LOADSLOT9, + IDM_LOADSLOT10, IDM_PLAY, IDM_STOP, IDM_BROWSE, diff --git a/Source/Core/VideoCommon/Src/SConscript b/Source/Core/VideoCommon/Src/SConscript index cab758ea50..012ac7b8d7 100644 --- a/Source/Core/VideoCommon/Src/SConscript +++ b/Source/Core/VideoCommon/Src/SConscript @@ -9,6 +9,7 @@ files = [ "XFBConvert.cpp", "Fifo.cpp", "VideoState.cpp", + "Profiler.cpp", ] env_common = env.Copy() diff --git a/Source/Core/VideoCommon/VideoCommon.vcproj b/Source/Core/VideoCommon/VideoCommon.vcproj index 0a72472bd4..7f775ee9aa 100644 --- a/Source/Core/VideoCommon/VideoCommon.vcproj +++ b/Source/Core/VideoCommon/VideoCommon.vcproj @@ -1,7 +1,7 @@ + + + + diff --git a/Source/PluginSpecs/pluginspecs_video.h b/Source/PluginSpecs/pluginspecs_video.h index d72b232df0..bbc205433a 100644 --- a/Source/PluginSpecs/pluginspecs_video.h +++ b/Source/PluginSpecs/pluginspecs_video.h @@ -18,6 +18,7 @@ typedef void (*TCopiedToXFB)(void); typedef BOOL (*TPeekMessages)(void); typedef void (*TUpdateInterrupts)(void); typedef void (*TUpdateFPSDisplay)(const char* text); // sets the window title +typedef void (*TKeyPressed)(int keycode, BOOL shift, BOOL control); // sets the window title typedef struct { @@ -54,8 +55,9 @@ typedef struct TPeekMessages pPeekMessages; TUpdateInterrupts pUpdateInterrupts; TUpdateFPSDisplay pUpdateFPSDisplay; - SCPFifoStruct *pCPFifo; + TKeyPressed pKeyPress; + SCPFifoStruct *pCPFifo; unsigned char *pVIRegs; void *pMemoryBase; } SVideoInitialize; diff --git a/Source/Plugins/Plugin_VideoDX9/Plugin_VideoDX9.vcproj b/Source/Plugins/Plugin_VideoDX9/Plugin_VideoDX9.vcproj index 0732cc4f1f..a61054d064 100644 --- a/Source/Plugins/Plugin_VideoDX9/Plugin_VideoDX9.vcproj +++ b/Source/Plugins/Plugin_VideoDX9/Plugin_VideoDX9.vcproj @@ -740,6 +740,14 @@ RelativePath=".\Src\W32Util\DialogManager.h" > + + + + @@ -1366,14 +1374,6 @@ RelativePath=".\Src\D3DUtil.h" > - - - - sendMessage(KEYDOWN...); */ } + g_VideoInitialize.pKeyPress(LOWORD(wParam), GetAsyncKeyState(VK_SHIFT) != 0, GetAsyncKeyState(VK_CONTROL) != 0); break; case WM_CLOSE: @@ -157,6 +159,6 @@ namespace EmuWindow rc.right = rc.left + w; rc.top = (1024 - h)/2; rc.bottom = rc.top + h; - ::MoveWindow(m_hWnd, rc.left,rc.top,rc.right-rc.left,rc.bottom-rc.top, TRUE); + ::MoveWindow(m_hWnd, rc.left, rc.top, rc.right-rc.left, rc.bottom-rc.top, TRUE); } } \ No newline at end of file diff --git a/Source/Plugins/Plugin_VideoOGL/Src/BPStructs.cpp b/Source/Plugins/Plugin_VideoOGL/Src/BPStructs.cpp index f19eac6387..8d806140aa 100644 --- a/Source/Plugins/Plugin_VideoOGL/Src/BPStructs.cpp +++ b/Source/Plugins/Plugin_VideoOGL/Src/BPStructs.cpp @@ -16,6 +16,7 @@ // http://code.google.com/p/dolphin-emu/ #include "Globals.h" +#include "Profiler.h" #include "VertexLoader.h" diff --git a/Source/Plugins/Plugin_VideoOGL/Src/Globals.cpp b/Source/Plugins/Plugin_VideoOGL/Src/Globals.cpp index 6172096770..af6d46d0a9 100644 --- a/Source/Plugins/Plugin_VideoOGL/Src/Globals.cpp +++ b/Source/Plugins/Plugin_VideoOGL/Src/Globals.cpp @@ -182,269 +182,6 @@ bool SaveTexture(const char* filename, u32 textarget, u32 tex, int width, int he return SaveTGA(filename, width, height, &data[0]); } -//////////////////// -// Small profiler // -//////////////////// -#include -#include -#include -using namespace std; - -int g_bWriteProfile=0; - -#ifdef _WIN32 - -#if defined (_MSC_VER) && _MSC_VER >= 1400 -#include -#pragma intrinsic(__rdtsc) -#endif - -static u64 luPerfFreq=0; -inline u64 GET_PROFILE_TIME() -{ -#if defined (_MSC_VER) && _MSC_VER >= 1400 - return __rdtsc(); -#else - LARGE_INTEGER lu; - QueryPerformanceCounter(&lu); - return lu.QuadPart; -#endif -} -#else -static u64 luPerfFreq=1000000; -#define GET_PROFILE_TIME() //GetCpuTick() -#endif - - -struct DVPROFSTRUCT; - -struct DVPROFSTRUCT -{ - struct DATA - { - DATA(u64 time, u32 user = 0) : dwTime(time), dwUserData(user) {} - DATA() : dwTime(0), dwUserData(0) {} - - u64 dwTime; - u32 dwUserData; - }; - - ~DVPROFSTRUCT() { - list::iterator it = listpChild.begin(); - while(it != listpChild.end() ) { - delete *it; *it = NULL; - ++it; - } - } - - list listTimes; // before DVProfEnd is called, contains the global time it started - // after DVProfEnd is called, contains the time it lasted - // the list contains all the tracked times - char pname[256]; - - list listpChild; // other profilers called during this profiler period -}; - -struct DVPROFTRACK -{ - u32 dwUserData; - DVPROFSTRUCT::DATA* pdwTime; - DVPROFSTRUCT* pprof; -}; - -list g_listCurTracking; // the current profiling functions, the back element is the - // one that will first get popped off the list when DVProfEnd is called - // the pointer is an element in DVPROFSTRUCT::listTimes -list g_listProfilers; // the current profilers, note that these are the parents - // any profiler started during the time of another is held in - // DVPROFSTRUCT::listpChild -list g_listAllProfilers; // ignores the hierarchy, pointer to elements in g_listProfilers - -void DVProfRegister(const char *pname) -{ - if (!g_bWriteProfile) - return; - -#ifdef _WIN32 - if (luPerfFreq <= 1) { -#if defined (_MSC_VER) && _MSC_VER >= 1400 - luPerfFreq = 1000000; -#else - LARGE_INTEGER temp; - QueryPerformanceFrequency(&temp); - luPerfFreq = temp.QuadPart; -#endif - } -#endif - - list::iterator it = g_listAllProfilers.begin(); - -// while(it != g_listAllProfilers.end() ) { -// -// if( _tcscmp(pname, (*it)->pname) == 0 ) { -// (*it)->listTimes.push_back(timeGetTime()); -// DVPROFTRACK dvtrack; -// dvtrack.pdwTime = &(*it)->listTimes.back(); -// dvtrack.pprof = *it; -// g_listCurTracking.push_back(dvtrack); -// return; -// } -// -// ++it; -// } - - // else add in a new profiler to the appropriate parent profiler - DVPROFSTRUCT* pprof = NULL; - - if (g_listCurTracking.size() > 0) { - _assert_( g_listCurTracking.back().pprof != NULL ); - g_listCurTracking.back().pprof->listpChild.push_back(new DVPROFSTRUCT()); - pprof = g_listCurTracking.back().pprof->listpChild.back(); - } - else { - g_listProfilers.push_back(DVPROFSTRUCT()); - pprof = &g_listProfilers.back(); - } - - strncpy(pprof->pname, pname, 256); - - // setup the profiler for tracking - pprof->listTimes.push_back(DVPROFSTRUCT::DATA(GET_PROFILE_TIME())); - - DVPROFTRACK dvtrack; - dvtrack.pdwTime = &pprof->listTimes.back(); - dvtrack.pprof = pprof; - dvtrack.dwUserData = 0; - - g_listCurTracking.push_back(dvtrack); - - // add to all profiler list - g_listAllProfilers.push_back(pprof); -} - -void DVProfEnd(u32 dwUserData) -{ - if (!g_bWriteProfile) - return; - if (g_listCurTracking.size() == 0) - return; - - DVPROFTRACK dvtrack = g_listCurTracking.back(); - - _assert_( dvtrack.pdwTime != NULL && dvtrack.pprof != NULL ); - - dvtrack.pdwTime->dwTime = GET_PROFILE_TIME()- dvtrack.pdwTime->dwTime; - dvtrack.pdwTime->dwUserData= dwUserData; - - g_listCurTracking.pop_back(); -} - -struct DVTIMEINFO -{ - DVTIMEINFO() : uInclusive(0), uExclusive(0) {} - u64 uInclusive, uExclusive; -}; - -map mapAggregateTimes; - -u64 DVProfWriteStruct(FILE* f, DVPROFSTRUCT* p, int ident) -{ - fprintf(f, "%*s%s - ", ident, "", p->pname); - - list::iterator ittime = p->listTimes.begin(); - - u64 utime = 0; - - while(ittime != p->listTimes.end() ) { - utime += ittime->dwTime; - - if (ittime->dwUserData) - fprintf(f, "time: %d, user: 0x%8.8x", (u32)ittime->dwTime, ittime->dwUserData); - else - fprintf(f, "time: %d", (u32)ittime->dwTime); - ++ittime; - } - - // yes this is necessary, maps have problems with constructors on their type - map::iterator ittimes = mapAggregateTimes.find(p->pname); - if (ittimes == mapAggregateTimes.end()) { - ittimes = mapAggregateTimes.insert(map::value_type(p->pname, DVTIMEINFO())).first; - ittimes->second.uExclusive = 0; - ittimes->second.uInclusive = 0; - } - - ittimes->second.uInclusive += utime; - - fprintf(f, "\n"); - - list::iterator itprof = p->listpChild.begin(); - - u64 uex = utime; - while(itprof != p->listpChild.end() ) { - - uex -= DVProfWriteStruct(f, *itprof, ident+4); - ++itprof; - } - - if (uex > utime) { - uex = 0; - } - - ittimes->second.uExclusive += uex; - return utime; -} - -void DVProfWrite(const char* pfilename, u32 frames) -{ - _assert_( pfilename != NULL ); - FILE* f = fopen(pfilename, "w"); - - // pop back any unused - mapAggregateTimes.clear(); - list::iterator it = g_listProfilers.begin(); - - while(it != g_listProfilers.end() ) { - DVProfWriteStruct(f, &(*it), 0); - ++it; - } - - { - map::iterator it; - fprintf(f, "\n\n-------------------------------------------------------------------\n\n"); - - u64 uTotal[2] = {0}; - double fiTotalTime[2]; - - for(it = mapAggregateTimes.begin(); it != mapAggregateTimes.end(); ++it) { - uTotal[0] += it->second.uExclusive; - uTotal[1] += it->second.uInclusive; - } - - fprintf(f, "total times (%d): ex: %Lu ", frames, 1000000*uTotal[0]/(luPerfFreq*(u64)frames)); - fprintf(f, "inc: %Lu\n", 1000000 * uTotal[1]/(luPerfFreq*(u64)frames)); - - fiTotalTime[0] = 1.0 / (double)uTotal[0]; - fiTotalTime[1] = 1.0 / (double)uTotal[1]; - - // output the combined times - for(it = mapAggregateTimes.begin(); it != mapAggregateTimes.end(); ++it) { - fprintf(f, "%s - ex: %f inc: %f\n", it->first.c_str(), (float)((double)it->second.uExclusive * fiTotalTime[0]), - (float)((double)it->second.uInclusive * fiTotalTime[1])); - } - } - - - fclose(f); -} - -void DVProfClear() -{ - g_listCurTracking.clear(); - g_listProfilers.clear(); - g_listAllProfilers.clear(); -} - - #ifdef _WIN32 // The one for Linux is in Linux/Linux.cpp static HANDLE hConsole = NULL; diff --git a/Source/Plugins/Plugin_VideoOGL/Src/Globals.h b/Source/Plugins/Plugin_VideoOGL/Src/Globals.h index 5fba86cd02..7ce3e3b491 100644 --- a/Source/Plugins/Plugin_VideoOGL/Src/Globals.h +++ b/Source/Plugins/Plugin_VideoOGL/Src/Globals.h @@ -269,54 +269,4 @@ inline float Memory_Read_Float(u32 _uAddress) return temp.f; } -//// -// profiling -/// - -extern int g_bWriteProfile; // global variable to enable/disable profiling (if DVPROFILE is defined) - -// IMPORTANT: For every Reigster there must be an End -void DVProfRegister(const char* pname); // first checks if this profiler exists in g_listProfilers -void DVProfEnd(u32 dwUserData); -void DVProfWrite(const char* pfilename, u32 frames = 0); -void DVProfClear(); // clears all the profilers - -//#define DVPROFILE // comment out to disable profiling - -#if defined(DVPROFILE) && (defined(_WIN32)||defined(WIN32)) - -#ifdef _MSC_VER - -#ifndef __PRETTY_FUNCTION__ -#define __PRETTY_FUNCTION__ __FUNCTION__ -#endif - -#endif - -#define DVSTARTPROFILE() DVProfileFunc _pf(__PRETTY_FUNCTION__); - -class DVProfileFunc -{ -public: - u32 dwUserData; - DVProfileFunc(const char* pname) { DVProfRegister(pname); dwUserData = 0; } - DVProfileFunc(const char* pname, u32 dwUserData) : dwUserData(dwUserData) { DVProfRegister(pname); } - ~DVProfileFunc() { DVProfEnd(dwUserData); } -}; - -#else - -#define DVSTARTPROFILE() - -class DVProfileFunc -{ -public: - u32 dwUserData; - __forceinline DVProfileFunc(const char* pname) {} - __forceinline DVProfileFunc(const char* pname, u32 dwUserData) { } - ~DVProfileFunc() {} -}; - -#endif - #endif diff --git a/Source/Plugins/Plugin_VideoOGL/Src/OS/Win32.cpp b/Source/Plugins/Plugin_VideoOGL/Src/OS/Win32.cpp index 9adfc11543..323841ebec 100644 --- a/Source/Plugins/Plugin_VideoOGL/Src/OS/Win32.cpp +++ b/Source/Plugins/Plugin_VideoOGL/Src/OS/Win32.cpp @@ -25,6 +25,7 @@ #include #include "../Globals.h" +#include "main.h" #include "../../Core/Src/Core.h" #include "Win32.h" @@ -118,6 +119,7 @@ namespace EmuWindow hypotheticalScene->sendMessage(KEYDOWN...); */ } + g_VideoInitialize.pKeyPress(LOWORD(wParam), GetAsyncKeyState(VK_SHIFT) != 0, GetAsyncKeyState(VK_CONTROL) != 0); break; case WM_CLOSE: diff --git a/Source/Plugins/Plugin_VideoOGL/Src/OpcodeDecoding.cpp b/Source/Plugins/Plugin_VideoOGL/Src/OpcodeDecoding.cpp index 5abdd35a2c..6055240867 100644 --- a/Source/Plugins/Plugin_VideoOGL/Src/OpcodeDecoding.cpp +++ b/Source/Plugins/Plugin_VideoOGL/Src/OpcodeDecoding.cpp @@ -25,6 +25,7 @@ // called. The reason is that the vertex format affects the sizes of the vertices. #include "Globals.h" +#include "Profiler.h" #include "OpcodeDecoding.h" #include "VertexLoader.h" #include "VertexShaderManager.h" diff --git a/Source/Plugins/Plugin_VideoOGL/Src/PixelShader.cpp b/Source/Plugins/Plugin_VideoOGL/Src/PixelShader.cpp index e71c306d1f..28b0939faa 100644 --- a/Source/Plugins/Plugin_VideoOGL/Src/PixelShader.cpp +++ b/Source/Plugins/Plugin_VideoOGL/Src/PixelShader.cpp @@ -21,6 +21,7 @@ #include #include +#include "Profiler.h" #include "PixelShader.h" #include "XFMemory.h" // for texture projection mode #include "BPMemory.h" diff --git a/Source/Plugins/Plugin_VideoOGL/Src/PixelShaderManager.cpp b/Source/Plugins/Plugin_VideoOGL/Src/PixelShaderManager.cpp index 01a2c12826..e315f240d0 100644 --- a/Source/Plugins/Plugin_VideoOGL/Src/PixelShaderManager.cpp +++ b/Source/Plugins/Plugin_VideoOGL/Src/PixelShaderManager.cpp @@ -16,6 +16,7 @@ // http://code.google.com/p/dolphin-emu/ #include "Globals.h" +#include "Profiler.h" #include diff --git a/Source/Plugins/Plugin_VideoOGL/Src/Render.cpp b/Source/Plugins/Plugin_VideoOGL/Src/Render.cpp index 579caf6e39..1a253e0df5 100644 --- a/Source/Plugins/Plugin_VideoOGL/Src/Render.cpp +++ b/Source/Plugins/Plugin_VideoOGL/Src/Render.cpp @@ -23,6 +23,7 @@ #endif #include "GLInit.h" +#include "Profiler.h" #include "Render.h" #include "OpcodeDecoding.h" #include "BPStructs.h" diff --git a/Source/Plugins/Plugin_VideoOGL/Src/TextureMngr.cpp b/Source/Plugins/Plugin_VideoOGL/Src/TextureMngr.cpp index 4b24a6ca05..23547096b7 100644 --- a/Source/Plugins/Plugin_VideoOGL/Src/TextureMngr.cpp +++ b/Source/Plugins/Plugin_VideoOGL/Src/TextureMngr.cpp @@ -20,6 +20,7 @@ #endif #include "Globals.h" +#include "Profiler.h" #include "Render.h" diff --git a/Source/Plugins/Plugin_VideoOGL/Src/VertexLoader.cpp b/Source/Plugins/Plugin_VideoOGL/Src/VertexLoader.cpp index 7d1cd5413e..d1324df9d3 100644 --- a/Source/Plugins/Plugin_VideoOGL/Src/VertexLoader.cpp +++ b/Source/Plugins/Plugin_VideoOGL/Src/VertexLoader.cpp @@ -20,6 +20,7 @@ #include #include "x64Emitter.h" +#include "Profiler.h" #include "Render.h" #include "VertexLoader.h" diff --git a/Source/Plugins/Plugin_VideoOGL/Src/VertexShader.cpp b/Source/Plugins/Plugin_VideoOGL/Src/VertexShader.cpp index 2c28d5a4c0..d96bee5b7d 100644 --- a/Source/Plugins/Plugin_VideoOGL/Src/VertexShader.cpp +++ b/Source/Plugins/Plugin_VideoOGL/Src/VertexShader.cpp @@ -16,6 +16,7 @@ // http://code.google.com/p/dolphin-emu/ #include "Globals.h" +#include "Profiler.h" #include #include "BPStructs.h" diff --git a/Source/Plugins/Plugin_VideoOGL/Src/VertexShaderManager.cpp b/Source/Plugins/Plugin_VideoOGL/Src/VertexShaderManager.cpp index 589035da75..dcefafbf96 100644 --- a/Source/Plugins/Plugin_VideoOGL/Src/VertexShaderManager.cpp +++ b/Source/Plugins/Plugin_VideoOGL/Src/VertexShaderManager.cpp @@ -18,6 +18,8 @@ #include "Globals.h" +#include "Profiler.h" + #include #include "Render.h" #include "VertexShader.h"