mirror of
https://github.com/hrydgard/ppsspp.git
synced 2025-02-11 00:56:37 +00:00
Scale the frame profiler graph dynamically
This commit is contained in:
parent
26624709f7
commit
2e26a4798e
@ -569,7 +569,6 @@ 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.
|
||||
|
||||
@ -583,6 +582,9 @@ void TransformDrawEngine::ApplyDrawState(int prim) {
|
||||
}
|
||||
}
|
||||
|
||||
// Start profiling here to skip SetTexture which is already accounted for
|
||||
PROFILE_THIS_SCOPE("applydrawstate");
|
||||
|
||||
// Set blend - unless we need to do it in the shader.
|
||||
ApplyBlendState();
|
||||
|
||||
|
@ -782,6 +782,7 @@ UI::EventReturn JitCompareScreen::OnCurrentBlock(UI::EventParams &e) {
|
||||
}
|
||||
|
||||
void DrawProfile(UIContext &ui) {
|
||||
#ifdef USE_PROFILER
|
||||
int numCategories = Profiler_GetNumCategories();
|
||||
int historyLength = Profiler_GetHistoryLength();
|
||||
|
||||
@ -816,14 +817,29 @@ void DrawProfile(UIContext &ui) {
|
||||
*/
|
||||
|
||||
bool area = true;
|
||||
static float lastMaxVal = 1.0f / 60.0f;
|
||||
float minVal = 0.0f;
|
||||
float maxVal = lastMaxVal; // TODO - adjust to frame length
|
||||
if (maxVal < 0.001f)
|
||||
maxVal = 0.001f;
|
||||
if (maxVal > 1.0f / 30.0f)
|
||||
maxVal = 1.0f / 30.0f;
|
||||
|
||||
float scale = (graphHeight) / (maxVal - minVal);
|
||||
|
||||
float y_60th = ui.GetBounds().y2() - 10 - (1.0f / 60.0f) * scale;
|
||||
float y_1ms = ui.GetBounds().y2() - 10 - (1.0f / 1000.0f) * scale;
|
||||
|
||||
ui.FillRect(UI::Drawable(0x80FFFF00), Bounds(0, y_60th, graphWidth, 2));
|
||||
ui.FillRect(UI::Drawable(0x80FFFF00), Bounds(0, y_1ms, graphWidth, 2));
|
||||
ui.DrawTextShadow("1/60s", 5, y_60th, 0x80FFFF00);
|
||||
ui.DrawTextShadow("1ms", 5, y_1ms, 0x80FFFF00);
|
||||
|
||||
maxVal = 0.0f;
|
||||
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;
|
||||
@ -832,6 +848,8 @@ void DrawProfile(UIContext &ui) {
|
||||
if (area) {
|
||||
for (int n = 0; n < historyLength; n++) {
|
||||
float val = history[n];
|
||||
if (val > maxVal)
|
||||
maxVal = val;
|
||||
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));
|
||||
@ -847,4 +865,7 @@ void DrawProfile(UIContext &ui) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
lastMaxVal = lastMaxVal * 0.95f + maxVal * 0.05f;
|
||||
#endif
|
||||
}
|
||||
|
@ -21,6 +21,7 @@
|
||||
#include "base/display.h"
|
||||
#include "base/logging.h"
|
||||
#include "base/timeutil.h"
|
||||
#include "profiler/profiler.h"
|
||||
|
||||
#include "gfx_es2/glsl_program.h"
|
||||
#include "gfx_es2/gl_state.h"
|
||||
@ -908,9 +909,11 @@ void EmuScreen::render() {
|
||||
DrawFPS(draw2d, screenManager()->getUIContext()->GetBounds());
|
||||
}
|
||||
|
||||
#ifdef USE_PROFILER
|
||||
if (g_Config.bShowFrameProfiler) {
|
||||
// DrawProfile(*screenManager()->getUIContext());
|
||||
DrawProfile(*screenManager()->getUIContext());
|
||||
}
|
||||
#endif
|
||||
|
||||
screenManager()->getUIContext()->End();
|
||||
}
|
||||
@ -955,4 +958,4 @@ void EmuScreen::releaseButtons() {
|
||||
input.timestamp = time_now_d();
|
||||
input.id = 0;
|
||||
touch(input);
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user