mirror of
https://github.com/hrydgard/ppsspp.git
synced 2025-04-02 11:01:50 -04:00
Reduce refresh rate checks.
These turned out to be unexpectedly expensive, so cache the value and also try to check it a bit less.
This commit is contained in:
parent
008055d242
commit
e39980fc73
2 changed files with 18 additions and 13 deletions
|
@ -207,8 +207,6 @@ void UpdateRunLoop(GraphicsContext *ctx) {
|
||||||
|
|
||||||
// Note: not used on Android.
|
// Note: not used on Android.
|
||||||
void Core_RunLoop(GraphicsContext *ctx) {
|
void Core_RunLoop(GraphicsContext *ctx) {
|
||||||
float refreshRate = System_GetPropertyFloat(SYSPROP_DISPLAY_REFRESH_RATE);
|
|
||||||
|
|
||||||
if (windowHidden && g_Config.bPauseWhenMinimized) {
|
if (windowHidden && g_Config.bPauseWhenMinimized) {
|
||||||
sleep_ms(16);
|
sleep_ms(16);
|
||||||
return;
|
return;
|
||||||
|
@ -224,6 +222,7 @@ void Core_RunLoop(GraphicsContext *ctx) {
|
||||||
NativeFrame(ctx);
|
NativeFrame(ctx);
|
||||||
|
|
||||||
if (menuThrottle) {
|
if (menuThrottle) {
|
||||||
|
float refreshRate = System_GetPropertyFloat(SYSPROP_DISPLAY_REFRESH_RATE);
|
||||||
// Simple throttling to not burn the GPU in the menu.
|
// 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.
|
// TODO: This should move into NativeFrame. Also, it's only necessary in MAILBOX or IMMEDIATE presentation modes.
|
||||||
double diffTime = time_now_d() - startTime;
|
double diffTime = time_now_d() - startTime;
|
||||||
|
|
|
@ -283,22 +283,28 @@ static int ScreenDPI() {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static int ScreenRefreshRateHz() {
|
static int ScreenRefreshRateHz() {
|
||||||
DEVMODE lpDevMode;
|
static int rate = 0;
|
||||||
memset(&lpDevMode, 0, sizeof(DEVMODE));
|
static double lastCheck = 0.0;
|
||||||
lpDevMode.dmSize = sizeof(DEVMODE);
|
double now = time_now_d();
|
||||||
lpDevMode.dmDriverExtra = 0;
|
if (!rate || lastCheck < now - 10.0) {
|
||||||
|
lastCheck = now;
|
||||||
|
DEVMODE lpDevMode{};
|
||||||
|
lpDevMode.dmSize = sizeof(DEVMODE);
|
||||||
|
lpDevMode.dmDriverExtra = 0;
|
||||||
|
|
||||||
// TODO: Use QueryDisplayConfig instead (Win7+) so we can get fractional refresh rates correctly.
|
// TODO: Use QueryDisplayConfig instead (Win7+) so we can get fractional refresh rates correctly.
|
||||||
|
|
||||||
if (EnumDisplaySettings(NULL, ENUM_CURRENT_SETTINGS, &lpDevMode) == 0) {
|
if (EnumDisplaySettings(NULL, ENUM_CURRENT_SETTINGS, &lpDevMode) == 0) {
|
||||||
return 60; // default value
|
rate = 60; // default value
|
||||||
} else {
|
|
||||||
if (lpDevMode.dmFields & DM_DISPLAYFREQUENCY) {
|
|
||||||
return lpDevMode.dmDisplayFrequency > 60 ? lpDevMode.dmDisplayFrequency : 60;
|
|
||||||
} else {
|
} else {
|
||||||
return 60;
|
if (lpDevMode.dmFields & DM_DISPLAYFREQUENCY) {
|
||||||
|
rate = lpDevMode.dmDisplayFrequency > 60 ? lpDevMode.dmDisplayFrequency : 60;
|
||||||
|
} else {
|
||||||
|
rate = 60;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return rate;
|
||||||
}
|
}
|
||||||
|
|
||||||
int System_GetPropertyInt(SystemProperty prop) {
|
int System_GetPropertyInt(SystemProperty prop) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue