From 3f03f7333c33d0dcb3737fc91909bea18a2a3844 Mon Sep 17 00:00:00 2001 From: Gregory Hainaut Date: Fri, 8 Jul 2016 21:47:53 +0200 Subject: [PATCH] gsdx: improve builtin profiler * Does the first vsync (start counter) after the sleep * Dump data after the rendering, avoid to count extra destructor,sleep time * Dump data into a basic csv file (if people want nice graph) --- plugins/GSdx/GS.cpp | 13 ++++++++----- plugins/GSdx/GSDeviceOGL.cpp | 13 +++++++++---- 2 files changed, 17 insertions(+), 9 deletions(-) diff --git a/plugins/GSdx/GS.cpp b/plugins/GSdx/GS.cpp index 40047b37b8..752919206e 100644 --- a/plugins/GSdx/GS.cpp +++ b/plugins/GSdx/GS.cpp @@ -1569,9 +1569,6 @@ EXPORT_C GSReplay(char* lpszCmdLine, int renderer) file->Read(regs, 0x2000); - GSvsync(1); - - while(!file->IsEof()) { uint8 type; @@ -1628,7 +1625,7 @@ EXPORT_C GSReplay(char* lpszCmdLine, int renderer) delete file; } - sleep(1); + sleep(2); //while(IsWindowVisible(hWnd)) //FIXME map? @@ -1638,6 +1635,10 @@ EXPORT_C GSReplay(char* lpszCmdLine, int renderer) finished = 1; } unsigned long frame_number = 0; + + // Init vsync stuff + GSvsync(1); + while(finished > 0) { for(auto i = packets.begin(); i != packets.end(); i++) @@ -1690,6 +1691,8 @@ EXPORT_C GSReplay(char* lpszCmdLine, int renderer) } } + static_cast(s_gs->m_dev)->GenerateProfilerData(); + #ifdef ENABLE_OGL_DEBUG_MEM_BW unsigned long total_frame_nb = std::max(1ul, frame_number) << 10; fprintf(stderr, "memory bandwith. T: %f KB/f. V: %f KB/f. U: %f KB/f\n", @@ -1706,7 +1709,7 @@ EXPORT_C GSReplay(char* lpszCmdLine, int renderer) packets.clear(); - sleep(1); + sleep(2); GSclose(); GSshutdown(); diff --git a/plugins/GSdx/GSDeviceOGL.cpp b/plugins/GSdx/GSDeviceOGL.cpp index 8b837e0a03..ad61013ece 100644 --- a/plugins/GSdx/GSDeviceOGL.cpp +++ b/plugins/GSdx/GSDeviceOGL.cpp @@ -95,10 +95,6 @@ GSDeviceOGL::~GSDeviceOGL() GL_PUSH("GSDeviceOGL destructor"); - if (GLLoader::in_replayer) { - GenerateProfilerData(); - } - // Clean vertex buffer state delete m_va; @@ -194,6 +190,15 @@ void GSDeviceOGL::GenerateProfilerData() fprintf(stderr, "Max %4.2f ms\t(%4.2f fps)\n", *minmax_time.second, 1000.0 / *minmax_time.second); fprintf(stderr, "SD %4.2f ms\n", sd); fprintf(stderr, "\n"); + + FILE* csv = fopen("GSdx_profile.csv", "w"); + if (csv) { + for (size_t i = 0; i < times.size(); i++) { + fprintf(csv, "%d,%lf\n", i, times[i]); + } + + fclose(csv); + } } GSTexture* GSDeviceOGL::CreateSurface(int type, int w, int h, bool msaa, int fmt)