GUI: add option to disable VSync
also add frame rate limiter
This commit is contained in:
parent
9dbda09cd0
commit
fc68f17107
11 changed files with 145 additions and 75 deletions
|
|
@ -3769,6 +3769,10 @@ bool FurnaceGUI::loop() {
|
|||
scrConfW=scrW;
|
||||
scrConfH=scrH;
|
||||
}
|
||||
if (rend!=NULL) {
|
||||
logV("restoring swap interval...");
|
||||
rend->setSwapInterval(settings.vsync);
|
||||
}
|
||||
}
|
||||
// update canvas size as well
|
||||
if (!rend->getOutputSize(canvasW,canvasH)) {
|
||||
|
|
@ -4037,7 +4041,7 @@ bool FurnaceGUI::loop() {
|
|||
|
||||
logD("starting render backend...");
|
||||
while (++initAttempts<=5) {
|
||||
if (rend->init(sdlWin)) {
|
||||
if (rend->init(sdlWin,settings.vsync)) {
|
||||
break;
|
||||
}
|
||||
SDL_Delay(1000);
|
||||
|
|
@ -6534,6 +6538,22 @@ bool FurnaceGUI::loop() {
|
|||
}
|
||||
drawTimeEnd=SDL_GetPerformanceCounter();
|
||||
swapTimeBegin=SDL_GetPerformanceCounter();
|
||||
if (!settings.vsync || !rend->canVSync()) {
|
||||
unsigned int presentDelay=SDL_GetPerformanceFrequency()/settings.frameRateLimit;
|
||||
if ((nextPresentTime-swapTimeBegin)<presentDelay) {
|
||||
#ifdef _WIN32
|
||||
unsigned int mDivider=SDL_GetPerformanceFrequency()/1000;
|
||||
Sleep((unsigned int)(nextPresentTime-swapTimeBegin)/mDivider);
|
||||
#else
|
||||
unsigned int mDivider=SDL_GetPerformanceFrequency()/1000000;
|
||||
usleep((unsigned int)(nextPresentTime-swapTimeBegin)/mDivider);
|
||||
#endif
|
||||
|
||||
nextPresentTime+=presentDelay;
|
||||
} else {
|
||||
nextPresentTime=swapTimeBegin+presentDelay;
|
||||
}
|
||||
}
|
||||
rend->present();
|
||||
if (settings.renderClearPos) {
|
||||
rend->clear(uiColors[GUI_COLOR_BACKGROUND]);
|
||||
|
|
@ -7036,7 +7056,7 @@ bool FurnaceGUI::init() {
|
|||
}
|
||||
|
||||
logD("starting render backend...");
|
||||
if (!rend->init(sdlWin)) {
|
||||
if (!rend->init(sdlWin,settings.vsync)) {
|
||||
logE("it failed...");
|
||||
if (settings.renderBackend!="SDL") {
|
||||
settings.renderBackend="SDL";
|
||||
|
|
@ -7784,6 +7804,7 @@ FurnaceGUI::FurnaceGUI():
|
|||
eventTimeBegin(0),
|
||||
eventTimeEnd(0),
|
||||
eventTimeDelta(0),
|
||||
nextPresentTime(0),
|
||||
perfMetricsLen(0),
|
||||
chanToMove(-1),
|
||||
sysToMove(-1),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue