From 50eb11c66f49b8370f7efb36ce4cef5b5974ce47 Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Sun, 19 May 2013 20:20:41 -0700 Subject: [PATCH] Log some additional things during reporting. --- Core/HLE/sceDisplay.cpp | 36 ++++++++++++++++++++++------ Core/HLE/sceDisplay.h | 1 + Core/Reporting.cpp | 53 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 83 insertions(+), 7 deletions(-) diff --git a/Core/HLE/sceDisplay.cpp b/Core/HLE/sceDisplay.cpp index b26e7b850..52fb50300 100644 --- a/Core/HLE/sceDisplay.cpp +++ b/Core/HLE/sceDisplay.cpp @@ -115,6 +115,13 @@ enum { PSP_DISPLAY_SETBUF_NEXTFRAME = 1 }; +static int lastFpsFrame = 0; +static double lastFpsTime = 0.0; +static double fps = 0.0; +static double fpsHistory[120]; +static size_t fpsHistoryPos = 0; +static size_t fpsHistoryValid = 0; + void hleEnterVblank(u64 userdata, int cyclesLate); void hleLeaveVblank(u64 userdata, int cyclesLate); void hleAfterFlip(u64 userdata, int cyclesLate); @@ -143,6 +150,9 @@ void __DisplayInit() { curFrameTime = 0.0; nextFrameTime = 0.0; + fpsHistoryPos = 0; + fpsHistoryValid = 0; + InitGfxState(); } @@ -203,15 +213,25 @@ void __DisplayFireVblank() { } } -static double highestFps = 0.0; -static int lastFpsFrame = 0; -static double lastFpsTime = 0.0; -static double fps = 0.0; - void __DisplayGetFPS(float *out_vps, float *out_fps) { *out_vps = *out_fps = fps; } +void __DisplayGetAveragedFPS(float *out_vps, float *out_fps) { + float avg = 0.0; + if (fpsHistoryValid > 0) { + if (fpsHistoryValid > ARRAY_SIZE(fpsHistory)) { + fpsHistoryValid = ARRAY_SIZE(fpsHistory); + } + for (size_t i = 0; i < fpsHistoryValid; ++i) { + avg += fpsHistory[i]; + } + avg /= (double) fpsHistoryValid; + } + + *out_vps = *out_fps = avg; +} + void CalculateFPS() { time_update(); @@ -220,11 +240,13 @@ void CalculateFPS() if (now >= lastFpsTime + 1.0) { fps = (gpuStats.numFrames - lastFpsFrame) / (now - lastFpsTime); - if (fps > highestFps) - highestFps = fps; lastFpsFrame = gpuStats.numFrames; lastFpsTime = now; + + fpsHistory[fpsHistoryPos++] = fps; + fpsHistoryPos = fpsHistoryPos % ARRAY_SIZE(fpsHistory); + ++fpsHistoryValid; } } diff --git a/Core/HLE/sceDisplay.h b/Core/HLE/sceDisplay.h index c32799eb7..c6d784eef 100644 --- a/Core/HLE/sceDisplay.h +++ b/Core/HLE/sceDisplay.h @@ -35,3 +35,4 @@ void __DisplayListenVblank(VblankCallback callback); void __DisplayGetDebugStats(char stats[2048]); void __DisplayGetFPS(float *out_vps, float *out_fps); +void __DisplayGetAveragedFPS(float *out_vps, float *out_fps); diff --git a/Core/Reporting.cpp b/Core/Reporting.cpp index 26b9ee44a..be8d1f191 100644 --- a/Core/Reporting.cpp +++ b/Core/Reporting.cpp @@ -19,8 +19,11 @@ #include "Common/CPUDetect.h" #include "Common/StdThread.h" +#include "Core/CoreTiming.h" #include "Core/Config.h" #include "Core/System.h" +#include "Core/HLE/sceDisplay.h" +#include "Core/HLE/sceKernelMemory.h" #include "GPU/GPUInterface.h" #include "GPU/GPUState.h" @@ -59,6 +62,45 @@ namespace Reporting AppendEscaped(value); } + void Add(const std::string &key, const char *value) + { + Add(key, std::string(value)); + } + + template + void AddT(const std::string &key, const char *fmt, const T value) + { + char temp[64]; + snprintf(temp, sizeof(temp), fmt, value); + temp[sizeof(temp) - 1] = '\0'; + Add(key, temp); + } + + void Add(const std::string &key, const int value) + { + AddT(key, "%d", value); + } + + void Add(const std::string &key, const u32 value) + { + AddT(key, "%u", value); + } + + void Add(const std::string &key, const u64 value) + { + AddT(key, "%llu", value); + } + + void Add(const std::string &key, const double value) + { + AddT(key, "%f", value); + } + + void Add(const std::string &key, const bool value) + { + Add(key, value ? "true" : "false"); + } + // Percent encoding, aka application/x-www-form-urlencoded. void AppendEscaped(const std::string &value) { @@ -255,6 +297,17 @@ namespace Reporting postdata.Add("gpu_full", gpuFull); postdata.Add("cpu", cpu_info.Summarize()); postdata.Add("platform", GetPlatformIdentifer()); + postdata.Add("sdkver", sceKernelGetCompiledSdkVersion()); + postdata.Add("pixel_width", PSP_CoreParameter().pixelWidth); + postdata.Add("pixel_height", PSP_CoreParameter().pixelHeight); + postdata.Add("ticks", CoreTiming::GetTicks()); + + if (g_Config.bShowFPSCounter) + { + float vps, fps; + __DisplayGetAveragedFPS(&vps, &fps); + postdata.Add("vps", vps); + } // TODO: Settings, savestate/savedata status, some measure of speed/fps?