WIP max refresh rate
This commit is contained in:
parent
072af2155e
commit
00ac492a27
|
@ -27,6 +27,7 @@
|
||||||
<attnum name="gamma" val="1"/>
|
<attnum name="gamma" val="1"/>
|
||||||
<attstr name="video mode detect" in="auto,manual" val="auto"/>
|
<attstr name="video mode detect" in="auto,manual" val="auto"/>
|
||||||
<attstr name="video mode init" in="compatible,best" val="compatible"/>
|
<attstr name="video mode init" in="compatible,best" val="compatible"/>
|
||||||
|
<attnum name="maximum refresh frequency" val="50"/>
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
<section name="Menu Font">
|
<section name="Menu Font">
|
||||||
|
|
|
@ -143,13 +143,12 @@
|
||||||
<attstr name="font" val="medium"/>
|
<attstr name="font" val="medium"/>
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
<!--
|
|
||||||
<section name="MaxRefreshRateCombo">
|
<section name="MaxRefreshRateCombo">
|
||||||
<attstr name="type" val="combo box"/>
|
<attstr name="type" val="combo box"/>
|
||||||
<attnum name="max len" val="4"/>
|
<attnum name="max len" val="4"/>
|
||||||
<attstr name="tip" val="Select your max. refresh rate"/>
|
<attstr name="tip" val="Select your max. refresh rate"/>
|
||||||
<attnum name="x" val="320"/>
|
<attnum name="x" val="270"/>
|
||||||
<attnum name="y" val="158"/>
|
<attnum name="y" val="228"/>
|
||||||
<attnum name="width" val="220"/>
|
<attnum name="width" val="220"/>
|
||||||
<attnum name="arrows width" val="24"/>
|
<attnum name="arrows width" val="24"/>
|
||||||
<attnum name="arrows height" val="24"/>
|
<attnum name="arrows height" val="24"/>
|
||||||
|
@ -157,7 +156,6 @@
|
||||||
<attstr name="focused color" val="0xFFFFFF"/>
|
<attstr name="focused color" val="0xFFFFFF"/>
|
||||||
<attstr name="font" val="medium"/>
|
<attstr name="font" val="medium"/>
|
||||||
</section>
|
</section>
|
||||||
-->
|
|
||||||
|
|
||||||
<section name="CancelButton">
|
<section name="CancelButton">
|
||||||
<attstr name="type" val="text button"/>
|
<attstr name="type" val="text button"/>
|
||||||
|
@ -315,6 +313,17 @@
|
||||||
<attstr name="font" val="small_t"/>
|
<attstr name="font" val="small_t"/>
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
|
<section name="12">
|
||||||
|
<attstr name="type" val="label"/>
|
||||||
|
<attnum name="x" val="20"/>
|
||||||
|
<attnum name="y" val="232"/>
|
||||||
|
<attstr name="text" val="Max FPS:"/>
|
||||||
|
<attstr name="tip" val="Sets maximum frames per second rate"/>
|
||||||
|
<attstr name="h align" val="right"/>
|
||||||
|
<attnum name="width" val="220"/>
|
||||||
|
<attstr name="font" val="small_t"/>
|
||||||
|
</section>
|
||||||
|
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
</params>
|
</params>
|
||||||
|
|
|
@ -278,9 +278,4 @@ void GfEventLoop::recompute()
|
||||||
// Call the 'recompute' callback if any.
|
// Call the 'recompute' callback if any.
|
||||||
if (_pPrivate->cbRecompute)
|
if (_pPrivate->cbRecompute)
|
||||||
_pPrivate->cbRecompute();
|
_pPrivate->cbRecompute();
|
||||||
|
|
||||||
// ... otherwise let the CPU take breath (and fans stay at low and quiet speed,
|
|
||||||
// which would not be the case if really doing nothing).
|
|
||||||
else
|
|
||||||
SDL_Delay(1); // ms.
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,6 +19,8 @@
|
||||||
#include <SDL.h>
|
#include <SDL.h>
|
||||||
|
|
||||||
#include "tgfclient.h"
|
#include "tgfclient.h"
|
||||||
|
#include <chrono>
|
||||||
|
#include "tgf.h"
|
||||||
|
|
||||||
#ifdef WEBSERVER
|
#ifdef WEBSERVER
|
||||||
#include "webserver.h"
|
#include "webserver.h"
|
||||||
|
@ -48,13 +50,23 @@ class GfuiEventLoop::Private
|
||||||
|
|
||||||
// Variables.
|
// Variables.
|
||||||
bool bRedisplay; // Flag to say if a redisplay is necessary.
|
bool bRedisplay; // Flag to say if a redisplay is necessary.
|
||||||
|
double max_refresh; // Max refresh rate.
|
||||||
};
|
};
|
||||||
|
|
||||||
GfuiEventLoop::Private::Private()
|
GfuiEventLoop::Private::Private()
|
||||||
: cbMouseButton(0), cbMouseMotion(0), cbMousePassiveMotion(0), cbMouseWheel(0),
|
: cbMouseButton(0), cbMouseMotion(0), cbMousePassiveMotion(0), cbMouseWheel(0),
|
||||||
cbJoystickAxis(0), cbJoystickButton(0),
|
cbJoystickAxis(0), cbJoystickButton(0),
|
||||||
cbDisplay(0), cbReshape(0), bRedisplay(false)
|
cbDisplay(0), cbReshape(0), bRedisplay(false),
|
||||||
|
max_refresh(50.0)
|
||||||
{
|
{
|
||||||
|
void *hparmScrConf = GfParmReadFileLocal(GFSCR_CONF_FILE, GFPARM_RMODE_STD);
|
||||||
|
|
||||||
|
if (hparmScrConf)
|
||||||
|
{
|
||||||
|
max_refresh = GfParmGetNum(hparmScrConf, GFSCR_SECT_VALIDPROPS,
|
||||||
|
GFSCR_ATT_MAXREFRESH, NULL, 50.0);
|
||||||
|
GfParmReleaseHandle(hparmScrConf);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// GfuiEventLoop class ============================================================
|
// GfuiEventLoop class ============================================================
|
||||||
|
@ -238,11 +250,25 @@ void GfuiEventLoop::operator()()
|
||||||
|
|
||||||
if (!quitRequested())
|
if (!quitRequested())
|
||||||
{
|
{
|
||||||
|
const auto now = std::chrono::system_clock::now();
|
||||||
|
|
||||||
// Recompute if anything to.
|
// Recompute if anything to.
|
||||||
recompute();
|
recompute();
|
||||||
|
|
||||||
// Redisplay if anything to.
|
// Redisplay if anything to.
|
||||||
redisplay();
|
redisplay();
|
||||||
|
|
||||||
|
const std::chrono::duration<double> elapsed = std::chrono::system_clock::now() - now;
|
||||||
|
|
||||||
|
double rate;
|
||||||
|
|
||||||
|
if (_pPrivate->max_refresh)
|
||||||
|
{
|
||||||
|
rate = 1.0 / _pPrivate->max_refresh;
|
||||||
|
|
||||||
|
if (elapsed.count() < rate)
|
||||||
|
GfSleep(rate - elapsed.count());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -294,6 +320,11 @@ void GfuiEventLoop::postRedisplay(void)
|
||||||
_pPrivate->bRedisplay = true;
|
_pPrivate->bRedisplay = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GfuiEventLoop::setMaxRefreshRate(double rate)
|
||||||
|
{
|
||||||
|
_pPrivate->max_refresh = rate;
|
||||||
|
}
|
||||||
|
|
||||||
void GfuiEventLoop::forceRedisplay()
|
void GfuiEventLoop::forceRedisplay()
|
||||||
{
|
{
|
||||||
#ifdef WEBSERVER
|
#ifdef WEBSERVER
|
||||||
|
|
|
@ -205,6 +205,7 @@ ScreenSizeVector GfScrGetSupportedSizes(int nDisplayIndex)
|
||||||
tScreenSize last;
|
tScreenSize last;
|
||||||
last.width = 0;
|
last.width = 0;
|
||||||
last.height = 0;
|
last.height = 0;
|
||||||
|
last.refresh_rate = 0;
|
||||||
|
|
||||||
bounds.w = 0;
|
bounds.w = 0;
|
||||||
bounds.h = 0;
|
bounds.h = 0;
|
||||||
|
@ -238,6 +239,7 @@ ScreenSizeVector GfScrGetSupportedSizes(int nDisplayIndex)
|
||||||
GfLogDebug(" %d x %d x %d @ %d hz\n",mode.w,mode.h,SDL_BITSPERPIXEL(mode.format),mode.refresh_rate);
|
GfLogDebug(" %d x %d x %d @ %d hz\n",mode.w,mode.h,SDL_BITSPERPIXEL(mode.format),mode.refresh_rate);
|
||||||
last.width = mode.w;
|
last.width = mode.w;
|
||||||
last.height = mode.h;
|
last.height = mode.h;
|
||||||
|
last.refresh_rate = mode.refresh_rate;
|
||||||
vecSizes.push_back(last);
|
vecSizes.push_back(last);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -257,6 +259,7 @@ ScreenSizeVector GfScrGetSupportedSizes(int nDisplayIndex)
|
||||||
// Desperation stick the Display Bounds into the vector
|
// Desperation stick the Display Bounds into the vector
|
||||||
last.width = bounds.w;
|
last.width = bounds.w;
|
||||||
last.height = bounds.h;
|
last.height = bounds.h;
|
||||||
|
last.refresh_rate = mode.refresh_rate;
|
||||||
vecSizes.push_back(last);
|
vecSizes.push_back(last);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -802,6 +805,8 @@ void GfScrShutdown(void)
|
||||||
GfParmGetNum(hparmScreen, GFSCR_SECT_INTESTPROPS, GFSCR_ATT_STARTUPDISPLAY, 0, 0));
|
GfParmGetNum(hparmScreen, GFSCR_SECT_INTESTPROPS, GFSCR_ATT_STARTUPDISPLAY, 0, 0));
|
||||||
GfParmSetStr(hparmScreen, GFSCR_SECT_VALIDPROPS, GFSCR_ATT_VDETECT,
|
GfParmSetStr(hparmScreen, GFSCR_SECT_VALIDPROPS, GFSCR_ATT_VDETECT,
|
||||||
GfParmGetStr(hparmScreen, GFSCR_SECT_INTESTPROPS, GFSCR_ATT_VDETECT, GFSCR_VAL_VDETECT_AUTO));
|
GfParmGetStr(hparmScreen, GFSCR_SECT_INTESTPROPS, GFSCR_ATT_VDETECT, GFSCR_VAL_VDETECT_AUTO));
|
||||||
|
GfParmSetNum(hparmScreen, GFSCR_SECT_VALIDPROPS, GFSCR_ATT_MAXREFRESH, 0,
|
||||||
|
GfParmGetNum(hparmScreen, GFSCR_SECT_INTESTPROPS, GFSCR_ATT_MAXREFRESH, 0, 50));
|
||||||
const char* pszVInitMode =
|
const char* pszVInitMode =
|
||||||
GfParmGetStr(hparmScreen, GFSCR_SECT_INTESTPROPS, GFSCR_ATT_VINIT,
|
GfParmGetStr(hparmScreen, GFSCR_SECT_INTESTPROPS, GFSCR_ATT_VINIT,
|
||||||
GFSCR_VAL_VINIT_COMPATIBLE);
|
GFSCR_VAL_VINIT_COMPATIBLE);
|
||||||
|
@ -1372,4 +1377,4 @@ void gfScrDisableResizable()
|
||||||
GfParmWriteFile(NULL, hparmScreen, "Screen");
|
GfParmWriteFile(NULL, hparmScreen, "Screen");
|
||||||
GfParmReleaseHandle(hparmScreen);
|
GfParmReleaseHandle(hparmScreen);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -75,6 +75,7 @@ typedef struct ScreenSize
|
||||||
{
|
{
|
||||||
int width; // Width in pixels.
|
int width; // Width in pixels.
|
||||||
int height; // Height in pixels.
|
int height; // Height in pixels.
|
||||||
|
double refresh_rate; // Refresh rate in Hz.
|
||||||
} tScreenSize;
|
} tScreenSize;
|
||||||
|
|
||||||
typedef std::vector<tScreenSize> ScreenSizeVector;
|
typedef std::vector<tScreenSize> ScreenSizeVector;
|
||||||
|
@ -759,6 +760,9 @@ class TGFCLIENT_API GfuiEventLoop : public GfEventLoop
|
||||||
//! Force a call to the "redisplay/refresh" callback function.
|
//! Force a call to the "redisplay/refresh" callback function.
|
||||||
void forceRedisplay();
|
void forceRedisplay();
|
||||||
|
|
||||||
|
//! Sets maximum refresh rate to the event loop.
|
||||||
|
void setMaxRefreshRate(double rate);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
//! Process a keyboard event.
|
//! Process a keyboard event.
|
||||||
|
@ -840,5 +844,3 @@ void ScreenRelease(void* screen);
|
||||||
void UnregisterScreens(void* screen);
|
void UnregisterScreens(void* screen);
|
||||||
|
|
||||||
#endif /* __TGFCLIENT__H__ */
|
#endif /* __TGFCLIENT__H__ */
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -34,7 +34,7 @@ static const char* MonitorTypes[DisplayMenu::nDisplayTypes] = { "none", "4:3", "
|
||||||
static const char* SpansplitValues[] = { GR_VAL_NO, GR_VAL_YES };
|
static const char* SpansplitValues[] = { GR_VAL_NO, GR_VAL_YES };
|
||||||
static const int NbSpansplitValues = sizeof(SpansplitValues) / sizeof(SpansplitValues[0]);
|
static const int NbSpansplitValues = sizeof(SpansplitValues) / sizeof(SpansplitValues[0]);
|
||||||
#ifndef NoMaxRefreshRate
|
#ifndef NoMaxRefreshRate
|
||||||
static const int AMaxRefreshRates[] = { 0, 30, 40, 50, 60, 75, 85, 100, 120, 150, 200 };
|
static const int AMaxRefreshRates[] = {30, 40, 50, 60, 75, 85, 100, 120, 150, 200 };
|
||||||
static const int NMaxRefreshRates = sizeof(AMaxRefreshRates) / sizeof(AMaxRefreshRates[0]);
|
static const int NMaxRefreshRates = sizeof(AMaxRefreshRates) / sizeof(AMaxRefreshRates[0]);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -202,7 +202,8 @@ bool DisplayMenu::restartNeeded()
|
||||||
bool needRestart = ((_eDisplayMode != _eOriginalDisplayMode)
|
bool needRestart = ((_eDisplayMode != _eOriginalDisplayMode)
|
||||||
|| (_nScreenWidth !=_nOriginalScreenWidth)
|
|| (_nScreenWidth !=_nOriginalScreenWidth)
|
||||||
|| (_nScreenHeight != _nOriginalScreenHeight)
|
|| (_nScreenHeight != _nOriginalScreenHeight)
|
||||||
|| (_nOriginalMenuDisplay != _nMenuDisplay));
|
|| (_nOriginalMenuDisplay != _nMenuDisplay))
|
||||||
|
|| (_nOriginalMaxRefreshRate != _nMaxRefreshRate);
|
||||||
|
|
||||||
if(GfScrUsingResizableWindow() && (_eDisplayMode == eResizable))
|
if(GfScrUsingResizableWindow() && (_eDisplayMode == eResizable))
|
||||||
needRestart = false;
|
needRestart = false;
|
||||||
|
@ -305,7 +306,7 @@ void DisplayMenu::loadSettings()
|
||||||
|
|
||||||
#ifndef NoMaxRefreshRate
|
#ifndef NoMaxRefreshRate
|
||||||
// Max. refresh rate (Hz).
|
// Max. refresh rate (Hz).
|
||||||
_nMaxRefreshRate =
|
_nMaxRefreshRate = _nOriginalMaxRefreshRate =
|
||||||
(int)GfParmGetNum(hScrConfParams, pszScrPropSec, GFSCR_ATT_MAXREFRESH, NULL, 0);
|
(int)GfParmGetNum(hScrConfParams, pszScrPropSec, GFSCR_ATT_MAXREFRESH, NULL, 0);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -468,6 +469,7 @@ void DisplayMenu::resetScreenSizes()
|
||||||
tScreenSize _currSize = GfScrGetCurrentDisplaySize( _nMenuDisplay);
|
tScreenSize _currSize = GfScrGetCurrentDisplaySize( _nMenuDisplay);
|
||||||
_nScreenWidth = _currSize.width;
|
_nScreenWidth = _currSize.width;
|
||||||
_nScreenHeight = _currSize.height;
|
_nScreenHeight = _currSize.height;
|
||||||
|
_nMaxRefreshRate = _currSize.refresh_rate;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -586,7 +588,7 @@ DisplayMenu::DisplayMenu()
|
||||||
_nOriginalMenuDisplay = 0;
|
_nOriginalMenuDisplay = 0;
|
||||||
_eOriginalDisplayMode = eWindowed;
|
_eOriginalDisplayMode = eWindowed;
|
||||||
#ifndef NoMaxRefreshRate
|
#ifndef NoMaxRefreshRate
|
||||||
_nMaxRefreshRate = 0;
|
_nMaxRefreshRate = AMaxRefreshRates[0];
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -708,4 +710,4 @@ void DisplayMenuRelease(void)
|
||||||
{
|
{
|
||||||
delete PDisplayMenu;
|
delete PDisplayMenu;
|
||||||
PDisplayMenu = NULL;
|
PDisplayMenu = NULL;
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,7 +26,7 @@
|
||||||
#include "confscreens.h"
|
#include "confscreens.h"
|
||||||
|
|
||||||
// Comment-out to activate max. refresh rate settings.
|
// Comment-out to activate max. refresh rate settings.
|
||||||
#define NoMaxRefreshRate 1
|
//#define NoMaxRefreshRate 1
|
||||||
|
|
||||||
|
|
||||||
class DisplayMenu : public GfuiMenuScreen
|
class DisplayMenu : public GfuiMenuScreen
|
||||||
|
@ -111,6 +111,7 @@ private:
|
||||||
#ifndef NoMaxRefreshRate
|
#ifndef NoMaxRefreshRate
|
||||||
//! Currently selected max. refresh rate (Hz).
|
//! Currently selected max. refresh rate (Hz).
|
||||||
int _nMaxRefreshRate;
|
int _nMaxRefreshRate;
|
||||||
|
int _nOriginalMaxRefreshRate;
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -543,9 +543,6 @@ HostServerIdle(void)
|
||||||
|
|
||||||
GfuiApp().eventLoop().postRedisplay();
|
GfuiApp().eventLoop().postRedisplay();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Let CPU take breath (and fans stay at low and quiet speed) */
|
|
||||||
GfSleep(0.001);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -544,9 +544,6 @@ HostServerIdle(void)
|
||||||
|
|
||||||
GfuiApp().eventLoop().postRedisplay();
|
GfuiApp().eventLoop().postRedisplay();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Let CPU take breath (and fans stay at low and quiet speed) */
|
|
||||||
GfSleep(0.001);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -581,9 +578,6 @@ ClientIdle(void)
|
||||||
|
|
||||||
GfuiApp().eventLoop().postRedisplay();
|
GfuiApp().eventLoop().postRedisplay();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Let CPU take breath (and fans stay at low and quiet speed) */
|
|
||||||
GfSleep(0.001);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|
Loading…
Reference in New Issue