mirror of
https://github.com/overte-org/overte.git
synced 2025-08-07 18:30:42 +02:00
Merge pull request #3719 from samcake/tot
Fix the problem of actual framerate target not being true to the value ...
This commit is contained in:
commit
00b365318b
4 changed files with 93 additions and 97 deletions
|
@ -107,9 +107,6 @@ static unsigned STARFIELD_SEED = 1;
|
||||||
|
|
||||||
static const int BANDWIDTH_METER_CLICK_MAX_DRAG_LENGTH = 6; // farther dragged clicks are ignored
|
static const int BANDWIDTH_METER_CLICK_MAX_DRAG_LENGTH = 6; // farther dragged clicks are ignored
|
||||||
|
|
||||||
const int IDLE_SIMULATE_MSECS = 16; // How often should call simulate and other stuff
|
|
||||||
// in the idle loop? (60 FPS is default)
|
|
||||||
|
|
||||||
const unsigned MAXIMUM_CACHE_SIZE = 10737418240; // 10GB
|
const unsigned MAXIMUM_CACHE_SIZE = 10737418240; // 10GB
|
||||||
|
|
||||||
static QTimer* idleTimer = NULL;
|
static QTimer* idleTimer = NULL;
|
||||||
|
@ -185,9 +182,7 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) :
|
||||||
_trayIcon(new QSystemTrayIcon(_window)),
|
_trayIcon(new QSystemTrayIcon(_window)),
|
||||||
_lastNackTime(usecTimestampNow()),
|
_lastNackTime(usecTimestampNow()),
|
||||||
_lastSendDownstreamAudioStats(usecTimestampNow()),
|
_lastSendDownstreamAudioStats(usecTimestampNow()),
|
||||||
_renderTargetFramerate(0),
|
_isVSyncOn(true)
|
||||||
_isVSyncOn(true),
|
|
||||||
_renderResolutionScale(1.0f)
|
|
||||||
{
|
{
|
||||||
|
|
||||||
// read the ApplicationInfo.ini file for Name/Version/Domain information
|
// read the ApplicationInfo.ini file for Name/Version/Domain information
|
||||||
|
@ -604,7 +599,7 @@ void Application::paintGL() {
|
||||||
if (OculusManager::isConnected()) {
|
if (OculusManager::isConnected()) {
|
||||||
_textureCache.setFrameBufferSize(OculusManager::getRenderTargetSize());
|
_textureCache.setFrameBufferSize(OculusManager::getRenderTargetSize());
|
||||||
} else {
|
} else {
|
||||||
QSize fbSize = _glWidget->getDeviceSize() * _renderResolutionScale;
|
QSize fbSize = _glWidget->getDeviceSize() * getRenderResolutionScale();
|
||||||
_textureCache.setFrameBufferSize(fbSize);
|
_textureCache.setFrameBufferSize(fbSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1474,12 +1469,11 @@ void Application::idle() {
|
||||||
bool showWarnings = getLogger()->extraDebugging();
|
bool showWarnings = getLogger()->extraDebugging();
|
||||||
PerformanceWarning warn(showWarnings, "idle()");
|
PerformanceWarning warn(showWarnings, "idle()");
|
||||||
|
|
||||||
// Only run simulation code if more than IDLE_SIMULATE_MSECS have passed since last time we ran
|
// Only run simulation code if more than the targetFramePeriod have passed since last time we ran
|
||||||
double targetFramePeriod = 0.0;
|
double targetFramePeriod = 0.0;
|
||||||
if (_renderTargetFramerate > 0) {
|
unsigned int targetFramerate = getRenderTargetFramerate();
|
||||||
targetFramePeriod = 1000.0 / _renderTargetFramerate;
|
if (targetFramerate > 0) {
|
||||||
} else if (_renderTargetFramerate < 0) {
|
targetFramePeriod = 1000.0 / targetFramerate;
|
||||||
targetFramePeriod = IDLE_SIMULATE_MSECS;
|
|
||||||
}
|
}
|
||||||
double timeSinceLastUpdate = (double)_lastTimeUpdated.nsecsElapsed() / 1000000.0;
|
double timeSinceLastUpdate = (double)_lastTimeUpdated.nsecsElapsed() / 1000000.0;
|
||||||
if (timeSinceLastUpdate > targetFramePeriod) {
|
if (timeSinceLastUpdate > targetFramePeriod) {
|
||||||
|
@ -3179,7 +3173,7 @@ void Application::renderRearViewMirror(const QRect& region, bool billboard) {
|
||||||
} else {
|
} else {
|
||||||
// if not rendering the billboard, the region is in device independent coordinates; must convert to device
|
// if not rendering the billboard, the region is in device independent coordinates; must convert to device
|
||||||
QSize size = getTextureCache()->getFrameBufferSize();
|
QSize size = getTextureCache()->getFrameBufferSize();
|
||||||
float ratio = QApplication::desktop()->windowHandle()->devicePixelRatio() * _renderResolutionScale;
|
float ratio = QApplication::desktop()->windowHandle()->devicePixelRatio() * getRenderResolutionScale();
|
||||||
int x = region.x() * ratio, y = region.y() * ratio, width = region.width() * ratio, height = region.height() * ratio;
|
int x = region.x() * ratio, y = region.y() * ratio, width = region.width() * ratio, height = region.height() * ratio;
|
||||||
glViewport(x, size.height() - y - height, width, height);
|
glViewport(x, size.height() - y - height, width, height);
|
||||||
glScissor(x, size.height() - y - height, width, height);
|
glScissor(x, size.height() - y - height, width, height);
|
||||||
|
@ -4237,37 +4231,56 @@ void Application::takeSnapshot() {
|
||||||
_snapshotShareDialog->show();
|
_snapshotShareDialog->show();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Application::setRenderTargetFramerate(unsigned int framerate, bool vsyncOn) {
|
void Application::setVSyncEnabled(bool vsyncOn) {
|
||||||
if (vsyncOn != _isVSyncOn) {
|
|
||||||
#if defined(Q_OS_WIN)
|
#if defined(Q_OS_WIN)
|
||||||
if (wglewGetExtension("WGL_EXT_swap_control")) {
|
if (wglewGetExtension("WGL_EXT_swap_control")) {
|
||||||
wglSwapIntervalEXT(vsyncOn);
|
wglSwapIntervalEXT(vsyncOn);
|
||||||
int swapInterval = wglGetSwapIntervalEXT();
|
int swapInterval = wglGetSwapIntervalEXT();
|
||||||
_isVSyncOn = swapInterval;
|
qDebug("V-Sync is %s\n", (swapInterval > 0 ? "ON" : "OFF"));
|
||||||
qDebug("V-Sync is %s\n", (swapInterval > 0 ? "ON" : "OFF"));
|
} else {
|
||||||
} else {
|
|
||||||
qDebug("V-Sync is FORCED ON on this system\n");
|
|
||||||
}
|
|
||||||
#elif defined(Q_OS_LINUX)
|
|
||||||
// TODO: write the poper code for linux
|
|
||||||
/*
|
|
||||||
if (glQueryExtension.... ("GLX_EXT_swap_control")) {
|
|
||||||
glxSwapIntervalEXT(vsyncOn);
|
|
||||||
int swapInterval = xglGetSwapIntervalEXT();
|
|
||||||
_isVSyncOn = swapInterval;
|
|
||||||
qDebug("V-Sync is %s\n", (swapInterval > 0 ? "ON" : "OFF"));
|
|
||||||
} else {
|
|
||||||
qDebug("V-Sync is FORCED ON on this system\n");
|
qDebug("V-Sync is FORCED ON on this system\n");
|
||||||
}
|
|
||||||
*/
|
|
||||||
#else
|
|
||||||
qDebug("V-Sync is FORCED ON on this system\n");
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
_renderTargetFramerate = framerate;
|
#elif defined(Q_OS_LINUX)
|
||||||
|
// TODO: write the poper code for linux
|
||||||
|
/*
|
||||||
|
if (glQueryExtension.... ("GLX_EXT_swap_control")) {
|
||||||
|
glxSwapIntervalEXT(vsyncOn);
|
||||||
|
int swapInterval = xglGetSwapIntervalEXT();
|
||||||
|
_isVSyncOn = swapInterval;
|
||||||
|
qDebug("V-Sync is %s\n", (swapInterval > 0 ? "ON" : "OFF"));
|
||||||
|
} else {
|
||||||
|
qDebug("V-Sync is FORCED ON on this system\n");
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
#else
|
||||||
|
qDebug("V-Sync is FORCED ON on this system\n");
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Application::isVSyncEditable() {
|
bool Application::isVSyncOn() const {
|
||||||
|
#if defined(Q_OS_WIN)
|
||||||
|
if (wglewGetExtension("WGL_EXT_swap_control")) {
|
||||||
|
int swapInterval = wglGetSwapIntervalEXT();
|
||||||
|
return (swapInterval > 0);
|
||||||
|
} else {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
#elif defined(Q_OS_LINUX)
|
||||||
|
// TODO: write the poper code for linux
|
||||||
|
/*
|
||||||
|
if (glQueryExtension.... ("GLX_EXT_swap_control")) {
|
||||||
|
int swapInterval = xglGetSwapIntervalEXT();
|
||||||
|
return (swapInterval > 0);
|
||||||
|
} else {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
#else
|
||||||
|
return true;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Application::isVSyncEditable() const {
|
||||||
#if defined(Q_OS_WIN)
|
#if defined(Q_OS_WIN)
|
||||||
if (wglewGetExtension("WGL_EXT_swap_control")) {
|
if (wglewGetExtension("WGL_EXT_swap_control")) {
|
||||||
return true;
|
return true;
|
||||||
|
@ -4284,6 +4297,33 @@ bool Application::isVSyncEditable() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Application::setRenderResolutionScale(float scale) {
|
unsigned int Application::getRenderTargetFramerate() const {
|
||||||
_renderResolutionScale = scale;
|
if (Menu::getInstance()->isOptionChecked(MenuOption::RenderTargetFramerateUnlimited)) {
|
||||||
|
return 0;
|
||||||
|
} else if (Menu::getInstance()->isOptionChecked(MenuOption::RenderTargetFramerate60)) {
|
||||||
|
return 60;
|
||||||
|
} else if (Menu::getInstance()->isOptionChecked(MenuOption::RenderTargetFramerate50)) {
|
||||||
|
return 50;
|
||||||
|
} else if (Menu::getInstance()->isOptionChecked(MenuOption::RenderTargetFramerate40)) {
|
||||||
|
return 40;
|
||||||
|
} else if (Menu::getInstance()->isOptionChecked(MenuOption::RenderTargetFramerate30)) {
|
||||||
|
return 30;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
float Application::getRenderResolutionScale() const {
|
||||||
|
if (Menu::getInstance()->isOptionChecked(MenuOption::RenderResolutionOne)) {
|
||||||
|
return 1.f;
|
||||||
|
} else if (Menu::getInstance()->isOptionChecked(MenuOption::RenderResolutionTwoThird)) {
|
||||||
|
return 0.666f;
|
||||||
|
} else if (Menu::getInstance()->isOptionChecked(MenuOption::RenderResolutionHalf)) {
|
||||||
|
return 0.5f;
|
||||||
|
} else if (Menu::getInstance()->isOptionChecked(MenuOption::RenderResolutionThird)) {
|
||||||
|
return 0.333f;
|
||||||
|
} else if (Menu::getInstance()->isOptionChecked(MenuOption::RenderResolutionQuarter)) {
|
||||||
|
return 0.25f;
|
||||||
|
} else {
|
||||||
|
return 1.f;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -303,7 +303,12 @@ public:
|
||||||
|
|
||||||
bool isLookingAtMyAvatar(Avatar* avatar);
|
bool isLookingAtMyAvatar(Avatar* avatar);
|
||||||
|
|
||||||
float getRenderResolutionScale() const { return _renderResolutionScale; }
|
float getRenderResolutionScale() const;
|
||||||
|
|
||||||
|
unsigned int getRenderTargetFramerate() const;
|
||||||
|
bool isVSyncOn() const;
|
||||||
|
bool isVSyncEditable() const;
|
||||||
|
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
|
|
||||||
|
@ -367,12 +372,7 @@ public slots:
|
||||||
|
|
||||||
void domainSettingsReceived(const QJsonObject& domainSettingsObject);
|
void domainSettingsReceived(const QJsonObject& domainSettingsObject);
|
||||||
|
|
||||||
void setRenderTargetFramerate(unsigned int framerate, bool vsyncOn = true);
|
void setVSyncEnabled(bool vsyncOn);
|
||||||
bool isVSyncOn() { return _isVSyncOn; }
|
|
||||||
bool isVSyncEditable();
|
|
||||||
unsigned int getRenderTargetFramerate() const { return _renderTargetFramerate; }
|
|
||||||
|
|
||||||
void setRenderResolutionScale(float scale);
|
|
||||||
|
|
||||||
void resetSensors();
|
void resetSensors();
|
||||||
|
|
||||||
|
@ -624,9 +624,7 @@ private:
|
||||||
quint64 _lastNackTime;
|
quint64 _lastNackTime;
|
||||||
quint64 _lastSendDownstreamAudioStats;
|
quint64 _lastSendDownstreamAudioStats;
|
||||||
|
|
||||||
int _renderTargetFramerate;
|
|
||||||
bool _isVSyncOn;
|
bool _isVSyncOn;
|
||||||
float _renderResolutionScale;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // hifi_Application_h
|
#endif // hifi_Application_h
|
||||||
|
|
|
@ -377,13 +377,12 @@ Menu::Menu() :
|
||||||
{
|
{
|
||||||
QMenu* framerateMenu = renderOptionsMenu->addMenu(MenuOption::RenderTargetFramerate);
|
QMenu* framerateMenu = renderOptionsMenu->addMenu(MenuOption::RenderTargetFramerate);
|
||||||
QActionGroup* framerateGroup = new QActionGroup(framerateMenu);
|
QActionGroup* framerateGroup = new QActionGroup(framerateMenu);
|
||||||
|
framerateGroup->setExclusive(true);
|
||||||
framerateGroup->addAction(addCheckableActionToQMenuAndActionHash(framerateMenu, MenuOption::RenderTargetFramerateUnlimited, 0, true));
|
framerateGroup->addAction(addCheckableActionToQMenuAndActionHash(framerateMenu, MenuOption::RenderTargetFramerateUnlimited, 0, true));
|
||||||
framerateGroup->addAction(addCheckableActionToQMenuAndActionHash(framerateMenu, MenuOption::RenderTargetFramerate60, 0, false));
|
framerateGroup->addAction(addCheckableActionToQMenuAndActionHash(framerateMenu, MenuOption::RenderTargetFramerate60, 0, false));
|
||||||
framerateGroup->addAction(addCheckableActionToQMenuAndActionHash(framerateMenu, MenuOption::RenderTargetFramerate50, 0, false));
|
framerateGroup->addAction(addCheckableActionToQMenuAndActionHash(framerateMenu, MenuOption::RenderTargetFramerate50, 0, false));
|
||||||
framerateGroup->addAction(addCheckableActionToQMenuAndActionHash(framerateMenu, MenuOption::RenderTargetFramerate40, 0, false));
|
framerateGroup->addAction(addCheckableActionToQMenuAndActionHash(framerateMenu, MenuOption::RenderTargetFramerate40, 0, false));
|
||||||
framerateGroup->addAction(addCheckableActionToQMenuAndActionHash(framerateMenu, MenuOption::RenderTargetFramerate30, 0, false));
|
framerateGroup->addAction(addCheckableActionToQMenuAndActionHash(framerateMenu, MenuOption::RenderTargetFramerate30, 0, false));
|
||||||
connect(framerateMenu, SIGNAL(triggered(QAction*)), this, SLOT(changeRenderTargetFramerate(QAction*)));
|
|
||||||
|
|
||||||
#if defined(Q_OS_MAC)
|
#if defined(Q_OS_MAC)
|
||||||
#else
|
#else
|
||||||
|
@ -394,12 +393,12 @@ Menu::Menu() :
|
||||||
|
|
||||||
QMenu* resolutionMenu = renderOptionsMenu->addMenu(MenuOption::RenderResolution);
|
QMenu* resolutionMenu = renderOptionsMenu->addMenu(MenuOption::RenderResolution);
|
||||||
QActionGroup* resolutionGroup = new QActionGroup(resolutionMenu);
|
QActionGroup* resolutionGroup = new QActionGroup(resolutionMenu);
|
||||||
resolutionGroup->addAction(addCheckableActionToQMenuAndActionHash(resolutionMenu, MenuOption::RenderResolutionOne, 0, false));
|
resolutionGroup->setExclusive(true);
|
||||||
|
resolutionGroup->addAction(addCheckableActionToQMenuAndActionHash(resolutionMenu, MenuOption::RenderResolutionOne, 0, true));
|
||||||
resolutionGroup->addAction(addCheckableActionToQMenuAndActionHash(resolutionMenu, MenuOption::RenderResolutionTwoThird, 0, false));
|
resolutionGroup->addAction(addCheckableActionToQMenuAndActionHash(resolutionMenu, MenuOption::RenderResolutionTwoThird, 0, false));
|
||||||
resolutionGroup->addAction(addCheckableActionToQMenuAndActionHash(resolutionMenu, MenuOption::RenderResolutionHalf, 0, false));
|
resolutionGroup->addAction(addCheckableActionToQMenuAndActionHash(resolutionMenu, MenuOption::RenderResolutionHalf, 0, false));
|
||||||
resolutionGroup->addAction(addCheckableActionToQMenuAndActionHash(resolutionMenu, MenuOption::RenderResolutionThird, 0, true));
|
resolutionGroup->addAction(addCheckableActionToQMenuAndActionHash(resolutionMenu, MenuOption::RenderResolutionThird, 0, false));
|
||||||
resolutionGroup->addAction(addCheckableActionToQMenuAndActionHash(resolutionMenu, MenuOption::RenderResolutionQuarter, 0, false));
|
resolutionGroup->addAction(addCheckableActionToQMenuAndActionHash(resolutionMenu, MenuOption::RenderResolutionQuarter, 0, false));
|
||||||
connect(resolutionMenu, SIGNAL(triggered(QAction*)), this, SLOT(changeRenderResolution(QAction*)));
|
|
||||||
|
|
||||||
addCheckableActionToQMenuAndActionHash(renderOptionsMenu, MenuOption::Stars, Qt::Key_Asterisk, true);
|
addCheckableActionToQMenuAndActionHash(renderOptionsMenu, MenuOption::Stars, Qt::Key_Asterisk, true);
|
||||||
addCheckableActionToQMenuAndActionHash(renderOptionsMenu,
|
addCheckableActionToQMenuAndActionHash(renderOptionsMenu,
|
||||||
|
@ -1261,46 +1260,7 @@ void Menu::muteEnvironment() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Menu::changeVSync() {
|
void Menu::changeVSync() {
|
||||||
Application::getInstance()->setRenderTargetFramerate(
|
Application::getInstance()->setVSyncEnabled(isOptionChecked(MenuOption::RenderTargetFramerateVSyncOn));
|
||||||
Application::getInstance()->getRenderTargetFramerate(),
|
|
||||||
isOptionChecked(MenuOption::RenderTargetFramerateVSyncOn));
|
|
||||||
}
|
|
||||||
void Menu::changeRenderTargetFramerate(QAction* action) {
|
|
||||||
bool vsynOn = Application::getInstance()->isVSyncOn();
|
|
||||||
|
|
||||||
QString text = action->text();
|
|
||||||
if (text == MenuOption::RenderTargetFramerateUnlimited) {
|
|
||||||
Application::getInstance()->setRenderTargetFramerate(0, vsynOn);
|
|
||||||
}
|
|
||||||
else if (text == MenuOption::RenderTargetFramerate60) {
|
|
||||||
Application::getInstance()->setRenderTargetFramerate(60, vsynOn);
|
|
||||||
}
|
|
||||||
else if (text == MenuOption::RenderTargetFramerate50) {
|
|
||||||
Application::getInstance()->setRenderTargetFramerate(50, vsynOn);
|
|
||||||
}
|
|
||||||
else if (text == MenuOption::RenderTargetFramerate40) {
|
|
||||||
Application::getInstance()->setRenderTargetFramerate(40, vsynOn);
|
|
||||||
}
|
|
||||||
else if (text == MenuOption::RenderTargetFramerate30) {
|
|
||||||
Application::getInstance()->setRenderTargetFramerate(30, vsynOn);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void Menu::changeRenderResolution(QAction* action) {
|
|
||||||
QString text = action->text();
|
|
||||||
if (text == MenuOption::RenderResolutionOne) {
|
|
||||||
Application::getInstance()->setRenderResolutionScale(1.f);
|
|
||||||
} else if (text == MenuOption::RenderResolutionTwoThird) {
|
|
||||||
Application::getInstance()->setRenderResolutionScale(0.666f);
|
|
||||||
} else if (text == MenuOption::RenderResolutionHalf) {
|
|
||||||
Application::getInstance()->setRenderResolutionScale(0.5f);
|
|
||||||
} else if (text == MenuOption::RenderResolutionThird) {
|
|
||||||
Application::getInstance()->setRenderResolutionScale(0.333f);
|
|
||||||
} else if (text == MenuOption::RenderResolutionQuarter) {
|
|
||||||
Application::getInstance()->setRenderResolutionScale(0.25f);
|
|
||||||
} else {
|
|
||||||
Application::getInstance()->setRenderResolutionScale(1.f);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Menu::displayNameLocationResponse(const QString& errorString) {
|
void Menu::displayNameLocationResponse(const QString& errorString) {
|
||||||
|
|
|
@ -230,9 +230,7 @@ private slots:
|
||||||
void displayAddressOfflineMessage();
|
void displayAddressOfflineMessage();
|
||||||
void displayAddressNotFoundMessage();
|
void displayAddressNotFoundMessage();
|
||||||
void muteEnvironment();
|
void muteEnvironment();
|
||||||
void changeRenderTargetFramerate(QAction* action);
|
|
||||||
void changeVSync();
|
void changeVSync();
|
||||||
void changeRenderResolution(QAction* action);
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static Menu* _instance;
|
static Menu* _instance;
|
||||||
|
|
Loading…
Reference in a new issue