Merge pull request #2542 from unknownbrackets/fps-limit

Add an optional hack to force <= 60 FPS
This commit is contained in:
Henrik Rydgård 2013-06-30 00:07:24 -07:00
commit 0d32163248
7 changed files with 48 additions and 30 deletions

View File

@ -105,6 +105,7 @@ void Config::Load(const char *iniFileName)
graphics->Get("VBO", &bUseVBO, false);
graphics->Get("FrameSkip", &iFrameSkip, 0);
graphics->Get("FrameRate", &iFpsLimit, 60);
graphics->Get("ForceMaxEmulatedFPS", &iForceMaxEmulatedFPS, 0);
#ifdef USING_GLES2
graphics->Get("AnisotropyLevel", &iAnisotropyLevel, 0);
#else
@ -222,6 +223,7 @@ void Config::Save()
graphics->Set("VBO", bUseVBO);
graphics->Set("FrameSkip", iFrameSkip);
graphics->Set("FrameRate", iFpsLimit);
graphics->Set("ForceMaxEmulatedFPS", iForceMaxEmulatedFPS);
graphics->Set("AnisotropyLevel", iAnisotropyLevel);
graphics->Set("VertexCache", bVertexCache);
graphics->Set("FullScreen", bFullScreen);

View File

@ -88,6 +88,7 @@ public:
int iTexScalingType; // 0 = xBRZ, 1 = Hybrid
bool bTexDeposterize;
int iFpsLimit;
int iForceMaxEmulatedFPS;
int iMaxRecent;
bool bEnableCheats;
bool bReloadCheats;

View File

@ -124,6 +124,7 @@ static size_t fpsHistoryValid = 0;
static int lastNumFlips = 0;
static int numFlips = 0;
static float flips = 0.0f;
static u64 lastFlipCycles = 0;
void hleEnterVblank(u64 userdata, int cyclesLate);
void hleLeaveVblank(u64 userdata, int cyclesLate);
@ -142,6 +143,7 @@ void __DisplayInit() {
framebuf.topaddr = 0x04000000;
framebuf.pspFramebufFormat = PSP_DISPLAY_PIXEL_FORMAT_8888;
framebuf.pspFramebufLinesize = 480; // ??
lastFlipCycles = 0;
enterVblankEvent = CoreTiming::RegisterEvent("EnterVBlank", &hleEnterVblank);
leaveVblankEvent = CoreTiming::RegisterEvent("LeaveVBlank", &hleLeaveVblank);
@ -512,6 +514,14 @@ u32 sceDisplaySetFramebuf(u32 topaddr, int linesize, int pixelformat, int sync)
if (topaddr != framebuf.topaddr) {
++numFlips;
if (g_Config.iForceMaxEmulatedFPS) {
u64 now = CoreTiming::GetTicks();
u64 expected = msToCycles(1000) / g_Config.iForceMaxEmulatedFPS;
u64 actual = now - lastFlipCycles;
if (actual < expected)
hleEatCycles((int)(expected - actual));
lastFlipCycles = CoreTiming::GetTicks();
}
}
if (sync == PSP_DISPLAY_SETBUF_IMMEDIATE) {

View File

@ -216,6 +216,7 @@ namespace Reporting
float vps, fps;
__DisplayGetAveragedFPS(&vps, &fps);
postdata.Add("vps", vps);
postdata.Add("fps", fps);
}
// TODO: Settings, savestate/savedata status, some measure of speed/fps?

View File

@ -915,7 +915,7 @@ int TransformDrawEngine::EstimatePerVertexCost() {
for (int i = 0; i < 4; i++) {
if (gstate.lightEnable[i] & 1)
cost += 20;
cost += 10;
}
if (gstate.getUVGenMode() != 0) {
cost += 20;
@ -924,11 +924,6 @@ int TransformDrawEngine::EstimatePerVertexCost() {
cost += 5 * dec_->morphcount;
}
if (CoreTiming::GetClockFrequencyMHz() == 333) {
// Just brutally double to make God of War happier.
// FUDGE FACTORS! Delicious fudge factors!
cost *= 2;
}
return cost;
}

View File

@ -356,11 +356,11 @@ void EmuScreen::render() {
char fpsbuf[256];
switch (g_Config.iShowFPSCounter) {
case 1:
sprintf(fpsbuf, "VPS: %0.1f", vps); break;
sprintf(fpsbuf, "Speed: %0.1f", vps); break;
case 2:
sprintf(fpsbuf, "FPS: %0.1f", fps); break;
case 3:
sprintf(fpsbuf, "VPS: %0.1f\nFPS: %0.1f", vps, fps); break;
sprintf(fpsbuf, "Speed: %5.1f\nFPS: %0.1f", vps, fps); break;
}
ui_draw2d.DrawText(UBUNTU24, fpsbuf, dp_xres - 8, 12, 0xc0000000, ALIGN_TOPRIGHT);
ui_draw2d.DrawText(UBUNTU24, fpsbuf, dp_xres - 10, 10, 0xFF3fFF3f, ALIGN_TOPRIGHT);

View File

@ -966,51 +966,60 @@ void GraphicsScreenP3::render() {
int stride = 40;
int columnw = 400;
bool ForceMaxEmulatedFPS60 = g_Config.iForceMaxEmulatedFPS == 60;
if (UICheckBox(GEN_ID, x, y += stride, gs->T("Force 60 FPS or less"), ALIGN_TOPLEFT, &ForceMaxEmulatedFPS60))
g_Config.iForceMaxEmulatedFPS = ForceMaxEmulatedFPS60 ? 60 : 0;
bool ShowCounter = g_Config.iShowFPSCounter > 0;
UICheckBox(GEN_ID, x, y += stride, gs->T("Show VPS/FPS"), ALIGN_TOPLEFT, &ShowCounter);
UICheckBox(GEN_ID, x, y += stride, gs->T("Show speed / internal FPS"), ALIGN_TOPLEFT, &ShowCounter);
if (ShowCounter) {
#ifdef _WIN32
const int checkboxH = 32;
#else
const int checkboxH = 48;
#endif
ui_draw2d.DrawTextShadow(UBUNTU24, gs->T("(60.0 is full speed, internal FPS depends on game)"), x + UI_SPACE + 29, (y += stride) + checkboxH / 2, 0xFFFFFFFF, ALIGN_LEFT | ALIGN_VCENTER);
if (g_Config.iShowFPSCounter <= 0)
g_Config.iShowFPSCounter = 1;
char counter[256];
std::string type;
const char *type;
switch (g_Config.iShowFPSCounter) {
case 1: type = "VPS";break;
case 2: type = "FPS";break;
case 3: type = "Both";break;
case 1: type = gs->T("Display: Speed"); break;
case 2: type = gs->T("Display: FPS"); break;
case 3: type = gs->T("Display: Both"); break;
}
sprintf(counter, "%s %s", gs->T("Format :"), type.c_str());
ui_draw2d.DrawText(UBUNTU24, counter, x + 60, y += stride , 0xFFFFFFFF, ALIGN_LEFT);
HLinear hlinear1(x + 250, y, 20);
if (UIButton(GEN_ID, hlinear1, 80, 0, gs->T("VPS"), ALIGN_LEFT))
ui_draw2d.DrawText(UBUNTU24, type, x + 60, y += stride , 0xFFFFFFFF, ALIGN_LEFT);
HLinear hlinear1(x + 260, y, 20);
if (UIButton(GEN_ID, hlinear1, 100, 0, gs->T("Speed"), ALIGN_LEFT))
g_Config.iShowFPSCounter = 1;
if (UIButton(GEN_ID, hlinear1, 80, 0, gs->T("FPS"), ALIGN_LEFT))
if (UIButton(GEN_ID, hlinear1, 100, 0, gs->T("FPS"), ALIGN_LEFT))
g_Config.iShowFPSCounter = 2;
if (UIButton(GEN_ID, hlinear1, 90, 0, gs->T("Both"), ALIGN_LEFT))
if (UIButton(GEN_ID, hlinear1, 100, 0, gs->T("Both"), ALIGN_LEFT))
g_Config.iShowFPSCounter = 3;
y += 20;
} else
g_Config.iShowFPSCounter = 0;
bool FpsLimit = g_Config.iFpsLimit != 0;
UICheckBox(GEN_ID, x, y += stride, gs->T("FPS Limit"), ALIGN_TOPLEFT, &FpsLimit);
UICheckBox(GEN_ID, x, y += stride, gs->T("Toggled Speed Limit"), ALIGN_TOPLEFT, &FpsLimit);
if (FpsLimit) {
if (g_Config.iFpsLimit == 0)
g_Config.iFpsLimit = 60;
char showFps[256];
sprintf(showFps, "%s %d", gs->T("FPS :"), g_Config.iFpsLimit);
sprintf(showFps, "%s %d", gs->T("Speed :"), g_Config.iFpsLimit);
ui_draw2d.DrawText(UBUNTU24, showFps, x + 60, y += stride , 0xFFFFFFFF, ALIGN_LEFT);
HLinear hlinear1(x + 250, y, 20);
if (UIButton(GEN_ID, hlinear1, 80, 0, gs->T("Auto"), ALIGN_LEFT))
HLinear hlinear1(x + 260, y, 20);
if (UIButton(GEN_ID, hlinear1, 100, 0, gs->T("Auto"), ALIGN_LEFT))
g_Config.iFpsLimit = 60;
if (UIButton(GEN_ID, hlinear1, 40, 0, gs->T("-1"), ALIGN_LEFT))
if(g_Config.iFpsLimit > 30)
if (UIButton(GEN_ID, hlinear1, 50, 0, gs->T("-1"), ALIGN_LEFT))
if(g_Config.iFpsLimit > 10)
g_Config.iFpsLimit -= 1;
if (UIButton(GEN_ID, hlinear1, 40, 0, gs->T("+1"), ALIGN_LEFT))
if(g_Config.iFrameSkip != 120)
if (UIButton(GEN_ID, hlinear1, 50, 0, gs->T("+1"), ALIGN_LEFT))
if(g_Config.iFrameSkip < 240)
g_Config.iFpsLimit += 1;
y += 20;