Hook up the frame profiler to a few measurements

This commit is contained in:
Henrik Rydgard 2015-05-13 22:28:02 +02:00
parent 0595a76556
commit 26624709f7
12 changed files with 108 additions and 3 deletions

View File

@ -761,6 +761,7 @@ void Config::Load(const char *iniFileName, const char *controllerIniFilename) {
INFO_LOG(LOADER, "Loading config: %s", iniFilename_.c_str());
bSaveSettings = true;
bShowFrameProfiler = true;
IniFile iniFile;
if (!iniFile.Load(iniFilename_)) {

View File

@ -374,6 +374,9 @@ public:
bool bSkipDeadbeefFilling;
bool bFuncHashMap;
// Volatile development settings
bool bShowFrameProfiler;
std::string currentDirectory;
std::string externalDirectory;
std::string memStickDirectory;

View File

@ -20,6 +20,8 @@
#include "native/thread/thread.h"
#include "native/thread/threadutil.h"
#include "profiler/profiler.h"
#include "Core/Core.h"
#include "Core/Config.h"
#include "Core/Debugger/Breakpoints.h"
@ -760,6 +762,7 @@ static u32 npdrmRead(FileNode *f, u8 *data, int size) {
}
static bool __IoRead(int &result, int id, u32 data_addr, int size, int &us) {
PROFILE_THIS_SCOPE("ioread");
// Low estimate, may be improved later from the ReadFile result.
us = size / 100;
if (us < 100) {

View File

@ -16,6 +16,8 @@
// https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/.
#include "base/basictypes.h"
#include "profiler/profiler.h"
#include "Globals.h"
#include "Core/MemMapHelpers.h"
#include "Core/HLE/sceAtrac.h"
@ -525,6 +527,8 @@ void SasInstance::MixVoice(SasVoice &voice) {
}
void SasInstance::Mix(u32 outAddr, u32 inAddr, int leftVol, int rightVol) {
PROFILE_THIS_SCOPE("mixer");
int voicesPlayingCount = 0;
for (int v = 0; v < PSP_SAS_VOICES_MAX; v++) {

View File

@ -25,6 +25,8 @@
#include <string.h>
#include <algorithm>
#include "profiler/profiler.h"
#include "Common/CPUDetect.h"
#include "Core/Config.h"
@ -752,6 +754,7 @@ u32 DrawEngineCommon::NormalizeVertices(u8 *outPtr, u8 *bufPtr, const u8 *inPtr,
const GEPrimitiveType primType[] = { GE_PRIM_TRIANGLES, GE_PRIM_LINES, GE_PRIM_POINTS };
void DrawEngineCommon::SubmitSpline(const void *control_points, const void *indices, int count_u, int count_v, int type_u, int type_v, GEPatchPrimType prim_type, u32 vertType) {
PROFILE_THIS_SCOPE("spline");
DispatchFlush();
// TODO: Verify correct functionality with < 4.
@ -830,6 +833,8 @@ void DrawEngineCommon::SubmitSpline(const void *control_points, const void *indi
}
void DrawEngineCommon::SubmitBezier(const void *control_points, const void *indices, int count_u, int count_v, GEPatchPrimType prim_type, u32 vertType) {
PROFILE_THIS_SCOPE("bezier");
DispatchFlush();
// TODO: Verify correct functionality with < 4.

View File

@ -17,6 +17,7 @@
#include "base/logging.h"
#include "gfx_es2/gl_state.h"
#include "profiler/profiler.h"
#include "Common/ChunkFile.h"

View File

@ -21,7 +21,8 @@
#include "StateMapping.h"
#include "native/gfx_es2/gl_state.h"
#include "gfx_es2/gl_state.h"
#include "profiler/profiler.h"
#include "GPU/Math3D.h"
#include "GPU/GPUState.h"
@ -568,6 +569,8 @@ void TransformDrawEngine::ApplyBlendState() {
}
void TransformDrawEngine::ApplyDrawState(int prim) {
PROFILE_THIS_SCOPE("applydrawstate");
// TODO: All this setup is soon so expensive that we'll need dirty flags, or simply do it in the command writes where we detect dirty by xoring. Silly to do all this work on every drawcall.
if (gstate_c.textureChanged != TEXCHANGE_UNCHANGED && !gstate.isModeClear() && gstate.isTextureMapEnabled()) {

View File

@ -18,6 +18,8 @@
#include <algorithm>
#include <cstring>
#include "profiler/profiler.h"
#include "Common/ColorConv.h"
#include "Core/Host.h"
#include "Core/MemMap.h"
@ -1116,6 +1118,7 @@ bool TextureCache::SetOffsetTexture(u32 offset) {
}
void TextureCache::SetTexture(bool force) {
PROFILE_THIS_SCOPE("settexture");
#ifdef DEBUG_TEXTURES
if (SetDebugTexture()) {
// A different texture was bound, let's rebind next time.

View File

@ -72,7 +72,8 @@
#include "Core/Config.h"
#include "Core/CoreTiming.h"
#include "native/gfx_es2/gl_state.h"
#include "gfx_es2/gl_state.h"
#include "profiler/profiler.h"
#include "GPU/Math3D.h"
#include "GPU/GPUState.h"
@ -334,6 +335,8 @@ void TransformDrawEngine::DecodeVerts() {
}
void TransformDrawEngine::DecodeVertsStep() {
PROFILE_THIS_SCOPE("vertdec");
const int i = decodeCounter_;
const DeferredDrawCall &dc = drawCalls[i];

View File

@ -24,6 +24,7 @@
#include "ui/view.h"
#include "ui/viewgroup.h"
#include "ui/ui.h"
#include "profiler/profiler.h"
#include "Common/LogManager.h"
#include "Common/CPUDetect.h"
@ -69,6 +70,9 @@ void DevMenu::CreatePopupContents(UI::ViewGroup *parent) {
parent->Add(new Choice(de->T("Toggle Freeze")))->OnClick.Handle(this, &DevMenu::OnFreezeFrame);
parent->Add(new Choice(de->T("Dump Frame GPU Commands")))->OnClick.Handle(this, &DevMenu::OnDumpFrame);
parent->Add(new Choice(de->T("Toggle Audio Debug")))->OnClick.Handle(this, &DevMenu::OnToggleAudioDebug);
#ifdef USE_PROFILER
parent->Add(new CheckBox(&g_Config.bShowFrameProfiler, de->T("Frame Profiler"), ""));
#endif
RingbufferLogListener *ring = LogManager::GetInstance()->GetRingbufferListener();
if (ring) {
@ -776,3 +780,71 @@ UI::EventReturn JitCompareScreen::OnCurrentBlock(UI::EventParams &e) {
UpdateDisasm();
return UI::EVENT_DONE;
}
void DrawProfile(UIContext &ui) {
int numCategories = Profiler_GetNumCategories();
int historyLength = Profiler_GetHistoryLength();
float legendStartY = ui.GetBounds().centerY();
float legendStartX = ui.GetBounds().x2() - 100;
float rowH = 30;
for (int i = 0; i < numCategories; i++) {
const char *name = Profiler_GetCategoryName(i);
uint32_t color = Profiler_GetCategoryColor(i);
float y = legendStartY + i * rowH;
ui.FillRect(UI::Drawable(color), Bounds(legendStartX, y, rowH - 2, rowH - 2));
ui.DrawTextShadow(name, legendStartX + rowH + 2, y, 0xFFFFFFFF, ALIGN_VBASELINE);
}
float graphWidth = ui.GetBounds().x2() - 120;
float graphHeight = ui.GetBounds().h * 0.8f;
std::vector<float> history;
std::vector<float> total;
history.resize(historyLength);
total.resize(historyLength);
float dx = graphWidth / historyLength;
/*
ui.Flush();
ui.BeginNoTex();
*/
bool area = true;
for (int i = 0; i < numCategories; i++) {
Profiler_GetHistory(i, &history[0], historyLength);
float x = 10;
float minVal = 0.0f;
float maxVal = 1.0f / 60.0f; // TODO - adjust to frame length
float scale = (graphHeight) / (maxVal - minVal);
uint32_t col = Profiler_GetCategoryColor(i);
if (area)
col &= 0x7FFFFFFF;
UI::Drawable color(col);
if (area) {
for (int n = 0; n < historyLength; n++) {
float val = history[n];
float valY1 = ui.GetBounds().y2() - 10 - (val + total[n]) * scale;
float valY2 = ui.GetBounds().y2() - 10 - total[n] * scale;
ui.FillRect(color, Bounds(x, valY1, dx, valY2 - valY1));
x += dx;
total[n] += val;
}
} else {
for (int n = 0; n < historyLength; n++) {
float val = history[n];
float valY = ui.GetBounds().y2() - 10 - history[n] * scale;
ui.FillRect(color, Bounds(x, valY, dx, 5));
x += dx;
}
}
}
}

View File

@ -141,3 +141,6 @@ private:
UI::LinearLayout *leftDisasm_;
UI::LinearLayout *rightDisasm_;
};
void DrawProfile(UIContext &ui);

View File

@ -874,7 +874,7 @@ void EmuScreen::render() {
if (useBufferedRendering && g_Config.iGPUBackend == GPU_BACKEND_OPENGL)
fbo_unbind();
if (!osm.IsEmpty() || g_Config.bShowDebugStats || g_Config.iShowFPSCounter || g_Config.bShowTouchControls || g_Config.bShowDeveloperMenu || g_Config.bShowAudioDebug || saveStatePreview_->GetVisibility() != UI::V_GONE) {
if (!osm.IsEmpty() || g_Config.bShowDebugStats || g_Config.iShowFPSCounter || g_Config.bShowTouchControls || g_Config.bShowDeveloperMenu || g_Config.bShowAudioDebug || saveStatePreview_->GetVisibility() != UI::V_GONE || g_Config.bShowFrameProfiler) {
Thin3DContext *thin3d = screenManager()->getThin3DContext();
// This sets up some important states but not the viewport.
@ -908,6 +908,10 @@ void EmuScreen::render() {
DrawFPS(draw2d, screenManager()->getUIContext()->GetBounds());
}
if (g_Config.bShowFrameProfiler) {
// DrawProfile(*screenManager()->getUIContext());
}
screenManager()->getUIContext()->End();
}