mirror of
https://github.com/hrydgard/ppsspp.git
synced 2025-04-02 11:01:50 -04:00
Move the menu frame-rate throttling to NativeFrame
Now needed on Android since we added the ability to turn off vsync, which caused the menu to burn battery by rendering too fast.
This commit is contained in:
parent
f9403efaf0
commit
ae0c1e88c3
2 changed files with 17 additions and 17 deletions
|
@ -212,24 +212,7 @@ void Core_RunLoop(GraphicsContext *ctx) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool menuThrottle = (GetUIState() != UISTATE_INGAME || !PSP_IsInited()) && GetUIState() != UISTATE_EXIT;
|
|
||||||
|
|
||||||
double startTime;
|
|
||||||
if (menuThrottle) {
|
|
||||||
startTime = time_now_d();
|
|
||||||
}
|
|
||||||
|
|
||||||
NativeFrame(ctx);
|
NativeFrame(ctx);
|
||||||
|
|
||||||
if (menuThrottle) {
|
|
||||||
float refreshRate = System_GetPropertyFloat(SYSPROP_DISPLAY_REFRESH_RATE);
|
|
||||||
// Simple throttling to not burn the GPU in the menu.
|
|
||||||
// TODO: This should move into NativeFrame. Also, it's only necessary in MAILBOX or IMMEDIATE presentation modes.
|
|
||||||
double diffTime = time_now_d() - startTime;
|
|
||||||
int sleepTime = (int)(1000.0 / refreshRate) - (int)(diffTime * 1000.0);
|
|
||||||
if (sleepTime > 0)
|
|
||||||
sleep_ms(sleepTime);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Core_DoSingleStep() {
|
void Core_DoSingleStep() {
|
||||||
|
|
|
@ -1070,6 +1070,13 @@ static Matrix4x4 ComputeOrthoMatrix(float xres, float yres) {
|
||||||
void NativeFrame(GraphicsContext *graphicsContext) {
|
void NativeFrame(GraphicsContext *graphicsContext) {
|
||||||
PROFILE_END_FRAME();
|
PROFILE_END_FRAME();
|
||||||
|
|
||||||
|
bool menuThrottle = (GetUIState() != UISTATE_INGAME || !PSP_IsInited()) && GetUIState() != UISTATE_EXIT;
|
||||||
|
|
||||||
|
double startTime;
|
||||||
|
if (menuThrottle) {
|
||||||
|
startTime = time_now_d();
|
||||||
|
}
|
||||||
|
|
||||||
std::vector<PendingMessage> toProcess;
|
std::vector<PendingMessage> toProcess;
|
||||||
{
|
{
|
||||||
std::lock_guard<std::mutex> lock(pendingMutex);
|
std::lock_guard<std::mutex> lock(pendingMutex);
|
||||||
|
@ -1184,6 +1191,16 @@ void NativeFrame(GraphicsContext *graphicsContext) {
|
||||||
// INFO_LOG(G3D, "Polling graphics context");
|
// INFO_LOG(G3D, "Polling graphics context");
|
||||||
graphicsContext->Poll();
|
graphicsContext->Poll();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (menuThrottle) {
|
||||||
|
float refreshRate = System_GetPropertyFloat(SYSPROP_DISPLAY_REFRESH_RATE);
|
||||||
|
// Simple throttling to not burn the GPU in the menu.
|
||||||
|
// TODO: This should move into NativeFrame. Also, it's only necessary in MAILBOX or IMMEDIATE presentation modes.
|
||||||
|
double diffTime = time_now_d() - startTime;
|
||||||
|
int sleepTime = (int)(1000.0 / refreshRate) - (int)(diffTime * 1000.0);
|
||||||
|
if (sleepTime > 0)
|
||||||
|
sleep_ms(sleepTime);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool HandleGlobalMessage(UIMessage message, const std::string &value) {
|
bool HandleGlobalMessage(UIMessage message, const std::string &value) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue