mirror of
https://github.com/overte-org/overte.git
synced 2025-08-05 05:50:19 +02:00
Snapshot of "working" version.
This commit is contained in:
parent
faec4639b1
commit
5b41d4da1c
5 changed files with 20 additions and 14 deletions
|
@ -1086,6 +1086,7 @@ void Application::paintGL() {
|
|||
|
||||
// update fps moving average
|
||||
uint64_t now = usecTimestampNow();
|
||||
qint64 sinceSync = getActiveDisplayPlugin()->getTimeSinceSync();
|
||||
static uint64_t lastPaintBegin{ now };
|
||||
uint64_t diff = now - lastPaintBegin;
|
||||
float instantaneousFps = 0.0f;
|
||||
|
@ -1122,8 +1123,8 @@ void Application::paintGL() {
|
|||
_inPaint = true;
|
||||
Finally clearFlagLambda([this] { _inPaint = false; });
|
||||
|
||||
_lastPaintWait = (float)(now - _paintWaitStart) / (float)USECS_PER_SECOND;
|
||||
_lastInstantaneousFps = instantaneousFps;
|
||||
//_lastPaintWait = (float)(now - _paintWaitStart) / (float)USECS_PER_SECOND;
|
||||
//_lastInstantaneousFps = instantaneousFps;
|
||||
// Some LOD-like controls need to know a smoothly varying "potential" frame rate that doesn't
|
||||
// include time waiting for vsync, and which can report a number above target if we've got the headroom.
|
||||
// For example, if we're shooting for 75fps and paintWait is 3.3333ms (= 75% * 13.33ms), our deducedNonVSyncFps
|
||||
|
@ -1422,6 +1423,10 @@ void Application::paintGL() {
|
|||
});
|
||||
}
|
||||
_paintWaitStart = usecTimestampNow();
|
||||
_lastPaintWait = (float)sinceSync / (float)MSECS_PER_SECOND;
|
||||
_lastInstantaneousFps = instantaneousFps;
|
||||
_lastDeducedNonVSyncFps = 1.0f / (((_paintWaitStart - now) / (float)USECS_PER_SECOND) + ((float)sinceSync / (float)MSECS_PER_SECOND));
|
||||
// qCDebug(interfaceapp) << "pw/now/sync" << _paintWaitStart << now << sinceSync << "period" << (((_paintWaitStart - now) / (float)USECS_PER_SECOND) + ((float)sinceSync / (float)MSECS_PER_SECOND)) << "hz" << _lastDeducedNonVSyncFps;
|
||||
}
|
||||
|
||||
void Application::runTests() {
|
||||
|
|
|
@ -154,24 +154,21 @@ void AvatarManager::updateOtherAvatars(float deltaTime) {
|
|||
const float targetFps = 60.0f;
|
||||
const float instantaneousFps = qApp->getLastInstanteousFps();
|
||||
const float paintWait = qApp->getLastPaintWait();
|
||||
const float actual = 1.0f / instantaneousFps;
|
||||
const float deduced = qApp->getLastDeducedNonVSyncFps();
|
||||
/*const float actual = 1.0f / instantaneousFps;
|
||||
const float target = 1.0f / targetFps;
|
||||
const float firstAdjusted = actual - paintWait /*+ 0.002f*/;
|
||||
const float machinery = (paintWait > target) ? fmod(paintWait, target) : 0.0f;
|
||||
const float secondAdjusted = firstAdjusted + machinery;
|
||||
const float deduced = 1.0f / secondAdjusted;
|
||||
const float modulus = (instantaneousFps >= targetFps) ?
|
||||
(1.0f + floor(instantaneousFps / targetFps)) :
|
||||
(1.0f / floor(targetFps / instantaneousFps));
|
||||
(1.0f + floor(instantaneousFps / targetFps)) :
|
||||
(1.0f / floor(targetFps / instantaneousFps));
|
||||
const float cap = modulus * targetFps;
|
||||
const float capped = glm::min(cap, deduced);
|
||||
const float deduced = instantaneousFps + ((cap - instantaneousFps) * (paintWait / target));*/
|
||||
/*qCDebug(interfaceapp) << "dump " << instantaneousFps << (1000.0f * paintWait)
|
||||
<< "(" << paintWait << actual
|
||||
<< "(" << firstAdjusted << machinery << secondAdjusted
|
||||
<< ")" << deduced << ")";*/
|
||||
<< ")" << deduced << modulus << cap << capped << ")";*/
|
||||
|
||||
//const float deduced = qApp->getLastDeducedNonVSyncFps();
|
||||
const float distance = 1.0f / _renderDistanceController.update(capped, deltaTime, false, paintWait, instantaneousFps);
|
||||
const float distance = 1.0f / _renderDistanceController.update(deduced, deltaTime, false, paintWait, instantaneousFps);
|
||||
_renderDistanceAverage.updateAverage(distance);
|
||||
_renderDistance = _renderDistanceAverage.getAverage();
|
||||
int renderableCount = 0;
|
||||
|
|
|
@ -168,8 +168,9 @@ OpenGLDisplayPlugin::OpenGLDisplayPlugin() {
|
|||
// This is likely to be mooted by further planned changes.
|
||||
if (_active && _sceneTextureEscrow.depth() <= 1) {
|
||||
#else
|
||||
if (_active && _sceneTextureEscrow.depth() < 1) {
|
||||
if (_active && _sceneTextureEscrow.depth() <= 1) {
|
||||
#endif
|
||||
_sinceSync.start();
|
||||
emit requestRender();
|
||||
}
|
||||
});
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
#include "DisplayPlugin.h"
|
||||
|
||||
#include <QtCore/QTimer>
|
||||
#include <QElapsedTimer.h>
|
||||
|
||||
#include <GLMHelpers.h>
|
||||
#include <SimpleMovingAverage.h>
|
||||
|
@ -40,6 +41,7 @@ public:
|
|||
}
|
||||
|
||||
virtual QImage getScreenshot() const override;
|
||||
virtual quint64 getTimeSinceSync() { return _sinceSync.elapsed(); }
|
||||
|
||||
protected:
|
||||
friend class PresentThread;
|
||||
|
@ -82,6 +84,7 @@ protected:
|
|||
GLTextureEscrow _sceneTextureEscrow;
|
||||
|
||||
bool _vsyncSupported { false };
|
||||
QElapsedTimer _sinceSync;
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -58,7 +58,7 @@ public:
|
|||
/// By default, all HMDs are stereo
|
||||
virtual bool isStereo() const { return isHmd(); }
|
||||
virtual bool isThrottled() const { return false; }
|
||||
virtual qint64 getLastSynchronizedElapsed() { return 0; }
|
||||
virtual quint64 getTimeSinceSync() { return 0; }
|
||||
|
||||
// Rendering support
|
||||
|
||||
|
|
Loading…
Reference in a new issue